xref: /freebsd/usr.sbin/ctladm/ctladm.8 (revision b7c60aadbbd5c846a250c05791fe7406d6d78bf4)
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 July 8, 2011
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 devlist
177.Op Fl b Ar backend
178.Op Fl v
179.Op Fl x
180.Nm
181.Ic port
182.Op Fl l
183.Op Fl o Ar on|off
184.Op Fl w Ar wwpn
185.Op Fl W Ar wwnn
186.Op Fl p Ar targ_port
187.Op Fl t Ar fe_type
188.Op Fl q
189.Op Fl x
190.Nm
191.Ic dumpooa
192.Nm
193.Ic dumpstructs
194.Nm
195.Ic help
196.Sh DESCRIPTION
197The
198.Nm
199utility is designed to provide a way to access and control the CAM Target
200Layer (CTL).
201It provides a way to send
202.Tn SCSI
203commands to the CTL layer, and also provides
204some meta-commands that utilize
205.Tn SCSI
206commands.
207(For instance, the
208.Ic lunlist
209command is implemented using the
210.Tn SCSI
211REPORT LUNS and INQUIRY commands.)
212.Pp
213The
214.Nm
215utility has a number of primary functions, many of which require a device
216identifier.
217The device identifier takes the following form:
218.Bl -tag -width 14n
219.It target:lun
220Specify the target (almost always 0) and LUN number to operate on.
221.El
222Many of the primary functions of the
223.Nm
224utility take the following optional arguments:
225.Pp
226.Bl -tag -width 10n
227.It Fl C Ar retries
228Specify the number of times to retry a command in the event of failure.
229.It Fl D Ar device
230Specify the device to open.  This allows opening a device other than the
231default device,
232.Pa /dev/cam/ctl ,
233to be opened for sending commands.
234.It Fl I Ar id
235Specify the initiator number to use.
236By default,
237.Nm
238will use 7 as the initiator number.
239.El
240.Pp
241Primary commands:
242.Bl -tag -width 11n
243.It Ic tur
244Send the
245.Tn SCSI
246TEST UNIT READY command to the device and report whether or not it is
247ready.
248.It Ic inquiry
249Send the
250.Tn SCSI
251INQUIRY command to the device and display some of the returned inquiry
252data.
253.It Ic reqsense
254Send the
255.Tn SCSI
256REQUEST SENSE command to the device and display the returned sense
257information.
258.It Ic reportluns
259Send the
260.Tn SCSI
261REPORT LUNS command to the device and display supported LUNs.
262.It Ic read
263Send a
264.Tn SCSI
265READ command to the device, and write the requested data to a file or
266stdout.
267.Bl -tag -width 12n
268.It Fl l Ar lba
269Specify the starting Logical Block Address for the READ.  This can be
270specified in decimal, octal (starting with 0), hexadecimal (starting with
2710x) or any other base supported by
272.Xr strtoull 3 .
273.It Fl d Ar datalen
274Specify the length, in 512 byte blocks, of the READ request.
275.It Fl f Ar file
276Specify the destination for the data read by the READ command.  Either a
277filename or
278.Sq -
279for stdout may be specified.
280.It Fl c Ar cdbsize
281Specify the minimum
282.Tn SCSI
283CDB (Command Data Block) size to be used for the READ request.  Allowable
284values are 6, 10, 12 and 16.  Depending upon the LBA and amount of data
285requested, a larger CDB size may be used to satisfy the request.  (e.g.,
286for LBAs above 0xffffffff, READ(16) must be used to satisfy the request.)
287.It Fl b Ar blocksize
288Specify the blocksize of the underlying
289.Tn SCSI
290device, so the transfer length
291can be calculated accurately.  The blocksize can be obtained via the
292.Tn SCSI
293READ CAPACITY command.
294.It Fl N
295Do not copy data to
296.Nm
297from the kernel when doing a read, just execute the command without copying
298data.
299This is to be used for performance testing.
300.El
301.It Ic write
302Read data from a file or stdin, and write the data to the device using the
303.Tn SCSI
304WRITE command.
305.Bl -tag -width 12n
306.It Fl l Ar lba
307Specify the starting Logical Block Address for the WRITE.  This can be
308specified in decimal, octal (starting with 0), hexadecimal (starting with
3090x) or any other base supported by
310.Xr strtoull 3 .
311.It Fl d Ar atalen
312Specify the length, in 512 byte blocks, of the WRITE request.
313.It Fl f Ar file
314Specify the source for the data to be written by the WRITE command.  Either a
315filename or
316.Sq -
317for stdin may be specified.
318.It Fl c Ar cdbsize
319Specify the minimum
320.Tn SCSI
321CDB (Command Data Block) size to be used for the READ request.  Allowable
322values are 6, 10, 12 and 16.  Depending upon the LBA and amount of data
323requested, a larger CDB size may be used to satisfy the request.  (e.g.,
324for LBAs above 0xffffffff, READ(16) must be used to satisfy the request.)
325.It Fl b Ar blocksize
326Specify the blocksize of the underlying
327.Tn SCSI
328device, so the transfer length
329can be calculated accurately.  The blocksize can be obtained via the
330.Tn SCSI
331READ CAPACITY command.
332.It Fl N
333Do not copy data to
334.Nm
335to the kernel when doing a write, just execute the command without copying
336data.
337This is to be used for performance testing.
338.El
339.It Ic bbrread
340Issue a SCSI READ command to the logical device to potentially force a bad
341block on a disk in the RAID set to be reconstructed from the other disks in
342the array.  This command should only be used on an array that is in the
343normal state.  If used on a critical array, it could cause the array to go
344offline if the bad block to be remapped is on one of the disks that is
345still active in the array.
346.Pp
347The data for this particular command will be discarded, and not returned to
348the user.
349.Pp
350In order to determine which LUN to read from, the user should first
351determine which LUN the disk with a bad block belongs to.  Then he should
352map the bad disk block back to the logical block address for the array in
353order to determine which LBA to pass in to the
354.Ic bbrread
355command.
356.Pp
357This command is primarily intended for testing.  In practice, bad block
358remapping will generally be triggered by the in-kernel Disk Aerobics and
359Disk Scrubbing code.
360.Bl -tag -width 10n
361.It Fl l Ar lba
362Specify the starting Logical Block Address.
363.It Fl d Ar datalen
364Specify the amount of data in bytes to read from the LUN.  This must be a
365multiple of the LUN blocksize.
366.El
367.It Ic readcap
368Send the
369.Tn SCSI
370READ CAPACITY command to the device and display the device size and device
371block size.  By default, READ CAPACITY(10) is
372used.  If the device returns a maximum LBA of 0xffffffff, however,
373.Nm
374will automatically issue a READ CAPACITY(16), which is implemented as a
375service action of the SERVICE ACTION IN(16) opcode.  The user can specify
376the minimum CDB size with the
377.Fl c
378argument.  Valid values for the
379.Fl c
380option are 10 and 16.  If a 10 byte CDB is specified, the request will be
381automatically reissued with a 16 byte CDB if the maximum LBA returned is
3820xffffffff.
383.It Ic modesense
384Send a
385.Tn SCSI
386MODE SENSE command to the device, and display the requested mode page(s) or
387page list.
388.Bl -tag -width 10n
389.It Fl m Ar page
390Specify the mode page to display.  This option and the
391.Fl l
392option are mutually exclusive.  One of the two must be specified, though.
393Mode page numbers may be specified in decimal or hexadecimal.
394.It Fl l
395Request that the list of mode pages supported by the device be returned.
396This option and the
397.Fl m
398option are mutually exclusive.  One of the two must be specified, though.
399.It Fl P Ar pc
400Specify the mode page page control value.  Possible values are:
401.Bl -tag -width 2n -compact
402.It 0
403Current values.
404.It 1
405Changeable value bitmask.
406.It 2
407Default values.
408.It 3
409Saved values.
410.El
411.It Fl d
412Disable block descriptors when sending the mode sense request.
413.It Fl S Ar subpage
414Specify the subpage used with the mode sense request.
415.It Fl c Ar cdbsize
416Specify the CDB size used for the mode sense request.  Supported values are
4176 and 10.
418.El
419.It Ic start
420Send the
421.Tn SCSI
422START STOP UNIT command to the specified LUN with the start
423bit set.
424.Bl -tag -width 4n
425.It Fl i
426Set the immediate bit in the CDB.  Note that CTL does not support the
427immediate bit, so this is primarily useful for making sure that CTL returns
428the proper error.
429.It Fl o
430Set the Copan proprietary on/offline bit in the CDB.  When this flag is
431used, the LUN will be marked online again (see the description of the
432.Ic shutdown
433and
434.Ic startup
435commands).  When this flag is used with a
436start command, the LUN will NOT be spun up.  You need to use a start
437command without the
438.Fl o
439flag to spin up the disks in the LUN.
440.El
441.It Ic stop
442Send the
443.Tn SCSI
444START STOP UNIT command to the specified LUN with the start
445bit cleared.  We use an ordered tag to stop the LUN, so we can guarantee
446that all pending I/O executes before it is stopped.  (CTL guarantees this
447anyway, but
448.Nm
449sends an ordered tag for completeness.)
450.Bl -tag -width 4n
451.It Fl i
452Set the immediate bit in the CDB.  Note that CTL does not support the
453immediate bit, so this is primarily useful for making sure that CTL returns
454the proper error.
455.It Fl o
456Set the Copan proprietary on/offline bit in the CDB.  When this flag is
457used, the LUN will be spun down and taken offline ("Logical unit not ready,
458manual intervention required").  See the description of the
459.Ic shutdown
460and
461.Ic startup
462options.
463.El
464.It Ic synccache
465Send the
466.Tn SCSI
467SYNCHRONIZE CACHE command to the device.  By default, SYNCHRONIZE
468CACHE(10) is used.  If the specified starting LBA is greater than
4690xffffffff or the length is greater than 0xffff, though,
470SYNCHRONIZE CACHE(16) will be used.  The 16 byte command will also be used
471if the user specifies a 16 byte CDB with the
472.Fl c
473argument.
474.Bl -tag -width 14n
475.It Fl l Ar lba
476Specify the starting LBA of the cache region to synchronize.  This option is a
477no-op for CTL.  If you send a SYNCHRONIZE CACHE command, it will sync the
478cache for the entire LUN.
479.It Fl b Ar blockcount
480Specify the length of the cache region to synchronize.  This option is a
481no-op for CTL.  If you send a SYNCHRONIZE CACHE command, it will sync the
482cache for the entire LUN.
483.It Fl r
484Specify relative addressing for the starting LBA.  CTL does not support
485relative addressing, since it only works for linked commands, and CTL
486doesn't support linked commands.
487.It Fl i
488Tell the target to return status immediately after issuing the SYHCHRONIZE CACHE
489command rather than waiting for the cache to finish syncing.  CTL does not
490support this bit.
491.It Fl c Ar cdbsize
492Specify the minimum CDB size.  Valid values are 10 and 16 bytes.
493.El
494.It Ic shutdown
495Issue a
496.Tn SCSI
497START STOP UNIT command with the start bit cleared and the on/offline bit
498set to all direct access LUNs.  This will spin down all direct access LUNs,
499and mark them offline ("Logical unit not ready, manual intervention
500required").  Once marked offline, the state can only be cleared by sending
501a START STOP UNIT command with the start bit set and the on/offline bit
502set.  The
503.Nm
504commands
505.Ic startup
506and
507.Ic start
508will accomplish this.  Note that the
509on/offline bit is a non-standard Copan extension to the
510.Tn SCSI
511START STOP UNIT command, so merely sending a normal start command from an
512initiator will not clear the condition.  (This is by design.)
513.It Ic startup
514Issue a
515.Tn SCSI
516START STOP UNIT command with the start bit set and the on/offline bit set
517to all direct access LUNs.  This will mark all direct access LUNs "online"
518again.  It will not cause any LUNs to start up.  A separate start command
519without the on/offline bit set is necessary for that.
520.It Ic hardstop
521Use the kernel facility for stopping all direct access LUNs and setting the
522offline bit.  Unlike the
523.Ic shutdown
524command above, this command allows shutting down LUNs with I/O active.  It
525will also issue a LUN reset to any reserved LUNs to break the reservation
526so that the LUN can be stopped.
527.Ic shutdown
528command instead.
529.It Ic hardstart
530This command is functionally identical to the
531.Ic startup
532command described above.  The primary difference is that the LUNs are
533enumerated and commands sent by the in-kernel Front End Target Driver
534instead of by
535.Nm .
536.It Ic lunlist
537List all LUNs registered with CTL.
538Because this command uses the ioctl port, it will only work when the FETDs
539(Front End Target Drivers) are enabled.
540This command is the equivalent of doing a REPORT LUNS on one LUN and then
541and then an INQUIRY on each LUN in the system.
542.It Ic delay
543Delay commands at the given location.  There are two places where commands
544may be delayed currently: before data is transferred
545.Pq Dq datamove
546and just prior to sending status to the host
547.Pq Dq done .
548One of the two must be supplied as an argument to the
549.Fl l
550option.  The
551.Fl t
552option must also be specified.
553.Bl -tag -width 12n
554.It Fl l Ar delayloc
555Delay command(s) at the specified location.
556This can either be at the data movement stage (datamove) or prior to
557command completion (done).
558.It Fl t Ar delaytime
559Delay command(s) for the specified number of seconds.  This must be
560specified.  If set to 0, it will clear out any previously set delay for
561this particular location (datamove or done).
562.It Fl T Ar delaytype
563Specify the delay type.
564By default, the
565.Ic delay
566option will delay the next command sent to the given LUN.
567With the
568.Fl T Ar cont
569option, every command will be delayed by the specified period of time.
570With the
571.Fl T Ar oneshot
572the next command sent to the given LUN will be delayed and all subsequent
573commands will be completed normally.
574This is the default.
575.El
576.It Ic realsync
577Query and control CTL's SYNCHRONIZE CACHE behavior.  The
578.Sq query
579argument
580will show whether SYNCHRONIZE CACHE commands are being sent to the backend
581or not.
582The default is to send SYNCHRONIZE CACHE commands to the backend.
583The
584.Sq on
585argument will cause all SYNCHRONIZE CACHE commands sent to all LUNs to be
586sent to the backend.
587The
588.Sq off
589argument will cause all SYNCHRONIZE CACHE commands sent to all LUNs to be
590immediately returned to the initiator with successful status.
591.It Ic setsync
592For a given lun, only actually service every Nth SYNCHRONIZE CACHE command
593that is sent.  This can be used for debugging the optimal time period for
594sending SYNCHRONIZE cache commands.  An interval of 0 means that the cache
595will be flushed for this LUN every time a SYNCHRONIZE CACHE command is
596received.
597.Pp
598You must specify the target and LUN you want to modify.
599.It Ic getsync
600Get the interval at which we actually service the SYNCHRONIZE CACHE
601command, as set by the
602.Ic setsync
603command above.
604The reported number means that we will actually flush the cache on every
605Nth SYNCHRONIZE CACHE command.  A value of 0 means that we will flush the
606cache every time.
607.Pp
608You must specify the target and LUN you want to query.
609.It Ic inject
610Inject the specified type of error for the LUN specified, when a command
611that matches the given pattern is seen.
612The sense data returned is in either fixed or descriptor format, depending
613upon the status of the D_SENSE bit in the control mode page (page 0xa) for
614the LUN.
615.Pp
616Errors are only injected for commands that have not already failed for
617other reasons.
618By default, only the first command matching the pattern specified is
619returned with the supplied error.
620.Pp
621If the
622.Fl c
623flag is specified, all commands matching the pattern will be returned with
624the specified error until the error injection command is deleted with
625.Fl d
626flag.
627.Bl -tag -width 17n
628.It Fl i Ar action
629Specify the error to return:
630.Bl -tag -width 10n
631.It aborted
632Return the next matching command on the specified LUN with the sense key
633ABORTED COMMAND (0x0b), and the ASC/ASCQ 0x45,0x00 ("Select or reselect
634failure").
635.It mediumerr
636Return the next matching command on the specified LUN with the sense key
637MEDIUM ERROR (0x03) and the ASC/ASCQ 0x11,0x00 ("Unrecovered read error") for
638reads, or ASC/ASCQ 0x0c,0x02 ("Write error - auto reallocation failed")
639for write errors.
640.It ua
641Return the next matching command on the specified LUN with the sense key
642UNIT ATTENTION (0x06) and the ASC/ASCQ 0x29,0x00 ("POWER ON, RESET, OR BUS
643DEVICE RESET OCCURRED").
644.It custom
645Return the next matching command on the specified LUN with the supplied
646sense data.
647The
648.Fl s
649argument must be specified.
650.El
651.It Fl p Ar pattern
652Specify which commands should be returned with the given error.
653.Bl -tag -width 10n
654.It read
655The error should apply to READ(6), READ(10), READ(12), READ(16), etc.
656.It write
657The error should apply to WRITE(6), WRITE(10), WRITE(12), WRITE(16), WRITE
658AND VERIFY(10), etc.
659.It rw
660The error should apply to both read and write type commands.
661.It readcap
662The error should apply to READ CAPACITY(10) and READ CAPACITY(16) commands.
663.It tur
664The error should apply to TEST UNIT READY commands.
665.It any
666The error should apply to any command.
667.El
668.It Fl r Ar lba,len
669Specify the starting lba and length of the range of LBAs which should
670trigger an error.
671This option is only applies when read and/or write patterns are specified.
672If used with other command types, the error will never be triggered.
673.It Fl s Ar len fmt Op Ar args
674Specify the sense data that is to be returned for custom actions.
675If the format is
676.Sq - ,
677len bytes of sense data will be read from standard input and written to the
678sense buffer.
679If len is longer than 252 bytes (the maximum allowable
680.Tn SCSI
681sense data length), it will be truncated to that length.
682The sense data format is described in
683.Xr cam_cdparse 3 .
684.It Fl c
685The error injection should be persistent, instead of happening once.
686Persistent errors must be deleted with the
687.Fl d
688argument.
689.It Fl d Ar delete_id
690Delete the specified error injection serial number.
691The serial number is returned when the error is injected.
692.El
693.It Ic port
694Perform one of several CTL frontend port operations.
695Either get a list of frontend ports
696.Pq Fl l ,
697turn one or more frontends on
698or off
699.Pq Fl o Ar on|off ,
700or set the World Wide Node Name
701.Pq Fl w Ar wwnn
702or World Wide Port Name
703.Pq Fl W Ar wwpn
704for a given port.
705One of
706.Fl l ,
707.Fl o ,
708or
709.Fl w
710or
711.Fl W
712must be specified.
713The WWNN and WWPN may both be specified at the same time, but cannot be
714combined with enabling/disabling or listing ports.
715.Bl -tag -width 12n
716.It Fl l
717List all CTL frontend ports or a specific port type or number.
718.It Fl o Ar on|off
719Turn the specified CTL frontend ports off or on.
720If no port number or port type is specified, all ports are turned on or
721off.
722.It Fl p Ar targ_port
723Specify the frontend port number.
724The port numbers can be found in the frontend port list.
725.It Fl q
726Omit the header in the port list output.
727.It Fl t Ar fe_type
728Specify the frontend type.
729Currently defined port types are
730.Dq fc
731(Fibre Channel),
732.Dq scsi
733(Parallel SCSI),
734.Dq ioctl
735(CTL ioctl interface),
736and
737.Dq internal
738(CTL CAM SIM).
739.It Fl w Ar wwnn
740Set the World Wide Node Name for the given port.
741The
742.Fl n
743argument must be specified, since this is only possible to implement on a
744single port.
745As a general rule, the WWNN should be the same across all ports on the
746system.
747.It Fl W Ar wwpn
748Set the World Wide Node Name for the given port.
749The
750.Fl n
751argument must be specified, since this is only possible to implement on a
752single port.
753As a general rule, the WWPN must be different for every port in the system.
754.It Fl x
755Output the port list in XML format.
756.El
757.It Ic dumpooa
758Dump the OOA (Order Of Arrival) queue for each LUN registered with CTL.
759.It Ic dumpstructs
760Dump the CTL structures to the console.
761.It Ic create
762Create a new LUN.
763The backend must be specified, and depending upon the backend requested,
764some of the other options may be required.
765If the LUN is created successfully, the LUN configuration will be
766displayed.
767If LUN creation fails, a message will be displayed describing the failure.
768.Bl -tag -width 14n
769.It Fl b Ar backend
770The
771.Fl b
772flag is required.
773This specifies the name backend to use when creating the LUN.
774Examples are
775.Dq ramdisk
776and
777.Dq block .
778.It Fl B Ar blocksize
779Specify the blocksize of the backend in bytes.
780.It Fl d Ar device_id
781Specify the LUN-associated string to use in the
782.Tn SCSI
783INQUIRY VPD page 0x83 data.
784.It Fl l Ar lun_id
785Request that a particular LUN number be assigned.
786If the requested LUN number is not available, the request will fail.
787.It Fl o Ar name=value
788Specify a backend-specific name/value pair.
789Multiple
790.Fl o
791arguments may be specified.
792Refer to the backend documentation for arguments that may be used.
793.It Fl s Ar size_bytes
794Specify the size of the LUN in bytes.
795Some backends may allow setting the size (e.g. the ramdisk backend) and for
796others the size may be implicit (e.g. the block backend).
797.It Fl S Ar serial_num
798Specify the serial number to be used in the
799.Tn SCSI
800INQUIRY VPD page 0x80 data.
801.It Fl t Ar device_type
802Specify the numeric SCSI device type to use when creating the LUN.
803For example, the Direct Access type is 0.
804If this flag is not used, the type of LUN created is backend-specific.
805Not all LUN types are supported.
806Currently CTL only supports Direct Access (type 0) and Processor (type 3)
807LUNs.
808The backend requested may or may not support all of the LUN types that CTL
809supports.
810.El
811.It Ic remove
812Remove a LUN.
813The backend must be specified, and the LUN number must also be specified.
814Backend-specific options may also be specified with the
815.Fl o
816flag.
817.Bl -tag -width 14n
818.It Fl b Ar backend
819Specify the backend that owns the LUN to be removed.
820Examples are
821.Dq ramdisk
822and
823.Dq block .
824.It Fl l Ar lun_id
825Specify the LUN number to remove.
826.It Fl o Ar name=value
827Specify a backend-specific name/value pair.
828Multiple
829.Fl o
830arguments may be specified.
831Refer to the backend documentation for arguments that may be used.
832.El
833.It Ic devlist
834Get a list of all configured LUNs.
835This also includes the LUN size and blocksize, serial number and device ID.
836.Bl -tag -width 11n
837.It Fl b Ar backend
838Specify the backend.
839This restricts the LUN list to the named backend.
840Examples are
841.Dq ramdisk
842and
843.Dq block .
844.It Fl v
845Be verbose.
846This will also display any backend-specific LUN attributes in addition to
847the standard per-LUN information.
848.It Fl x
849Dump the raw XML.
850The LUN list information from the kernel comes in XML format, and this
851option allows the display of the raw XML data.
852This option and the
853.Fl v
854and
855.Fl b
856options are mutually exclusive.
857If you specify
858.Fl x ,
859the entire LUN database is displayed in XML format.
860.El
861.It Ic help
862Display
863.Nm
864usage information.
865.El
866.Sh EXAMPLES
867.Dl ctladm tur 0:1
868.Pp
869Send a
870.Tn SCSI
871TEST UNIT READY command to LUN 1.
872.Pp
873.Dl ctladm modesense 0:1 -l
874.Pp
875Display the list of mode pages supported by LUN 1.
876.Pp
877.Dl ctladm modesense 0:0 -m 10 -P 3 -d -c 10
878.Pp
879Display the saved version of the Control mode page (page 10) on LUN 0.
880Disable fetching block descriptors, and use a 10 byte MODE SENSE command
881instead of the default 6 byte command.
882.Pp
883.Bd -literal
884ctladm read 0:2 -l 0 -d 1 -b 512 -f - > foo
885.Ed
886.Pp
887Read the first 512 byte block from LUN 2 and dump it to the file
888.Pa foo .
889.Bd -literal
890ctladm write 0:3 -l 0xff432140 -d 20 -b 512 -f /tmp/bar
891.Ed
892.Pp
893Read 10240 bytes from the file
894.Pa /tmp/bar
895and write it to target 0, LUN 3.
896starting at LBA 0xff432140.
897.Pp
898.Dl ctladm create -b ramdisk -s 10485760000000000
899.Pp
900Create a LUN with the
901.Dq fake
902ramdisk as a backing store.
903The LUN will claim to have a size of approximately 10 terabytes.
904.Pp
905.Dl ctladm create -b block -o file=src/usr.sbin/ctladm/ctladm.8
906.Pp
907Create a LUN using the block backend, and specify the file
908.Pa src/usr.sbin/ctladm/ctladm.8
909as the backing store.
910The size of the LUN will be derived from the size of the file.
911.Pp
912.Dl ctladm create -b block -o file=src/usr.sbin/ctladm/ctladm.8 -S MYSERIAL321 -d MYDEVID123
913.Pp
914Create a LUN using the block backend, specify the file
915.Pa src/usr.sbin/ctladm/ctladm.8
916as the backing store, and specify the
917.Tn SCSI
918VPD page 0x80 and 0x83 serial number (
919.Fl S)
920and device ID (
921.Fl d).
922.Pp
923.Dl ctladm remove -b block -l 12
924.Pp
925Remove LUN 12, which is handled by the block backend, from the system.
926.Pp
927.Dl ctladm devlist
928.Pp
929List configured LUNs in the system, along with their backend and serial
930number.
931This works when the Front End Target Drivers are enabled or disabled.
932.Pp
933.Dl ctladm lunlist
934.Pp
935List all LUNs in the system, along with their inquiry data and device type.
936This only works when the FETDs are enabled, since the commands go through the
937ioctl port.
938.Pp
939.Dl ctladm inject 0:6 -i mediumerr -p read -r 0,512 -c
940.Pp
941Inject a medium error on LUN 6 for every read that covers the first 512
942blocks of the LUN.
943.Pp
944.Bd -literal -offset indent
945ctladm inject 0:6 -i custom -p tur -s 18 "f0 0 02 s12 04 02"
946.Ed
947.Pp
948Inject a custom error on LUN 6 for the next TEST UNIT READY command only.
949This will result in a sense key of NOT READY (0x02), and an ASC/ASCQ of
9500x04,0x02 ("Logical unit not ready, initializing command required").
951.Sh SEE ALSO
952.Xr cam 3 ,
953.Xr cam_cdbparse 3 ,
954.Xr cam 4 ,
955.Xr xpt 4 ,
956.Xr camcontrol 8
957.Sh HISTORY
958The
959.Nm
960utility was originally written during the Winter/Spring of 2003 as an
961interface to CTL.
962.Sh AUTHORS
963.An Ken Merry Aq ken@FreeBSD.org
964