]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - usr.sbin/ctladm/ctladm.8
MFC r275482: Document r275481 changes.
[FreeBSD/stable/10.git] / usr.sbin / ctladm / ctladm.8
1 .\"
2 .\" Copyright (c) 2003 Silicon Graphics International Corp.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions, and the following disclaimer,
10 .\"    without modification.
11 .\" 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 .\"    substantially similar to the "NO WARRANTY" disclaimer below
13 .\"    ("Disclaimer") and any redistribution must be conditioned upon
14 .\"    including a substantially similar Disclaimer requirement for further
15 .\"    binary redistribution.
16 .\"
17 .\" NO WARRANTY
18 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
21 .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 .\" HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 .\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGES.
29 .\"
30 .\" ctladm utility man page.
31 .\"
32 .\" Author: Ken Merry <ken@FreeBSD.org>
33 .\"
34 .\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $
35 .\" $FreeBSD$
36 .\"
37 .Dd December 6, 2014
38 .Dt CTLADM 8
39 .Os
40 .Sh NAME
41 .Nm ctladm
42 .Nd CAM Target Layer control utility
43 .Sh SYNOPSIS
44 .Nm
45 .Aq Ar command
46 .Op target:lun
47 .Op generic args
48 .Op command args
49 .Nm
50 .Ic tur
51 .Aq target:lun
52 .Op general options
53 .Nm
54 .Ic inquiry
55 .Aq target:lun
56 .Op general options
57 .Nm
58 .Ic reqsense
59 .Aq target:lun
60 .Op general options
61 .Nm
62 .Ic reportluns
63 .Aq target:lun
64 .Op general options
65 .Nm
66 .Ic read
67 .Aq target:lun
68 .Op general options
69 .Aq Fl l Ar lba
70 .Aq Fl d Ar datalen
71 .Aq Fl f Ar file|-
72 .Aq Fl b Ar blocksize_bytes
73 .Op Fl c Ar cdbsize
74 .Op Fl N
75 .Nm
76 .Ic write
77 .Aq target:lun
78 .Op general options
79 .Aq Fl l Ar lba
80 .Aq Fl d Ar datalen
81 .Aq Fl f Ar file|-
82 .Aq Fl b Ar blocksize_bytes
83 .Op Fl c Ar cdbsize
84 .Op Fl N
85 .Nm
86 .Ic bbrread
87 .Aq target:lun
88 .Op general options
89 .Aq Fl -l Ar lba
90 .Aq Fl -d Ar datalen
91 .Nm
92 .Ic readcap
93 .Aq target:lun
94 .Op general options
95 .Op Fl c Ar cdbsize
96 .Nm
97 .Ic modesense
98 .Aq target:lun
99 .Aq Fl m Ar page | Fl l
100 .Op Fl P Ar pc
101 .Op Fl d
102 .Op Fl S Ar subpage
103 .Op Fl c Ar size
104 .Nm
105 .Ic start
106 .Aq target:lun
107 .Op general options
108 .Op Fl i
109 .Op Fl o
110 .Nm
111 .Ic stop
112 .Aq target:lun
113 .Op general options
114 .Op Fl i
115 .Op Fl o
116 .Nm
117 .Ic synccache
118 .Aq target:lun
119 .Op general options
120 .Op Fl l Ar lba
121 .Op Fl b Ar blockcount
122 .Op Fl r
123 .Op Fl i
124 .Op Fl c Ar cdbsize
125 .Nm
126 .Ic shutdown
127 .Op general options
128 .Nm
129 .Ic startup
130 .Op general options
131 .Nm
132 .Ic hardstop
133 .Nm
134 .Ic hardstart
135 .Nm
136 .Ic lunlist
137 .Nm
138 .Ic delay
139 .Aq target:lun
140 .Aq Fl l Ar datamove|done
141 .Aq Fl t Ar secs
142 .Op Fl T Ar oneshot|cont
143 .Nm
144 .Ic realsync Aq on|off|query
145 .Nm
146 .Ic setsync interval
147 .Aq target:lun
148 .Aq Fl i Ar interval
149 .Nm
150 .Ic getsync
151 .Aq target:lun
152 .Nm
153 .Ic inject
154 .Aq Fl i Ar action
155 .Aq Fl p Ar pattern
156 .Op Fl r Ar lba,len
157 .Op Fl s Ar len fmt Op Ar args
158 .Op Fl c
159 .Op Fl d Ar delete_id
160 .Nm
161 .Ic create
162 .Aq Fl b Ar backend
163 .Op Fl B Ar blocksize
164 .Op Fl d Ar device_id
165 .Op Fl l Ar lun_id
166 .Op Fl o Ar name=value
167 .Op Fl s Ar size_bytes
168 .Op Fl S Ar serial_num
169 .Op Fl t Ar device_type
170 .Nm
171 .Ic remove
172 .Aq Fl b Ar backend
173 .Aq Fl l Ar lun_id
174 .Op Fl o Ar name=value
175 .Nm
176 .Ic modify
177 .Aq Fl b Ar backend
178 .Aq Fl l Ar lun_id
179 .Aq Fl s Ar size_bytes
180 .Nm
181 .Ic devlist
182 .Op Fl b Ar backend
183 .Op Fl v
184 .Op Fl x
185 .Nm
186 .Ic port
187 .Op Fl l
188 .Op Fl o Ar on|off
189 .Op Fl w Ar wwpn
190 .Op Fl W Ar wwnn
191 .Op Fl p Ar targ_port
192 .Op Fl t Ar fe_type
193 .Op Fl q
194 .Op Fl x
195 .Nm
196 .Ic portlist
197 .Op Fl f Ar frontend
198 .Op Fl i
199 .Op Fl p Ar targ_port
200 .Op Fl q
201 .Op Fl v
202 .Op Fl x
203 .Nm
204 .Ic dumpooa
205 .Nm
206 .Ic dumpstructs
207 .Nm
208 .Ic islist
209 .Op Fl v
210 .Op Fl x
211 .Nm
212 .Ic islogout
213 .Aq Fl a | Fl c Ar connection-id | Fl i Ar name | Fl p Ar portal
214 .Nm
215 .Ic isterminate
216 .Aq Fl a | Fl c Ar connection-id | Fl i Ar name | Fl p Ar portal
217 .Nm
218 .Ic help
219 .Sh DESCRIPTION
220 The
221 .Nm
222 utility is designed to provide a way to access and control the CAM Target
223 Layer (CTL).
224 It provides a way to send
225 .Tn SCSI
226 commands to the CTL layer, and also provides
227 some meta-commands that utilize
228 .Tn SCSI
229 commands.
230 (For instance, the
231 .Ic lunlist
232 command is implemented using the
233 .Tn SCSI
234 REPORT LUNS and INQUIRY commands.)
235 .Pp
236 The
237 .Nm
238 utility has a number of primary functions, many of which require a device
239 identifier.
240 The device identifier takes the following form:
241 .Bl -tag -width 14n
242 .It target:lun
243 Specify the target (almost always 0) and LUN number to operate on.
244 .El
245 Many of the primary functions of the
246 .Nm
247 utility take the following optional arguments:
248 .Bl -tag -width 10n
249 .It Fl C Ar retries
250 Specify the number of times to retry a command in the event of failure.
251 .It Fl D Ar device
252 Specify the device to open.  This allows opening a device other than the
253 default device,
254 .Pa /dev/cam/ctl ,
255 to be opened for sending commands.
256 .It Fl I Ar id
257 Specify the initiator number to use.
258 By default,
259 .Nm
260 will use 7 as the initiator number.
261 .El
262 .Pp
263 Primary commands:
264 .Bl -tag -width 11n
265 .It Ic tur
266 Send the
267 .Tn SCSI
268 TEST UNIT READY command to the device and report whether or not it is
269 ready.
270 .It Ic inquiry
271 Send the
272 .Tn SCSI
273 INQUIRY command to the device and display some of the returned inquiry
274 data.
275 .It Ic reqsense
276 Send the
277 .Tn SCSI
278 REQUEST SENSE command to the device and display the returned sense
279 information.
280 .It Ic reportluns
281 Send the
282 .Tn SCSI
283 REPORT LUNS command to the device and display supported LUNs.
284 .It Ic read
285 Send a
286 .Tn SCSI
287 READ command to the device, and write the requested data to a file or
288 stdout.
289 .Bl -tag -width 12n
290 .It Fl l Ar lba
291 Specify the starting Logical Block Address for the READ.  This can be
292 specified in decimal, octal (starting with 0), hexadecimal (starting with
293 0x) or any other base supported by
294 .Xr strtoull 3 .
295 .It Fl d Ar datalen
296 Specify the length, in 512 byte blocks, of the READ request.
297 .It Fl f Ar file
298 Specify the destination for the data read by the READ command.  Either a
299 filename or
300 .Sq -
301 for stdout may be specified.
302 .It Fl c Ar cdbsize
303 Specify the minimum
304 .Tn SCSI
305 CDB (Command Data Block) size to be used for the READ request.  Allowable
306 values are 6, 10, 12 and 16.  Depending upon the LBA and amount of data
307 requested, a larger CDB size may be used to satisfy the request.  (e.g.,
308 for LBAs above 0xffffffff, READ(16) must be used to satisfy the request.)
309 .It Fl b Ar blocksize
310 Specify the blocksize of the underlying
311 .Tn SCSI
312 device, so the transfer length
313 can be calculated accurately.  The blocksize can be obtained via the
314 .Tn SCSI
315 READ CAPACITY command.
316 .It Fl N
317 Do not copy data to
318 .Nm
319 from the kernel when doing a read, just execute the command without copying
320 data.
321 This is to be used for performance testing.
322 .El
323 .It Ic write
324 Read data from a file or stdin, and write the data to the device using the
325 .Tn SCSI
326 WRITE command.
327 .Bl -tag -width 12n
328 .It Fl l Ar lba
329 Specify the starting Logical Block Address for the WRITE.  This can be
330 specified in decimal, octal (starting with 0), hexadecimal (starting with
331 0x) or any other base supported by
332 .Xr strtoull 3 .
333 .It Fl d Ar atalen
334 Specify the length, in 512 byte blocks, of the WRITE request.
335 .It Fl f Ar file
336 Specify the source for the data to be written by the WRITE command.  Either a
337 filename or
338 .Sq -
339 for stdin may be specified.
340 .It Fl c Ar cdbsize
341 Specify the minimum
342 .Tn SCSI
343 CDB (Command Data Block) size to be used for the READ request.  Allowable
344 values are 6, 10, 12 and 16.  Depending upon the LBA and amount of data
345 requested, a larger CDB size may be used to satisfy the request.  (e.g.,
346 for LBAs above 0xffffffff, READ(16) must be used to satisfy the request.)
347 .It Fl b Ar blocksize
348 Specify the blocksize of the underlying
349 .Tn SCSI
350 device, so the transfer length
351 can be calculated accurately.  The blocksize can be obtained via the
352 .Tn SCSI
353 READ CAPACITY command.
354 .It Fl N
355 Do not copy data to
356 .Nm
357 to the kernel when doing a write, just execute the command without copying
358 data.
359 This is to be used for performance testing.
360 .El
361 .It Ic bbrread
362 Issue a SCSI READ command to the logical device to potentially force a bad
363 block on a disk in the RAID set to be reconstructed from the other disks in
364 the array.  This command should only be used on an array that is in the
365 normal state.  If used on a critical array, it could cause the array to go
366 offline if the bad block to be remapped is on one of the disks that is
367 still active in the array.
368 .Pp
369 The data for this particular command will be discarded, and not returned to
370 the user.
371 .Pp
372 In order to determine which LUN to read from, the user should first
373 determine which LUN the disk with a bad block belongs to.  Then he should
374 map the bad disk block back to the logical block address for the array in
375 order to determine which LBA to pass in to the
376 .Ic bbrread
377 command.
378 .Pp
379 This command is primarily intended for testing.  In practice, bad block
380 remapping will generally be triggered by the in-kernel Disk Aerobics and
381 Disk Scrubbing code.
382 .Bl -tag -width 10n
383 .It Fl l Ar lba
384 Specify the starting Logical Block Address.
385 .It Fl d Ar datalen
386 Specify the amount of data in bytes to read from the LUN.  This must be a
387 multiple of the LUN blocksize.
388 .El
389 .It Ic readcap
390 Send the
391 .Tn SCSI
392 READ CAPACITY command to the device and display the device size and device
393 block size.  By default, READ CAPACITY(10) is
394 used.  If the device returns a maximum LBA of 0xffffffff, however,
395 .Nm
396 will automatically issue a READ CAPACITY(16), which is implemented as a
397 service action of the SERVICE ACTION IN(16) opcode.  The user can specify
398 the minimum CDB size with the
399 .Fl c
400 argument.  Valid values for the
401 .Fl c
402 option are 10 and 16.  If a 10 byte CDB is specified, the request will be
403 automatically reissued with a 16 byte CDB if the maximum LBA returned is
404 0xffffffff.
405 .It Ic modesense
406 Send a
407 .Tn SCSI
408 MODE SENSE command to the device, and display the requested mode page(s) or
409 page list.
410 .Bl -tag -width 10n
411 .It Fl m Ar page
412 Specify the mode page to display.  This option and the
413 .Fl l
414 option are mutually exclusive.  One of the two must be specified, though.
415 Mode page numbers may be specified in decimal or hexadecimal.
416 .It Fl l
417 Request that the list of mode pages supported by the device be returned.
418 This option and the
419 .Fl m
420 option are mutually exclusive.  One of the two must be specified, though.
421 .It Fl P Ar pc
422 Specify the mode page control value.  Possible values are:
423 .Bl -tag -width 2n -compact
424 .It 0
425 Current values.
426 .It 1
427 Changeable value bitmask.
428 .It 2
429 Default values.
430 .It 3
431 Saved values.
432 .El
433 .It Fl d
434 Disable block descriptors when sending the mode sense request.
435 .It Fl S Ar subpage
436 Specify the subpage used with the mode sense request.
437 .It Fl c Ar cdbsize
438 Specify the CDB size used for the mode sense request.  Supported values are
439 6 and 10.
440 .El
441 .It Ic start
442 Send the
443 .Tn SCSI
444 START STOP UNIT command to the specified LUN with the start
445 bit set.
446 .Bl -tag -width 4n
447 .It Fl i
448 Set the immediate bit in the CDB.  Note that CTL does not support the
449 immediate bit, so this is primarily useful for making sure that CTL returns
450 the proper error.
451 .It Fl o
452 Set the Copan proprietary on/offline bit in the CDB.  When this flag is
453 used, the LUN will be marked online again (see the description of the
454 .Ic shutdown
455 and
456 .Ic startup
457 commands).  When this flag is used with a
458 start command, the LUN will NOT be spun up.  You need to use a start
459 command without the
460 .Fl o
461 flag to spin up the disks in the LUN.
462 .El
463 .It Ic stop
464 Send the
465 .Tn SCSI
466 START STOP UNIT command to the specified LUN with the start
467 bit cleared.  We use an ordered tag to stop the LUN, so we can guarantee
468 that all pending I/O executes before it is stopped.  (CTL guarantees this
469 anyway, but
470 .Nm
471 sends an ordered tag for completeness.)
472 .Bl -tag -width 4n
473 .It Fl i
474 Set the immediate bit in the CDB.  Note that CTL does not support the
475 immediate bit, so this is primarily useful for making sure that CTL returns
476 the proper error.
477 .It Fl o
478 Set the Copan proprietary on/offline bit in the CDB.  When this flag is
479 used, the LUN will be spun down and taken offline ("Logical unit not ready,
480 manual intervention required").  See the description of the
481 .Ic shutdown
482 and
483 .Ic startup
484 options.
485 .El
486 .It Ic synccache
487 Send the
488 .Tn SCSI
489 SYNCHRONIZE CACHE command to the device.  By default, SYNCHRONIZE
490 CACHE(10) is used.  If the specified starting LBA is greater than
491 0xffffffff or the length is greater than 0xffff, though,
492 SYNCHRONIZE CACHE(16) will be used.  The 16 byte command will also be used
493 if the user specifies a 16 byte CDB with the
494 .Fl c
495 argument.
496 .Bl -tag -width 14n
497 .It Fl l Ar lba
498 Specify the starting LBA of the cache region to synchronize.  This option is a
499 no-op for CTL.  If you send a SYNCHRONIZE CACHE command, it will sync the
500 cache for the entire LUN.
501 .It Fl b Ar blockcount
502 Specify the length of the cache region to synchronize.  This option is a
503 no-op for CTL.  If you send a SYNCHRONIZE CACHE command, it will sync the
504 cache for the entire LUN.
505 .It Fl r
506 Specify relative addressing for the starting LBA.  CTL does not support
507 relative addressing, since it only works for linked commands, and CTL
508 does not support linked commands.
509 .It Fl i
510 Tell the target to return status immediately after issuing the SYNCHRONIZE CACHE
511 command rather than waiting for the cache to finish syncing.  CTL does not
512 support this bit.
513 .It Fl c Ar cdbsize
514 Specify the minimum CDB size.  Valid values are 10 and 16 bytes.
515 .El
516 .It Ic shutdown
517 Issue a
518 .Tn SCSI
519 START STOP UNIT command with the start bit cleared and the on/offline bit
520 set to all direct access LUNs.  This will spin down all direct access LUNs,
521 and mark them offline ("Logical unit not ready, manual intervention
522 required").  Once marked offline, the state can only be cleared by sending
523 a START STOP UNIT command with the start bit set and the on/offline bit
524 set.  The
525 .Nm
526 commands
527 .Ic startup
528 and
529 .Ic start
530 will accomplish this.  Note that the
531 on/offline bit is a non-standard Copan extension to the
532 .Tn SCSI
533 START STOP UNIT command, so merely sending a normal start command from an
534 initiator will not clear the condition.  (This is by design.)
535 .It Ic startup
536 Issue a
537 .Tn SCSI
538 START STOP UNIT command with the start bit set and the on/offline bit set
539 to all direct access LUNs.  This will mark all direct access LUNs "online"
540 again.  It will not cause any LUNs to start up.  A separate start command
541 without the on/offline bit set is necessary for that.
542 .It Ic hardstop
543 Use the kernel facility for stopping all direct access LUNs and setting the
544 offline bit.  Unlike the
545 .Ic shutdown
546 command above, this command allows shutting down LUNs with I/O active.  It
547 will also issue a LUN reset to any reserved LUNs to break the reservation
548 so that the LUN can be stopped.
549 .Ic shutdown
550 command instead.
551 .It Ic hardstart
552 This command is functionally identical to the
553 .Ic startup
554 command described above.  The primary difference is that the LUNs are
555 enumerated and commands sent by the in-kernel Front End Target Driver
556 instead of by
557 .Nm .
558 .It Ic lunlist
559 List all LUNs registered with CTL.
560 Because this command uses the ioctl port, it will only work when the FETDs
561 (Front End Target Drivers) are enabled.
562 This command is the equivalent of doing a REPORT LUNS on one LUN and then
563 an INQUIRY on each LUN in the system.
564 .It Ic delay
565 Delay commands at the given location.  There are two places where commands
566 may be delayed currently: before data is transferred
567 .Pq Dq datamove
568 and just prior to sending status to the host
569 .Pq Dq done .
570 One of the two must be supplied as an argument to the
571 .Fl l
572 option.  The
573 .Fl t
574 option must also be specified.
575 .Bl -tag -width 12n
576 .It Fl l Ar delayloc
577 Delay command(s) at the specified location.
578 This can either be at the data movement stage (datamove) or prior to
579 command completion (done).
580 .It Fl t Ar delaytime
581 Delay command(s) for the specified number of seconds.  This must be
582 specified.  If set to 0, it will clear out any previously set delay for
583 this particular location (datamove or done).
584 .It Fl T Ar delaytype
585 Specify the delay type.
586 By default, the
587 .Ic delay
588 option will delay the next command sent to the given LUN.
589 With the
590 .Fl T Ar cont
591 option, every command will be delayed by the specified period of time.
592 With the
593 .Fl T Ar oneshot
594 the next command sent to the given LUN will be delayed and all subsequent
595 commands will be completed normally.
596 This is the default.
597 .El
598 .It Ic realsync
599 Query and control CTL's SYNCHRONIZE CACHE behavior.  The
600 .Sq query
601 argument
602 will show whether SYNCHRONIZE CACHE commands are being sent to the backend
603 or not.
604 The default is to send SYNCHRONIZE CACHE commands to the backend.
605 The
606 .Sq on
607 argument will cause all SYNCHRONIZE CACHE commands sent to all LUNs to be
608 sent to the backend.
609 The
610 .Sq off
611 argument will cause all SYNCHRONIZE CACHE commands sent to all LUNs to be
612 immediately returned to the initiator with successful status.
613 .It Ic setsync
614 For a given lun, only actually service every Nth SYNCHRONIZE CACHE command
615 that is sent.  This can be used for debugging the optimal time period for
616 sending SYNCHRONIZE cache commands.  An interval of 0 means that the cache
617 will be flushed for this LUN every time a SYNCHRONIZE CACHE command is
618 received.
619 .Pp
620 You must specify the target and LUN you want to modify.
621 .It Ic getsync
622 Get the interval at which we actually service the SYNCHRONIZE CACHE
623 command, as set by the
624 .Ic setsync
625 command above.
626 The reported number means that we will actually flush the cache on every
627 Nth SYNCHRONIZE CACHE command.  A value of 0 means that we will flush the
628 cache every time.
629 .Pp
630 You must specify the target and LUN you want to query.
631 .It Ic inject
632 Inject the specified type of error for the LUN specified, when a command
633 that matches the given pattern is seen.
634 The sense data returned is in either fixed or descriptor format, depending
635 upon the status of the D_SENSE bit in the control mode page (page 0xa) for
636 the LUN.
637 .Pp
638 Errors are only injected for commands that have not already failed for
639 other reasons.
640 By default, only the first command matching the pattern specified is
641 returned with the supplied error.
642 .Pp
643 If the
644 .Fl c
645 flag is specified, all commands matching the pattern will be returned with
646 the specified error until the error injection command is deleted with
647 .Fl d
648 flag.
649 .Bl -tag -width 17n
650 .It Fl i Ar action
651 Specify the error to return:
652 .Bl -tag -width 10n
653 .It aborted
654 Return the next matching command on the specified LUN with the sense key
655 ABORTED COMMAND (0x0b), and the ASC/ASCQ 0x45,0x00 ("Select or reselect
656 failure").
657 .It mediumerr
658 Return the next matching command on the specified LUN with the sense key
659 MEDIUM ERROR (0x03) and the ASC/ASCQ 0x11,0x00 ("Unrecovered read error") for
660 reads, or ASC/ASCQ 0x0c,0x02 ("Write error - auto reallocation failed")
661 for write errors.
662 .It ua
663 Return the next matching command on the specified LUN with the sense key
664 UNIT ATTENTION (0x06) and the ASC/ASCQ 0x29,0x00 ("POWER ON, RESET, OR BUS
665 DEVICE RESET OCCURRED").
666 .It custom
667 Return the next matching command on the specified LUN with the supplied
668 sense data.
669 The
670 .Fl s
671 argument must be specified.
672 .El
673 .It Fl p Ar pattern
674 Specify which commands should be returned with the given error.
675 .Bl -tag -width 10n
676 .It read
677 The error should apply to READ(6), READ(10), READ(12), READ(16), etc.
678 .It write
679 The error should apply to WRITE(6), WRITE(10), WRITE(12), WRITE(16), WRITE
680 AND VERIFY(10), etc.
681 .It rw
682 The error should apply to both read and write type commands.
683 .It readcap
684 The error should apply to READ CAPACITY(10) and READ CAPACITY(16) commands.
685 .It tur
686 The error should apply to TEST UNIT READY commands.
687 .It any
688 The error should apply to any command.
689 .El
690 .It Fl r Ar lba,len
691 Specify the starting lba and length of the range of LBAs which should
692 trigger an error.
693 This option is only applies when read and/or write patterns are specified.
694 If used with other command types, the error will never be triggered.
695 .It Fl s Ar len fmt Op Ar args
696 Specify the sense data that is to be returned for custom actions.
697 If the format is
698 .Sq - ,
699 len bytes of sense data will be read from standard input and written to the
700 sense buffer.
701 If len is longer than 252 bytes (the maximum allowable
702 .Tn SCSI
703 sense data length), it will be truncated to that length.
704 The sense data format is described in
705 .Xr cam_cdparse 3 .
706 .It Fl c
707 The error injection should be persistent, instead of happening once.
708 Persistent errors must be deleted with the
709 .Fl d
710 argument.
711 .It Fl d Ar delete_id
712 Delete the specified error injection serial number.
713 The serial number is returned when the error is injected.
714 .El
715 .It Ic port
716 Perform one of several CTL frontend port operations.
717 Either get a list of frontend ports
718 .Pq Fl l ,
719 turn one or more frontends on
720 or off
721 .Pq Fl o Ar on|off ,
722 or set the World Wide Node Name
723 .Pq Fl w Ar wwnn
724 or World Wide Port Name
725 .Pq Fl W Ar wwpn
726 for a given port.
727 One of
728 .Fl l ,
729 .Fl o ,
730 or
731 .Fl w
732 or
733 .Fl W
734 must be specified.
735 The WWNN and WWPN may both be specified at the same time, but cannot be
736 combined with enabling/disabling or listing ports.
737 .Bl -tag -width 12n
738 .It Fl l
739 List all CTL frontend ports or a specific port type or number.
740 .It Fl o Ar on|off
741 Turn the specified CTL frontend ports off or on.
742 If no port number or port type is specified, all ports are turned on or
743 off.
744 .It Fl p Ar targ_port
745 Specify the frontend port number.
746 The port numbers can be found in the frontend port list.
747 .It Fl q
748 Omit the header in the port list output.
749 .It Fl t Ar fe_type
750 Specify the frontend type.
751 Currently defined port types are
752 .Dq fc
753 (Fibre Channel),
754 .Dq scsi
755 (Parallel SCSI),
756 .Dq ioctl
757 (CTL ioctl interface),
758 and
759 .Dq internal
760 (CTL CAM SIM).
761 .It Fl w Ar wwnn
762 Set the World Wide Node Name for the given port.
763 The
764 .Fl n
765 argument must be specified, since this is only possible to implement on a
766 single port.
767 As a general rule, the WWNN should be the same across all ports on the
768 system.
769 .It Fl W Ar wwpn
770 Set the World Wide Port Name for the given port.
771 The
772 .Fl n
773 argument must be specified, since this is only possible to implement on a
774 single port.
775 As a general rule, the WWPN must be different for every port in the system.
776 .It Fl x
777 Output the port list in XML format.
778 .El
779 .It Ic portlist
780 List CTL frontend ports.
781 .Bl -tag -width 12n
782 .It Fl f Ar frontend
783 Specify the frontend type.
784 .It Fl i
785 Report target and connected initiators addresses
786 .It Fl p Ar targ_port
787 Specify the frontend port number.
788 .It Fl q
789 Omit the header in the port list output.
790 .It Fl v
791 Enable verbose output (report all port options).
792 .It Fl x
793 Output the port list in XML format.
794 .El
795 .It Ic dumpooa
796 Dump the OOA (Order Of Arrival) queue for each LUN registered with CTL.
797 .It Ic dumpstructs
798 Dump the CTL structures to the console.
799 .It Ic create
800 Create a new LUN.
801 The backend must be specified, and depending upon the backend requested,
802 some of the other options may be required.
803 If the LUN is created successfully, the LUN configuration will be
804 displayed.
805 If LUN creation fails, a message will be displayed describing the failure.
806 .Bl -tag -width 14n
807 .It Fl b Ar backend
808 The
809 .Fl b
810 flag is required.
811 This specifies the name backend to use when creating the LUN.
812 Examples are
813 .Dq ramdisk
814 and
815 .Dq block .
816 .It Fl B Ar blocksize
817 Specify the blocksize of the backend in bytes.
818 .It Fl d Ar device_id
819 Specify the LUN-associated string to use in the
820 .Tn SCSI
821 INQUIRY VPD page 0x83 data.
822 .It Fl l Ar lun_id
823 Request that a particular LUN number be assigned.
824 If the requested LUN number is not available, the request will fail.
825 .It Fl o Ar name=value
826 Specify a backend-specific name/value pair.
827 Multiple
828 .Fl o
829 arguments may be specified.
830 Refer to the backend documentation for arguments that may be used.
831 .It Fl s Ar size_bytes
832 Specify the size of the LUN in bytes.
833 Some backends may allow setting the size (e.g. the ramdisk backend) and for
834 others the size may be implicit (e.g. the block backend).
835 .It Fl S Ar serial_num
836 Specify the serial number to be used in the
837 .Tn SCSI
838 INQUIRY VPD page 0x80 data.
839 .It Fl t Ar device_type
840 Specify the numeric SCSI device type to use when creating the LUN.
841 For example, the Direct Access type is 0.
842 If this flag is not used, the type of LUN created is backend-specific.
843 Not all LUN types are supported.
844 Currently CTL only supports Direct Access (type 0) and Processor (type 3)
845 LUNs.
846 The backend requested may or may not support all of the LUN types that CTL
847 supports.
848 .El
849 .It Ic remove
850 Remove a LUN.
851 The backend must be specified, and the LUN number must also be specified.
852 Backend-specific options may also be specified with the
853 .Fl o
854 flag.
855 .Bl -tag -width 14n
856 .It Fl b Ar backend
857 Specify the backend that owns the LUN to be removed.
858 Examples are
859 .Dq ramdisk
860 and
861 .Dq block .
862 .It Fl l Ar lun_id
863 Specify the LUN number to remove.
864 .It Fl o Ar name=value
865 Specify a backend-specific name/value pair.
866 Multiple
867 .Fl o
868 arguments may be specified.
869 Refer to the backend documentation for arguments that may be used.
870 .El
871 .It Ic modify
872 Modify a LUN size.
873 The backend, the LUN number, and the size must be specified.
874 .Bl -tag -width 14n
875 .It Fl b Ar backend
876 Specify the backend that owns the LUN to be removed.
877 Examples are
878 .Dq ramdisk
879 and
880 .Dq block .
881 .It Fl l Ar lun_id
882 Specify the LUN number to remove.
883 .It Fl s Ar size_bytes
884 Specify the size of the LUN in bytes.
885 For the
886 .Dq block
887 backend, an
888 .Dq auto
889 keyword may be passed instead; this will make CTL use the size of backing
890 file or device.
891 .El
892 .It Ic devlist
893 Get a list of all configured LUNs.
894 This also includes the LUN size and blocksize, serial number and device ID.
895 .Bl -tag -width 11n
896 .It Fl b Ar backend
897 Specify the backend.
898 This restricts the LUN list to the named backend.
899 Examples are
900 .Dq ramdisk
901 and
902 .Dq block .
903 .It Fl v
904 Be verbose.
905 This will also display any backend-specific LUN attributes in addition to
906 the standard per-LUN information.
907 .It Fl x
908 Dump the raw XML.
909 The LUN list information from the kernel comes in XML format, and this
910 option allows the display of the raw XML data.
911 This option and the
912 .Fl v
913 and
914 .Fl b
915 options are mutually exclusive.
916 If you specify
917 .Fl x ,
918 the entire LUN database is displayed in XML format.
919 .El
920 .It Ic islist
921 Get a list of currently running iSCSI connections.
922 This includes initiator and target names and the unique connection IDs.
923 .Bl -tag -width 11n
924 .It Fl v
925 Verbose mode.
926 .It Fl x
927 Dump the raw XML.
928 The connections list information from the kernel comes in XML format, and this
929 option allows the display of the raw XML data.
930 .El
931 .It Ic islogout
932 Ask the initiator to log out iSCSI connections matching criteria.
933 .Bl -tag -width 11n
934 .It Fl a
935 Log out all connections.
936 .It Fl c
937 Specify connection ID.
938 .It Fl i
939 Specify initiator name.
940 .It Fl p
941 Specify initiator portal (hostname or IP address).
942 .El
943 .It Ic isterminate
944 Forcibly terminate iSCSI connections matching criteria.
945 .Bl -tag -width 11n
946 .It Fl a
947 Terminate all connections.
948 .It Fl c
949 Specify connection ID.
950 .It Fl i
951 Specify initiator name.
952 .It Fl p
953 Specify initiator portal (hostname or IP address).
954 .El
955 .It Ic help
956 Display
957 .Nm
958 usage information.
959 .El
960 .Sh OPTIONS
961 Number of additional configuration options may be specified for LUNs.
962 Some options are global, others are backend-specific.
963 .Pp
964 Global options:
965 .Bl -tag -width 12n
966 .It Va vendor
967 Specifies LUN vendor string up to 8 chars.
968 .It Va product
969 Specifies LUN product string up to 16 chars.
970 .It Va revision
971 Specifies LUN revision string up to 4 chars.
972 .It Va scsiname
973 Specifies LUN SCSI name string.
974 .It Va eui
975 Specifies LUN EUI-64 identifier.
976 .It Va naa
977 Specifies LUN NAA identifier.
978 Either EUI or NAA identifier should be set to UNIQUE value to allow
979 EXTENDED COPY command access the LUN.
980 Non-unique LUN identifiers may lead to data corruption.
981 .It Va insecure_tpc
982 Setting to "on" allows EXTENDED COPY command sent to this LUN access
983 other LUNs on this host, not accessible otherwise.
984 This allows to offload copying between different iSCSI targets residing
985 on the same host in trusted environments.
986 .It Va readcache
987 Set to "off", disables read caching for the LUN, if supported by the backend.
988 .It Va readonly
989 Set to "on", blocks all media write operations to the LUN, reporting it
990 as write protected.
991 .It Va reordering
992 Set to "unrestricted", allows target to process commands with SIMPLE task
993 attribute in arbitrary order.  Any data integrity exposures related to
994 command sequence order shall be explicitly handled by the application
995 client through the selection of appropriate commands and task attributes.
996 The default value is "restricted".  It improves data integrity, but may
997 introduce some additional delays.
998 .It Va serseq
999 Set to "on" to serialize conseсutive reads/writes.
1000 Set to "read" to serialize conseсutive reads.
1001 Set to "off" to allow them be issued in parallel.
1002 Parallel issue of consecutive operations may confuse logic of the
1003 backing file system, hurting performance; but it may improve performance
1004 of backing stores without prefetch/write-back.
1005 .It Va rpm
1006 Specifies medium rotation rate of the device: 0 -- not reported,
1007 1 -- non-rotating (SSD), >1024 -- value in revolutions per minute.
1008 .It Va formfactor
1009 Specifies nominal form factor of the device: 0 -- not reported, 1 -- 5.25",
1010 2 -- 3.5", 3 -- 2.5", 4 -- 1.8", 5 -- less then 1.8".
1011 .It Va unmap
1012 Set to "on", enables UNMAP support for the LUN, if supported by the backend.
1013 .It Va avail-threshold
1014 .It Va used-threshold
1015 .It Va pool-avail-threshold
1016 .It Va pool-used-threshold
1017 Set per-LUN/-pool thin provisioning soft thresholds.
1018 LUN will establish UNIT ATTENTION condition if its or pool available space
1019 get below configured avail values, or its or pool used space get above
1020 configured used values.
1021 Pool thresholds are working only for ZVOL-backed LUNs.
1022 .It Va writecache
1023 Set to "off", disables write caching for the LUN, if supported by the backend.
1024 .El
1025 .Pp
1026 Options specific for block backend:
1027 .Bl -tag -width 12n
1028 .It Va file
1029 Specifies file or device name to use for backing store.
1030 .It Va num_threads
1031 Specifies number of backend threads to use for this LUN.
1032 .El
1033 .Sh EXAMPLES
1034 .Dl ctladm tur 0:1
1035 .Pp
1036 Send a
1037 .Tn SCSI
1038 TEST UNIT READY command to LUN 1.
1039 .Pp
1040 .Dl ctladm modesense 0:1 -l
1041 .Pp
1042 Display the list of mode pages supported by LUN 1.
1043 .Pp
1044 .Dl ctladm modesense 0:0 -m 10 -P 3 -d -c 10
1045 .Pp
1046 Display the saved version of the Control mode page (page 10) on LUN 0.
1047 Disable fetching block descriptors, and use a 10 byte MODE SENSE command
1048 instead of the default 6 byte command.
1049 .Bd -literal
1050 ctladm read 0:2 -l 0 -d 1 -b 512 -f - > foo
1051 .Ed
1052 .Pp
1053 Read the first 512 byte block from LUN 2 and dump it to the file
1054 .Pa foo .
1055 .Bd -literal
1056 ctladm write 0:3 -l 0xff432140 -d 20 -b 512 -f /tmp/bar
1057 .Ed
1058 .Pp
1059 Read 10240 bytes from the file
1060 .Pa /tmp/bar
1061 and write it to target 0, LUN 3.
1062 starting at LBA 0xff432140.
1063 .Pp
1064 .Dl ctladm create -b ramdisk -s 10485760000000000
1065 .Pp
1066 Create a LUN with the
1067 .Dq fake
1068 ramdisk as a backing store.
1069 The LUN will claim to have a size of approximately 10 terabytes.
1070 .Pp
1071 .Dl ctladm create -b block -o file=src/usr.sbin/ctladm/ctladm.8
1072 .Pp
1073 Create a LUN using the block backend, and specify the file
1074 .Pa src/usr.sbin/ctladm/ctladm.8
1075 as the backing store.
1076 The size of the LUN will be derived from the size of the file.
1077 .Pp
1078 .Dl ctladm create -b block -o file=src/usr.sbin/ctladm/ctladm.8 -S MYSERIAL321 -d MYDEVID123
1079 .Pp
1080 Create a LUN using the block backend, specify the file
1081 .Pa src/usr.sbin/ctladm/ctladm.8
1082 as the backing store, and specify the
1083 .Tn SCSI
1084 VPD page 0x80 and 0x83 serial number
1085 .Fl ( S )
1086 and device ID
1087 .Fl ( d ) .
1088 .Pp
1089 .Dl ctladm remove -b block -l 12
1090 .Pp
1091 Remove LUN 12, which is handled by the block backend, from the system.
1092 .Pp
1093 .Dl ctladm devlist
1094 .Pp
1095 List configured LUNs in the system, along with their backend and serial
1096 number.
1097 This works when the Front End Target Drivers are enabled or disabled.
1098 .Pp
1099 .Dl ctladm lunlist
1100 .Pp
1101 List all LUNs in the system, along with their inquiry data and device type.
1102 This only works when the FETDs are enabled, since the commands go through the
1103 ioctl port.
1104 .Pp
1105 .Dl ctladm inject 0:6 -i mediumerr -p read -r 0,512 -c
1106 .Pp
1107 Inject a medium error on LUN 6 for every read that covers the first 512
1108 blocks of the LUN.
1109 .Bd -literal -offset indent
1110 ctladm inject 0:6 -i custom -p tur -s 18 "f0 0 02 s12 04 02"
1111 .Ed
1112 .Pp
1113 Inject a custom error on LUN 6 for the next TEST UNIT READY command only.
1114 This will result in a sense key of NOT READY (0x02), and an ASC/ASCQ of
1115 0x04,0x02 ("Logical unit not ready, initializing command required").
1116 .Sh SEE ALSO
1117 .Xr cam 3 ,
1118 .Xr cam_cdbparse 3 ,
1119 .Xr cam 4 ,
1120 .Xr ctl 4 ,
1121 .Xr xpt 4 ,
1122 .Xr camcontrol 8 ,
1123 .Xr ctld 8
1124 .Sh HISTORY
1125 The
1126 .Nm
1127 utility was originally written during the Winter/Spring of 2003 as an
1128 interface to CTL.
1129 .Sh AUTHORS
1130 .An Ken Merry Aq ken@FreeBSD.org