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