History log of /freebsd-10-stable/sys/cam/
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
344394 20-Feb-2019 dab

MFC r344024:

CID 1009492: Logically dead code in sys/cam/scsi/scsi_xpt.c

In `probedone()`, for the `PROBE_REPORT_LUNS` case, all paths that
fall to the bottom of the case set `lp` to `NULL`, so the test for a
non-NULL value of `lp` and call to `free()` if true is dead code as
the test can never be true. Fix by eliminating the whole if
statement. To guard against a possible future change that accidentally
violates this assumption, use a `KASSERT()` to catch if `lp` is
non-NULL.

Sponsored by: Dell EMC Isilon

344221 17-Feb-2019 avos

MFC r343501:
Add NO_6_BYTE / NO_SYNC_CACHE quirks for (C|D|E).* Olympus digital cameras

PR: 97472
Submitted by: Fabio Luis Girardi <papelhigienico@gmail.com>
Reviewed by: imp

332933 24-Apr-2018 ken

MFC r332458:
------------------------------------------------------------------------
r332458 | ken | 2018-04-12 15:21:18 -0600 (Thu, 12 Apr 2018) | 34 lines

Handle Programmable Early Warning for control commands in sa(4).

When the tape position is inside the Early Warning area, the tape
drive will return a sense key of NO SENSE, and an ASC/ASCQ of
0x00,0x02, which means: End-of-partition/medium detected". If
this was in response to a control command like WRITE FILEMARKS,
we correctly translate this as informational status and return
0 from saerror().

Programmable Early Warning should be handled the same way, but
we weren't handling it that way. As a result, if a PEW status
(sense key of NO SENSE, ASC/ASCQ of 0x00,0x07, "Programmable early
warning detected") came back in response to a WRITE FILEMARKS,
we returned an error.

The impact of this was that if an application was writing to a
sa(4) device, and a PEW area was set (in the Device Configuration
Extension subpage -- mode page 0x10, subpage 1), and a filemark
needed to be written on close, we could wind up returning an error
to the user on close because of a "failure" to write the filemarks.

It actually isn't a failure, but rather just a status report from
the drive, and shouldn't be treated as a failure.

sys/cam/scsi/scsi_sa.c:
For control commands in saerror(), treat asc/ascq 0x00,0x07
the same as 0x00,{0-5} -- not an error. Return 0, since
the command actually did succeed.

Reported by: Dr. Andreas Haakh <andreas@haakh.de>
Tested by: Dr. Andreas Haakh <andreas@haakh.de>
Sponsored by: Spectra Logic
------------------------------------------------------------------------

331633 27-Mar-2018 brooks

MFC r330820:

Reject ioctls to SCSI enclosures from 32-bit compat processes.

The ioctl objects contain pointers and require translation and some
refactoring of the infrastructure to work. For now prevent opertion
on garbage values. This is very slightly overbroad in that ENCIOC_INIT
is safe.

Reviewed by: imp, kib
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14671

331632 27-Mar-2018 brooks

MFC r330819, r330885, r330934

r330819:
Reject CAMIOGET and CAMIOQUEUE ioctl's on pass(4) in 32-bit compat mode.

These take a union ccb argument which is full of kernel pointers.
Substantial translation efforts would be required to make this work.
By rejecting the request we avoid processing or returning entierly
wrong data.

Reviewed by: imp, ken, markj, cem
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14654

r330885:
We need opt_compat.h after r330819 and 330820.

Add opt_compat.h to fix the stand-alone build case.

Sponsored by: Netflix.

r330934:
This should have been += so clean builds work.

Noticed by: hps@

329319 15-Feb-2018 avg

MFC r327996: geom_disk / scsi_da: deny opening write-protected disks for writing

Ths change consists of two parts.

geom_disk: deny opening a disk for writing if it's marked as
write-protected. A new disk(9) flag is added to mark write protected
disks. A possible alternative could be to add another parameter to d_open,
so that the open mode could be passed to it and the disk drivers could
make the decision internally, but the flag required less churn.

scsi_da: add a new phase of disk probing to query the all pages mode
sense page. We can determine if the disk is write protected using bit 7
of the device specific field in the mode parameter header returned by
MODE SENSE.

PR: 224037

323987 25-Sep-2017 jkim

MFC: r323840

Remove an ancient comment about the existence of READ(16)/WRITE(16) for MMC.

323737 19-Sep-2017 avg

MFV r318962: Allow PROBE_SPINUP to fail in CAM ATA transport

The motivation for this is two-fold.

1. Some old WD SATA disks may appear as if they need to be spun up
when they are already spinning. Those disks would respond with
an error to the spin-up request.

2. Even if we really fail to spin up the disk, we still can try to
proceed to the subsequent phases. If we fail later on, then no
difference. Otherwise we get a chance to communicate with the
disk which is better than completely ignoring it, because a user
can try to recover the disk.

320601 03-Jul-2017 ken

MFC r320421:

------------------------------------------------------------------------
r320421 | ken | 2017-06-27 13:26:02 -0600 (Tue, 27 Jun 2017) | 37 lines

Fix a panic in camperiphfree().

If a peripheral driver (e.g. da, sa, cd) is added or removed from the
peripheral driver list while an unrelated peripheral driver instance (e.g.
da0, sa5, cd2) is going away and is inside camperiphfree(), we could
dereference an invalid pointer.

When peripheral drivers are added or removed (see periphdriver_register()
and periphdriver_unregister()), the peripheral driver array is resized
and existing entries are moved.

Although we hold the topology lock while we traverse the peripheral driver
list, we retain a pointer to the location of the peripheral driver pointer
and then drop the topology lock. So we are still vulnerable to the list
getting moved around while the lock is dropped.

To solve the problem, cache a copy of the peripheral driver pointer. If
its storage location in the list changes while we have the lock dropped, it
won't have any effect.

This doesn't solve the issue that peripheral drivers ("da", "cd", as opposed
to individual instances like "da0", "cd0") are not generally part of a
reference counting scheme to guard against deregistering them while there
are instances active. The caller (generally the person unloading a module)
has to be aware of active drivers and not unload something that is in use.

sys/cam/cam_periph.c:
In camperiphfree(), cache a pointer to the peripheral driver
instance to avoid holding a pointer to an invalid memory location
in the event that the peripheral driver list changes while we have
the topology lock dropped.

PR: kern/219701
Submitted by: avg
Sponsored by: Spectra Logic

------------------------------------------------------------------------
PR: kern/219701
Sponsored by: Spectra Logic

320474 29-Jun-2017 markj

MFC r320372:
Fix a memory leak in ses_get_elm_devnames().

320361 26-Jun-2017 ken

MFC r320123:

Fix a potential sleep while holding a mutex in the sa(4) driver.

If the user issues a MTIOCEXTGET ioctl, and the tape drive in question has
a serial number that is longer than 80 characters, we malloc a buffer in
saextget() to hold the output of cam_strvis().

Since a mutex is held in that codepath, doing a M_WAITOK malloc could lead
to sleeping while holding a mutex. Change it to a M_NOWAIT malloc and bail
out if we fail to allocate the memory. Devices with serial numbers longer
than 80 bytes are very rare (I don't recall seeing one), so this
should be a very unusual case to hit. But it is a bug that should be fixed.

sys/cam/scsi/scsi_sa.c:
In saextget(), if we need to malloc a buffer to hold the output of
cam_strvis(), don't wait for the memory. Fail and return an error
if we can't allocate the memory immediately.

PR: kern/220094
Submitted by: Jia-Ju Bai <baijiaju1990@163.com>
Sponsored by: Spectra Logic

318140 10-May-2017 ken

MFC r317775:

Fix error recovery behavior in the pass(4) driver.

After FreeBSD SVN revision 236814, the pass(4) driver changed from
only doing error recovery when the CAM_PASS_ERR_RECOVER flag was
set on a CCB to sometimes doing error recovery if the passed in
retry count was non-zero.

Error recovery would happen if two conditions were met:

1. The error recovery action was simply a retry. (Which is most
cases.)
2. The retry_count is non-zero. (Which happened a lot because of
cut-and-pasted code.)

This explains a bug I noticed in with camcontrol:

# camcontrol tur da34 -v
Unit is ready
# camcontrol reset da34
Reset of 1:172:0 was successful

At this point, there should be a Unit Attention:

# camcontrol tur da34 -v
Unit is ready

No Unit Attention.

Try it again:

# camcontrol reset da34
Reset of 1:172:0 was successful

Now set the retry_count to 0 for the TUR:

# camcontrol tur da34 -v -C 0
Unit is not ready
(pass42:mps1:0:172:0): TEST UNIT READY. CDB: 00 00 00 00 00 00
(pass42:mps1:0:172:0): CAM status: SCSI Status Error
(pass42:mps1:0:172:0): SCSI status: Check Condition
(pass42:mps1:0:172:0): SCSI sense: UNIT ATTENTION asc:29,2 (SCSI bus reset
occurred)
(pass42:mps1:0:172:0): Field Replaceable Unit: 2

There is the unit attention. camcontrol(8) has a default
retry_count of 1, in case someone sets the -E flag without
setting -C.

The CAM_PASS_ERR_RECOVER behavior was only broken with the
CAMIOCOMMAND ioctl, which is the synchronous pass(4) API. It has
worked as intended (error recovery is only done when the flag
is set) in the asynchronous API (CAMIOQUEUE ioctl).

sys/cam/scsi/scsi_pass.c:
In passsendccb(), when calling cam_periph_runccb(), only
specify the error routine when CAM_PASS_ERR_RECOVER is set.

share/man/man4/pass.4:
Document that CAM_PASS_ERR_RECOVER is needed to enable
error recovery.

Reported by: Terry Kennedy <TERRY@glaver.org>
PR: kern/218572
Sponsored by: Spectra Logic

317964 08-May-2017 ken

MFC r317848:

Add basic programmable early warning error injection to the sa(4) driver.

This will help application developers simulate end of tape conditions.

To inject an error in sa0:

sysctl kern.cam.sa.0.inject_eom=1

This will return the next read or write request queued with 0 bytes
written. Any subsequent writes or reads will go along as usual.

This will also cause the early warning position flag to get set
for the next position query. So, 'mt status' will show the BPEW
(Beyond Programmable Early Warning) flag on the first query after
an error injection. After that, the position flags will be as they
are in the underlying tape drive.

Also, update the sa(4) man page to describe tape parameters,
which can be set via 'mt param'.

sys/cam/scsi/scsi_sa.c:
In saregister(), create the inject_eom sysctl variable.

In sastart(), check to see whether inject_eom is set. If
so, return the read or write with 0 bytes written to
indicate EOM. Set the set_pews_status flag so that we
fake PEWS status in the next position call for reads, and the
next 3 calls for writes. This allows the user to see the BPEW
flag one time via 'mt status'.

In sagetpos(), check the set_pews_status flag and fake
PEWS status and decrement the counter if it is set.

share/man/man4/sa.4:
Document the inject_eom sysctl variable.

Document all of the parameters currently supported via
'mt param'.

usr.bin/mt/mt.1:
Point the user to the sa(4) man page for more details on
supported parameters.

Sponsored by: Spectra Logic

317962 08-May-2017 ken

MFC r317799:

Add the SCSI Solid State Media Log page (0x11) definition.

sys/cam/scsi/scsi_all.h:
Add the SCSI Solid State Media log page (0x11) structure
definition. This gives the percentage used (in terms of
lifetime flash wear) of an SSD.

Sponsored by: Spectra Logic

317941 08-May-2017 ken

MFC r317745:

Don't bother retrying errors for encrypted drives that are locked.

sys/cam/scsi/scsi_all.c:
In the asc_table, if we get a 0x20,0x02 error ("Access denied -
no access rights"), don't bother retrying. Instead, immediately
fail the command.

This is the error returned by Self Encrypting Drives (SED) when
they are locked.

Sponsored by: Spectra Logic

317851 05-May-2017 ken

MFC r317680:

Add the SCSI SSC Manufacturer assigned serial number VPD page.

This is current as of SSC-5r03.

Submitted by: Sam Klopsch
Sponsored by: Spectra Logic

317320 23-Apr-2017 mav

MFC r316653: Fix few minor issues found by Clang Analyzer.

316791 13-Apr-2017 bdrewery

MFC r316066:

Release ccb if mode_buffer allocation fails.

316499 04-Apr-2017 mav

MFC r315673, r315674: Make CAM SIM lock optional.

For three years now CAM does not use SIM lock, but still enforces SIM to
use it. Remove this requirement, allowing SIMs to have any locking they
prefer, if they pass no mutex to cam_sim_alloc().

315939 25-Mar-2017 mav

MFC r315084: Increase device openings to tagged maximum.

Some SIMs report much less untagged device openings then tagged ones.
Target mode devices are not handled by regular probing routines, and so
there is nothing to increase queue size for them to the SIM's maximum.
To fix that resize the queue explicitly on ctl periph registration.
This radically improves performance of mpt(4) in target mode.

Also fetch and report device queue statistics in `ctladm dumpstructs`,
since regular way of `camcontrol tags` is not usable in target mode.

315937 25-Mar-2017 mav

MFC r315082: Allow XPT_GDEV_STATS for UNCONFIGURED devices.

Queue statistics has nothing to do with presence or absence of INQUIRY
data, etc. Target mode devices are never configured, but have queues.

315891 24-Mar-2017 mav

MFC r315022: Request change of SIM target role only when it is different.

Separate WWNs change into separate request to know what actually failed.

315889 24-Mar-2017 mav

MFC r315030: Abort all ATIOs and INOTs queued to SIM on LUN disable.

Some SIMs may not abort them implicitly, that either fail the LUN disable
request or just make us wait for those CCBs forever. With this change
I can successfully disable LUNs on mpt(4). For isp(4), which aborts them
implicitly, this change should be irrelevant.

315887 24-Mar-2017 mav

MFC r315025: Switch work_queue from TAILQ to STAILQ.

It is mostly FIFO and we don't need random removal there.

315813 23-Mar-2017 mav

MFC r311305 (by asomers):
Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name)

The sim_vid, hba_vid, and dev_name fields of struct ccb_pathinq are
fixed-length strings. AFAICT the only place they're read is in
sbin/camcontrol/camcontrol.c, which assumes they'll be null-terminated.
However, the kernel doesn't null-terminate them. A bunch of copy-pasted code
uses strncpy to write them, and doesn't guarantee null-termination. For at
least 4 drivers (mpr, mps, ciss, and hyperv), the hba_vid field actually
overflows. You can see the result by doing "camcontrol negotiate da0 -v".

This change null-terminates those fields everywhere they're set in the
kernel. It also shortens a few strings to ensure they'll fit within the
16-character field.

PR: 215474
Reported by: Coverity
CID: 1009997 1010000 1010001 1010002 1010003 1010004 1010005
CID: 1331519 1010006 1215097 1010007 1288967 1010008 1306000
CID: 1211924 1010009 1010010 1010011 1010012 1010013 1010014
CID: 1147190 1010017 1010016 1010018 1216435 1010020 1010021
CID: 1010022 1009666 1018185 1010023 1010025 1010026 1010027
CID: 1010028 1010029 1010030 1010031 1010033 1018186 1018187
CID: 1010035 1010036 1010042 1010041 1010040 1010039


cam_xpt.c
ctl/ctl_frontend_cam_sim.c
scsi/scsi_low.c
/freebsd-10-stable/sys/dev/aac/aac_cam.c
/freebsd-10-stable/sys/dev/aacraid/aacraid_cam.c
/freebsd-10-stable/sys/dev/advansys/advansys.c
/freebsd-10-stable/sys/dev/advansys/adwcam.c
/freebsd-10-stable/sys/dev/aha/aha.c
/freebsd-10-stable/sys/dev/ahb/ahb.c
/freebsd-10-stable/sys/dev/ahci/ahci.c
/freebsd-10-stable/sys/dev/ahci/ahciem.c
/freebsd-10-stable/sys/dev/aic/aic.c
/freebsd-10-stable/sys/dev/aic7xxx/aic79xx_osm.c
/freebsd-10-stable/sys/dev/aic7xxx/aic7xxx_osm.c
/freebsd-10-stable/sys/dev/amr/amr_cam.c
/freebsd-10-stable/sys/dev/arcmsr/arcmsr.c
/freebsd-10-stable/sys/dev/ata/ata-all.c
/freebsd-10-stable/sys/dev/buslogic/bt.c
/freebsd-10-stable/sys/dev/ciss/ciss.c
/freebsd-10-stable/sys/dev/dpt/dpt_scsi.c
/freebsd-10-stable/sys/dev/esp/ncr53c9x.c
/freebsd-10-stable/sys/dev/firewire/sbp.c
/freebsd-10-stable/sys/dev/firewire/sbp_targ.c
/freebsd-10-stable/sys/dev/hpt27xx/hpt27xx_osm_bsd.c
/freebsd-10-stable/sys/dev/hptiop/hptiop.c
/freebsd-10-stable/sys/dev/hptmv/entry.c
/freebsd-10-stable/sys/dev/hptnr/hptnr_osm_bsd.c
/freebsd-10-stable/sys/dev/hptrr/hptrr_osm_bsd.c
/freebsd-10-stable/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
/freebsd-10-stable/sys/dev/iir/iir.c
/freebsd-10-stable/sys/dev/isci/isci_controller.c
/freebsd-10-stable/sys/dev/iscsi_initiator/isc_cam.c
/freebsd-10-stable/sys/dev/isp/isp_freebsd.c
/freebsd-10-stable/sys/dev/mfi/mfi_cam.c
/freebsd-10-stable/sys/dev/mly/mly.c
/freebsd-10-stable/sys/dev/mpr/mpr_sas.c
/freebsd-10-stable/sys/dev/mps/mps_sas.c
/freebsd-10-stable/sys/dev/mpt/mpt_cam.c
/freebsd-10-stable/sys/dev/mrsas/mrsas_cam.c
/freebsd-10-stable/sys/dev/mvs/mvs.c
/freebsd-10-stable/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c
/freebsd-10-stable/sys/dev/ppbus/vpo.c
/freebsd-10-stable/sys/dev/siis/siis.c
/freebsd-10-stable/sys/dev/sym/sym_hipd.c
/freebsd-10-stable/sys/dev/trm/trm.c
/freebsd-10-stable/sys/dev/twa/tw_osl_cam.c
/freebsd-10-stable/sys/dev/tws/tws_cam.c
/freebsd-10-stable/sys/dev/virtio/scsi/virtio_scsi.c
/freebsd-10-stable/sys/powerpc/ps3/ps3cdrom.c
/freebsd-10-stable/sys/powerpc/pseries/phyp_vscsi.c
315138 12-Mar-2017 mav

MFC r314307: Add support for SIMs without autosense.

If we asked to send sense data by setting CAM_SEND_SENSE, but SIM didn't
confirm transmission by setting CAM_SENT_SENSE, assume it was not sent.
Queue the I/O back to CTL for later REQUEST SENSE with ctl_queue_sense().
This is needed for error reporting on SPI HBAs like ahc(4)/ahd(4).

314767 06-Mar-2017 mav

MFC r314338: Polish handling of different reset flavours.

The biggest change is that ctl_remove_initiator() now generates I_T NEXUS
LOSS event, cleaning part of LUs state related to the initiator.

314763 06-Mar-2017 mav

MFC r314496: Add check missed in r314257.

314761 06-Mar-2017 mav

MFC r314387: Make ctl_queue_sense() not sleep.

It may be called in non-sleepable frontend context.

314757 06-Mar-2017 mav

MFC r314299, r314300: Fix residual length reporting in target mode.

This allows to properly handle cases when target wants to receive or send
more data then initiator wants to send or receive. Previously in such
cases isp(4) returned CAM_DATA_RUN_ERR, while now it returns resid > 0.

314755 06-Mar-2017 mav

MFC r314257: Add reporting SAS protocol, in case we ever have one.

314753 06-Mar-2017 mav

MFC r314255: Reenable CTL_WITH_CA, optimizing it for lower memory usage.

This code was disabled due to its high memory usage. But now we need this
functionality for cfumass(4) frontend, since USB MS BBB transport does not
support autosense.

314751 06-Mar-2017 mav

MFC r314247: Axe out some forever disabled questionable functionality.

This code is complicated enough even in its base shape.

314749 06-Mar-2017 mav

MFC r314246: Improve CAM target frontend reference counting.

Before this change it was possible to trigger some use-after-free panics
by disabling LUNs/ports under heavy load.

314745 06-Mar-2017 mav

MFC r314204: Explicitly abort ATIO if CTIO sending status has failed.

This helps SIM to free related resources in questionable cases.

314740 06-Mar-2017 mav

MFC r314200: We can't access periph after ctlfe_free_ccb().

314739 06-Mar-2017 mav

MFC r314196: Unify ATIO/INOT CCBs requeuing.

314737 06-Mar-2017 mav

MFC r314193: Some code cleanup.

314727 06-Mar-2017 mav

MFC r314027: Do not blindly free completed ATIOs/INOTs on invalidation.

When LUN is disabled, SIM starts returning queued ATIOs/INOTs. But at the
same time there can be some ATIOs/INOTs still carrying real new requests.
If we free those, SIM may leak some resources, forever expecting for any
response from us. So try to be careful, separating ATIOs/INOTs carrying
requests which still must be processed, from ATIOs/INOTs completed with
errors which can be freed.

314380 28-Feb-2017 mav

MFC r313744: No need to erase sense_data when sense_len is set to zero.

314238 25-Feb-2017 mav

MFC r313910: Change XCOPY memory allocations.

Before this change XCOPY code could allocate memory in chunks up to 16-32MB
(VMware does XCOPY in 4MB chunks by default), that could be difficult for
VM subsystem to do due to KVA fragmentation, that sometimes created huge
allocation delays, blocking any I/O for respective LU for that time.

This change limits allocations down to TPC_MAX_IO_SIZE, which is 1MB now.
1MB is also not a cookie, but ZFS also can do that for large blocks, so
it should be less dramatic. As drawback this increases CPU overhead, but
it still look acceptable comparing to time consumed by ZFS read/write.

314026 21-Feb-2017 mav

MFC r313736: Fix panic on shutdown of ramdisk LU with zero capacity.

313998 20-Feb-2017 ken

MFC 313895:

------------------------------------------------------------------------
r313895 | ken | 2017-02-17 13:15:27 -0700 (Fri, 17 Feb 2017) | 9 lines

Make ctl(4) build with CTL_IO_DELAY defined.

sys/cam/ctl/ctl.c:
In ctl_datamove(), inside CTL_IO_DELAY, add a lun variable and fill
it in before trying to dereference it.

Sponsored by: Spectra Logic

------------------------------------------------------------------------

313371 07-Feb-2017 mav

MFC r312694: Make CTL ramdisk backend a real RAM disk.

If "capacity" LU option is set, ramdisk backend now implements featured
thin provisioned disk, storing data in malloc(9) allocated memory blocks
of pblocksize bytes (default PAGE_SIZE or 4KB). Additionally ~0.2% of LU
size is used for indirection tree (bigger pblocksize reduce the overhead).
Backend supports all unmap and anchor operations. If configured capacity
is overflowed, proper error conditions are reported.

If "capacity" LU option is not set, the backend operates mostly the same
as before without allocating real storage: writes go to nowhere, reads
return zeroes, reporting that all LBAs are unmapped.

This backend is still mostly oriented on testing and benchmarking (it is
still a volatile RAM disk), but now it should allow to run real FS tests,
not only simple dumb dd.

313369 07-Feb-2017 mav

MFC r312603: Add initial support for CTL module unloading.

It is only a first step and not perfect, but better then nothing.
The main blocker is CAM target frontend, that can not be unloaded,
since CAM does not have mechanism to unregister periph driver now.

313367 07-Feb-2017 mav

MFC r312348: Remove writing 'residual' field of struct ctl_scsiio.

This field has no practical use and never readed. Initiators already
receive respective residual size from frontends. Removed field had
different semantics, which looks useless, and was never passed through
by any frontend.

While there, fix kern_data_resid field support in case of HA, missed in
r312291.

313365 07-Feb-2017 mav

MFC r312291, r312669:
Make CTL frontends report kern_data_resid for under-/overruns.

It seems like kern_data_resid was never really implemented. This change
finally does it. Now frontends update this field while transferring data,
while CTL/backends getting it can more flexibly handle the result.
At this point behavior should not change significantly, still reporting
errors on write overrun, but that may be changed later, if we decide so.

CAM target frontend still does not properly handle overruns due to CAM API
limitations. We may need to add some fields to struct ccb_accept_tio to
pass information about initiator requested transfer size(s).

313363 07-Feb-2017 mav

MFC r312343: Improve error message on duplicate iSCSI port.

312850 26-Jan-2017 mav

MFC r296891 (by imp):
Make sure we check for CAM_CDB_POINTER for all drivers. Also, for the
drivers I've touched, filter out CAM_CDB_PHYS.

Differential Revision: https://reviews.freebsd.org/D5585

312849 26-Jan-2017 mav

MFC r312232: Add under-/overrun support to IOCTL and CAM SIM frontends.

312847 26-Jan-2017 mav

MFC r312231: When in kernel, map ctl_scsi_zero_io() to ctl_zero_io().

312845 26-Jan-2017 mav

MFC r312026: Improve CAM_CDB_POINTER support.

312843 26-Jan-2017 mav

MFC r311873: Fix malloc(M_WAITOK) under mutex, introduced at r311787.

312841 26-Jan-2017 mav

MFC r311804: Rewrite CTL statistics in more simple and scalable way.

Instead of collecting statistics for each combination of ports and logical
units, that consumed ~45KB per LU with present number of ports, collect
separate statistics for every port and every logical unit separately, that
consume only 176 bytes per each single LU/port. This reduces struct
ctl_lun size down to just 6KB.

Also new IOCTL API/ABI does not hardcode number of LUs/ports, and should
allow handling of very large quantities.

Old API is still enabled in stable branches for compatibility reasons.

312839 26-Jan-2017 mav

MFC r311787: Allocate memory for prevent flags only for removable LUs.

This array takes 64KB of RAM now, that was more then half of struct ctl_lun
size. If at some point we support more ports, this may need another tune.

312837 26-Jan-2017 mav

MFC r311680: Make CTL_GETSTATS ioctl return partial data if buffer is small.

312835 26-Jan-2017 mav

MFC r310778, r310782: Improve use of I/O's private area.

- Since I/Os are allocates from per-port pools, make allocations store
pointer to CTL softc there, and use it where needed instead of global.
- Created bunch of helper macros to access LUN, port and CTL softc.

312587 21-Jan-2017 mav

MFC r311892: Do not wait for HA thread shutdown if scheduler is stopped.

This wait loop made system hang on panic instead of reboot.

312585 21-Jan-2017 mav

MFC r310649: Allow more efficient use of private area.

There are 16 bytes of space, so we may store two pointers in one.

312583 21-Jan-2017 mav

MFC r310646: Do not update "saved" mode page on every MODE SELECT.

We do not have non-volatile memory to really save those values, so we
neither report nor support this capability. Also saved mode pages are
not replicated between HA peers now.

312581 21-Jan-2017 mav

MFC r310644: Fix/synchronize field types in struct ctl_modepage_header.

312579 21-Jan-2017 mav

MFC r310640, r310643:
Add support for revert to defaults (RTD) bit in MODE SELECT.

312577 21-Jan-2017 mav

MFC r310635: Decouple limits on number of LUNs per port and LUs per CTL.

Those two values are not directly related, so make them independent.
This does not change any limits immediately, but makes number of LUNs
per port controllable via tunable/sysctl kern.cam.ctl.lun_map_size.
After this change increasing CTL_MAX_LUNS should be pretty cheap,
and even making it tunable should be easy.

312575 21-Jan-2017 mav

MFC r310575: Fix improperly used nexus.targ_lun.

312573 21-Jan-2017 mav

MFC r310555: Some random code cleaning.

- Reduce indentation.
- Remove extra braces.
- Add few missing savety checks.

312571 21-Jan-2017 mav

MFC r310539: Remove CTL_MAX_LUNS from places where it is not required.

312567 21-Jan-2017 mav

MFC r311636: Make 'camcontrol modepage' support subpages.

312357 17-Jan-2017 ngie

MFC r299864,r303166:

r299864 (by markj):

opt_kdtrace.h is not needed for SDT probes as of r258541.

r303166 (by imp):

Add opt_ddb.h.

311673 08-Jan-2017 mav

MFC r311446: Fix bootverbose affecting code logic in r294558.

Reported by: Jilles Tjoelker <jilles@stack.nl>

311444 05-Jan-2017 mav

MFC r305591: Decode ATA Status Return descriptor.

311443 05-Jan-2017 mav

MFC r297756: Add couple new constants from SPC5r08.

311442 05-Jan-2017 mav

MFC r310534: Improve third-party copy error reporting.

For EXTENDED COPY:
- improve parameters checking to report some errors before copy start;
- forward sense data from copy target as descriptor in case of error;
- report which CSCD reported error in sense key specific information.
For WRITE USING TOKEN:
- pass through real sense data from copy target instead of reporting
our copy error, since for initiator its a "simple" write, not a copy.

311440 05-Jan-2017 mav

MFC r310524: Improve length handling when writing sense data.

- Allow maximal sense size limitation via Control Extension mode page.
- When sense size limited, include descriptors atomically: whole or none.
- Set new SDAT_OVFL bit if some descriptors don't fit the limit.
- Report real written sense length instead of static maximal 252 bytes.

311438 05-Jan-2017 mav

MFC r310489: Implement printing forwarded sense data.

311436 05-Jan-2017 mav

MFC r310478: Add place-holders for TAPE STREAM MIRRORING subcommands of XCOPY.

We do not support tapes, so this is only a comments.

311433 05-Jan-2017 mav

MFC r310390: Add support for REPD bit in RSTMF command.

We have no real timeout values to report there, but its better then error.

311432 05-Jan-2017 mav

MFC r310389:
Fix REPORT SUPPORTED OPERATION CODES for READ/WRITE BUFFER commands.

Specifications require MODE parameter of those commands to be treated
the same as SERVICE ACTION parameter of other commands.

311430 05-Jan-2017 mav

MFC r310373:
Add support for REPORTING OPTIONS == 3 in REPORT SUPPORTED OPERATION CODES.

311428 05-Jan-2017 mav

MFC r310366: Add support for SITUA bit in Logical Block Provisioning mode page.

VMware tries to enable this bit to avoid multiple threshold notifications
in case of multiple initiators connected to the same LUN. Unfortunately
their code sends MODE SELECT(6) request with parameter length hardcoded
for the page without any thresholds. Since we have four threshold and our
page is bigger, this attempt fails, that is correct in my understanding.
So all we can do about this now is to report proper error code and hope
VMware fix their code one day.

311425 05-Jan-2017 mav

MFC r310360, r310361: Report UUID and MD5 LUN IDs.

311423 05-Jan-2017 mav

MFC r310356: Add support for locally assigned RFC 4122 UUID LUN identifiers.

311421 05-Jan-2017 mav

MFC r310339: Bump specifications support to SAM-6/SPC-5.

311419 05-Jan-2017 mav

MFC r310298: Improve error handling when I/O split between several BIOs.

If we get several error codes, handle one with lowest offset.

311417 05-Jan-2017 mav

MFC r310285:
When reporting "Logical block address out of range" error, report the LBA
in sense data INFORMATION field.

311415 05-Jan-2017 mav

MFC r310284:
When writing fixed format sense data, set VALID bit only if provided value
for INFORMATION field fit into available 4 bytes (has no non-zero bytes
except last 4), as explicitly required by SPC-5 specification.

311413 05-Jan-2017 mav

MFC r310275: Fix typo in function name.

311411 05-Jan-2017 mav

MFC r310272: Add new bits into Extended Inquiry VPD page.

311409 05-Jan-2017 mav

MFC r310266: Add support for NUAR bit in Control mode page.

311407 05-Jan-2017 mav

MFC r310265: Add set of macros to simplify code access to mode pages fields.

311404 05-Jan-2017 mav

MFC r310259:
Following SPC-5, make REQUEST SENSE report "Logical unit not supported"
in returned parameter data for not accessible LUNs.

311403 05-Jan-2017 mav

MFC r310257: Improve support for informational exceptions.

While CTL still has no real events to report in this way (like SMART),
it is possible to trigger false event by manually setting TEST bit in
Informational Exceptions Control mode page, that can be useful for
initiator testing. This code supports all flavours of IE reporting:
UNIT ATTENTION, RECOVERED ERROR and NO SENSE sense keys, REQUEST SENSE
command and Informational Exceptions log page.

311402 05-Jan-2017 mav

MFC r298810 (by pfg): sys/cam: spelling fixes in comments.

No functional change.

311401 05-Jan-2017 mav

MFC r295476 (by trasz): Remove stray semicolons from the iSCSI code.

311400 05-Jan-2017 mav

MFC r294558: Hide "soconnect() error" messages under bootverbose.

They can be too noisy.

311398 05-Jan-2017 mav

MFC r310230:
Don't treat informational exceptions (warnings and impending failures)
a.k.a. SCSI SMART events as errors. Log them to console and continue.

311396 05-Jan-2017 mav

MFC r309297: Make SES status updates more aggressive.

- On control request update all status pages, since they may also be
affected if user enables/disables enclosure slots.
- Periodically update element descriptors too, since there is some
hardware where they are changed dynamically.

309629 06-Dec-2016 mav

MFC r309282: Explicitly initialize cdai.flags.

In SES driver uninitialized value caused unreliable physpath reporting.

309042 23-Nov-2016 mav

MFC r308425: Add support for EIIOE flag in Additional Element Status.

It was added in SES-3 spec, and its support required to properly link
the Additional Element Status page data to the original elements.

308123 31-Oct-2016 mav

MFC r307523: Make pass driver better support CAM_CDB_POINTER flag.

Previously pass driver just ignored the flag, making random kernel code
access user-space pointer, sometime causing crashes even for correctly
written applications if user-level context was switched or swapped out.
This patch tries to copyin the CDB into kernel space to avoid it.

308081 29-Oct-2016 mav

MFC r307507, r307509, r307515:
Consider device as clean even if SYNCHRONIZE CACHE failed.

If device reservation was preempted by other initiator, our sync request
will always fail. Without this change CAM tried to sync cache on every
following device close, including numerous GEOM tasting opens/closes,
causing lots of useless noise in logs.

308079 29-Oct-2016 mav

MFC r307374: Add LU option to control reported provisioning type.

308078 29-Oct-2016 mav

MFC r307350: Add LUN options to limit UNMAP and WRITE SAME sizes.

CTL itself has no limits on on UNMAP and WRITE SAME sizes. But depending
on backends large requests may take too much time. To avoid that new
configuration options allow to hint initiator maximal sizes it should not
exceed.

308075 29-Oct-2016 mav

MFC r304918: Decode some new ATA commands found in ACS-3.

307957 26-Oct-2016 mav

MFC r307132: Use copyout() instead of pointing sbuf to user-space buffer.

307253 14-Oct-2016 sephe

MFC 306396

cam/ata: Allow drivers to veto ATA disk attachment.

This eventhandler is mainly used by VMs, e.g. Hyper-V, whose disk
controllers share the disks with the simulated ATA controllers.

Submitted by: Hongjiang Zhang <honzhan microsoft com>
Discussed with: mav
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7693

307162 13-Oct-2016 sephe

MFC 303944

cam/da: Add quirk for I-O Data USB Flash Disk

PR: 211716
Submitted by: Jun Su <junsu microsoft com>
Reported by: Jun Su <junsu microsoft com>
Sponsored by: Microsoft

307129 12-Oct-2016 mav

MFC 306699: Do not retry on some security sense codes.

306750 06-Oct-2016 mav

Fix ABI compat shims for FreeBSD 9.0-9.1 binaries (CAM_VERSION 0x16).

This is a direct commit to stable/10, inspired by some commits to later
branches.

306156 22-Sep-2016 mav

MFC r305610: Don't report to devd statuses that CAM doesn't consider errors.

Some statuses, such as "ATA pass through information available", are part
part of absolutely normal operation and do not worth reporting.

306155 22-Sep-2016 mav

MFC r305609: "Extended copy information available" is not an error either.

306154 22-Sep-2016 mav

MFC r305608: "ATA pass through information available" is not an error.

305615 08-Sep-2016 pfg

MFC r303891, r303892:
sys: replace comma with semicolon when pertinent.

Uses of commas instead of a semicolons can easily go undetected. The comma
can serve as a statement separator but this shouldn't be abused when
statements are meant to be standalone.

304737 24-Aug-2016 mav

Fix HA mode configuration on FreeBSD 10.x.

This is direct commit, compensating CTLFLAG_RDTUN difference between
FreeBSD 10.x and 11.x branches.

304417 18-Aug-2016 mav

MFC r300293:
Pass task management response information from CTL through CAM to isp(4),
utilizing previously unused arg field of struct ccb_notify_acknowledge.

This makes new QUERY TASK, QUERY TASK SET and QUERY ASYNC EVENT requests
really functional for CAM target mode drivers.

303179 22-Jul-2016 sbruno

MFC r302281
Correct PERSISTENT RESERVE OUT command and populate scsi_cmd->length.

PR: 202625

302377 06-Jul-2016 truckman

MFC r300547

Fix multiple Coverity Out-of-bounds access false postive issues in CAM

The currently used idiom for clearing the part of a ccb after its
header generates one or two Coverity errors for each time it is
used. All instances generate an Out-of-bounds access (ARRAY_VS_SINGLETON)
error because of the treatment of the header as a two element array,
with a pointer to the non-existent second element being passed as
the starting address to bzero(). Some instances also alsp generate
Out-of-bounds access (OVERRUN) errors, probably because the space
being cleared is larger than the sizeofstruct ccb_hdr).

In addition, this idiom is difficult for humans to understand and
it is error prone. The user has to chose the proper struct ccb_*
type (which does not appear in the surrounding code) for the sizeof()
in the length calculation. I found several instances where the
length was incorrect, which could cause either an actual out of
bounds write, or incompletely clear the ccb.

A better way is to write the code to clear the ccb itself starting
at sizeof(ccb_hdr) bytes from the start of the ccb, and calculate
the length based on the specific type of struct ccb_* being cleared
as specified by the union ccb member being used. The latter can
normally be seen in the nearby code. This is friendlier for Coverity
and other static analysis tools because they will see that the
intent is to clear the trailing part of the ccb.

Wrap all of the boilerplate code in a convenient macro that only
requires a pointer to the desired union ccb member (or a pointer
to the union ccb itself) as an argument.

Reported by: Coverity
CID: 1007578, 1008684, 1009724, 1009773, 1011304, 1011306
CID: 1011307, 1011308, 1011309, 1011310, 1011311, 1011312
CID: 1011313, 1011314, 1011315, 1011316, 1011317, 1011318
CID: 1011319, 1011320, 1011321, 1011322, 1011324, 1011325
CID: 1011326, 1011327, 1011328, 1011329, 1011330, 1011374
CID: 1011390, 1011391, 1011392, 1011393, 1011394, 1011395
CID: 1011396, 1011397, 1011398, 1011399, 1011400, 1011401
CID: 1011402, 1011403, 1011404, 1011405, 1011406, 1011408
CID: 1011409, 1011410, 1011411, 1011412, 1011413, 1011414
CID: 1017461, 1018387, 1086860, 1086874, 1194257, 1229897
CID: 1229968, 1306229, 1306234, 1331282, 1331283, 1331294
CID: 1331295, 1331535, 1331536, 1331539, 1331540, 1341623
CID: 1341624, 1341637, 1341638, 1355264, 1355324
Reviewed by: scottl, ken, delphij, imp
MFH: 1 month
Differential Revision: https://reviews.freebsd.org/D6496

302376 06-Jul-2016 truckman

MFC r299371 (by trasz)

Add "camcontrol reprobe" subcommand, and implement it for da(4).
This makes it possible to manually force updating capacity data
after the disk got resized. Without it it might be neccessary to
reboot before FreeBSD notices updated disk size under eg VMWare.

Differential Revision: https://reviews.freebsd.org/D6108

302237 27-Jun-2016 bdrewery

MFC r292384:

Fix style issues around existing SDT probes.

** Changes to sys/netinet/in_kdtrace.c and sys/netinet/in_kdtrace.h skipped.

300589 24-May-2016 mav

MFC r299373: Allow sleepable allocations in enclosure daemon threads.

There were at least two places where M_NOWAIT was used without NULL check.
This change should fix NULL-dereference panic there and possibly improve
operation in other ways under memory pressure.

300588 24-May-2016 mav

MFC r299347, r299348: Validate XCOPY range offsets and lengths.

300587 24-May-2016 mav

MFC r299346: More XCOPY parameters validation.

300586 24-May-2016 mav

MFC r299329: Improve validation of some POPULATE TOKEN parameters.

299961 16-May-2016 asomers

MFC 298212

Add the ability to read a SAS device's Target Port NAA designator

sys/cam/scsi/scsi_all.h
sys/cam/scsi/scsi_all.c
Add the scsi_devid_is_port_naa helper function

299677 13-May-2016 pfg

MFC r298809, r298817
Minor spelling fixes.

299531 12-May-2016 scottl

MFC r298977: Fix a memory leak introduced with the devctl intergration of
cam_periph

299400 11-May-2016 pfg

MFC r298703:
cam: unsign some types to match their definitions and avoid overflows.

numpatterns is u_int.

ctl:
CTL_NUM_MODE_PAGES comes from sizeof().
In struct:ctl_scsiio, kern_sg_entries is uint32_t.

299191 06-May-2016 sbruno

MFC r298279

Plug memory leak in ctl(4) when ctl_copyin_args() is called with a non-
null terminated ASCII string.

PR: 207626
Submitted by: cturt@hardenedbsd.org

298406 21-Apr-2016 pfg

MFC r297527, r297688:
chdone(): Prevent returning uninitialized scalar value.

Instead of attempting to initialize all the possible cases, just
move the check nearer to the case where it makes sense.

CID: 1006486
Reviewed by: ken

298134 17-Apr-2016 scottl

MFC r298004:

Add a devctl/devd notification conduit for CAM errors that happen at the
periph level.

Due to not merging the changes to ata_res_sbuf(), this version is a little
messy.

Sponsored by: Netflix

298100 16-Apr-2016 scottl

Partial MFC of r297933

Add sbuf variants ata_cmd_sbuf()

Sponsored by: Netflix

298093 16-Apr-2016 scottl

MFC r297925, r297926:

Add scsi_cdb_sbuf() for handling CDB strings. Reimplement scsi_cdb_string()
in terms of it.

Use scsi_cdb_sbuf() inside of scsi_command_string now that the temporary
string storage is no longer needed.

Sponsored by: Netflix

297711 08-Apr-2016 sbruno

Revert svn 297681 as it has been deprecated by svn 297575.

Submitted by: Tomoaki AOKI <junchoon@dec.dakura.ne.jp>

297681 07-Apr-2016 sbruno

MFC r297237

Add 4k enabled cam quirks for Samsung SM863 Series SSDs

297575 05-Apr-2016 dumbbell

CAM: Generalize 4k quirk to all Samsung MZ7* SSDs

This adds Samsung PM851 to the list. It can be found in Lenovo Thinkpad
T440 for instance.

MFC of: r297370
Reviewed by: Kevin Bowling <kevin.bowling@kev009.com>,
Jason Wolfe <j@nitrology.com>
Approved by: Kevin Bowling <kevin.bowling@kev009.com>,
Jason Wolfe <j@nitrology.com>
Differential Revision: https://reviews.freebsd.org/D5753

296442 07-Mar-2016 mav

MFC r296392: Set bhsdi_target_transfer_tag to reserved value, which is
0xffffffff.

This should be a purely cosmetic change.

296421 06-Mar-2016 rpokala

MFC r295276: Add defines for WRITE_UNCORRECTABLE ATA command, and improve
command logging

Add #defines for ATA_WRITE_UNCORRECTABLE48 and its features. Update the
decoding in ATACAM to recognize the new values. Also improve command
decoding for a few other commands (SMART, NOP, SET_FEATURES). Bring the
decoding in ata(4) up to parity with ATACAM.

Sponsored by: Panasas, Inc.

295819 19-Feb-2016 ken

MFC, r295417:

r295417 | ken | 2016-02-08 15:13:08 -0700 (Mon, 08 Feb 2016) | 9 lines

Fix the SCSI Extended INQUIRY probe case when an error is returned
and a retry is scheduled.

Instead of leaving the device queue frozen, unfreeze the device queue so
that the retry can happen.

Sponsored by: Spectra Logic

Approved by: re (gjb)

294978 28-Jan-2016 kib

MFC r293350:
Convert sys/cam to use make_dev_s().

292590 22-Dec-2015 mav

MFC r292290: Set DS flag, required for LPB log page by spec.

292348 16-Dec-2015 ken

MFC r291716, r291724, r291741, r291742

In addition to those revisions, add this change to a file that is not in
head:

sys/ia64/include/bus.h:
Guard kernel-only parts of the ia64 machine/bus.h header with
#ifdef _KERNEL.

This allows userland programs to include <machine/bus.h> to get the
definition of bus_addr_t and bus_size_t.

------------------------------------------------------------------------
r291716 | ken | 2015-12-03 15:54:55 -0500 (Thu, 03 Dec 2015) | 257 lines

Add asynchronous command support to the pass(4) driver, and the new
camdd(8) utility.

CCBs may be queued to the driver via the new CAMIOQUEUE ioctl, and
completed CCBs may be retrieved via the CAMIOGET ioctl. User
processes can use poll(2) or kevent(2) to get notification when
I/O has completed.

While the existing CAMIOCOMMAND blocking ioctl interface only
supports user virtual data pointers in a CCB (generally only
one per CCB), the new CAMIOQUEUE ioctl supports user virtual and
physical address pointers, as well as user virtual and physical
scatter/gather lists. This allows user applications to have more
flexibility in their data handling operations.

Kernel memory for data transferred via the queued interface is
allocated from the zone allocator in MAXPHYS sized chunks, and user
data is copied in and out. This is likely faster than the
vmapbuf()/vunmapbuf() method used by the CAMIOCOMMAND ioctl in
configurations with many processors (there are more TLB shootdowns
caused by the mapping/unmapping operation) but may not be as fast
as running with unmapped I/O.

The new memory handling model for user requests also allows
applications to send CCBs with request sizes that are larger than
MAXPHYS. The pass(4) driver now limits queued requests to the I/O
size listed by the SIM driver in the maxio field in the Path
Inquiry (XPT_PATH_INQ) CCB.

There are some things things would be good to add:

1. Come up with a way to do unmapped I/O on multiple buffers.
Currently the unmapped I/O interface operates on a struct bio,
which includes only one address and length. It would be nice
to be able to send an unmapped scatter/gather list down to
busdma. This would allow eliminating the copy we currently do
for data.

2. Add an ioctl to list currently outstanding CCBs in the various
queues.

3. Add an ioctl to cancel a request, or use the XPT_ABORT CCB to do
that.

4. Test physical address support. Virtual pointers and scatter
gather lists have been tested, but I have not yet tested
physical addresses or scatter/gather lists.

5. Investigate multiple queue support. At the moment there is one
queue of commands per pass(4) device. If multiple processes
open the device, they will submit I/O into the same queue and
get events for the same completions. This is probably the right
model for most applications, but it is something that could be
changed later on.

Also, add a new utility, camdd(8) that uses the asynchronous pass(4)
driver interface.

This utility is intended to be a basic data transfer/copy utility,
a simple benchmark utility, and an example of how to use the
asynchronous pass(4) interface.

It can copy data to and from pass(4) devices using any target queue
depth, starting offset and blocksize for the input and ouptut devices.
It currently only supports SCSI devices, but could be easily extended
to support ATA devices.

It can also copy data to and from regular files, block devices, tape
devices, pipes, stdin, and stdout. It does not support queueing
multiple commands to any of those targets, since it uses the standard
read(2)/write(2)/writev(2)/readv(2) system calls.

The I/O is done by two threads, one for the reader and one for the
writer. The reader thread sends completed read requests to the
writer thread in strictly sequential order, even if they complete
out of order. That could be modified later on for random I/O patterns
or slightly out of order I/O.

camdd(8) uses kqueue(2)/kevent(2) to get I/O completion events from
the pass(4) driver and also to send request notifications internally.

For pass(4) devcies, camdd(8) uses a single buffer (CAM_DATA_VADDR)
per CAM CCB on the reading side, and a scatter/gather list
(CAM_DATA_SG) on the writing side. In addition to testing both
interfaces, this makes any potential reblocking of I/O easier. No
data is copied between the reader and the writer, but rather the
reader's buffers are split into multiple I/O requests or combined
into a single I/O request depending on the input and output blocksize.

For the file I/O path, camdd(8) also uses a single buffer (read(2),
write(2), pread(2) or pwrite(2)) on reads, and a scatter/gather list
(readv(2), writev(2), preadv(2), pwritev(2)) on writes.

Things that would be nice to do for camdd(8) eventually:

1. Add support for I/O pattern generation. Patterns like all
zeros, all ones, LBA-based patterns, random patterns, etc. Right
Now you can always use /dev/zero, /dev/random, etc.

2. Add support for a "sink" mode, so we do only reads with no
writes. Right now, you can use /dev/null.

3. Add support for automatic queue depth probing, so that we can
figure out the right queue depth on the input and output side
for maximum throughput. At the moment it defaults to 6.

4. Add support for SATA device passthrough I/O.

5. Add support for random LBAs and/or lengths on the input and
output sides.

6. Track average per-I/O latency and busy time. The busy time
and latency could also feed in to the automatic queue depth
determination.

sys/cam/scsi/scsi_pass.h:
Define two new ioctls, CAMIOQUEUE and CAMIOGET, that queue
and fetch asynchronous CAM CCBs respectively.

Although these ioctls do not have a declared argument, they
both take a union ccb pointer. If we declare a size here,
the ioctl code in sys/kern/sys_generic.c will malloc and free
a buffer for either the CCB or the CCB pointer (depending on
how it is declared). Since we have to keep a copy of the
CCB (which is fairly large) anyway, having the ioctl malloc
and free a CCB for each call is wasteful.

sys/cam/scsi/scsi_pass.c:
Add asynchronous CCB support.

Add two new ioctls, CAMIOQUEUE and CAMIOGET.

CAMIOQUEUE adds a CCB to the incoming queue. The CCB is
executed immediately (and moved to the active queue) if it
is an immediate CCB, but otherwise it will be executed
in passstart() when a CCB is available from the transport layer.

When CCBs are completed (because they are immediate or
passdone() if they are queued), they are put on the done
queue.

If we get the final close on the device before all pending
I/O is complete, all active I/O is moved to the abandoned
queue and we increment the peripheral reference count so
that the peripheral driver instance doesn't go away before
all pending I/O is done.

The new passcreatezone() function is called on the first
call to the CAMIOQUEUE ioctl on a given device to allocate
the UMA zones for I/O requests and S/G list buffers. This
may be good to move off to a taskqueue at some point.
The new passmemsetup() function allocates memory and
scatter/gather lists to hold the user's data, and copies
in any data that needs to be written. For virtual pointers
(CAM_DATA_VADDR), the kernel buffer is malloced from the
new pass(4) driver malloc bucket. For virtual
scatter/gather lists (CAM_DATA_SG), buffers are allocated
from a new per-pass(9) UMA zone in MAXPHYS-sized chunks.
Physical pointers are passed in unchanged. We have support
for up to 16 scatter/gather segments (for the user and
kernel S/G lists) in the default struct pass_io_req, so
requests with longer S/G lists require an extra kernel malloc.

The new passcopysglist() function copies a user scatter/gather
list to a kernel scatter/gather list. The number of elements
in each list may be different, but (obviously) the amount of data
stored has to be identical.

The new passmemdone() function copies data out for the
CAM_DATA_VADDR and CAM_DATA_SG cases.

The new passiocleanup() function restores data pointers in
user CCBs and frees memory.

Add new functions to support kqueue(2)/kevent(2):

passreadfilt() tells kevent whether or not the done
queue is empty.

passkqfilter() adds a knote to our list.

passreadfiltdetach() removes a knote from our list.

Add a new function, passpoll(), for poll(2)/select(2)
to use.

Add devstat(9) support for the queued CCB path.

sys/cam/ata/ata_da.c:
Add support for the BIO_VLIST bio type.

sys/cam/cam_ccb.h:
Add a new enumeration for the xflags field in the CCB header.
(This doesn't change the CCB header, just adds an enumeration to
use.)

sys/cam/cam_xpt.c:
Add a new function, xpt_setup_ccb_flags(), that allows specifying
CCB flags.

sys/cam/cam_xpt.h:
Add a prototype for xpt_setup_ccb_flags().

sys/cam/scsi/scsi_da.c:
Add support for BIO_VLIST.

sys/dev/md/md.c:
Add BIO_VLIST support to md(4).

sys/geom/geom_disk.c:
Add BIO_VLIST support to the GEOM disk class. Re-factor the I/O size
limiting code in g_disk_start() a bit.

sys/kern/subr_bus_dma.c:
Change _bus_dmamap_load_vlist() to take a starting offset and
length.

Add a new function, _bus_dmamap_load_pages(), that will load a list
of physical pages starting at an offset.

Update _bus_dmamap_load_bio() to allow loading BIO_VLIST bios.
Allow unmapped I/O to start at an offset.

sys/kern/subr_uio.c:
Add two new functions, physcopyin_vlist() and physcopyout_vlist().

sys/pc98/include/bus.h:
Guard kernel-only parts of the pc98 machine/bus.h header with
#ifdef _KERNEL.

This allows userland programs to include <machine/bus.h> to get the
definition of bus_addr_t and bus_size_t.

sys/sys/bio.h:
Add a new bio flag, BIO_VLIST.

sys/sys/uio.h:
Add prototypes for physcopyin_vlist() and physcopyout_vlist().

share/man/man4/pass.4:
Document the CAMIOQUEUE and CAMIOGET ioctls.

usr.sbin/Makefile:
Add camdd.

usr.sbin/camdd/Makefile:
Add a makefile for camdd(8).

usr.sbin/camdd/camdd.8:
Man page for camdd(8).

usr.sbin/camdd/camdd.c:
The new camdd(8) utility.

Sponsored by: Spectra Logic

------------------------------------------------------------------------
r291724 | ken | 2015-12-03 17:07:01 -0500 (Thu, 03 Dec 2015) | 6 lines

Fix typos in the camdd(8) usage() function output caused by an error in
my diff filter script.

Sponsored by: Spectra Logic

------------------------------------------------------------------------
r291741 | ken | 2015-12-03 22:38:35 -0500 (Thu, 03 Dec 2015) | 10 lines

Fix g_disk_vlist_limit() to work properly with deletes.

Add a new bp argument to g_disk_maxsegs(), and add a new function,
g_disk_maxsize() tha will properly determine the maximum I/O size for a
delete or non-delete bio.

Submitted by: will
Sponsored by: Spectra Logic

------------------------------------------------------------------------
------------------------------------------------------------------------
r291742 | ken | 2015-12-03 22:44:12 -0500 (Thu, 03 Dec 2015) | 5 lines

Fix a style issue in g_disk_limit().

Noticed by: bdrewery

------------------------------------------------------------------------

Sponsored by: Spectra Logic

291497 30-Nov-2015 mav

MFC r289138: Remove legacy CHS geometry from dmesg and unify capacity outputs.

291496 30-Nov-2015 mav

MFC r291383: Fix panic when trying to sort unsupported command in OOA queue.

Handle unsupported commands as not conflicting/blocking.

291429 28-Nov-2015 mav

MFC r291126:
Add API to obtain primary enclosure name and ID for /dev/sesX devices.

sesX device number may change between reboots, so to properly identify
the instance we need more data. Name and ID reported here may mach ones
reported by SCSI device, but that is not really required by specs.

Sponsored by: iXsystems, Inc.

291389 27-Nov-2015 mav

MFC r290820: Add NULL check to make Coverity happy.

291388 27-Nov-2015 mav

MFC r290670: Modify target port groups logic in CTL.

- Introduce "ha_shared" port option, which being set to "on" moves the
port into separate port group, shared between HA nodes. This allows to
better handle cases when iSCSI portals are bound to CARP address that can
dynamically move between nodes. Some initiators (at least VMware) don't
detect that after iSCSI reconnect they've attached to different SCSI port
from different port group, that totally breakes ALUA status parsing.
In theory, I believe, it should be enough to have different iSCSI portal
group tags on different nodes to make initiators detect this condition,
but it seems like VMware ignores those values, and even full LUN retaste
forced by UA does not help.
- Make CTL report up to three port groups: 1 -- non-HA mode or ports
with "ha_shared" option set, 2 -- HA node 1, 3 -- HA node 2.
- Report Transitioning state for all port groups when HA interlink is
connected, but neither of nodes is primary for the LUN.

290778 13-Nov-2015 mav

MFC r290458: Add two more KASSERTs.

290777 13-Nov-2015 mav

MFC r290387: Extend mask of VMware virtual disks.

290776 13-Nov-2015 mav

MFC r289881: Give CTL support for PIM_EXTLUNS when talking to CAM.

CTL itself still lives in flat LUN space, but it can generate extended
numbers if CAM SIM reports such capability.

290775 13-Nov-2015 mav

MFC r289843: Add partial support for QUERY TMF to CAM and isp(4).

This change allows to decode respective functions in isp(4) in target mode
and pass them through CAM to CTL. Unfortunately neither CAM nor isp(4)
support returning response info for those task management functions now.

On the other side I just have no initiator to test this functionality.

290774 13-Nov-2015 mav

MFC r289702: Make some panic strings mode informative.

290768 13-Nov-2015 mav

MFC r290462: Removed unused malloc types.

Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>

290172 30-Oct-2015 mav

MFC r289819: Fix LUN disable in CAM broken at r285155.

290137 29-Oct-2015 mav

MFC r290004: Don't try to replicate mode pages not present on this device.

289924 25-Oct-2015 mav

MFC r289146:
Make delete method set via kern.cam.da.X.delete_method persistent.

This allows to set delete method via tunable, before device capabilities
are known. Also allow ZERO method for devices not reporting LBP, if user
explicitly requests it -- it may be useful if storage supports compression
and WRITE SAME, but does not support UNMAP.

289489 18-Oct-2015 mav

MFC r289136: Remove lock upgrade attempt from ctl_be_block_open_file().

I am not sure what for it was done. Now open routine should automatically
fall back to read-only if open for writing is impossible. In such case
attempt to upgrade to write sounds strange.

289363 15-Oct-2015 mav

MFC r289017: Add missing vnode lock in case of file modify request.

Submitted by: Richard Kojedzinszky

288822 05-Oct-2015 mav

MFC r288458: More aggressively fill WUT read pipeline.

On some tests I've measured 5% copy speedup from this.

288821 05-Oct-2015 mav

MFC r288450: Make zero WUT use WRITE SAME with recently allowed NDOB flag.

288820 05-Oct-2015 mav

MFC r288449:
Implement SPC-3 exceptions to SPC-2 RESERVE and RELEASE behavior.

288819 05-Oct-2015 mav

MFC r288448: Unify PR variable names to reduce confusion.

288818 05-Oct-2015 mav

MFC r288427: Use proper STAILQ_* macros where possible.

288817 05-Oct-2015 mav

MFC r288420: Make pass, sg and targ drivers respect HBA's maxio.

Previous limitation of 64K (DFLTPHYS) is quite annoying.

288816 05-Oct-2015 mav

MFC r288369: Really implement PREVENT ALLOW MEDIUM REMOVAL command.

288815 05-Oct-2015 mav

MFC r288368: Don't report SYNC_NV bit set in SYNCHRONIZE CACHE as error.

While this bit is obsolete in SBC-3, behavior controlled by it is allowed
on device discretion.

288814 05-Oct-2015 mav

MFC r288367: Fix arguments order.

288813 05-Oct-2015 mav

MFC r288359: Report that we can read all flavours of DVD. Why not?

288812 05-Oct-2015 mav

MFC r288358: Add CD/DVD Capabilities and Mechanical Status Page.

This page is obsolete since MMC-4, but still used by some software.

approved by:

288811 05-Oct-2015 mav

MFC r288348: Umplement media load/eject support for removable devices.

In case of block backend eject really closes the backing store, while
load tries to open it back. Failed store open is reported as no media.

288810 05-Oct-2015 mav

MFC r288310: Add to CTL initial support for CDROMs and removable devices.

Relnotes: yes

288809 05-Oct-2015 mav

MFC r288264: Allow LOG SENSE command on non-disk devices.

288808 05-Oct-2015 mav

MFC r288262: Remove concept of control device.

288807 05-Oct-2015 mav

MFC r288261: Move ioctl frontend defines where they belong.

288806 05-Oct-2015 mav

MFC r288260: Remove few more unused variables.

288805 05-Oct-2015 mav

MFC r288259: Remove some duplicate, legacy, dead and questionable code.

288804 05-Oct-2015 mav

MFC r288247: Pass to sobind() copy of the address, not the original.

288803 05-Oct-2015 mav

MFC r288239: Properly lock LUN in ctl_failover_lun().

288802 05-Oct-2015 mav

MFC r288224: Constify ctl_serialize_table.

288801 05-Oct-2015 mav

MFC r288229: Fix bit masks changed for the wrong commands in r288221.

288800 05-Oct-2015 mav

MFC r288221: Remove some dead code found by Clang analyzer.

288799 05-Oct-2015 mav

MFC r288220: Remove stale comments and some excessive empty lines.

288798 05-Oct-2015 mav

MFC r288215: Switch I/O time accounting from system time to uptime.

While there, make num_dmas accounted independently of CTL_TIME_IO.

288797 05-Oct-2015 mav

MFC r288214: Collect DMA statistics on secondary HA node.

288796 05-Oct-2015 mav

MFC r288213:
Make HA handle datamove and done in a universal way, using port methods.

Now from primary node point of view requests transferred from secondary
node should look almost normal and always have valid port.

288795 05-Oct-2015 mav

MFC r288211: Remove some control_softc references.

288794 05-Oct-2015 mav

MFC r288175: Allow WRITE SAME with NDOB bit set but without UNMAP.

This combination was originally forbidden, but allowed at spc4r3.

288793 05-Oct-2015 mav

MFC r288170: Add new report types to REPORT LUNS command.

This is only for completeness, since we have nothing new to report there.

288792 05-Oct-2015 mav

MFC r288166: Update WRITE ATOMIC(16) support to sbc4r8 draft.

This is only a cosmetic change. We still don't support atomic boundary
field in the CDB, but at least now we do it formally.

288791 05-Oct-2015 mav

MFC r288165: Add support for READ BUFFER(16) command.

288790 05-Oct-2015 mav

MFC r288148: Synchronize mode pages between HA peers.

We allow to modify only few fields in mode pages now, but still it is
not good if they unexpectedly change during failover. Also this fixes
reporting of "Mode parameters changed" UAs on secondary node.

288789 05-Oct-2015 mav

MFC r288146: Make HA peers announce their parameters on connect.

HA protocol requires strict version, parameters and configuration match.
Differences there may cause full set of problems up to kernel panic.
To avoid that, validate peer parameters on connect, and abort connection
immediately if some mismatch detected.

288788 05-Oct-2015 mav

MFC r288110: Add support for Control extension mode page.

288787 05-Oct-2015 mav

MFC r288104: Remove duplicate and incomplete code handling LUN modify.

Instead reuse code from LUN creation. This allows most of LUN media
options to be changed live with modify request without full restart.

288786 05-Oct-2015 mav

MFC r288067: Log iSCSI session reinstatements.

False session reinstatements can be result of misconfiguration, when
several initiators use the same initiator name and ISID.

288782 05-Oct-2015 mav

MFC r288021: Mark with DMA flag I/Os waiting for iSCSI write data after R2T.

Reads and immediate writes are not blocking, so don't bother.

288781 05-Oct-2015 mav

MFC r288020: Remove couple excess SGLIST I/O flags.

Those flags duplicated respective (sg_entries > 0) values.

288779 05-Oct-2015 mav

MFC r287994: Always execute REPORT LUNS and REQUEST SENSE commands locally.

REPORT LUNS command is more related to target rather then specific LUN.
This node may be primary for LUNs for some reason unknown to another,
and command forwarded to another node won't be able to report them.

REQUEST SENSE is related to LUN, but in our implementation it reports
only UAs and CAs, that are stored locally rather then on primary node.

288778 05-Oct-2015 mav

MFC r287993: Split two command flags with different meaning.

This is only a cosmetical change.

288777 05-Oct-2015 mav

MFC r287991: Pack struct ctl_ha_msg_hdr by 8 bytes.

288776 05-Oct-2015 mav

MFC r287986: Fix memory corruption when >128K transferred through HA link.

While there, do some cleaning.

288775 05-Oct-2015 mav

MFC r287968: Mark I/Os with DMA flag while moving data through the HA link.

288774 05-Oct-2015 mav

MFC r287967: Relax serseq option operation for reads.

Previously, with serseq enabled, next command was unblocked only after
previous completed. With this change, for read operations, next command
is unblocked as soon as last media read completed. This is important
for frontends that actually wait for data move completion (like camtgt),
or when data are moved through the HA link, or especially when both.

288773 05-Oct-2015 mav

MFC r287957: Kill HA link and shutdown the threads on shutdown.

288772 05-Oct-2015 mav

MFC r287956: Update list of opcodes to 5/26/15.

288771 05-Oct-2015 mav

MFC r287955: Update list of ASC/ASCQ codes from 5/20/12 to 8/12/15.

288770 05-Oct-2015 mav

MFC r287940: Replicate initiators WWPNs and names between HA peers.

288769 05-Oct-2015 mav

MFC r287933: Replicate port->init_devid to HA peer.

288768 05-Oct-2015 mav

MFC r287921: When reporting TPT UA, report which of thresholds was reached.

288767 05-Oct-2015 mav

MFC r287913: Report number of failed XCOPY segment.

288765 05-Oct-2015 mav

MFC r287912: Report proper medium error code for VERIFY commands.

288764 05-Oct-2015 mav

MFC r287875: Fix reading after end of file for file-backed LUNs.

If backing file is smaller then the LUN size, we have to explicitly clear
the rest of the buffer to not leak some random data from previous I/Os.

288763 05-Oct-2015 mav

MFC r287868: Make COMPARE AND WRITE report offset of difference.

288762 05-Oct-2015 mav

MFC r287860: Frontends don't need to set errors themselves.

288761 05-Oct-2015 mav

MFC r287855: Don't flap the HA link if sysctl is reset to the same value.

288759 05-Oct-2015 mav

MFC r287818: Fix completion/error status reporting.

288758 05-Oct-2015 mav

MFC r287816: Close potential race between datamove and HA failover.

288757 05-Oct-2015 mav

MFC r287784: Implement data/status aggregation for secondary HA node.

For short read requests this reduces latency by 30%, reporting command
completion after two interlink roundtrips instead of full three.

288756 05-Oct-2015 mav

MFC r287783: Implement data/status aggregation for camsim backend.

This is almost pointless for primary HA node, but useful for secondary,
where between fe_datamove and fe_done calls goes another link roundtrip.

288755 05-Oct-2015 mav

MFC r287778: Remove CTL_PRIV_LBA_LEN from HA messages.

Previously it was used for statistics, but now just a 16 extra bytes.

288754 05-Oct-2015 mav

MFC r287774: Implement QUERY TASK, QUERY TASK SET and QUERY ASYNC EVENT.

Now we support most of SAM-5 task management.

288752 05-Oct-2015 mav

MFC r287765: Map CLEAR TASK SET and I_T NEXUS RESET for iSCSI.

The last should not be called without iSCSIProtocolLevel negotiation.

288751 05-Oct-2015 mav

MFC r287764: Implement iSCSI TARGET COLD RESET task management function.

Implement it as CTL_TASK_TARGET_RESET plus termination of all sessions.

288750 05-Oct-2015 mav

MFC r287760: Improve read-only support.

288749 05-Oct-2015 mav

MFC r287758: Reannounce port to HA peer if LUN map changed after online.

288747 05-Oct-2015 mav

MFC r287756:
Report INQUIRY DATA HAS CHANGED for related LUNs on port on-/offline.

288746 05-Oct-2015 mav

MFC r287754: Report CTL_UA_LUN_CHANGE on LUN map change.

288745 05-Oct-2015 mav

MFC r287748: Make TARGET RESET respect LUN mapping.

288744 05-Oct-2015 mav

MFC r287724: Check for obsolete NUL bin in CSCD descriptor.

288743 05-Oct-2015 mav

MFC r287721: Add HA support for CTL_TASK_I_T_NEXUS_RESET.

288742 05-Oct-2015 mav

MFC r287720: Fix false CTL_UA_RES_RELEASE on secondary HA node.

288741 05-Oct-2015 mav

MFC r287718: Decode WRITE ATOMIC(16) command.

288740 05-Oct-2015 mav

MFC r287715: Improve XCOPY error reporting.

288739 05-Oct-2015 mav

MFC r287714: Report that we have no limit on POPULATE TOKEN segment size.

288738 05-Oct-2015 mav

MFC r287712: Correct RTPG bitmask.

288737 05-Oct-2015 mav

MFC r287711: Some HA polishing.

288736 05-Oct-2015 mav

MFC r287707: CTL documentation update, mostly for HA.

288735 05-Oct-2015 mav

MFC r287671:
Make ctld restart on primary HA node less invasive for secondary.

288734 05-Oct-2015 mav

MFC r287670: Close races between device close and request processing.

All requests arriving for processing after OFFLINE flag set are rejected
with BUSY status. Races around OFFLINE flag setting are closed by calling
taskqueue_drain_all().

288733 05-Oct-2015 mav

MFC r287664: Reference/release devices on every I/O, rather on open/close.

While this may be slower, it allows device destruction to complete,
rather then block waiting for indefinitely long time.

288732 05-Oct-2015 mav

MFC r287621: Reimplement CTL High Availability.

CTL HA functionality was originally implemented by Copan many years ago,
but large part of the sources was never published. This change includes
clean room implementation of the missing code and fixes for many bugs.

This code supports dual-node HA with ALUA in four modes:
- Active/Unavailable without interlink between nodes;
- Active/Standby with second node handling only basic LUN discovery and
reservation, synchronizing with the first node through the interlink;
- Active/Active with both nodes processing commands and accessing the
backing storage, synchronizing with the first node through the interlink;
- Active/Active with second node working as proxy, transfering all
commands to the first node for execution through the interlink.

Unlike original Copan's implementation, depending on specific hardware,
this code uses simple custom TCP-based protocol for interlink. It has
no authentication, so it should never be enabled on public interfaces.

The code may still need some polishing, but generally it is functional.

Relnotes: yes
Sponsored by: iXsystems, Inc.

288731 05-Oct-2015 mav

MFC r287620: Remove unused target and initiator IDs.

288730 05-Oct-2015 mav

MFC r287618: Disable CTL_IO_DELAY feature.

It is too developer-oriented to be enabled by default.

288728 05-Oct-2015 mav

MFC r287500: Allow LUN options modification via CTL_LUNREQ_MODIFY.

Not all changes take effect, but that is a different question.

288727 05-Oct-2015 mav

MFC r287499: Move setting of media parameters inside open routines.

This is preparation for possibility to open/close media several times
per LUN life cycle. While there, rename variables to reduce confusion.
As additional bonus this allows to open read-only media, such as ZFS
snapshots.

288726 05-Oct-2015 mav

MFC r287455, r287458, r287459: Remove some dead code.

288725 05-Oct-2015 mav

MFC r287433: Small UA cleanup.

288724 05-Oct-2015 mav

MFC r287372:
Make most of port methods optional and remove bunch of dummies.

288723 05-Oct-2015 mav

MFC r287293: Remove 600 bytes of port_priv from struct ctl_io_hdr.

This field used only for camtgt frontend, and once it any way preallocates
all requests, let it preallocate this memory too, not bothering core code.

288722 05-Oct-2015 mav

MFC r287221: Fix type bug introduced at r286811.

288721 05-Oct-2015 mav

MFC r286811: Polish sizes processing.

288720 05-Oct-2015 mav

MFC r286807: Move "ioctl" CAM frontend into separate file.

It has nothing to share with too huge ctl.c other then device descriptor,
but even that may be counted as design error that may be fixed later.
At some point we may even want to have several ioctl ports.

288719 05-Oct-2015 mav

MFC r286806: Drop "internal" CTL frontend.

Its idea was to be a simple initiator and execute several commands from
kernel level, but FreeBSD never had consumer for that functionality,
while its implementation polluted many unrelated places.

288718 05-Oct-2015 mav

MFC r286406, r286414:
Wrap some unused functions with notyet, it is necessary to be able to
build the modules/ctl directly.
Remove a dead MALLOC_DEFINE.

288713 05-Oct-2015 mav

MFC r285155:
Make first step toward supporting target and initiator roles same time.

To avoid conflicts between target and initiator devices in CAM, make
CTL use target ID reported by HBA as its initiator_id in XPT_PATH_INQ.
That target ID is known to never be used for initiator role, so it won't
conflict. For Fibre Channel and FireWire HBAs this specific ID choice
is irrelevant since all target IDs there are virtual. Same time for SPI
HBAs it seems could be even requirement to use same target ID for both
initiator and target roles.

While there are some more things to polish in isp(4) driver, first tests
of using both roles same time on the same port appeared successfull:

# camcontrol devlist -v
scbus0 on isp0 bus 0:
<FREEBSD CTLDISK 0001> at scbus0 target 1 lun 0 (da20,pass21)
<> at scbus0 target 256 lun 0 (ctl0)
<> at scbus0 target -1 lun ffffffff (ctl1)

288706 05-Oct-2015 mav

MFC r285030: Fix couple panics on forced unmount of backing file.

288702 05-Oct-2015 mav

MFC r281531 (by asomers):
Initialize async_arg_ptr in xpt_async when called with async_code
AC_ADVINFO_CHANGED.

Without this change, newly inserted hard disks won't always have their
physical path device nodes created. The problem reproduces most readily
when attaching a large number of disks at once.

288701 05-Oct-2015 mav

MFC r280845 (by eadler):
Add some additional quirks for various Western Digital Caviar MHDDs

288700 05-Oct-2015 mav

MFC r280388 (by benno): Be consistent with M_ZERO when allocating ccbs.

There are four places, all in cam_xpt.c, where ccbs are malloc'ed. Two of
these use M_ZERO, two don't. The two that don't meant that allocated ccbs
had trash in them making it hard to debug errors where they showed up. Due
to this, use M_ZERO all the time when allocating ccbs.

288697 05-Oct-2015 mav

MFC r278398 (by trasz):
Fix ordering of "*logout" and "*terminate"; no functional changes.

288696 05-Oct-2015 mav

MFC r257831 (by smh):
Corrected definition for old_rate to match d_rotation_rate

288695 05-Oct-2015 mav

MFC r277440 (by will):
Restore the CAM XPT peripheral generation counter, and export it via sysctl.

Define it as an atomic uint32_t. These increments happen infrequently
enough for the atomic overhead to be a problem, and since they're now
independent atomics, they won't contend with xpt_lock_buses().

This counter is useful as a means of cheaply identifying whether any changes
have been made to the CAM peripheral list. Userland programs have no guarantee
that the counter won't change on them while being returned or while processing
the information, so they must be written accordingly.

288694 05-Oct-2015 mav

MFC r277101 (by imp):
Explain a bit of tricky code dealing with trims and how it prevents
starvation. These side effects aren't obvious without extremely
careful study, and are important to do just so.

288693 05-Oct-2015 mav

MFC r270225 (by jhb): Unexpand TAILQ_FOREACH().

288692 05-Oct-2015 mav

MFC r269709 (by imp): is_full_id is set to 0 and then not used. remove it.

288409 30-Sep-2015 markj

MFC r287806:
Preserve the device queue status before retrying a sense request in
chdone().

288354 29-Sep-2015 mav

MFC r287819: Make CAM log errors that make it wait.

Waiting can take minutes, and it would be good for user to know what is
going on.

288338 28-Sep-2015 mav

MFC r287289: Attach pass driver to LUNs is OFFLINE state.

Previously such LUNs were silently ignored. But while they indeed unable
to process most of SCSI commands, some, like RTPG, they still can.

288142 23-Sep-2015 mav

MFC r287866: Fix fixed sense writing when passed more data then it can fit.

287498 06-Sep-2015 mav

MFC r287432: Fix copy-paste bug introduced in r275458.

287286 29-Aug-2015 mav

MFC r287025: Remove some code duplication by using biofinish().

287203 27-Aug-2015 ken

MFC, r286965:

------------------------------------------------------------------------
r286965 | ken | 2015-08-20 10:07:51 -0600 (Thu, 20 Aug 2015) | 297 lines

Revamp camcontrol(8) fwdownload support and add the opcodes subcommand.

The significant changes and bugs fixed here are:

1. Fixed a bug in the progress display code:

When the user's filename is too big, or his terminal width is too
small, the progress code could wind up using a negative number for
the length of the "stars" that it uses to indicate progress.

This negative value was assigned to an unsigned variable, resulting
in a very large positive value.

The result is that we wound up writing garbage from memory to the
user's terminal.

With an 80 column terminal, a file name length of more than 35
characters would generate this problem.

To address this, we now set a minimum progress bar length, and
truncate the user's file name as needed.

This has been tested with large filenames and small terminals, and
at least produces reasonable results. If the terminal is too
narrow, the progress display takes up an additional line with each
update, but this is more user friendly than writing garbage to the
tty.

2. SATA drives connected via a SATA controller didn't have SCSI Inquiry
data populated in struct cam_device. This meant that the code in
fw_get_vendor() in fwdownload.c would try to match a zero-length
vendor ID, and so return the first entry in the vendor table. (Which
used to be HITACHI.) Fixed by grabbing identify data, passing the
identify buffer into fw_get_vendor(), and matching against the model
name.

3. SATA drives connected via a SAS controller do have Inquiry data
populated. The table included a couple of entries -- "ATA ST" and
"ATA HDS", intended to handle Seagate and Hitachi SATA drives attached
via a SAS controller. SCSI to ATA translation layers use a vendor
ID of "ATA" (which is standard), and then the model name from the ATA
identify data as the SCSI product name when they are returning data on
SATA disks. The cam_strmatch code will match the first part of the
string (because the length it is given is the length of the vendor,
"ATA"), and return 0 (i.e. a match). So all SATA drives attached to
a SAS controller would be programmed using the Seagate method
(WRITE BUFFER mode 7) of SCSI firmware downloading.

4. Issue #2 above covered up a bug in fw_download_img() -- if the
maximum packet size in the vendor table was 0, it tried to default
to a packet size of 32K. But then it didn't actually succeed in
doing that, because it set the packet size to the value that was
in the vendor table (0). Now that we actually have ATA attached
drives fall use the VENDOR_ATA case, we need a reasonable default
packet size. So this is fixed to properly set the default packet size.

5. Add support for downloading firmware to IBM LTO drives, and add a
firmware file validation method to make sure that the firmware
file matches the drive type. IBM tape drives include a Load ID and
RU name in their vendor-specific VPD page 0x3. Those should match
the IDs in the header of the firmware file to insure that the
proper firmware file is loaded.

6. This also adds a new -q option to the camcontrol fwdownload
subcommand to suppress informational output. When -q is used in
combination with -y, the firmware upgrade will happen without
prompting and without output except if an error condition occurs.

7. Re-add support for printing out SCSI inquiry information when
asking the user to confirm that they want to download firmware, and
add printing of ATA Identify data if it is a SATA disk. This was
removed in r237281 when support for flashing ATA disks was added.

8. Add a new camcontrol(8) "opcodes" subcommand, and use the
underlying code to get recommended timeout values for drive
firmware downloads.

Many SCSI devices support the REPORT SUPPORTED OPERATION CODES
command, and some support the optional timeout descriptor that
specifies nominal and recommended timeouts for the commands
supported by the device.

The new camcontrol opcodes subcommand allows displaying all
opcodes supported by a drive, information about which fields
in a SCSI CDB are actually used by a given SCSI device, and the
nominal and recommended timeout values for each command.

Since firmware downloads can take a long time in some devices, and
the time varies greatly between different types of devices, take
advantage of the infrastructure used by the camcontrol opcodes
subcommand to determine the best timeout to use for the WRITE
BUFFER command in SCSI device firmware downloads.

If the device recommends a timeout, it is likely to be more
accurate than the default 50 second timeout used by the firmware
download code. If the user specifies a timeout, it will override
the default or device recommended timeout. If the device doesn't
support timeout descriptors, we fall back to the default.

9. Instead of downloading firmware to SATA drives behind a SAS controller
using WRITE BUFFER, use the SCSI ATA PASS-THROUGH command to compose
an ATA DOWNLOAD MICROCODE command and it to the drive. The previous
version of this code attempted to send a SCSI WRITE BUFFER command to
SATA drives behind a SAS controller. Although that is part of the
SAT-3 spec, it doesn't work with the parameters used with LSI
controllers at least.

10.Add a new mechanism for making common ATA passthrough and
ATA-behind-SCSI passthrough commands.

The existing camcontrol(8) ATA command mechanism checks the device
type on every command executed. That works fine for individual
commands, but is cumbersome for things like a firmware download
that send a number of commands.

The fwdownload code detects the device type up front, and then
sends the appropriate commands.

11.In simulation mode (-s), if the user specifies the -v flag, print out
the SCSI CDB or ATA registers that would be sent to the drive. This will
aid in debugging any firmware download issues.

sbin/camcontrol/fwdownload.c:
Add a device type to the fw_vendor structure, so that we can
specify different download methods for different devices from the
same vendor. In this case, IBM hard drives (from when they
still made hard drives) and tape drives.

Add a tur_status field to the fw_vendor structure so that we can
specify whether the drive to be upgraded should be ready, not
ready, or whether it doesn't matter. Add the corresponding
capability in fw_download_img().

Add comments describing each of the vendor table fields.

Add HGST and SmrtStor to the supported SCSI vendors list.

In fw_get_vendor(), look at ATA identify data if we have a SATA
device to try to identify what the drive vendor is.

Add IBM firmware file validation. This gets VPD page 0x3, and
compares the Load ID and RU name in the page to the values
included in the header. The validation code will refuse to load
a firmware file if the values don't match. This does allow the
user to attempt a downgrade; whether or not it succeeds will
likely depend on the drive settings.

Add a -q option, and disable all informative output
(progress bars, etc.) when this is enabled.

Re-add the inquiry in the confirmation dialog so the user has
a better idea of which device he is talking to. Add support for
displaying ATA identify data.

Don't automatically disable confirmation in simulation (-s) mode.
This allows the user to see the inquiry or identify data in the
dialog, and see exactly what they would see when the command
actually runs. Also, in simulation mode, if the user specifies
the -v flag, print out the SCSI CDB or ATA registers that would
be sent to the drive. This will aid in debugging any firmware
download issues.

Add a timeout field and timeout type to the firmware download
vendor table. This allows specifying a default timeout and allows
specifying whether we should attempt to probe for a recommended
timeout from the drive.

Add a new fuction, fw_get_timeout(), that will determine
which timeout to use for the WRITE BUFFER command. If the
user specifies a timeout, we always use that. Otherwise,
we will use the drive recommended timeout, if available,
and fall back to the default when a drive recommended
timeout isn't available.

When we prompt the user, tell him what timeout we're going
to use, and the source of the timeout.

Revamp the way SATA devices are handled.

In fwdownload(), use the new get_device_type() function to
determine what kind of device we're talking to.

Allow firmware downloads to any SATA device, but restrict
SCSI downloads to known devices. (The latter is not a
change in behavior.)

Break out the "ready" check from fw_download_img() into a
new subfunction, fw_check_device_ready(). This sends the
appropriate command to the device in question -- a TEST
UNIT READY or an IDENTIFY. The IDENTIFY for SATA devices
a SAT layer is done using the SCSI ATA PASS-THROUGH
command.

Use the new build_ata_cmd() function to build either a SCSI or
ATA I/O CCB to issue the DOWNLOAD MICROCODE command to SATA
devices. build_ata_cmd() figures looks at the devtype argument
and fills in the correct CCB type and CDB or ATA registers.

Revamp the vendor table to remove the previous
vendor-specific ATA entries and use a generic ATA vendor
placeholder. We currently use the same method for all ATA
drives, although we may have to add vendor-specific
behavior once we test this with more drives.

sbin/camcontrol/progress.c:
In progress_draw(), make barlength a signed value so that
we can easily detect a negative value.

If barlength (the length of the progress bar) would wind up
negative due to a small TTY width or a large filename,
set the bar length to the new minimum (10 stars) and
truncate the user's filename. We will truncate it down to
0 characters if necessary.

Calculate a new prefix_len variable (user's filename length)
and use it as the precision when printing the filename.

sbin/camcontrol/camcontrol.c:
Implement a new camcontrol(8) subcommand, "opcodes". The
opcodes subcommand allows displaying the entire list of
SCSI commands supported by a device, or details on an
individual command. In either case, it can display
nominal and recommended timeout values.

Add the scsiopcodes() function, which calls the new
scsigetopcodes() function to fetch opcode data from a
drive.

Add two new functions, scsiprintoneopcode() and
scsiprintopcodes(), which print information about one
opcode or all opcodes, respectively.

Remove the get_disk_type() function. It is no longer used.

Add a new function, dev_has_vpd_page(), that fetches the
supported INQUIRY VPD list from a device and tells the
caller whether the requested VPD page is available.

Add a new function, get_device_type(), that returns a more
precise device type than the old get_disk_type() function.
The get_disk_type() function only distinguished between
SCSI and ATA devices, and SATA devices behind a SCSI to ATA
translation layer were considered to be "SCSI".

get_device_type() offers a third type, CC_DT_ATA_BEHIND_SCSI.
We need to know this to know whether to attempt to send ATA
passthrough commands. If the device has the ATA
Information VPD page (0x89), then it is an ATA device
behind a SCSI to ATA translation layer.

Remove the type argument from the fwdownload() subcommand.

Add a new function, build_ata_cmd(), that will take one set
of common arguments and build either a SCSI or ATA I/O CCB,
depending on the device type passed in.

sbin/camcontrol/camcontrol.h:
Add a prototype for scsigetopcodes().

Add a new enumeration, camcontrol_devtype.

Add prototypes for dev_has_vpd_page(), get_device_type()
and build_ata_cmd().

Remove the type argument from the fwdownload() subcommand.

sbin/camcontrol/camcontrol.8
Explain that the fwdownload subcommand will use the drive
recommended timeout if available, and that the user can
override the timeout.

Document the new opcodes subcommand.

Explain that we will attempt to download firmware to any
SATA device.

Document supported SCSI vendors, and models tested if known.

Explain the commands used to download firmware for the
three different drive and controller combinations.

Document that the -v flag in simulation mode for the fwdownload
subcommand will print out the SCSI CDBs or ATA registers that would
be used.

sys/cam/scsi/scsi_all.h:
Add new bit definitions for the one opcode descriptor for
the REPORT SUPPORTED OPCODES command.

Add a function prototype for scsi_report_supported_opcodes().

sys/cam/scsi/scsi_all.c:
Add a new CDB building function, scsi_report_supported_opcodes().

Sponsored by: Spectra Logic

286931 19-Aug-2015 mav

MFC r286353: Pass SYNCHRONIZE CACHE command parameters to backends.

At this point IMMED flag is translated to MNT_NOWAIT flag of VOP_FSYNC(),
hoping that file system implements that (ZFS seems doesn't).

286930 19-Aug-2015 mav

MFC r286345: Relax serialization of SYNCHRONIZE CACHE commands.

Before this change SYNCHRONIZE CACHE commands were executed exclusively,
as if they had ORDERED tag. But looking through SCSI specs I've found
no any reason to be so strict. For reads this ordering seems pointless.
For writes it looks less obvious, so I left ordering against preceeding
write commands, while following ones are no longer required to wait.

286928 19-Aug-2015 mav

MFC r286320: Issue all reads of single XCOPY segment simultaneously.

During vMotion and Clone VMware by default runs multiple sequential 4MB
XCOPY requests same time. If CTL issues reads sequentially in 1MB chunks
for each XCOPY command, reads from different commands are not detected
as sequential by serseq option code and allowed to execute simultaneously.
Such read pattern confused ZFS prefetcher, causing suboptimal disk access.
Issuing all reads same time make serseq code work properly, serializing
reads both within each XCOPY command and between them.

My tests with ZFS pool of 14 disks in RAID10 shows prefetcher efficiency
improved from 37% to 99.7%, copying speed improved by 10-60%, average
read latency reduced twice on HDD layer and by five times on zvol layer.

286817 16-Aug-2015 mav

MFC r286514: Remove verbose CTL messages.

Reporting SCSI errors to console is often useless, pollutes logs and may
affect performance. For debugging there is kern.cam.ctl.debug sysctl

286800 15-Aug-2015 mav

MFC r286447:
Don't panic if disk lost TRIM support due to switching to PIO mode.

284798 25-Jun-2015 mav

MFC r284640: Bring per-port LUN enable/disable code up to date:
- remove last remnants of never implemented multiple targets support;
- implement missing support for LUN mapping in this area.

Due to existing locking constraints LUN mapping code is practically
unlocked at this point. Hopefully it is not racy enough to live until
somebody get idea how to call sleeping fronend methods under lock also
taken by the same frontend in non-sleepable context. :(

284797 25-Jun-2015 mav

MFC r284627: Remove some dead and duplicate LUN enabling code.

284796 25-Jun-2015 mav

MFC r284639: Introduce separate lock for tokens to reduce ctl_lock scope.

284795 25-Jun-2015 mav

MFC r284641:
Fix REPORT LUNS command output for the case when same LUN mapped to same
port several times. While it is unusual configuration, it is not illegal.

284794 25-Jun-2015 mav

MFC r284622: Remove device queue freeze handling and replace it with dummy.

At this point CTL has no known use case for device queue freezes.
Same time existing (considered to be broken) code was found to cause
modify-after-free issues.

284793 25-Jun-2015 mav

MFC r284541:
Change ATIO/INOT counting to prevent periph destruction while requests
are still running inside CTL.

284586 19-Jun-2015 mav

MFC r284013: Allow setting only WWNN or only WWPN.

284435 16-Jun-2015 ken

MFC, r284192:

------------------------------------------------------------------------
r284192 | ken | 2015-06-09 15:39:38 -0600 (Tue, 09 Jun 2015) | 102 lines

Add support for reading MAM attributes to camcontrol(8) and libcam(3).

MAM is Medium Auxiliary Memory and is most commonly found as flash
chips on tapes.

This includes support for reading attributes and decoding most
known attributes, but does not yet include support for writing
attributes or reporting attributes in XML format.

libsbuf/Makefile:
Add subr_prf.c for the new sbuf_hexdump() function. This
function is essentially the same function.

libsbuf/Symbol.map:
Add a new shared library minor version, and include the
sbuf_hexdump() function.

libsbuf/Version.def:
Add version 1.4 of the libsbuf library.

libutil/hexdump.3:
Document sbuf_hexdump() alongside hexdump(3), since it is
essentially the same function.

camcontrol/Makefile:
Add attrib.c.

camcontrol/attrib.c:
Implementation of READ ATTRIBUTE support for camcontrol(8).

camcontrol/camcontrol.8:
Document the new 'camcontrol attrib' subcommand.

camcontrol/camcontrol.c:
Add the new 'camcontrol attrib' subcommand.

camcontrol/camcontrol.h:
Add a function prototype for scsiattrib().

share/man/man9/sbuf.9:
Document the existence of sbuf_hexdump() and point users to
the hexdump(3) man page for more details.

sys/cam/scsi/scsi_all.c:
Add a table of known attributes, text descriptions and
handler functions.

Add a new scsi_attrib_sbuf() function along with a number
of other related functions that help decode attributes.

scsi_attrib_ascii_sbuf() decodes ASCII format attributes.

scsi_attrib_int_sbuf() decodes binary format attributes, and
will pass them off to scsi_attrib_hexdump_sbuf() if they're
bigger than 8 bytes.

scsi_attrib_vendser_sbuf() decodes the vendor and drive
serial number attribute.

scsi_attrib_volcoh_sbuf() decodes the Volume Coherency
Information attribute that LTFS writes out.

sys/cam/scsi/scsi_all.h:
Add a number of attribute-related structure definitions and
other defines.

Add function prototypes for all of the functions added in
scsi_all.c.

sys/kern/subr_prf.c:
Add a new function, sbuf_hexdump(). This is the same as
the existing hexdump(9) function, except that it puts the
result in an sbuf.

This also changes subr_prf.c so that it can be compiled in
userland for includsion in libsbuf.

We should work to change this so that the kernel hexdump
implementation is a wrapper around sbuf_hexdump() with a
statically allocated sbuf with a drain. That will require
a drain function that goes to the kernel printf() buffer
that can take a non-NUL terminated string as input.
That is because an sbuf isn't NUL-terminated until it is
finished, and we don't want to finish it while we're still
using it.

We should also work to consolidate the userland hexdump and
kernel hexdump implemenatations, which are currently
separate. This would also mean making applications that
currently link in libutil link in libsbuf.

sys/sys/sbuf.h:
Add the prototype for sbuf_hexdump(), and add another copy
of the hexdump flag values if they aren't already defined.

Ideally the flags should be defined in one place but the
implemenation makes it difficult to do properly. (See
above.)

Sponsored by: Spectra Logic Corporation

------------------------------------------------------------------------

284158 08-Jun-2015 mav

MFC r284044: Fix wrong function name in error message.

283349 24-May-2015 trasz

MFC r279554:

Make periphdriver_register() take XPT lock when modifying the periph_drivers
array.

This fixes a panic that sometimes occured when kldloading ctl.ko.

PR: 200384
Sponsored by: The FreeBSD Foundation

283189 21-May-2015 hselasky

MFC r279726:
Add DA_Q_NO_RC16 quirk for USB mass storage device.

PR: 194062

282862 13-May-2015 mav

MFC r282565: Handle EDQUOT backend storage errors same as ENOSPC.

282670 08-May-2015 delphij

MFC r281840:

Extend DA_Q_NO_RC16 to MXUB3* devices.

PR: kern/198647

282512 05-May-2015 hselasky

MFC r280597:
Add DA_Q_NO_RC16 quirk for USB mass storage device.

PR: 198647

281961 25-Apr-2015 pfg

MFC r281795:
scsi_parse_transportid_rdma(): fix mismatch in memory access size.

Independently found by Coverity and gcc49.

CID: 1230006
Reviewed by: ken

280898 31-Mar-2015 mav

MFC r280172: Improve ATA and SCSI versions printing.

There is no "SCSI-6" and "ATA-9", but there is "SPC-4" and "ACS-2".

280754 27-Mar-2015 mav

MFC r270832 (by imp):
Add a few defines and packet types for SATA 3.2 and FPDMA (First Party
DMA).

280722 27-Mar-2015 ken

MFC revision 280463

------------------------------------------------------------------------
r280463 | ken | 2015-03-24 15:42:28 -0600 (Tue, 24 Mar 2015) | 5 lines

Remove some #if 0'ed code that apparently confuses cscope.

Requested by: Peter Xu <xzpeter@gmail.com>
MFC after: 3 days

------------------------------------------------------------------------

Sponsored by: Spectra Logic

280446 24-Mar-2015 ken

MFC, r279375

------------------------------------------------------------------------
r279375 | ken | 2015-02-27 14:35:36 -0700 (Fri, 27 Feb 2015) | 26 lines

Fix I/O size calculation for pass(4) driver requests and add latency
tracking.

It is important to subtract the residual from the requested
transfer size to see how much data was actually transferred. With
tape drives in particular, it is common to request more data than is
returned.

Also, add I/O latency tracking for CAM requests issued by
cam_periph_runccb().

If the caller supplies a struct devstat, and the I/O is a SCSI or
ATA I/O, we will track the elapsed time to provide I/O latency
statistics for the request.

sys/cam/scsi/cam_periph.c:
In cam_periph_runccb(), subtract the residual when reporting I/O
totals to devstat(9) for SCSI and ATA passthrough requests.

In cam_periph_runccb(), grab the I/O start time and supply
the start time to devstat_end_transaction() so that it can
calculate the elapsed I/O time.

Sponsored by: Spectra Logic
MFC after: 1 week

------------------------------------------------------------------------

Sponsored by: Spectra Logic

280438 24-Mar-2015 ken

MFC sa(4) and mt(1) improvements.

This includes these changes: 279219, 279229, 279261, 279534, 279570,
280230, 280231.

In addition, bump __FreeBSD_version for the addition of the new
mtio(4) / sa(4) ioctls.

Thanks to Dan Langille, Harald Schmalzbauer and Rudolf Cejka for spending
a significant amount of time and effort testing these changes.

------------------------------------------------------------------------
r279219 | ken | 2015-02-23 14:59:30 -0700 (Mon, 23 Feb 2015) | 282 lines

Significant upgrades to sa(4) and mt(1).

The primary focus of these changes is to modernize FreeBSD's
tape infrastructure so that we can take advantage of some of the
features of modern tape drives and allow support for LTFS.

Significant changes and new features include:

o sa(4) driver status and parameter information is now exported via an
XML structure. This will allow for changes and improvements later
on that will not break userland applications. The old MTIOCGET
status ioctl remains, so applications using the existing interface
will not break.

o 'mt status' now reports drive-reported tape position information
as well as the previously available calculated tape position
information. These numbers will be different at times, because
the drive-reported block numbers are relative to BOP (Beginning
of Partition), but the block numbers calculated previously via
sa(4) (and still provided) are relative to the last filemark.
Both numbers are now provided. 'mt status' now also shows the
drive INQUIRY information, serial number and any position flags
(BOP, EOT, etc.) provided with the tape position information.
'mt status -v' adds information on the maximum possible I/O size,
and the underlying values used to calculate it.

o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed.

The extra devices were originally added as place holders for
density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap
and Solaris) have had device nodes that, when you write to them,
will automatically select a given density for particular tape drives.

This is a convenient way of switching densities, but it was never
implemented in FreeBSD. Only the device nodes were there, and that
sometimes confused users.

For modern tape devices, the density is generally not selectable
(e.g. with LTO) or defaults to the highest availble density when
the tape is rewritten from BOT (e.g. TS11X0). So, for most users,
density selection won't be necessary. If they do need to select
the density, it is easy enough to use 'mt density' to change it.

o Protection information is now supported. This is either a
Reed-Solomon CRC or CRC32 that is included at the end of each block
read and written. On write, the tape drive verifies the CRC, and
on read, the tape drive provides a CRC for the userland application
to verify.

o New, extensible tape driver parameter get/set interface.

o Density reporting information. For drives that support it,
'mt getdensity' will show detailed information on what formats the
tape drive supports, and what formats the tape drive supports.

o Some mt(1) functionality moved into a new mt(3) library so that
external applications can reuse the code.

o The new mt(3) library includes helper routines to aid in parsing
the XML output of the sa(4) driver, and build a tree of driver
metadata.

o Support for the MTLOAD (load a tape in the drive) and MTWEOFI
(write filemark immediate) ioctls needed by IBM's LTFS
implementation.

o Improve device departure behavior for the sa(4) driver. The previous
implementation led to hangs when the device was open.

o This has been tested on the following types of drives:
IBM TS1150
IBM TS1140
IBM LTO-6
IBM LTO-5
HP LTO-2
Seagate DDS-4
Quantum DLT-4000
Exabyte 8505
Sony DDS-2

contrib/groff/tmac/doc-syms,
share/mk/bsd.libnames.mk,
lib/Makefile,
Add libmt.

lib/libmt/Makefile,
lib/libmt/mt.3,
lib/libmt/mtlib.c,
lib/libmt/mtlib.h,
New mt(3) library that contains functions moved from mt(1) and
new functions needed to interact with the updated sa(4) driver.

This includes XML parser helper functions that application writers
can use when writing code to query tape parameters.

rescue/rescue/Makefile:
Add -lmt to CRUNCH_LIBS.

src/share/man/man4/mtio.4
Clarify this man page a bit, and since it contains what is
essentially the mtio.h header file, add new ioctls and structure
definitions from mtio.h.

src/share/man/man4/sa.4
Update BUGS and maintainer section.

sys/cam/scsi/scsi_all.c,
sys/cam/scsi/scsi_all.h:
Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building
functions.

sys/cam/scsi/scsi_sa.c
sys/cam/scsi/scsi_sa.h
Many tape driver changes, largely outlined above.

Increase the sa(4) driver read/write timeout from 4 to 32
minutes. This is based on the recommended values for IBM LTO
5/6 drives. This may also avoid timeouts for other tape
hardware that can take a long time to do retries and error
recovery. Longer term, a better way to handle this is to ask
the drive for recommended timeout values using the REPORT
SUPPORTED OPCODES command. Modern IBM and Oracle tape drives
at least support that command, and it would allow for more
accurate timeout values.

Add XML status generation. This is done with a series of
macros to eliminate as much duplicate code as possible. The
new XML-based status values are reported through the new
MTIOCEXTGET ioctl.

Add XML driver parameter reporting, using the new MTIOCPARAMGET
ioctl.

Add a new driver parameter setting interface, using the new
MTIOCPARAMSET and MTIOCSETLIST ioctls.

Add a new MTIOCRBLIM ioctl to get block limits information.

Add CCB/CDB building routines scsi_locate_16, scsi_locate_10,
and scsi_read_position_10().

scsi_locate_10 implements the LOCATE command, as does the
existing scsi_set_position() command. It just supports
additional arguments and features. If/when we figure out a
good way to provide backward compatibility for older
applications using the old function API, we can just revamp
scsi_set_position(). The same goes for
scsi_read_position_10() and the existing scsi_read_position()
function.

Revamp sasetpos() to take the new mtlocate structure as an
argument. It now will use either scsi_locate_10() or
scsi_locate_16(), depending upon the arguments the user
supplies. As before, once we change position we don't have a
clear idea of what the current logical position of the tape
drive is.

For tape drives that support long form position data, we
read the current position and store that for later reporting
after changing the position. This should help applications
like Bacula speed tape access under FreeBSD once they are
modified to support the new ioctls.

Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all
drives that report SCSI-2 or older, as well as drives that
report an Illegal Request type error for READ POSITION with
the long format. So we should automatically detect drives
that don't support the long form and stop asking for it after
an initial try.

Add a partition number to the sa(4) softc.

Improve device departure handling. The previous implementation
led to hangs when the device was open.

If an application had the sa(4) driver open, and attempted to
close it after it went away, the cam_periph_release() call in
saclose() would cause the periph to get destroyed because that
was the last reference to it. Because destroy_dev() was
called from the sa(4) driver's cleanup routine (sacleanup()),
and would block waiting for the close to happen, a deadlock
would result.

So instead of calling destroy_dev() from the cleanup routine,
call destroy_dev_sched_cb() from saoninvalidate() and wait for
the callback.

Acquire a reference for devfs in saregister(), and release it
in the new sadevgonecb() routine when all devfs devices for
the particular sa(4) driver instance are gone.

Add a new function, sasetupdev(), to centralize setting
per-instance devfs device parameters instead of repeating the
code in saregister().

Add an open count to the softc, so we know how many
peripheral driver references are a result of open
sessions.

Add the D_TRACKCLOSE flag to the cdevsw flags so
that we get a 1:1 mapping of open to close calls
instead of a N:1 mapping.

This should be a no-op for everything except the
control device, since we don't allow more than one
open on non-control devices.

However, since we do allow multiple opens on the
control device, the combination of the open count
and the D_TRACKCLOSE flag should result in an
accurate peripheral driver reference count, and an
accurate open count.

The accurate open count allows us to release all
peripheral driver references that are the result
of open contexts once we get the callback from devfs.

sys/sys/mtio.h:
Add a number of new mt(4) ioctls and the requisite data
structures. None of the existing interfaces been removed
or changed.

This includes definitions for the following new ioctls:

MTIOCRBLIM /* get block limits */
MTIOCEXTLOCATE /* seek to position */
MTIOCEXTGET /* get tape status */
MTIOCPARAMGET /* get tape params */
MTIOCPARAMSET /* set tape params */
MTIOCSETLIST /* set N params */

usr.bin/mt/Makefile:
mt(1) now depends on libmt, libsbuf and libbsdxml.

usr.bin/mt/mt.1:
Document new mt(1) features and subcommands.

usr.bin/mt/mt.c:
Implement support for mt(1) subcommands that need to
use getopt(3) for their arguments.

Implement a new 'mt status' command to replace the old
'mt status' command. The old status command has been
renamed 'ostatus'.

The new status function uses the MTIOCEXTGET ioctl, and
therefore parses the XML data to determine drive status.
The -x argument to 'mt status' allows the user to dump out
the raw XML reported by the kernel.

The new status display is mostly the same as the old status
display, except that it doesn't print the redundant density
mode information, and it does print the current partition
number and position flags.

Add a new command, 'mt locate', that will supersede the
old 'mt setspos' and 'mt sethpos' commands. 'mt locate'
implements all of the functionality of the MTIOCEXTLOCATE
ioctl, and allows the user to change the logical position
of the tape drive in a number of ways. (Partition,
block number, file number, set mark number, end of data.)
The immediate bit and the explicit address bits are
implemented, but not documented in the man page.

Add a new 'mt weofi' command to use the new MTWEOFI ioctl.
This allows the user to ask the drive to write a filemark
without waiting around for the operation to complete.

Add a new 'mt getdensity' command that gets the XML-based
tape drive density report from the sa(4) driver and displays
it. This uses the SCSI REPORT DENSITY SUPPORT command
to get comprehensive information from the tape drive about
what formats it is able to read and write.

Add a new 'mt protect' command that allows getting and setting
tape drive protection information. The protection information
is a CRC tacked on to the end of every read/write from and to
the tape drive.

Sponsored by: Spectra Logic
MFC after: 1 month

------------------------------------------------------------------------
------------------------------------------------------------------------
r279229 | ken | 2015-02-23 22:43:16 -0700 (Mon, 23 Feb 2015) | 5 lines

Fix printf format warnings on sparc64 and mips.

Sponsored by: Spectra Logic
MFC after: 1 month

------------------------------------------------------------------------
------------------------------------------------------------------------
r279261 | ken | 2015-02-24 21:30:23 -0700 (Tue, 24 Feb 2015) | 23 lines

Fix several problems found by Coverity.

lib/libmt/mtlib.c:
In mt_start_element(), make sure we don't overflow the
cur_sb array. CID 1271325

usr.bin/mt/mt.c:
In main(), bzero the mt_com structure so that we aren't
using any uninitialized stack variables. CID 1271319

In mt_param(), only allow one -s and one -p argument. This
will prevent a memory leak caused by overwriting the
param_name and/or param_value variables. CID 1271320 and
CID 1271322

To make things simpler in mt_param(), make sure there
there is only one exit path for the function. Make sure
the arguments are explicitly freed.

Sponsored by: Spectra Logic
Pointed out by: emaste
MFC after: 1 month

------------------------------------------------------------------------
------------------------------------------------------------------------
r279534 | ken | 2015-03-02 11:09:49 -0700 (Mon, 02 Mar 2015) | 18 lines

Change the sa(4) driver to check for long position support on
SCSI-2 devices.

Some older tape devices claim to be SCSI-2, but actually do support
long position information. (Long position information includes
the current file mark.) For example, the COMPAQ SuperDLT1.

So we now only disable the check on SCSI-1 and older devices.

sys/cam/scsi/scsi_sa.c:
In saregister(), only disable fetching long position
information on SCSI-1 and older drives. Update the
comment to explain why.

Confirmed by: dvl
Sponsored by: Spectra Logic
MFC after: 3 weeks

------------------------------------------------------------------------
------------------------------------------------------------------------
r279570 | ken | 2015-03-03 15:49:07 -0700 (Tue, 03 Mar 2015) | 21 lines

Add density code for DAT-72, and notes on DAT-160.

As it turns out, the density code for DAT-160 (0x48) is the same
as for SDLT220. Since the SDLT values are already in the table,
we will leave them in place.

Thanks to Harald Schmalzbauer for confirming the DAT-72 density code.

lib/libmt/mtlib.c:
Add DAT-72 density code, and commented out DAT-160 density
code. Explain why DAT-160 is commented out. Add notes
explaining where the bpi values for these formats came from.

usr.bin/mt/mt.1:
Add DAT-72 density code, and add a note explaining that
the SDLTTapeI(110) density code (0x48) is the same as
DAT-160.

Sponsored by: Spectra Logic
MFC after: 3 weeks

------------------------------------------------------------------------
------------------------------------------------------------------------
r280230 | ken | 2015-03-18 14:52:34 -0600 (Wed, 18 Mar 2015) | 25 lines

Fix a couple of problems in the sa(4) media type reports.

The only drives I have discovered so far that support medium type
reports are newer HP LTO (LTO-5 and LTO-6) drives. IBM drives
only support the density reports.

sys/cam/scsi/scsi_sa.h:
The number of possible density codes in the medium type
report is 9, not 8. This caused problems parsing all of
the medium type report after this point in the structure.

usr.bin/mt/mt.c:
Run the density codes returned in the medium type report
through denstostring(), just like the primary and secondary
density codes in the density report. This will print the
density code in hex, and give a text description if it
is available.

Thanks to Rudolf Cejka for doing extensive testing with HP LTO drives
and Bacula and discovering these problems.

Tested by: Rudolf Cejka <cejkar at fit.vutbr.cz>
Sponsored by: Spectra Logic
MFC after: 4 days

------------------------------------------------------------------------
------------------------------------------------------------------------
r280231 | ken | 2015-03-18 14:54:54 -0600 (Wed, 18 Mar 2015) | 16 lines

Improve the mt(1) rblim display.

The granularity reported by READ BLOCK LIMITS is an exponent, not a
byte value. So a granularity of 0 means 2^0, or 1 byte. A
granularity of 1 means 2^1, or 2 bytes.

Print out the individual block limits on separate lines to improve
readability and avoid exceeding 80 columns.

usr.bin/mt/mt.c:
Fix and improve the 'mt rblim' output. Add a MT_PLURAL()
macro so we can print "byte" or "bytes" as appropriate.

Sponsored by: Spectra Logic
MFC after: 4 days

------------------------------------------------------------------------

Sponsored by: Spectra Logic

280258 19-Mar-2015 rwatson

Merge r263233 from HEAD to stable/10:

Update kernel inclusions of capability.h to use capsicum.h instead; some
further refinement is required as some device drivers intended to be
portable over FreeBSD versions rely on __FreeBSD_version to decide whether
to include capability.h.

Sponsored by: Google, Inc.


/freebsd-10-stable/sys/amd64/amd64/sys_machdep.c
/freebsd-10-stable/sys/amd64/linux32/linux32_machdep.c
/freebsd-10-stable/sys/arm/arm/sys_machdep.c
ctl/ctl_frontend_iscsi.c
/freebsd-10-stable/sys/cddl/compat/opensolaris/sys/file.h
/freebsd-10-stable/sys/compat/freebsd32/freebsd32_capability.c
/freebsd-10-stable/sys/compat/freebsd32/freebsd32_ioctl.c
/freebsd-10-stable/sys/compat/freebsd32/freebsd32_misc.c
/freebsd-10-stable/sys/compat/linux/linux_file.c
/freebsd-10-stable/sys/compat/linux/linux_ioctl.c
/freebsd-10-stable/sys/compat/linux/linux_socket.c
/freebsd-10-stable/sys/compat/svr4/svr4_fcntl.c
/freebsd-10-stable/sys/compat/svr4/svr4_filio.c
/freebsd-10-stable/sys/compat/svr4/svr4_ioctl.c
/freebsd-10-stable/sys/compat/svr4/svr4_misc.c
/freebsd-10-stable/sys/compat/svr4/svr4_stream.c
/freebsd-10-stable/sys/dev/aac/aac_linux.c
/freebsd-10-stable/sys/dev/aacraid/aacraid_linux.c
/freebsd-10-stable/sys/dev/amr/amr_linux.c
/freebsd-10-stable/sys/dev/filemon/filemon.c
/freebsd-10-stable/sys/dev/hwpmc/hwpmc_logging.c
/freebsd-10-stable/sys/dev/ipmi/ipmi_linux.c
/freebsd-10-stable/sys/dev/iscsi/icl.c
/freebsd-10-stable/sys/dev/iscsi/icl_proxy.c
/freebsd-10-stable/sys/dev/iscsi_initiator/iscsi.c
/freebsd-10-stable/sys/dev/mfi/mfi_linux.c
/freebsd-10-stable/sys/dev/tdfx/tdfx_linux.c
/freebsd-10-stable/sys/fs/fdescfs/fdesc_vnops.c
/freebsd-10-stable/sys/fs/fuse/fuse_vfsops.c
/freebsd-10-stable/sys/fs/nfsclient/nfs_clport.c
/freebsd-10-stable/sys/fs/nfsserver/nfs_nfsdport.c
/freebsd-10-stable/sys/i386/i386/sys_machdep.c
/freebsd-10-stable/sys/i386/ibcs2/ibcs2_fcntl.c
/freebsd-10-stable/sys/i386/ibcs2/ibcs2_ioctl.c
/freebsd-10-stable/sys/i386/ibcs2/ibcs2_misc.c
/freebsd-10-stable/sys/i386/linux/linux_machdep.c
/freebsd-10-stable/sys/kern/imgact_elf.c
/freebsd-10-stable/sys/kern/kern_descrip.c
/freebsd-10-stable/sys/kern/kern_event.c
/freebsd-10-stable/sys/kern/kern_exec.c
/freebsd-10-stable/sys/kern/kern_exit.c
/freebsd-10-stable/sys/kern/kern_ktrace.c
/freebsd-10-stable/sys/kern/kern_sig.c
/freebsd-10-stable/sys/kern/kern_sysctl.c
/freebsd-10-stable/sys/kern/subr_capability.c
/freebsd-10-stable/sys/kern/subr_syscall.c
/freebsd-10-stable/sys/kern/subr_trap.c
/freebsd-10-stable/sys/kern/sys_capability.c
/freebsd-10-stable/sys/kern/sys_generic.c
/freebsd-10-stable/sys/kern/sys_procdesc.c
/freebsd-10-stable/sys/kern/tty.c
/freebsd-10-stable/sys/kern/uipc_mqueue.c
/freebsd-10-stable/sys/kern/uipc_sem.c
/freebsd-10-stable/sys/kern/uipc_shm.c
/freebsd-10-stable/sys/kern/uipc_syscalls.c
/freebsd-10-stable/sys/kern/uipc_usrreq.c
/freebsd-10-stable/sys/kern/vfs_acl.c
/freebsd-10-stable/sys/kern/vfs_aio.c
/freebsd-10-stable/sys/kern/vfs_extattr.c
/freebsd-10-stable/sys/kern/vfs_lookup.c
/freebsd-10-stable/sys/kern/vfs_syscalls.c
/freebsd-10-stable/sys/netsmb/smb_dev.c
/freebsd-10-stable/sys/nfsserver/nfs_srvkrpc.c
/freebsd-10-stable/sys/security/mac/mac_syscalls.c
/freebsd-10-stable/sys/sparc64/sparc64/sys_machdep.c
/freebsd-10-stable/sys/ufs/ffs/ffs_alloc.c
/freebsd-10-stable/sys/vm/vm_mmap.c
279329 26-Feb-2015 ken

MFC r278964:

The __FreeBSD_version was changed to 1001510 to be appropriate for
stable/10.

I will followup with a commit to mpr(4) and mps(4) in head to reflect
the stable/10 __FreeBSD_version and merge the change back to stable/10.

------------------------------------------------------------------------
r278964 | ken | 2015-02-18 11:30:19 -0700 (Wed, 18 Feb 2015) | 46 lines

Make sure that the flags for the XPT_DEV_ADVINFO CCB are initialized
properly.

If there is garbage in the flags field, it can sometimes include a
set CDAI_FLAG_STORE flag, which may cause either an error or
perhaps result in overwriting the field that was intended to be
read.

sys/cam/cam_ccb.h:
Add a new flag to the XPT_DEV_ADVINFO CCB, CDAI_FLAG_NONE,
that callers can use to set the flags field when no store
is desired.

sys/cam/scsi/scsi_enc_ses.c:
In ses_setphyspath_callback(), explicitly set the
XPT_DEV_ADVINFO flags to CDAI_FLAG_NONE when fetching the
physical path information. Instead of ORing in the
CDAI_FLAG_STORE flag when storing the physical path, set
the flags field to CDAI_FLAG_STORE.

sys/cam/scsi/scsi_sa.c:
Set the XPT_DEV_ADVINFO flags field to CDAI_FLAG_NONE when
fetching extended inquiry information.

sys/cam/scsi/scsi_da.c:
When storing extended READ CAPACITY information, set the
XPT_DEV_ADVINFO flags field to CDAI_FLAG_STORE instead of
ORing it into a field that isn't initialized.

sys/dev/mpr/mpr_sas.c,
sys/dev/mps/mps_sas.c:
When fetching extended READ CAPACITY information, set the
XPT_DEV_ADVINFO flags field to CDAI_FLAG_NONE instead of
setting it to 0.

sbin/camcontrol/camcontrol.c:
When fetching a device ID, set the XPT_DEV_ADVINFO flags
field to CDAI_FLAG_NONE instead of 0.

sys/sys/param.h:
Bump __FreeBSD_version to 1100061 for the new XPT_DEV_ADVINFO
CCB flag, CDAI_FLAG_NONE.

Sponsored by: Spectra Logic

279273 25-Feb-2015 mav

MFC r278584: Add support for General Statistics and Performance log page.

CTL already collects most of statistics reported there, so why not.

279005 19-Feb-2015 mav

MFC r278672: Teach CTL to ask GEOM devices about BIO_DELETE support.

279004 19-Feb-2015 mav

MFC r278625: Make XCOPY and WUT commands respect physical block size/offset.

This change by 2-3 times improves performance of misaligned XCOPY and WUT
commands by avoiding unneeded read-modify-write cycles inside ZFS.

279003 19-Feb-2015 mav

MFC r278161: Bring some more order into iSCSI portal group tags support.

While ctld(8) still does not allow multiple portal groups per target
to be configured, kernel should now be able to handle it.

Sponsored by: iXsystems, Inc.

279002 19-Feb-2015 mav

MFC r278037: CTL LUN mapping rewrite.

Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.

Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.

While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.

Relnotes: yes
Sponsored by: iXsystems, Inc.

278999 19-Feb-2015 mav

MFC r278619: Make WRITE SAME commands respect physical block size.

This change by 2-3 times improves performance of misaligned WRITE SAME
commands by avoiding unneeded read-modify-write cycles inside ZFS.

278974 18-Feb-2015 ken

MFC 278228:

The __FreeBSD_version has been changed to 1001508 for the addition of the
CDAI_TYPE_EXT_INQ request type.

------------------------------------------------------------------------
r278228 | ken | 2015-02-04 17:12:21 -0700 (Wed, 04 Feb 2015) | 32 lines

Add support for probing the SCSI VPD Extended Inquiry page (0x86).

This VPD page is effectively an extension of the standard Inquiry
data page, and includes lots of additional bits.

This commit includes support for probing the page in the SCSI probe code,
and an additional request type for the XPT_DEV_ADVINFO CCB. CTL already
supports the Extended Inquiry page.

Support for querying this page in the sa(4) driver will come later.

sys/cam/scsi/scsi_xpt.c:
Probe the Extended Inquiry page, if the device supports it, and
return it in response to a XPT_DEV_ADVINFO CCB if it is requested.

sys/cam/scsi/cam_ccb.h:
Define a new advanced information CCB data type, CDAI_TYPE_EXT_INQ.

sys/cam/cam_xpt.c:
Free the extended inquiry data in a device when the device goes
away.

sys/cam/cam_xpt_internal.h:
Add an extended inquiry data pointer and length to struct cam_ed.

sys/sys/param.h
Bump __FreeBSD_version for the addition of the new
CDAI_TYPE_EXT_INQ advanced information type.

Sponsored by: Spectra Logic
MFC after: 1 week

------------------------------------------------------------------------

Sponsored by: Spectra Logic

278906 17-Feb-2015 mav

MFC r278500: Do not abort already aborted tasks.

This fixes abort of new tasks with the same tags as previously aborted,
but still remaining on the queue.

278796 15-Feb-2015 mav

MFC r277917 (by ken), r278598:
Improve SCSI Extended Inquiry VPD page (0x86) support.

sys/cam/scsi/scsi_all.h:
In struct scsi_extended_inquiry_data:
- Increase the length field to 2 bytes, as it is 2 bytes in SPC-4.
- Add bit definitions for the various Activiate Microcode actions.
- Add the Sequential Access Logical Block Protection support bit,
since we need that in the sa(4) driver. (For modifications
that will come later.)
- Add definitions for the various Multi I_T Nexus Microcode
Download modes.

sys/cam/ctl/ctl.c:
As of SPC-4, a single report of "REPORTED LUNS DATA HAS CHANGED"
is to be given per I_T nexus. Once it is reported, the unit
attention condition should be cleared for all LUNS attached to
an I_T nexus.

Previously that only happened when a REPORT LUNS command was
processed.

This behavior may be different (according to SAM-5) when the
UA_INTLCK_CTRL bits are non-zero in the control mode page but
CTL does not currently support that.

So, in view of the spec, whenever we report a LUN inventory
change unit attention, clear it on all LUNs for that
particular I_T nexus.

Add a new function, ctl_clear_ua() that will clear a unit
attention on all LUNs for the given I_T nexus.

One field in the extended inquiry data that we could potentially
report at some point is the maximum supported sense data length.
To do that, we would the SIM to report (via path inquiry
perhaps) how much sense data it is able to send.

Add comments to explain some of the bits that are set in the
Extended Inquiry VPD page.

Add a few comments to make it more clear which functions handle
various VPD pages.

278440 09-Feb-2015 mav

MFC r278111: Retry indefinitely on SCSI BUSY status from VMware disks and CDs.

VMware returns BUSY status when storage has transient connectivity issues.
It is often better to wait and let VM admin fix the problem then crash.

278170 03-Feb-2015 ken

MFC r276835:

r276835 | ken | 2015-01-08 09:58:40 -0700 (Thu, 08 Jan 2015) | 91 lines

Improve camcontrol(8) handling of drive defect data.

This includes a new summary mode (-s) for camcontrol defects that
quickly tells the user the most important thing: how many defects
are in the requested list. The actual location of the defects is
less important.

Modern drives frequently have more than the 8191 defects that can
be reported by the READ DEFECT DATA (10) command. If they don't
have that many grown defects, they certainly have more than 8191
defects in the primary (i.e. factory) defect list.

The READ DEFECT DATA (12) command allows for longer parameter
lists, as well as indexing into the list of defects, and so allows
reporting many more defects.

This has been tested with HGST drives and Seagate drives, but
does not fully work with Seagate drives. Once I have a Seagate
spec I may be able to determine whether it is possible to make it
work with Seagate drives.

scsi_da.h: Add a definition for the new long block defect
format.

Add bit and mask definitions for the new extended
physical sector and bytes from index defect
formats.

Add a prototype for the new scsi_read_defects() CDB
building function.

scsi_da.c: Add a new scsi_read_defects() CDB building function.
camcontrol(8) was previously composing CDBs manually.
This is long overdue.

camcontrol.c: Revamp the camcontrol defects subcommand. We now
go through multiple stages in trying to get defect
data off the drive while avoiding various drive
firmware quirks.

We start off by requesting the defect header with
the 10 byte command. If we're in summary mode (-s)
and the drive reports fewer defects than can be
represented in the 10 byte header, we're done.
Otherwise, we know that we need to issue the
12 byte command if the drive reports the maximum
number of defects.

If we're in summary mode, we're done if we get a
good response back when asking for the 12 byte header.

If the user has asked for the full list, then we
use the address descriptor index field in the 12
byte CDB to step through the list in 64K chunks.
64K is small enough to work with most any ancient
or modern SCSI controller.

Add support for printing the new long block defect
format, as well as the extended physical sector and
bytes from index formats. I don't have any drives
that support the new formats.

Add a hexadecimal output format that can be turned
on with -X.

Add a quiet mode (-q) that can be turned on with
the summary mode (-s) to just print out a number.

Revamp the error detection and recovery code for
the defects command to work with HGST drives.

Call the new scsi_read_defects() CDB building
function instead of rolling the CDB ourselves.

Pay attention to the residual from the defect list
request when printing it out, so we don't run off
the end of the list.

Use the new scsi_nv library routines to convert
from strings to numbers and back.

camcontrol.8: Document the new defect formats (longblock, extbfi,
extphys) and command line options (-q, -s, -S and
-X) for the defects subcommand.

Explain a little more about what drives generally
do and don't support.

Sponsored by: Spectra Logic

278169 03-Feb-2015 ken

MFC 276831:

r276831 | ken | 2015-01-08 09:27:56 -0700 (Thu, 08 Jan 2015) | 30 lines

Fix a bug in the CAM SCSI probe code that caused changes in inquiry
data to go undetected.

The probe code does an MD5 checksum of the inquiry data (and page
0x80 serial number if available) before doing a reprobe of an
existing device, and then compares a checksum after the probe to
see whether the device has changed.

This check was broken in January, 2000 by change 56146 when the extended
inquiry probe code was added.

In the extended inquiry probe case, it was calculating the checksum
a second time. The second time it included the updated inquiry
data from the short inquiry probe (first 36 bytes). So it wouldn't
catch cases where the vendor, product, revision, etc. changed.

This change will have the effect that when a device's inquiry data is
updated and a rescan is issued, it will disappear and then reappear.
This is the appropriate action, because if the inquiry data or serial
number changes, it is either a different device or the device
configuration may have changed significantly. (e.g. with updated
firmware.)

scsi_xpt.c: Don't calculate the initial MD5 checksum on
standard inquiry data and the page 0x80 serial
number if we have already calculated it.

Sponsored by: Spectra Logic

278076 02-Feb-2015 mav

MFC r277758: Fix several potential overflows in UNMAP code.

277919 30-Jan-2015 mav

MFC r277247: Don't count status as sent until CTIO completes successfully.

If we aggregated status sending with data move and got error, allow status
to be updated and resent again separately. Without this command may stuck
without status sent at all.

277918 30-Jan-2015 mav

MFC r277529: Don't count requests with status sent as overlapping.

While those requests are still in target OOA queue, for initiator they are
already completed, so tags can be reused.

277810 27-Jan-2015 mav

MFC r277647: Fix wrong LUN reference in XCOPY block-to-block operation.

This could cause data corruption due to accessing wrong LUN in case of
retries on write errors. Failed writes were retried to read LUN.

277762 26-Jan-2015 mav

MFC r277385: Remove extra mtx_unlock().

Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>

277407 20-Jan-2015 hselasky

MFC r276825 and r277372:
Allow a block size of zero to mean 512 bytes, which is the most common
block size for USB disks. This fixes support for "Action Cam SJ4000".

276618 03-Jan-2015 mav

MFC r274036 (by trasz):
s/icl_pdu_new_bhs/icl_pdu_new/; no functional changes, just a little
nicer code.

276617 03-Jan-2015 mav

MFC r276141: Hide block device VPD pages for non-block devices.

276616 03-Jan-2015 mav

MFC r275953: Replace ctl_min() macro with MIN().

276615 03-Jan-2015 mav

MFC r275943: Constify some static data.

276614 03-Jan-2015 mav

MFC r275942: Reduce number of places where global control_softc is used.

At some point we may want to have several CTL instances, and that is not
really impossible.

276613 03-Jan-2015 mav

MFC r275864: Make sequence numbers checks more strict.

While we don't support MCS, hole in received sequence numbers may mean
only PDU loss. While we don't support lost PDU recovery, terminate the
connection to avoid stuck commands.

While there, improve handling of sequence numbers wrap after 2^32 PDUs.

276237 26-Dec-2014 mav

MFC r275920, r276127: Pass real optimal transfer size supported by backend.

For files and ZVOLs that is 1MB now, not 128K.

276179 24-Dec-2014 mav

MFC r275865:
Add configuration options to override physical and UNMAP blocks geometry.

While in most cases CTL should correctly fetch those values from backing
storages, there are some initiators (like MS SQL), that may not like large
physical block sizes, even if they are true. For such cases allow override
fetched values with supported ones (like 4K).

276139 23-Dec-2014 mav

MFC r275959: Report initiator id in portlist XML in more formalized way.

276137 23-Dec-2014 mav

MFC r275842: Do not count RCTD bit set as an error.

We can not really implement it, but specification tells that it "shall"
work, so it can be safely ignored.

275982 21-Dec-2014 smh

MFC r274819:
Prevent overflow issues in timeout processing

MFC r274852:
Fix build with asr driver

Sponsored by: Multiplay

275895 18-Dec-2014 mav

MFC r275568:
Count consecutive read requests as blocking in CTL for files and ZVOLs.

Technically read requests can be executed in any order or simultaneously
since they are not changing any data. But ZFS prefetcher goes crasy when
it receives consecutive requests from different threads. Since prefetcher
works on level of separate blocks, instead of two consecutive 128K requests
it may receive 32 8K requests in mixed order.

This patch is more workaround then a real fix, and it does not fix all of
prefetcher problems, but it improves sequential read speed by 3-4x times
in some configurations. On the other side it may hurt performance if
some backing store has no prefetch, that is why it is disabled by default
for raw devices.

275894 18-Dec-2014 mav

MFC r275512:
In addition to r275481 allow threshold notifications work without UNMAP.

While without UNMAP support there is not much initiator can do about it,
the administrator still better be notified about the storage overflow.

Sponsored by: iXsystems, Inc.

275893 18-Dec-2014 mav

MFC r275481:
Add to CTL support for threshold notifications for file-backed LUNs.

Previously it was supported only for ZVOL-backed LUNs, but now should work
for file-backed LUNs too. Used value in this case is a space occupied by
the backing file, while available value is an available space on file
system. Pool thresholds are still not implemented in this case.

Sponsored by: iXsystems, Inc.

275892 18-Dec-2014 mav

MFC r275474: Add GET LBA STATUS command support to CTL.

It is implemented for LUNs backed by ZVOLs in "dev" mode and files.
GEOM has no such API, so for LUNs backed by raw devices all LBAs will
be reported as mapped/unknown.

Sponsored by: iXsystems, Inc.

275891 18-Dec-2014 mav

MFC r275461:
Increase CTL ports limit from 128 to 256 and LUNs limit from 256 to 1024.

After recent optimizations this change is no longer blocked by CTL memory
consumption. Those limits are still not free, but much cheaper now.

Relnotes: yes
Sponsored by: iXsystems, Inc.

275889 18-Dec-2014 mav

MFC r275459: Unify function names after r275458.

275888 18-Dec-2014 mav

MFC r275458:
Do not pre-allocate UNIT ATTENTIONs storage for every possible initiator.

Abusing ability of major UAs cover minor ones we may not account UAs for
inactive ports. Allocate UAs storage for port and start accounting only
after some initiator from that port fetched its first POWER ON OCCURRED.

This reduces per-LUN CTL memory usage from >1MB to less then 100K.

275887 18-Dec-2014 mav

MFC r275455: Remove some unused code.

275886 18-Dec-2014 mav

MFC r275447:
Do not pre-allocate reservation keys memory for every possible initiator.

In configurations with many ports, like iSCSI, each LUN is typically
accessed only by limited subset of ports. Allocating that memory on
demand allows to reduce CTL memory usage from 5.3MB/LUN to 1.3MB/LUN.

275885 18-Dec-2014 mav

MFC r275405: Convert persis_offset from global variable to softc field.

275884 18-Dec-2014 mav

MFC r275404: Reduce code duplication by creating ctl_set_res_ua() helper.

275883 18-Dec-2014 mav

MFC r275403: Removed unused variable and unify some names.

275882 18-Dec-2014 mav

MFC r275365: Move ctlfe_onoffline() out of lock to let it sleep when needed.

Do some more other polishing while there.

275881 18-Dec-2014 mav

MFC r275058: Coalesce last data move and command status for read commands.

Make CTL core and block backend set success status before initiating last
data move for read commands. Make CAM target and iSCSI frontends detect
such condition and send command status together with data. New I/O flag
allows to skip duplicate status sending on later fe_done() call.

For Fibre Channel this change saves one of three interrupts per read command,
increasing performance from 126K to 160K IOPS. For iSCSI this change saves
one of three PDUs per read command, increasing performance from 1M to 1.2M
IOPS.

Sponsored by: iXsystems, Inc.

275880 18-Dec-2014 mav

MFC r275032: Decouple datamove/done logic from CTL status set.

275879 18-Dec-2014 mav

MFC r275009: Use ctl_set_success() instead of direct inlining.

275878 18-Dec-2014 mav

MFC r274962: Replace home-grown CTL IO allocator with UMA.

Old allocator created significant lock congestion protecting its lists
of preallocated I/Os, while UMA provides much better SMP scalability.
The downside of UMA is lack of reliable preallocation, that could guarantee
successful allocation in non-sleepable environments. But careful code
review shown, that only CAM target frontend really has that requirement.
Fix that making that frontend preallocate and statically bind CTL I/O for
every ATIO/INOT it preallocates any way. That allows to avoid allocations
in hot I/O path. Other frontends either may sleep in allocation context
or can properly handle allocation errors.

On 40-core server with 6 ZVOL-backed LUNs and 7 iSCSI client connections
this change increases peak performance from ~700K to >1M IOPS! Yay! :)

Sponsored by: iXsystems, Inc.

275722 12-Dec-2014 mav

MFC r274411: Improve CAM's reaction on asymmetric access errors.

275694 11-Dec-2014 mav

MFC r275478: Swap resource count scopes for used/available space.

Used count should be reported as per-LUN, while available should not.

275673 10-Dec-2014 mav

MFC r275446: Plug memory leaks on UNMAP and XCOPY with invalid parameters.

275603 08-Dec-2014 mav

MFC r275368:
When passing LUN IDs through treat ASCII values as fixed-length, not
interpreating NULLs as EOLs, but converting them to spaces.

SPC-4 does not tell that T10-based IDs should be NULL-terminated/padded.
And while it tells that it should include only ASCII chars (0x20-0x7F),
there are some USB sticks (SanDisk Ultra Fit), that have NULLs inside
the value. Treating NULLs as EOLs there made those LUN IDs non-unique.

275495 05-Dec-2014 mav

MFC r274805:
Make cfiscsi_offline() synchronous, waiting for connections termination
before return. This should make ctld restart more clean and predictable.

275494 05-Dec-2014 mav

MFC r274795:
Close race between cfiscsi_offline() and new connection arrival.

Incoming connection should be either rejected or accepted and terminated.

275493 05-Dec-2014 mav

MFC r274785: Partially reconstruct Active/Standby clusting.

In this mode one head is in Active state, supporting all commands, while
another is in Standby state, supporting only minimal LUN discovery subset.

It is still incomplete since Standby state requires reservation support,
which is impossible to do right without having interlink between heads.
But it allows to run some basic experiments.

275445 03-Dec-2014 trasz

MFC r274703:

Fix typo.

Sponsored by: The FreeBSD Foundation

275310 30-Nov-2014 trasz

MFC r273918:

Change the default log level for iSCSI target from 3 to 1. It should
have been 1 from the beginning; not sure how it ended up at 3.

Sponsored by: The FreeBSD Foundation

275204 28-Nov-2014 mav

MFC r274756:
Remove residual xpt_release_device() call left after r272406 cleanup.

Excessive release here could trigger use-after-free condition and kernel
panic on LUN 0 disconnect.

275203 28-Nov-2014 mav

MFC r274840, r274940:
Make iSCSI frontend less chatty while waiting for tasks termination.

275202 28-Nov-2014 mav

MFC r274790: Remove bunch of unused lun variables.

275201 28-Nov-2014 mav

MFC r274789: Reduce race between LUN destruction and request arrival.

275200 28-Nov-2014 mav

MFC r274786: Log errors for absent LUNs too.

274732 20-Nov-2014 mav

MFC r274154, r274163:
Add to CTL support for logical block provisioning threshold notifications.

For ZVOL-backed LUNs this allows to inform initiators if storage's used or
available spaces get above/below the configured thresholds.

Sponsored by: iXsystems, Inc.

274730 20-Nov-2014 mav

MFC r274477: Fix check for vendor-specific peripheral qualifier.

Submitted by: anton.rang@isilon.com

274562 16-Nov-2014 mav

MFC r274333: Handle PREEMPT AND ABORT service action equal to PREEMPT.

With command serialization used in CTL, there are no other commands to abort
when PREEMPT AND ABORT gets to run, so it is practically equal to PREEMPT.

274492 14-Nov-2014 mav

MFC r274206:
Synchronize medium rotation rate in legacy Rigid Disk Drive Geometry mode
page with modern Block Device Characteristics VPD page.

274389 11-Nov-2014 mav

MFC r274081: Fix residual copy/paste in r274080.

274388 11-Nov-2014 mav

MFC r274080: Improve error handling around duplicate lun and port enable.

This fixes kernel panic if port enabled twice and then disabled.

274387 11-Nov-2014 mav

MFC r274253: Fix LUN resize broken by r272911 commit.

274260 08-Nov-2014 gnn

MFC: 273279

Add new quirks for the latest Samsung SSD, model 850.

Submitted by: sbruno

274004 03-Nov-2014 mav

MFC r273809:
Implement better handling for ENOSPC error for both CTL and CAM.

This makes VMWare VAAI Thin Provisioning Stun primitive activate, pausing
the virtual machine, when backing storage (ZFS pool) is getting overflowed.

274003 03-Nov-2014 mav

MFC r273730, r273731:
Reduce code duplication around Write Exclusive persistent reservation.

While there, allow some more commands to pass persistent reservation.

274002 03-Nov-2014 mav

MFC r273711:
Allocate buffer for READ BUFFER/WRITE BUFFER commands on demand.

These commands are rare, but consume additional 256KB RAM per LUN.

273982 02-Nov-2014 mav

MFC r273708: Fix support for LUN flat space addressing.

273981 02-Nov-2014 mav

MFC r273693: Fix printing non-terminated strings in devlist XML.

273980 02-Nov-2014 mav

MFC r273687:
Add "rpm" and "formfactor" LUN options to match istgt functionality.

273979 02-Nov-2014 mav

MFC r273640: Add support for 12/16-byte EUI and 16-byte NAA IDs.

273978 02-Nov-2014 mav

MFC r273075: Remove couple Copan's vendor-specific mode pages.

Those pages are highly system-/hardware-specific, the code is incomplete,
and so they hardly can be useful for anybody else.

273977 02-Nov-2014 mav

MFC r273073: Some groundwork for later Informational Exceptions support.

This includes support for:
- Read-Write Error Recovery mode page;
- Informational Exceptions Control mode page;
- Logical Block Provisioning mode page;
- LOG SENSE command.

No real Informational Exceptions features yet. This is only a placeholder.

273976 02-Nov-2014 mav

MFC r272409:
Use REPORT LUNS command for SPC-2 devices with LUN 0 disconnected.

SPC-2 tells REPORT LUNS shall be supported by devices supporting LUNs other
then LUN 0. If we see LUN 0 disconnected, guess there may be others, and
so REPORT LUNS shall be supported.

273975 02-Nov-2014 mav

MFC r272406:
Make disconnected LUN 0 don't remain in half-configured state if there are
no LUNs on SPC-3 target after we tried REPORT LUNS.

273974 02-Nov-2014 mav

MFC r272401, r272402: Rework the logic of sequential SCSI LUN scanner.

Previous logic was not differentiating disconnected LUNs and absent targets.
That made it to stop scan if LUN 0 was not found for any reason. That made
problematic, for example, using iSCSI targets declaring SPC-2 compliance and
having no LUN 0 configured.

The new logic continues sequential LUN scan if:
-- we have more configured LUNs that need recheck;
-- this LUN is connected and its SCSI version allows more LUNs;
-- this LUN is disconnected, its SCSI version allows more LUNs and we
guess they may be connected (we haven't scanned first 8 LUNs yet or
kern.cam.cam_srch_hi sysctl is set to scan more).

273814 29-Oct-2014 smh

MFC: r273704

Fix CF ERASE breakage caused by 268205.

Sponsored by: Multiplay

273736 27-Oct-2014 hselasky

MFC r263710, r273377, r273378, r273423 and r273455:

- De-vnet hash sizes and hash masks.
- Fix multiple issues related to arguments passed to SYSCTL macros.

Sponsored by: Mellanox Technologies


/freebsd-10-stable/sys/amd64/amd64/fpu.c
/freebsd-10-stable/sys/arm/arm/busdma_machdep-v6.c
/freebsd-10-stable/sys/arm/arm/busdma_machdep.c
scsi/scsi_sa.c
/freebsd-10-stable/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
/freebsd-10-stable/sys/cddl/dev/dtrace/dtrace_sysctl.c
/freebsd-10-stable/sys/compat/ndis/kern_ndis.c
/freebsd-10-stable/sys/dev/acpi_support/acpi_asus.c
/freebsd-10-stable/sys/dev/acpi_support/acpi_asus_wmi.c
/freebsd-10-stable/sys/dev/acpi_support/acpi_hp.c
/freebsd-10-stable/sys/dev/acpi_support/acpi_ibm.c
/freebsd-10-stable/sys/dev/acpi_support/acpi_rapidstart.c
/freebsd-10-stable/sys/dev/acpi_support/acpi_sony.c
/freebsd-10-stable/sys/dev/bxe/bxe.c
/freebsd-10-stable/sys/dev/cxgb/cxgb_sge.c
/freebsd-10-stable/sys/dev/cxgbe/t4_main.c
/freebsd-10-stable/sys/dev/e1000/if_em.c
/freebsd-10-stable/sys/dev/e1000/if_igb.c
/freebsd-10-stable/sys/dev/e1000/if_lem.c
/freebsd-10-stable/sys/dev/hatm/if_hatm.c
/freebsd-10-stable/sys/dev/ixgbe/ixgbe.c
/freebsd-10-stable/sys/dev/ixgbe/ixv.c
/freebsd-10-stable/sys/dev/ixl/if_ixl.c
/freebsd-10-stable/sys/dev/mpr/mpr.c
/freebsd-10-stable/sys/dev/mps/mps.c
/freebsd-10-stable/sys/dev/mrsas/mrsas.c
/freebsd-10-stable/sys/dev/mrsas/mrsas.h
/freebsd-10-stable/sys/dev/mxge/if_mxge.c
/freebsd-10-stable/sys/dev/oce/oce_sysctl.c
/freebsd-10-stable/sys/dev/qlxgb/qla_os.c
/freebsd-10-stable/sys/dev/qlxgbe/ql_os.c
/freebsd-10-stable/sys/dev/rt/if_rt.c
/freebsd-10-stable/sys/dev/sound/pci/hda/hdaa.c
/freebsd-10-stable/sys/dev/vxge/vxge.c
/freebsd-10-stable/sys/dev/xen/netfront/netfront.c
/freebsd-10-stable/sys/fs/devfs/devfs_devs.c
/freebsd-10-stable/sys/fs/fuse/fuse_main.c
/freebsd-10-stable/sys/fs/fuse/fuse_vfsops.c
/freebsd-10-stable/sys/fs/nfsserver/nfs_nfsdkrpc.c
/freebsd-10-stable/sys/geom/geom_kern.c
/freebsd-10-stable/sys/kern/kern_cpuset.c
/freebsd-10-stable/sys/kern/kern_descrip.c
/freebsd-10-stable/sys/kern/kern_mib.c
/freebsd-10-stable/sys/kern/kern_synch.c
/freebsd-10-stable/sys/kern/subr_devstat.c
/freebsd-10-stable/sys/kern/subr_kdb.c
/freebsd-10-stable/sys/kern/subr_uio.c
/freebsd-10-stable/sys/kern/vfs_cache.c
/freebsd-10-stable/sys/mips/mips/busdma_machdep.c
/freebsd-10-stable/sys/net/if_lagg.c
/freebsd-10-stable/sys/net/pfvar.h
/freebsd-10-stable/sys/net80211/ieee80211_ht.c
/freebsd-10-stable/sys/net80211/ieee80211_hwmp.c
/freebsd-10-stable/sys/net80211/ieee80211_mesh.c
/freebsd-10-stable/sys/net80211/ieee80211_superg.c
/freebsd-10-stable/sys/netgraph/bluetooth/common/ng_bluetooth.c
/freebsd-10-stable/sys/netgraph/ng_base.c
/freebsd-10-stable/sys/netgraph/ng_socket.c
/freebsd-10-stable/sys/netinet/cc/cc_chd.c
/freebsd-10-stable/sys/netinet/tcp_reass.c
/freebsd-10-stable/sys/netipsec/ipsec.h
/freebsd-10-stable/sys/netipx/ipx_proto.c
/freebsd-10-stable/sys/netpfil/pf/if_pfsync.c
/freebsd-10-stable/sys/netpfil/pf/pf.c
/freebsd-10-stable/sys/netpfil/pf/pf_ioctl.c
/freebsd-10-stable/sys/ofed/drivers/net/mlx4/mlx4_en.h
/freebsd-10-stable/sys/powerpc/powermac/fcu.c
/freebsd-10-stable/sys/powerpc/powermac/smu.c
/freebsd-10-stable/sys/powerpc/powerpc/busdma_machdep.c
/freebsd-10-stable/sys/powerpc/powerpc/cpu.c
/freebsd-10-stable/sys/sys/sysctl.h
/freebsd-10-stable/sys/vm/memguard.c
/freebsd-10-stable/sys/vm/vm_kern.c
/freebsd-10-stable/sys/x86/x86/busdma_bounce.c
273532 23-Oct-2014 mav

MFC r273259:
Make VPD 80h (Serial Number) transfer length match serial number length.

273531 23-Oct-2014 mav

MFC r273163: Implement more functional CTL debug logging.

Setting bits in kern.cam.ctl.debug allows to log errors, commands and some
commands data respectively.

273325 20-Oct-2014 mav

MFC r273072: Add LBPERE mode bit definition.

273324 20-Oct-2014 mav

MFC r273046:
Don't confuse frontend with zero length data moves, just return immediately.

273323 20-Oct-2014 mav

MFC r273038: Add support for READ DEFECT DATA (10/12) commands.

SPC-4 r2 allows to return empty defect list if the list is not supported.
We don't reallu support defect data lists, but this suppresses some errors.

273322 20-Oct-2014 mav

MFC r273029:
Report physical block size for file-backed LUNs, using vattr.va_blocksize.

273321 20-Oct-2014 mav

MFC r273008: Remove stale comments.

273320 20-Oct-2014 mav

MFC r272978: Improve and document `ctladm portlist` subcommand.

Make this subcommand less FC-specific, reporting target and port addresses
in more generic way. Also make it report list of connected initiators in
unified way, working for both FC and iSCSI, and potentially others.

273319 20-Oct-2014 mav

MFC r272947: Give physical and virtual ports numbers some more meaning.

273318 20-Oct-2014 mav

MFC r272939: Shorten frontend name.

273317 20-Oct-2014 mav

MFC r272938: Filter out duplicate AC_PATH_REGISTERED async events.

Queued async events handling in CAM opened race, that may lead to duplicate
AC_PATH_REGISTERED events delivery during boot. That was not happening
before r272935 because the driver was initialized later. After that change
it started create duplicate ports in CTL.

273316 20-Oct-2014 mav

MFC r272935: Mark CTL frontend's CAM driver as CAM_PERIPH_DRV_EARLY.

Target mode operation does not depend on the initiator mode scan process.
This change allows the target driver to attach earlier and receive some
async events (like AC_CONTRACT) that could be lost otherwise.

273315 20-Oct-2014 mav

MFC r272911:
Make ctld start even if some LUNs are unable to open backing storage.

Such LUNs will be visible to initiators, but return "not ready" status
on media access commands. If backing storage become available later,
`ctladm modify ...` or `service ctld reload` can trigger its reopen.

273314 20-Oct-2014 mav

MFC r272893:
Store persistent reservation keys as uint64_t instead of uint8_t[8].

This allows to simplify the code and save 512KB of RAM per LUN (8%)
by removing no longer needed "registered" keys flags.

273313 20-Oct-2014 mav

MFC r272812: Make iSCSI connection close somewhat less aggressive.

It allows to push out some final data from the send queue to the socket
before its close. In particular, it increases chances for logout response
to be delivered to the initiator.

273312 20-Oct-2014 mav

MFC r272748:
Implement software (mode page) and hardware (config) write protection.

273311 20-Oct-2014 mav

MFC r272734:
Add support for WRITE ATOMIC (16) command and report SBC-4 compliance.

Atomic writes are only supported for ZVOLs in "dev" mode. In other cases
atomicity can not be guarantied and so the command is blocked.

273310 20-Oct-2014 mav

MFC r272613:
Add support for MaxBurstLength and Expected Data transfer Length parameters.

Before this change target could send R2T request for write transfer of any
size, that could violate iSCSI RFC, which allows initiator to limit maximum
R2T size by negotiating MaxBurstLength connection parameter.

Also report an error in case of write underflow, when initiator provides
less data than initiator expects. Previously in such case our target
sent R2T request for non-existing data, violating the RFC, and confusing
some initiators. SCSI specs don't explicitly define how write underflows
should be handled and there are different oppinions, but reporting error
is hopefully better then violating iSCSI RFC with unpredictable results.

273309 20-Oct-2014 mav

MFC r272597: Fix length of Extended INQUIRY Data VPD page.

273308 20-Oct-2014 mav

MFC r271718 (by bdrewery): Correct a comment

273307 20-Oct-2014 mav

MFC r271395 (by trasz):
Make sure we handle less than zero timeouts in iSCSI initiator and target
in a reasonable way.

Sponsored by: The FreeBSD Foundation

273078 14-Oct-2014 mav

MFC r271588: Update CAM CCB accounting for the new status quo.

devq_openings counter lost its meaning after allocation queues has gone.
held counter is still meaningful, but problematic to update due to separate
locking of CCB allocation and queuing.

To fix that replace devq_openings counter with allocated counter. held is
now calculated on request as difference between number of allocated, queued
and active CCBs.

272977 12-Oct-2014 mav

Use proper variable when looping through periphs with CAM_PERIPH_FREE.

PR: 194256
Submitted by: Scott M. Ferris <smferris@gmail.com>
Sponsored by: EMC/Isilon Storage Division

272798 09-Oct-2014 mav

MFC r272650: Set CAM_SIM_QUEUED flag before calling ctl_queue() to avoid race.

PR: 194128
Submitted by: Scott M. Ferris <smferris@gmail.com>
Sponsored by: EMC/Isilon Storage Division

272657 06-Oct-2014 mav

MFC r269472: Do not retry on set of non-transient XCOPY errors.

272656 06-Oct-2014 mav

MFC r269469: Do not retry token errors.

They are not going to disappear by themselves.

272647 06-Oct-2014 mav

MFC r272355: Fix couple issues with ROD tokens content.

272646 06-Oct-2014 mav

MFC r272247:
Do not transfer unneeded training zero bytes in INQUIRY response.

It is an addition to r269631.

272644 06-Oct-2014 mav

MFC r272224: Fix page length reported for Block Limits VPD page.

272643 06-Oct-2014 mav

MFC r272033:
Fix ASCQ for "Logical unit not ready, manual intervention required" error.

272642 06-Oct-2014 mav

MFC r271959: Pretend that we support BYTCHK=1 in WRITE AND VERIFY command.

Technically that is not true, but since we don't implement VERIFY there
at all, doing only WRITE part, this is a minor sin.

272641 06-Oct-2014 mav

MFC r271954:
Deny ANCHOR flag set without UNMAP flag set in WRITE SAME commands.

272640 06-Oct-2014 mav

MFC r271951: Don't try to continue aborted commands if status was not set.

272639 06-Oct-2014 mav

MFC r271945:
Simplify legacy reservation handling. Drop it on I_T nexus loss.

272638 06-Oct-2014 mav

MFC r271942:
Don't report unsupported FUA_NV bit set in READ/WRITE commands as error.

While this bit is obsolete in SBC-3, SBC-2 allowed to silently ignore it.

272637 06-Oct-2014 mav

MFC r271941:
Report proper errors codes for unsupported SERVICE ACTION values.

272636 06-Oct-2014 mav

MFC r271940: Polish INQUIRY command fields validation.

272635 06-Oct-2014 mav

MFC r271930: Allow SUBPAGE CODE field in MODE SENSE commands.

272634 06-Oct-2014 mav

MFC r271869:
Fix inverted expression to report block size in mode page block descriptor.

272633 06-Oct-2014 mav

MFC r271845:
Allow more commands to pass persistent reservation according to SPC-4 r37.

272632 06-Oct-2014 mav

MFC r271839:
Add support for "no Data-Out Buffer" (NDOB) flag of WRITE SAME (16) command.

272631 06-Oct-2014 mav

MFC r271606:
Always report that we support REPORT TARGET PORT GROUPS command.

Without clustering support we any way have only one group of permanently
active ports, but that gives us one more supported VMWare feature. ;)

Solaris' Comstar also reports it even when only one port is present.

272630 06-Oct-2014 mav

MFC r271507:
Implement control over command reordering via options and control mode page.

It allows to bypass range checks between UNMAP and READ/WRITE commands,
which may introduce additional delays while waiting for UNMAP parameters.
READ and WRITE commands are always processed in safe order since their
range checks are almost free.

272629 06-Oct-2014 mav

MFC r271505:
Add "readcache" and "writecache" LUN options to control default behavior.

Default values are "on". Disabling requires backend to support IO_DIRECT
and IO_SYNC flags respectively, or some alternatives.

272626 06-Oct-2014 mav

MFC r271503: Implement range checks between UNMAP and READ/WRITE commands.

Before this change UNMAP completely blocked other I/Os while running.
Now it blocks only colliding ones, slowing down others only due to ZFS
locks collisions.

Sponsored by: iXsystems, Inc.

272625 06-Oct-2014 mav

MFC r271443: Add support for Extended INQUIRY Data (0x86) VPD page.

272624 06-Oct-2014 mav

MFC r271313: Oops, missed piece of r271311.

272623 06-Oct-2014 mav

MFC r271360: Remove uninitialized and unused variable, reported by Coverity.

272622 06-Oct-2014 mav

MFC r271358: Fix array overrun, reported by Coverity.

272621 06-Oct-2014 mav

MFC r271354: Fix couple off-by-one range check errors, reported by Coverity.

272620 06-Oct-2014 mav

MFC r271353: Fix memory leak on error, reported by Coverity.

272619 06-Oct-2014 mav

MFC r271352: Fix minor buffer overflow reported by Coverity.

272618 06-Oct-2014 mav

MFC r271316: Report that DPO and FUA bits are supported after r271311.

272617 06-Oct-2014 mav

MFC r271311:
Add support for Mode Page Policy (0x87) VPD page.

272616 06-Oct-2014 mav

MFC r271309:
Improve cache control support, including DPO/FUA flags and the mode page.

At this moment it works only for files and ZVOLs in device mode since BIOs
have no respective respective cache control flags (DPO/FUA).

272203 27-Sep-2014 mav

MFC r272040:
When reporting some major UNIT ATTENTION condition, like POWER ON OCCURRED
or I_T NEXUS LOSS, clear all minor UAs for the LUN, redundant in this case.

All SAM specifications tell that target MAY do it, but libiscsi initiator
seems require it to be done, terminating connection with error if some more
UAs happen to be reported during iSCSI connection.

Approved by: re (gjb)

272101 25-Sep-2014 mav

MFC r271957: Fix read overrun handling, broken by using wrong variable.

Approved by: re (marius)

272100 25-Sep-2014 mav

MFC r271949:
Fix UNMAP stuck if the last block descriptor in the list is empty.

Approved by: re (glebius)

271928 21-Sep-2014 mav

MFC r271794: When updating device media size use cached cdevsw pointer.

Using pointer from the cdev directly is dangerous since we have no
reference on it, and it may change any time. That caused panic if
device has gone.

While there, report capacity change only if it really changed.

Approved by: re (dephij)

271904 20-Sep-2014 mav

MFC r271702:
Fix tpc_create_token() introduced in r269497 to encode CREATOR LOGICAL
UNIT DESCRIPTOR field as Identification Descriptor CSCD descriptor, not
just as Identification Descriptor.

Approved by: re (gjb)

271903 20-Sep-2014 mav

MFC r271700: Fix typo in defined ROD types in r269497.

Approved by: re (gjb)

271748 18-Sep-2014 mav

MFC r271644:
Add quirks to disable READ CAPACITY (16) for PNY USB 3.0 Flash Drives.

Submitted by: Sean Fagan <sef@ixsystems.com>
Approved by: re (kib)

271618 15-Sep-2014 trasz

MFC r271393:

Make it possible to disable NOP-In PDUs by the iSCSI initiator by setting
kern.cam.ctl.iscsi.ping_timeout to 0. This fixes interoperability with
some initiators that don't properly support NOP-Ins, namely iPXE/gPXE.

Approved by: re (kib)

271530 13-Sep-2014 mav

MFC r271407: Extend UNMAP blacklist on all STEC SSD models.

None of existing STEC devices need UNMAP or even support it well,
having many limitations and even hanging sometimes executing those
commands. New devices that may use UNMAP going to be released under
HGST name.

Approved by: re (delphij)

271529 13-Sep-2014 mav

MFC r271362:
Make ctl_port_mask an array to support more then 32 ports.

Overflow reported by Coverity.

CID: 1229894

Approved by: re (marius)

271238 07-Sep-2014 smh

MFC r256956:
Improve ZFS N-way mirror read performance by using load and locality
information.

MFC r260713:
Fix ZFS mirror code for handling multiple DVA's

Also make the addition of the d_rotation_rate binary compatible. This allows
storage drivers compiled for 10.0 to work by preserving the ABI for disks.

Approved by: re (gjb)
Sponsored by: Multiplay

270891 31-Aug-2014 trasz

MFC r270282:

Use proper include paths in kernel iSCSI code.

Sponsored by: The FreeBSD Foundation

270645 26-Aug-2014 imp

Merge SETAN changes from head:

r270327 | imp | 2014-08-22 07:15:59 -0600 (Fri, 22 Aug 2014) | 6 lines
We should never enter the PROBE_SETAN phase if we're not ATAPI, since
that's ATAPI specific. Instead, skip to PROBE_SET_MULTI instead for
non ATAPI protocols. The prior code incorrectly terminated the probe
with a break, rather than arranging for probedone to get called. This
caused panics or worse on some systems.

r270249 | imp | 2014-08-20 16:58:12 -0600 (Wed, 20 Aug 2014) | 13 lines
Turns out that IDENTIFY DEVICE and IDENTIFY PACKET DEVICE return data
that's only mostly similar. Specifically word 78 bits are defined for
IDENTIFY DEVICE as
5 Supports Hardware Feature Control
while a IDENTIFY PACKET DEVICE defines them as
5 Asynchronous notification supported
Therefore, only pay attention to bit 5 when we're talking to ATAPI
devices (we don't use the hardware feature control at this time).
Ignore it for ATA devices. Remove kludge that papered over this issue
for Samsung SATA SSDs, since Micron drives also have the bit set and
the error was caused by this bad interpretation of the spec (which is
quite easy to do, since bits aren't normally overlapping like this).

Sponsored by: Netflix (the merge and the original work)

270389 23-Aug-2014 mav

MFC r270176:
Fix lock recursion on LUN shutdown, introduced on r269497.

270313 21-Aug-2014 smh

MFC r269974 - Added 4K quirks for Corsair Force GT and Samsung 840 SSDs

Sponsored by: Multiplay

270109 17-Aug-2014 mav

MFC r269631:
Reduce reported additional INQUIRY data length.

sizeof(struct scsi_inquiry_data) of 256 bytes combined with off-by-one
error in the changed code gave total INQUIRY data length above 255 bytes,
that was maximal INQUIRY length in SPC-2. While SPC-3 increased the
maximal length to 64K, at least sg3_utils are still confused by that.

270108 17-Aug-2014 mav

MFC r269622:
Fix several issues and inconsistencies in UNMAP capabilities reporting.

This makes Windows 2012 to start using UNMAP on our disks.

270107 17-Aug-2014 mav

MFC r269587:
Reimplement WRITE USING TOKEN with Block Zero token using WRITE SAME.

On my ZVOL of SSDs that increases speed of zero writing in that way from
1 to 2.5GB/s by reducing CPU overhead.

270106 17-Aug-2014 mav

MFC r269497:
Add support for Windows dialect of EXTENDED COPY command, aka Microsoft ODX.

This allows to avoid extra network traffic when copying files on NTFS iSCSI
disks within one storage host by drag'n'dropping them in Windows Explorer
of Windows 8/2012. It should also accelerate Hyper-V VM operations, etc.

269717 08-Aug-2014 joerg

Merge r269353:

Fix breakage introduced by r256843: removing the SA_CCB_WAITING bit
left some of the decisions based on its counterpart, SA_CCB_BUFFER_IO
being random. As a result, propagation of the residual information
for the SPACE command was broken, so the number of filemarks
encountered during a SPACE operation was miscalculated. Consequently,
systems relying on properly tracked filemark counters (like Bacula)
fell apart.

The change also removes a switch/case in sadone() which r256843
degraded to a single remaining case label.

PR: 192285

269574 05-Aug-2014 mav

MFC r269444, r269450:
Plug EXTENDED COPY request data memory leak.

269572 05-Aug-2014 mav

MFC r269442:
Fix some bugs in RECEIVE COPY STATUS data.

269570 05-Aug-2014 mav

MFC r269441:
Add missing comparisons to make list IDs in EXTENDED COPY per-initiator,
as they should be. Wrap it into a function to not duplicate the code.

269429 02-Aug-2014 mav

MFC r269123:
Implement separate I/O dispatch method for ZVOLs in "dev" mode.

Unlike disk devices ZVOLs process all requests synchronously. That makes
impossible sending multiple requests to them from single thread. From the
other side ZVOLs have real d_read/d_write methods, which unlike d_strategy
can handle uio scatter/gather and have no strict I/O size limitations.

So, if ZVOL in "dev" mode is detected, use of d_read/d_write methods instead
of d_strategy allows to avoid pointless splitting of large requests into
MAXPHYS (128K) sized chunks.

269298 30-Jul-2014 mav

MFC r268808:
Increase maximal number of SCSI ports in CTL from 32 to 128.

After I gave each iSCSI target its own port, the old limit appeared to be
not so big. This change almost proportionally increases per-LUN memory
use, but it is still three times better then it was before r268807.

269297 30-Jul-2014 mav

MFC r268807:
Reduce per-LUN memory usage from 18MB to 1.8MB.

CTL never had use for CA support code since SPI has gone, and there is no
even frontends supporting that. But it still was reserving 256 bytes of
memory per LUN per every possible initiator on every possible port.

Wrap unused code with ifdef's in case somebody ever need it.

269296 30-Jul-2014 mav

MFC r268767:
Add support for VMWare dialect of EXTENDED COPY command, aka VAAI Clone.

This allows to clone VMs and move them between LUNs inside one storage
host without generating extra network traffic to the initiator and back,
and without being limited by network bandwidth.

LUNs participating in copy operation should have UNIQUE NAA or EUI IDs set.
For LUNs without these IDs VMWare will use traditional copy operations.

Beware: the above LUN IDs explicitly set to values non-unique from the VM
cluster point of view may cause data corruption if wrong LUN is addressed!

Sponsored by: iXsystems, Inc.

269295 30-Jul-2014 mav

MFC r268581:
Merge several equal serialization indexes.

269294 30-Jul-2014 mav

MFC r269149:
Fix several cases of NULL dereference when INQUIRY sent to absent LUN.

269226 29-Jul-2014 mav

MFC r269122:
Fix infinite loop, when doing WRITE SAME on file-backed LUN.

269202 28-Jul-2014 trasz

MFC r269088:

Fix ctl(4) kldload failure that manifested like this:

link_elf_obj: symbol icl_pdu_new_bhs undefined

PR: 192031
Submitted by: Nils Beyer (earlier version)
Sponsored by: FreeBSD Foundation

269151 27-Jul-2014 mav

MFC r269058:
Fix build with QUEUE_MACRO_DEBUG.

268816 17-Jul-2014 imp

MFC:

>r267118 | imp | 2014-06-05 11:13:42 -0600 (Thu, 05 Jun 2014) | 9 lines
>The code that combines adjacent ranges for BIO_DELETEs to optimize
>trims to the device assumes the list is sorted. Don't apply the
>optimization of not sorting the queue when we have SSDs to the
>delete_queue, since it causes more discard traffic to the drive. While
>one could argue that the higher levels should coalesce the trims,
>that's not done today, so some optimization at this level is needed.
>CR: https://phabric.freebsd.org/D142

268815 17-Jul-2014 imp

MFC:

>r268205 | imp | 2014-07-02 23:22:13 -0600 (Wed, 02 Jul 2014) | 9 lines
>Rework the BIO_DELETE code slightly. Always queue the BIO_DELETE
>requests on the trim_queue, even for the CFA ERASE. This allows us, in
>the future, to collapse adjacent requests. Since CFA ERASE is only for
>CF cards, and it is so restrictive in what it can do, the collapse
>code is not presently here. This also brings the ada driver more in
>line with the da driver's treatment of BIO_DELETEs.

268700 15-Jul-2014 mav

MFC r268240 (by ken):
Add persistent reservation support to camcontrol(8).

camcontrol(8) now supports a new 'persist' subcommand that allows users to
issue SCSI PERSISTENT RESERVE IN / OUT commands.

268699 15-Jul-2014 mav

MFC r268447:
Add LUN options to specify 64-bit EUI and NAA identifiers.

268698 15-Jul-2014 mav

MFC r268421:
Remove status setting from datamove() path. Leave that to other places.

268697 15-Jul-2014 mav

MFC r268418:
Enable TAS feature: notify initiator if its command was aborted by other.

That should make operation more kind to multi-initiator environment.
Without this, other initiators may find out that something bad happened
to their commands only via command timeout.

268696 15-Jul-2014 mav

MFC r268387:
Fix task management functions status: task not found is not an error,
while not implemented function is.

268695 15-Jul-2014 mav

MFC r268364:
Fix "use after free" on port creation error in r268291.

268694 15-Jul-2014 mav

MFC r268363:
Add support for READ FULL STATUS action of PERSISTENT RESERVE IN command.

268692 15-Jul-2014 mav

MFC r268362:
Teach ctl_add_initiator() to dynamically allocate IIDs from pool.

If port passed negative IID value, the function will try to allocate IID
from the pool of unused, based on passed wwpn or name arguments. It does
all its best to make IID unique and persistent across reconnects.

This makes persistent reservation properly work for iSCSI. Previously,
in case of reconnects, reservation could be unexpectedly lost, or even
migrate between intiators.

268691 15-Jul-2014 mav

MFC r268356, r268357:
When new connection comes in, check whether we already have session from
the same intiator (Name+ISID). If so -- terminate the old session and let
the new one take its place, as required by iSCSI RFC.

268690 15-Jul-2014 mav

MFC r268353:
Implement ABORT TASK SET and I_T NEXUS RESET task management functions.

Use the last one to terminate active commands on iSCSI session termination.
Previous code was aborting only commands doing some data moves.

268689 15-Jul-2014 mav

MFC r268330:
Make gcc happy, init idlen2.

268688 15-Jul-2014 mav

MFC r268328:
Close race in r268291 between port destruction, delayed by sessions
teardown, and new port creation during `service ctld restart`.

Close it by returning iSCSI port internal state, that allows to identify
dying ports, which should not be counted as existing, from really alive.

268687 15-Jul-2014 mav

MFC r268309:
Add support for SCSI Ports (88h) VPD page.

268686 15-Jul-2014 mav

MFC r268308:
Make REPORT TARGET PORT GROUPS command report realistic data instead of
hardcoded garbage.

268685 15-Jul-2014 mav

MFC r268307:
Move lun_map() method from command nexus to port.

Previous implementation made impossible to do some things, such as calling
it for ports other then one through which command arrived.

268684 15-Jul-2014 mav

MFC r268302:
Pass through iSCSI session ISID from LOGIN request to the CTL frontend.

ISID is an important part of initiator transport ID for iSCSI. It is not
used now, but should be to properly implement persistent reservation.

268683 15-Jul-2014 mav

MFC r268293:
Burry devid port method, which was a gross hack.

Instead make ports provide wanted port and target IDs, and LUNs provide
wanted LUN IDs. After that core Device ID VPD code only had to link all
of them together and add relative port and port group numbers.

LUN ID for iSCSI LUNs no longer created by CTL, but by ctld, and passed
to CTL as "scsiname" LUN option. This makes LUNs to report the same set
of IDs, independently from the port through which it is accessed, as
required by SCSI specifications.

268682 15-Jul-2014 mav

MFC r268291:
Create separate CTL port for every iSCSI target (and maybe portal group).

Having single port for all iSCSI connections makes problematic implementing
some more advanced SCSI functionality in CTL, that require proper ports
enumeration and identification.

This change extends CTL iSCSI API, making ctld daemon to control list of
iSCSI ports in CTL. When new target is defined in config fine, ctld will
create respective port in CTL. When target is removed -- port will be
also removed after all active commands through that port properly aborted.
This change require ctld to be rebuilt to match the kernel.

As a minor side effect, this allows to have iSCSI targets without LUNs.
While that may look odd and not very useful, that is not incorrect.

268681 15-Jul-2014 mav

MFC r268288:
Improve CTL_BEARG_* flags support, including optional values copyout.

268680 15-Jul-2014 mav

MFC r268287:
Implement and use ctl_frontend_find().

268679 15-Jul-2014 mav

MFC r268284:
Introduce new IOCTL CTL_PORT_LIST reporting in more flexible XML format.

Leave old CTL_GET_PORT_LIST in place so far. Garbage-collect it later.

268678 15-Jul-2014 mav

MFC r268280:
Make options KPI more generic to allow it to be used for ports too,
not only for LUNs.

268677 15-Jul-2014 mav

MFC r268266, r268275:
Separate concepts of frontend and port.

Before iSCSI implementation CTL had no knowledge about frontend drivers,
it had only frontends, which really were ports (alike to LUNs, if comparing
to backends). But iSCSI added there ioctl() method, which does not belong
to frontend as a port, but belongs to a frontend driver.

268676 15-Jul-2014 mav

MFC r268265:
Remove targ_enable()/targ_disable() frontend methods.

Those methods were never implemented, and I believe that their concept is
wrong, since single frontend (SCSI port) can not handle several targets.

268675 15-Jul-2014 mav

MFC r268103:
Add support for REPORT TIMESTAMP command.

268674 15-Jul-2014 mav

MFC r268096, r268306, r268361:
Add more formal and strict command parsing and validation.

For every supported command define CDB length and mask of bits that are
allowed to be set. This allows to remove bunch of checks through the code
and still make the validation more strict. To properly do it for commands
supporting multiple service actions, formalize their parsing by adding
subtables for each of such commands.

As visible effect, this change allows to add support for REPORT SUPPORTED
OPERATION CODES command, reporting to client all the data about supported
SCSI commands, except timeouts.

268673 15-Jul-2014 mav

MFC r267639:
Increase CTL_DEVID_LEN from 16 to 64 bytes.

SPC-4 recommends T10 vendor ID based LUN ID was created by concatenating
product name and serial number (and istgt follows that). But product name
is 16 bytes long by itself, so 16 bytes total length is clearly not enough
to fit both.

To keep compatibility with existing configurations, pad short device IDs
to old length of 16, same as before.

This change probably breaks CTL user-level ABI, so control tools should
be rebuilt after this change.

268556 12-Jul-2014 mav

MFC r267643, r267873, r268391, r268398:
Introduce fine-grained CTL locking to improve SMP scalability.

Split global ctl_lock, historically protecting most of CTL context:
- remaining ctl_lock now protects lists of fronends and backends;
- per-LUN lun_lock(s) protect LUN-specific information;
- per-thread queue_lock(s) protect request queues.
This allows to radically reduce congestion on ctl_lock.

Create multiple worker threads, depending on number of CPUs, and assign
each LUN to one of them. This allows to spread load between multiple CPUs,
still avoiging congestion on queues and LUNs locks.

On 40-core server, exporting 5 LUNs, each backed by gstripe of SATA SSDs,
accessed via 6 iSCSI connections, this change improves peak request rate
from 250K to 680K IOPS.

Sponsored by: iXsystems, Inc.

268555 12-Jul-2014 mav

MFC r268283:
Improve readability of XML generated by CTL_LUN_LIST.

268554 12-Jul-2014 mav

MFC r268392:
Do not return statuses for aborted iSCSI commands.

268553 12-Jul-2014 mav

MFC r268204:
Use separate memory type M_CTLIO for I/Os.

CTL allocate large amount of RAM. This change give some more stats.

268552 12-Jul-2014 mav

MFC r267933:
Simplify statistics calculation.

Instead of trying to guess size of disk I/O operations (it just won't work
that way for newly added commands, and is equal to data move size for old
ones), account data move traffic. If disk I/Os are that interesting, then
backends have to account and provide that information.

Block backend already exports the information about disk I/Os via devstat,
so having it here too is excessive.

268551 12-Jul-2014 mav

MFC r267906:
Allow MODE SENSE commands through Write Exclusive persistent reservation,
as required by SPC-4.

Report that fact in persistent reservation capabilities.

268550 12-Jul-2014 mav

MFC r267905:
Add READ BUFFER and improve WRITE BUFFER SCSI commands support.

This gives some use to 512KB per-LUN buffers, allocated for Copan-specific
processor code and not used. It allows, for example, to test transport
performance and/or correctness without accessing the media, as supported
by Linux version of sg3_utils.

268549 12-Jul-2014 mav

MFC r267877:
Lock devstat updates in block backend to make it usable. Polish lock names.

268546 12-Jul-2014 mav

MFC r268419:
Fix use-after-free on XPT_RESET_BUS.

That command is not queued, so does not use later status update.

268545 12-Jul-2014 mav

MFC r267986:
Remove odd practice of inverting error codes.

-EPERM is equal to ERESTART, returning which from ioctl() handler causes
infinite syscall restart.

268261 04-Jul-2014 mav

MFC r267641:
Add some more CTL_FLAG_ABORT check points.

This should allow to abort commands doing mostly disk I/O, such as VERIFY
or WRITE SAME. Before this change CTL_FLAG_ABORT was only checked around
data moves, which for these commands may not happen for a very long time.

268260 04-Jul-2014 mav

MFC r267637:
Add iSCSI Target Name ID descriptor to VPD 83h.

It shall/should be there according to SPC-4, and istgt also provides it.

268259 04-Jul-2014 mav

MFC r267610 (by trasz):
Rework session termination in iSCSI target to actually wait
for any outstanding commands to be properly aborted by CTL.
Without it, in some cases (such as files backing the LUNs
stored on failing disk drives), terminating a busy session
would result in panic.

268258 04-Jul-2014 mav

MFC r267574 (by trasz):
Make cs_terminating a bool; no functional changes.

268257 04-Jul-2014 mav

MFC r267547, r267551 (by trasz):
Add LUN-associated name to VPD, to make Hyper-V Failover Cluster happy.

268255 04-Jul-2014 mav

MFC r267051:
- Add support for SG_GET_SG_TABLESIZE IOCTL to report that we don't support
scatter/gather lists.
- Return error for still unsupported SG 3.x API read/write calls.

268151 02-Jul-2014 mav

MFC r267537:
Add support for VERIFY(10/12/16) and COMPARE AND WRITE SCSI commands.

Make data_submit backends method support not only read and write requests,
but also two new ones: verify and compare. Verify just checks readability
of the data in specified location without transferring them outside.
Compare reads the specified data and compares them to received data,
returning error if they are different.

VERIFY(10/12/16) commands request either verify or compare from backend,
depending on BYTCHK CDB field. COMPARE AND WRITE command executed in two
stages: first it requests compare, and then, if succeesed, requests write.
Atomicity of operation is guarantied by CTL request ordering code.

Sponsored by: iXsystems, Inc.

268150 02-Jul-2014 mav

MFC r267519:
Make backends track completion by processed number of sectors instead of
total transfer size.

Commands such as VERIFY or COMPARE AND WRITE may have transfer size not
matching directly to number of sectors.

268149 02-Jul-2014 mav

MFC r267515:
Remove memcpy() from ctl_private[] accesses.

That union is aligned enough to access data directly.

268148 02-Jul-2014 mav

MFC r267514:
Move kern_total_len setting from backend to core code.

268147 02-Jul-2014 mav

MFC r267500:
Format Portal Group Tag same as istgt does -- %4.4x instead of %x.

SPC-4 spec tells it should be "two or more hexadecimal digits".
RFC3720 tells it is 16-bit value.

268146 02-Jul-2014 mav

MFC r267499:
Remove custom processing for "file" option.

268145 02-Jul-2014 mav

MFC r267496, r267498:
Add "vendor", "product" and "revision" options to control inquiry data.

268144 02-Jul-2014 mav

MFC r267485:
Remove non-functional remnants of control LUN -- 18MB of RAM for nothing.

268143 02-Jul-2014 mav

MFC r267481, r267952:
Implement small KPI to access LUN options instead doing it by hands.

268142 02-Jul-2014 mav

MFC r265323 (by trasz):
Provide better descriptions for 'struct ctl_scsiio' fields; based mostly
on emails from ken@.

268141 02-Jul-2014 mav

MFC r267872:
Allow to use iSCSI immediate data by several ctl_datamove() calls.

While for FreeBSD client that is only a minor optimization, VMWare client
doesn't support additional data requests after all data being sent once as
immediate.

268139 02-Jul-2014 mav

MFC r266981:
Overhaul CAM SG driver IOCTL interfaces.

Make it really work for native FreeBSD programs. Before this it was broken
for years due to different number of pointer dereferences in Linux and
FreeBSD IOCTL paths, permanently returning errors to FreeBSD programs.
This change breaks the driver FreeBSD IOCTL ABI, making it more strict,
but since it was not working any way -- who bother.

Add shims for 32-bit programs on 64-bit host, translating the argument
of the SG_IO IOCTL for both FreeBSD and Linux ABIs.

With this change I was able to run 32-bit Linux sg3_utils tools and simple
32 and 64-bit FreeBSD test tools on both 32 and 64-bit FreeBSD systems.

267778 23-Jun-2014 marius

MFC: r267638

Don't denounce peripherals on system shutdown. Together with r267321
(MFCed to stable/10 in r267775), we're now back to the pre-r228483
level of default verbosity. This in turn again typically allows for
reading information that userland might have printed on the screen
before initiating a halt, but still permits to debug potential device
shutdown problems on system shutdown via CAM_DEBUG etc.

Reviewed by: mav
Sponsored by: Bally Wulff Games & Entertainment GmbH

267754 22-Jun-2014 mav

MFC r267429:
Fix some leaks on LUN creation error.

265644 08-May-2014 mav

MFC r265159:
Respect MAXIMUM TRANSFER LENGTH field of Block Limits VPD page.

Nobody yet reported disk supporting I/Os less then our MAXPHYS value, but
since we any way have code to read Block Limits VPD page, that is easy.

265643 08-May-2014 mav

MFC r265150:
Do not reread SCSI disk VPD pages on every device open.

Instead of rereading VPD pages on every device open, do it only on initial
device probe, and in cases when device reported via UNIT ATTENTIONs that
something has changed. Capacity is still rereaded on every open because
it is more critical for operation and more probable to change in run time.

On my tests with Intel 530 SSDs on mps(4) HBA this change reduces time
GEOM needs to retaste the device (that includes few open/close cycles)
from ~150ms to ~30ms.

265642 08-May-2014 mav

MFC r264886:
Remove limits on size of READ/WRITE operations.

Instead of allocating up to 16MB or RAM at once to handle whole I/O,
allocate up to 1MB at a time, but do multiple ctl_datamove() and storage
I/Os if needed.

265641 08-May-2014 mav

MFC r264884:
Make CAM target CTL frontend respect SIM I/O size limitations.

If datamove size is bigger then SIM can handle, or it has more segments
then this code can handle -- split it into several CTIO requests.

265640 08-May-2014 mav

MFC r264880 (by trasz):
Modify CTL iSCSI frontend to properly handle situations where datamove
routine is called multiple times per SCSI task.

265638 08-May-2014 mav

MFC r264834:
Disable UNMAP support for STEC 842 SSDs.

In some unknown cases UNMAP commands make device firmware stuck.

265637 08-May-2014 mav

MFC r264407:
Join CTL worker threads into one process for convenience.
Report their idle state as "-".

265635 08-May-2014 mav

MFC r264406:
Report more readable state "-" for idle CAM scan thread.

265634 08-May-2014 mav

MFC r264274, r264279, r264283, r264296, r264297:
Add support for SCSI UNMAP commands to CTL.

This patch adds support for three new SCSI commands: UNMAP, WRITE SAME(10)
and WRITE SAME(16). WRITE SAME commands support both normal write mode
and UNMAP flag. To properly report UNMAP capabilities this patch also adds
support for reporting two new VPD pages: Block limits and Logical Block
Provisioning.

UNMAP support can be enabled per-LUN by adding "-o unmap=on" to `ctladm
create` command line or "option unmap on" to lun sections of /etc/ctl.conf.

At this moment UNMAP supported for ramdisks and device-backed block LUNs.
It was tested to work great with ZFS ZVOLs. For file-backed LUNs UNMAP
support is unfortunately missing due to absence of respective VFS KPI.

Sponsored by: iXsystems, Inc

265632 08-May-2014 mav

MFC r260509:
Replace several instances of -1 with appropriate CAM_*_WILDCARD and types.

It was equal before r259397, but for good or bad, not any more for LUNs.

This change fixes at least CAM debugging.

265513 07-May-2014 trasz

MFC r264530:

Properly pass the initiator address when running in proxy mode.

Sponsored by: The FreeBSD Foundation

265510 07-May-2014 trasz

MFC r264527:

Make it possible to interrupt login when running in proxy mode.

Sponsored by: The FreeBSD Foundation

265509 07-May-2014 trasz

MFC r264526:

Properly identify target portal when running in proxy mode. While here,
remove CTL_ISCSI_CLOSE, it wasn't used or implemented anyway.

Sponsored by: The FreeBSD Foundation

265508 07-May-2014 trasz

MFC r264525:

Add some stuff to make it easier to figure out for the system administrator
whether the ICL_KERNEL_PROXY stuff got compiled in correctly.

Sponsored by: The FreeBSD Foundation

265507 07-May-2014 trasz

MFC r264524:

Make it possible for the iSCSI target side to operate in both normal
and ICL_KERNEL_PROXY mode, and fix some bit rot so the latter actually
works again.

Sponsored by: The FreeBSD Foundation

265505 07-May-2014 trasz

MFC r263740:

Use a less unusual syntax in debug printfs.

Sponsored by: The FreeBSD Foundation

265504 07-May-2014 trasz

MFC r264264 by mav@:

Wakeup only one thread of added in r263978i at a time.

This slightly reduces lock congestion between threads.

265501 07-May-2014 trasz

MFC r264110:

All the iSCSI sysctls are also tunables; advertise that.

Sponsored by: The FreeBSD Foundation

265497 07-May-2014 trasz

MFC r264024:

Use atomic ops instead of mutexes where appropriate.

Submitted by: mav@
Sponsored by: The FreeBSD Foundation

265496 07-May-2014 trasz

MFC r264023:

Instead of "icltx" and "iclrx", use thread names with prefix from upper
layer, so that one can see which side of the stack the threads are for.

Sponsored by: The FreeBSD Foundation

265495 07-May-2014 trasz

MFC r264022:

Get rid of ICL lock; use upper-layer (initiator or target) lock instead.
This avoids extra locking in icl_pdu_queue(); the upper layer needs to call
it while holding its own lock anyway, to avoid sending PDUs out of order.

Sponsored by: The FreeBSD Foundation

265494 07-May-2014 trasz

MFC r264020:

Remove the homegrown ctl_be_block_io allocator, replacing it with UMA.
There is no performance difference.

Reviewed by: mav@
Sponsored by: The FreeBSD Foundation

265493 07-May-2014 trasz

MFC r263979:

Hide CTL messages about SCSI error responses. Too many users take
them for actual target errors. They can be enabled back by setting
kern.cam.ctl.verbose=1, or booting with bootverbose.

Sponsored by: The FreeBSD Foundation

265492 07-May-2014 trasz

MFC r263978:

Make it possible to have multiple CTL worker threads. Leave the default
of 1 for now.

Sponsored by: The FreeBSD Foundation

265491 07-May-2014 trasz

MFC r263811:

Remove ctl_mem_pool.{c,h}.

Sponsored by: The FreeBSD Foundation

265490 07-May-2014 trasz

MFC r263810:

Rework cfiscsi_datamove_in() to obey expected data transfer length
received from the initiator.

Sponsored by: The FreeBSD Foundation

265489 07-May-2014 trasz

MFC r263745:

Target Transfer Tag is opaque; no need to htonl(3) it.

Sponsored by: The FreeBSD Foundation

264727 21-Apr-2014 mav

MFC r264191:
Report stripe size and offset of the backing device in READ CAPACITY (16)
as physical sector size and offset.

264602 17-Apr-2014 trasz

MFC r262837:

Make reset handling in iSCSI target RFC-compliant. This fixes some rare
hangs with Open-iSCSI (Linux).

Sponsored by: The FreeBSD Foundation

264541 16-Apr-2014 mav

MFC r264311 (by smh):
Fix build breakage caused by r264295

264523 16-Apr-2014 mav

MFC r264307:
Fix three refcounter leaks and lock recursion they covered.

264522 16-Apr-2014 mav

MFC r264295:
Remove support of LUN-based CD changers from cd(4) driver.

This code was heavily broken few months ago during CAM locking changes.
Fixing it would require almost complete rewrite. Since there are no
known devices on market using this interface younger then ~15 years, and
they are CD, not even DVD, I don't see much reason to rewrite it.

This change does not mean those devices won't work. They will just work
slower due to inefficient disks load/unload schedule if several LUNs
accessed same time.

263735 25-Mar-2014 trasz

MFC 262782:

Fix missing unlock in persistent reservations code, which resulted in panics
with Hyper-V Failover Cluster.

Sponsored by: The FreeBSD Foundation

263299 18-Mar-2014 mav

MFC r262741:
Do not retry on CAM_FUNC_NOTAVAIL error, but return immediately.

263156 14-Mar-2014 mav

MFC r262886:
Fix support for increased logical sector size (4K-native drives).

- Logical sector size is measured in words, not bytes.
- If physical sector is not bigger then logical sector, it does not mean
it should be set equal to 512 bytes, but set to logical sector.

PR: misc/187269
Submitted by: Ravi Pokala <rpokala@panasas.com>

262299 21-Feb-2014 mav

MFC r261538:
Make CTL block backend return proper error code for operations unsupposed
by the underlying device.

261450 04-Feb-2014 mav

MFC r260996:
Fix memory and references leak due to unfreed path in case we can't
allocate bus scan CCB.

261255 29-Jan-2014 mav

MFC r260267 (by smh), r261042:
Correct short delete issue in SCSI UNMAP support
Correct missing \n's in xpt_print's
Correct incorrect count being passed to short delete xpt_print

261145 25-Jan-2014 mav

MFC r260549:
Move xpt_run_devq() call before request completion callback where it was
originally.

I am not sure why exactly have I moved it during one of many refactorings
during camlock project, but obviously it opens race window that may cause
use after free panics during SIM (in reported cases umass(4)) detach.

260958 20-Jan-2014 mav

MFC r260407:
Allow delete_method sysctl to be set to "DISABLE".

260817 17-Jan-2014 avg

MFC r258622: dtrace sdt: remove the ugly sname parameter of SDT_PROBE_DEFINE


/freebsd-10-stable/share/man/man9/SDT.9
ctl/ctl_backend_block.c
/freebsd-10-stable/sys/cddl/dev/dtrace/dtrace_test.c
/freebsd-10-stable/sys/cddl/dev/sdt/sdt.c
/freebsd-10-stable/sys/compat/linux/linux_dtrace.h
/freebsd-10-stable/sys/dev/xen/blkback/blkback.c
/freebsd-10-stable/sys/kern/kern_clock.c
/freebsd-10-stable/sys/kern/kern_exec.c
/freebsd-10-stable/sys/kern/kern_exit.c
/freebsd-10-stable/sys/kern/kern_fork.c
/freebsd-10-stable/sys/kern/kern_priv.c
/freebsd-10-stable/sys/kern/kern_proc.c
/freebsd-10-stable/sys/kern/kern_racct.c
/freebsd-10-stable/sys/kern/kern_sig.c
/freebsd-10-stable/sys/kern/kern_synch.c
/freebsd-10-stable/sys/kern/kern_thread.c
/freebsd-10-stable/sys/kern/kern_timeout.c
/freebsd-10-stable/sys/kern/sched_4bsd.c
/freebsd-10-stable/sys/kern/sched_ule.c
/freebsd-10-stable/sys/kern/subr_devstat.c
/freebsd-10-stable/sys/kern/subr_turnstile.c
/freebsd-10-stable/sys/kern/vfs_cache.c
/freebsd-10-stable/sys/kern/vfs_lookup.c
/freebsd-10-stable/sys/kern/vfs_syscalls.c
/freebsd-10-stable/sys/net/vnet.c
/freebsd-10-stable/sys/netinet/in_kdtrace.c
/freebsd-10-stable/sys/netinet/in_kdtrace.h
/freebsd-10-stable/sys/netinet/sctp_dtrace_define.h
/freebsd-10-stable/sys/netinet/tcp_input.c
/freebsd-10-stable/sys/netinet/tcp_output.c
/freebsd-10-stable/sys/netinet/tcp_subr.c
/freebsd-10-stable/sys/opencrypto/cryptodeflate.c
/freebsd-10-stable/sys/security/mac/mac_framework.c
/freebsd-10-stable/sys/security/mac/mac_internal.h
/freebsd-10-stable/sys/sys/sdt.h
/freebsd-10-stable/sys/tools/vnode_if.awk
260626 14-Jan-2014 mav

MFC r260541, r260547:
Take additional reference on SCSI probe periph to cover its freeze count.

Otherwise periph may be invalidated and freed before single-stepping freeze
is dropped, causing use after free panic.

260477 09-Jan-2014 mav

MFC r257946:
Introduce seperate mutex lock to protect protect CTL I/O pools, slightly
reducing global CTL lock scope and congestion.

While there, simplify CTL I/O pools KPI, hiding implementation details.

260476 09-Jan-2014 mav

MFC r256995:
Remove 128KB bzero() call done for every block I/O data buffer.

260475 09-Jan-2014 mav

MFC r256547 (by smh):
Added 4K quirks for Corsair Neutron GTX SSD's

260387 07-Jan-2014 scottl

MFC Alexander Motin's direct dispatch, multi-queue, and finer-grained
locking support for CAM

r256826:
Fix several target mode SIMs to not blindly clear ccb_h.flags field of
ATIO CCBs. Not all CCB flags there belong to them.

r256836:
Remove hard limit on number of BIOs handled with one ATA TRIM request.

r256843:
Merge CAM locking changes from the projects/camlock branch to radically
reduce lock congestion and improve SMP scalability of the SCSI/ATA stack,
preparing the ground for the coming next GEOM direct dispatch support.

r256888:
Unconditionally acquire periph reference on CCB allocation failure.

r256895:
Fix memory and references leak due to unfreed path.

r256960:
Move CAM_UNQUEUED_INDEX setting to the last moment and under the periph lock.
This fixes race condition with cam_periph_ccbwait(), causing use-after-free.

r256975:
Minor (mostly cosmetical) addition to r256960.

r257054:
Some microoptimizations for da and ada drivers:
- Replace ordered_tag_count counter with single flag;
- From da remove outstanding_cmds counter, duplicating pending_ccbs list;
- From da_softc remove unused links field.

r257482:
Fix lock recursion, triggered by `smartctl -a /dev/adaX`.

r257501:
Make getenv_*() functions and respectively TUNABLE_*_FETCH() macros not
allocate memory and so not require sleepable environment. getenv() has
already used on-stack temporary storage, so just use it more rationally.
getenv_string() receives buffer as argument, so don't need another one.

r257914:
Some CAM locks polishing:
- Fix LOR and possible lock recursion when handling high-power commands.
Introduce new lock to protect left power quota and list of frozen devices.
- Correct locking around xpt periph creation.
- Remove seems never used XPT_FLAG_OPEN xpt periph flag.

Again, Netflix assisted with testing the merge, but all of the credit goes
to Alexander and iX Systems.

Submitted by: mav
Sponsored by: iX Systems

260385 07-Jan-2014 scottl

MFC Alexander Motin's GEOM direct dispatch work:

r256603:
Introduce new function devstat_end_transaction_bio_bt(), adding new argument
to specify present time. Use this function to move binuptime() out of lock,
substantially reducing lock congestion when slow timecounter is used.

r256606:
Move g_io_deliver() out of the lock, as required for direct dispatch.
Move g_destroy_bio() out too to reduce lock scope even more.

r256607:
Fix passing uninitialized bio_resid argument to g_trace().

r256610:
Add unmapped I/O support to GEOM RAID.

r256830:
Restore BIO_UNMAPPED and BIO_TRANSIENT_MAPPING in biodonne() when unmapping
temporary mapped buffer. That fixes double unmap if biodone() called twice
for the same BIO (but with different done methods).

r256880:
Merge GEOM direct dispatch changes from the projects/camlock branch.

When safety requirements are met, it allows to avoid passing I/O requests
to GEOM g_up/g_down thread, executing them directly in the caller context.
That allows to avoid CPU bottlenecks in g_up/g_down threads, plus avoid
several context switches per I/O.

r259247:
Fix bug introduced at r256607. We have to recalculate bp_resid here since
sizes of original and completed requests may differ due to end of media.

Testing of the stable/10 merge was done by Netflix, but all of the credit
goes to Alexander and iX Systems.

Submitted by: mav
Sponsored by: iX Systems


ata/ata_da.c
scsi/scsi_da.c
/freebsd-10-stable/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
/freebsd-10-stable/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c
/freebsd-10-stable/sys/dev/md/md.c
/freebsd-10-stable/sys/geom/concat/g_concat.c
/freebsd-10-stable/sys/geom/concat/g_concat.h
/freebsd-10-stable/sys/geom/gate/g_gate.c
/freebsd-10-stable/sys/geom/geom.h
/freebsd-10-stable/sys/geom/geom_dev.c
/freebsd-10-stable/sys/geom/geom_disk.c
/freebsd-10-stable/sys/geom/geom_disk.h
/freebsd-10-stable/sys/geom/geom_int.h
/freebsd-10-stable/sys/geom/geom_io.c
/freebsd-10-stable/sys/geom/geom_kern.c
/freebsd-10-stable/sys/geom/geom_slice.c
/freebsd-10-stable/sys/geom/geom_vfs.c
/freebsd-10-stable/sys/geom/mirror/g_mirror.c
/freebsd-10-stable/sys/geom/mirror/g_mirror.h
/freebsd-10-stable/sys/geom/multipath/g_multipath.c
/freebsd-10-stable/sys/geom/nop/g_nop.c
/freebsd-10-stable/sys/geom/nop/g_nop.h
/freebsd-10-stable/sys/geom/part/g_part.c
/freebsd-10-stable/sys/geom/raid/g_raid.c
/freebsd-10-stable/sys/geom/raid/g_raid.h
/freebsd-10-stable/sys/geom/raid/md_ddf.c
/freebsd-10-stable/sys/geom/raid/md_intel.c
/freebsd-10-stable/sys/geom/raid/md_jmicron.c
/freebsd-10-stable/sys/geom/raid/md_nvidia.c
/freebsd-10-stable/sys/geom/raid/md_promise.c
/freebsd-10-stable/sys/geom/raid/md_sii.c
/freebsd-10-stable/sys/geom/raid/tr_concat.c
/freebsd-10-stable/sys/geom/raid/tr_raid0.c
/freebsd-10-stable/sys/geom/raid/tr_raid1.c
/freebsd-10-stable/sys/geom/raid/tr_raid1e.c
/freebsd-10-stable/sys/geom/raid/tr_raid5.c
/freebsd-10-stable/sys/geom/stripe/g_stripe.c
/freebsd-10-stable/sys/geom/stripe/g_stripe.h
/freebsd-10-stable/sys/geom/zero/g_zero.c
/freebsd-10-stable/sys/kern/subr_devstat.c
/freebsd-10-stable/sys/kern/vfs_bio.c
/freebsd-10-stable/sys/sys/devicestat.h
/freebsd-10-stable/sys/sys/proc.h
259721 22-Dec-2013 mav

MFC r259108:
When comparing device IDs, make sure that they have the same type
(like NAA assigned) and identify the same entity (like device or port).
Otherwise there can be false positives since at least some models of
Seagate disks use same IDs for the whole device and one of its ports.

259304 13-Dec-2013 trasz

MFC r258871:

Properly report an error instead of panicing when user tries to create
LUN backed by non-disk device, e.g. /dev/null.

Sponsored by: The FreeBSD Foundation

259204 10-Dec-2013 nwhitehorn

MFC r257345,257382,257388:

Implement extended LUN support. If PIM_EXTLUNS is set by a SIM, encode
the upper 32-bits of the LUN, if possible, into the target_lun field as
passed directly from the REPORT LUNs response. This allows extended LUN
support to work for all LUNs with zeros in the lower 32-bits, which covers
most addressing modes without breaking KBI. Behavior for drivers not
setting PIM_EXTLUNS is unchanged. No user-facing interfaces are modified.

Extended LUNs are stored with swizzled 16-bit word order so that, for
devices implementing LUN addressing (like SCSI-2), the numerical
representation of the LUN is identical with and without PIM_EXTLUNS. Thus
setting PIM_EXTLUNS keeps most behavior, and user-facing LUN IDs, unchanged.
This follows the strategy used in Solaris. A macro (CAM_EXTLUN_BYTE_SWIZZLE)
is provided to transform a lun_id_t into a uint64_t ordered for the wire.

This is the second part of work for full 64-bit extended LUN support and is
designed to a bridge for stable/10 to the final 64-bit LUN code. The
third and final part will involve widening lun_id_t to 64 bits and will
not be MFCed. This third part will break the KBI but will keep the KPI
unchanged so that all drivers that will care about this can be updated now
and not require code changes between HEAD and stable/10.

Reviewed by: scottl

257049 24-Oct-2013 mav

MFC r256552:
Unify periph invalidation and destruction reporting.
Print message containing device model and serial number on invalidation.

Approved by: re (hrs)

257047 24-Oct-2013 mav

MFC r256533:
Unhide "Serial Number" lines from bootverbose. That information may
be useful for system administration to have in hard copy (in logs) if
one of several devices suddenly dies.

Approved by: re (hrs)

256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


256201 09-Oct-2013 trasz

Remove no longer useful debugging output and a stale comment.

Approved by: re (gjb)
Sponsored by: FreeBSD Foundation


256197 09-Oct-2013 trasz

Make the error handling more consistant. Shouldn't make any functional
difference.

Approved by: re (gjb)
Sponsored by: FreeBSD Foundation


256195 09-Oct-2013 trasz

Tidy up, cache return value of a function, and add an assertion;
shouldn't make any functional difference.

Approved by: re (gjb)
Sponsored by: FreeBSD Foundation


256188 09-Oct-2013 mav

Close the race on path ID allocation in xpt_bus_register() if two buses are
registered simultaneously. Due to topology unlock between the ID allocation
and the bus registration there is a chance that two buses may get the
same IDs. That is supposed reason of lock assertion panic in CAM during
initial bus scanning after new iscsid initiates two sessions same time.

Reported by: trasz
Approved by: re (glebus, marius)
MFC after: 2 weeks


256187 09-Oct-2013 trasz

Fix NOP-In/NOP-Out payload handling. Previous way didn't work at all; fortunately
nothing seems to actually use this feature, but it's required by standard.

Approved by: re (glebius)
Sponsored by: FreeBSD Foundation


256163 08-Oct-2013 trasz

Properly fix out of memory handling in the iSCSI target.

Approved by: re (glebius)
Sponsored by: FreeBSD Foundation


256065 05-Oct-2013 trasz

Split cfiscsi_datamove() in two; no functional changes.

Approved by: re (glebius)
Sponsored by: FreeBSD Foundation


256058 04-Oct-2013 trasz

Don't leak memory when removing an unconnected session, and remove useless
UMA_ZONE_NOFREE that caused another leak when unloading the module.

Approved by: re (glebius)
Sponsored by: FreeBSD Foundation


255915 27-Sep-2013 nwhitehorn

Make sure the CCB xflags field is initialized to zero so that
CAM_EXTLUN_VALID is not erroneously set. Also add an XPORT_SRP
identifier to the known SCSI transports for the SCSI RDMA protocol, as
used, for example with Infiniband storage.

Reviewed by: scottl
Approved by: re (marius)


255870 25-Sep-2013 scottl

Re-do r255853. Along with adding back the API/ABI changes from the
original, this hides the contents of cam_compat.h from ktrace/kdump/truss,
avoiding problems there. There are no user-servicable parts in there, so
no need for those tools to be groping around in there.

Approved by: re


255865 25-Sep-2013 gjb

Revert r255853 pending fixes to build errors in usr.bin/kdump

Approved by: re (implicit)


255853 24-Sep-2013 scottl

Update the CAM API for FreeBSD 10:

- Remove the timeout_ch field. It's been deprecated since FreeBSD 7.0;
MPSAFE drivers should be managing their own timeout storage. The
remaining non-MPSAFE drivers have been modified to also manage their own
storage, and should be considered for updating to MPSAFE (or removal)
during the FreeBSD 10.x lifecycle.

- Add fields related to soft timeouts and quality of service, to be used
in upcoming work.

- Add room for more flags in the CCB header and path_inq structures.

- Begin support for extended 64-bit LUNs.

- Bump the CAM version number to 0x18, but add compat shims. Tested with
camcontrol and smartctl.

Reviewed by: nathanw, ken, kib
Approved by: re
Obtained from: Netflix


255848 24-Sep-2013 trasz

Properly ignore PDUs with CmdSN outside of allowed range.

Approved by: re (glebius)
Sponsored by: FreeBSD Foundation


255837 24-Sep-2013 trasz

Fix a few instances of M_WAITOK in threads marked as prohibited from sleep,
missed in r255824.

Approved by: re (kib)
Sponsored by: FreeBSD Foundation


255824 23-Sep-2013 trasz

Don't use M_WAITOK when running from context where sleeping is prohibited,
such as callout or a geom thread.

Approved by: re (marius)
Sponsored by: FreeBSD Foundation


255739 20-Sep-2013 trasz

Add some spare fields to structs used by the new iSCSI stack - some just
in case, some for future MC/S support.

This requires kernel and world rebuild.

Approved by: re (blanket)
Sponsored by: FreeBSD Foundation


255570 14-Sep-2013 trasz

Bring in the new iSCSI target and initiator.

Reviewed by: ken (parts)
Approved by: re (delphij)
Sponsored by: FreeBSD Foundation


255309 06-Sep-2013 mav

Make SES driver adequately react on simple enclosure devices -- read Short
Enclosure status to enclosure status field, clear previous state and exit.


255307 06-Sep-2013 bryanv

Add camcontrol support for the SCSI sanitize command

Reviewed by: ken, mjacob (eariler version)
Sponsored by: Netapp


255304 06-Sep-2013 mav

Fix kernel panic if cache->nelms is zero.

MFC after: 2 weeks


255126 01-Sep-2013 mav

Add debug trace points for freeze/release device queue.


255120 01-Sep-2013 mav

Bring legacy CAM target implementation back into API/KPI-coherent and even
functional state. While CTL is much more superior target from all points,
there is no reason why this code should not work.

Tested with ahc(4) as target side HBA.

MFC after: 2 weeks


255119 01-Sep-2013 mav

Fix SES_ENABLE_PASSTHROUGH kernel option, unexpectedly broken during driver
overhaul.

MFC after: 3 days


255118 01-Sep-2013 mav

Fix targbh crash on XPT_IMMED_NOTIFY error during attach.


255117 01-Sep-2013 mav

Fix the build with CTLFEDEBUG, broken by unmapped I/O support changes.


255043 29-Aug-2013 ken

Bump up the default timeouts for move commands in the ch(4) driver
to 15 minutes, and 5 minutes for things like READ ELEMENT STATUS.

This is needed to account for the worst case scenarios on at least
some Spectra Logic tape libraries.

Sponsored by: Spectra Logic
MFC after: 3 days


254970 27-Aug-2013 ken

If a drive returns ASC/ASCQ 0x04,0x11 "Logical unit not ready,
notify (enable spinup) required", instead of doing the normal
retries, poll for a change in status.

We will poll every half second for a minute for the status to
change.

Hitachi drives (and likely other SAS drives) return that ASC/ASCQ
when they are waiting to spin up. What it means is that they are
waiting for the SAS expander to send them the SAS
NOTIFY (ENABLE SPINUP) primitive.

That primitive is the mechanism expanders/enclosures use to
sequence drive spinup to avoid overloading power supplies.

Sponsored by: Spectra Logic
MFC after: 3 days


254766 24-Aug-2013 mav

Add new attribute lunname to report only textual LUN-specific device IDs.
While lunid attribute prefers to report numeric ones, having both may be
useful in some situations.


254760 24-Aug-2013 ken

Add support to physio(9) for devices that don't want I/O split and
configure sa(4) to request no I/O splitting by default.

For tape devices, the user needs to be able to clearly understand
what blocksize is actually being used when writing to a tape
device. The previous behavior of physio(9) was that it would split
up any I/O that was too large for the device, or too large to fit
into MAXPHYS. This means that if, for instance, the user wrote a
1MB block to a tape device, and MAXPHYS was 128KB, the 1MB write
would be split into 8 128K chunks. This would be done without
informing the user.

This has suboptimal effects, especially when trying to communicate
status to the user. In the event of an error writing to a tape
(e.g. physical end of tape) in the middle of a 1MB block that has
been split into 8 pieces, the user could have the first two 128K
pieces written successfully, the third returned with an error, and
the last 5 returned with 0 bytes written. If the user is using
a standard write(2) system call, all he will see is the ENOSPC
error. He won't have a clue how much actually got written. (With
a writev(2) system call, he should be able to determine how much
got written in addition to the error.)

The solution is to prevent physio(9) from splitting the I/O. The
new cdev flag, SI_NOSPLIT, tells physio that the driver does not
want I/O to be split beforehand.

Although the sa(4) driver now enables SI_NOSPLIT by default,
that can be disabled by two loader tunables for now. It will not
be configurable starting in FreeBSD 11.0. kern.cam.sa.allow_io_split
allows the user to configure I/O splitting for all sa(4) driver
instances. kern.cam.sa.%d.allow_io_split allows the user to
configure I/O splitting for a specific sa(4) instance.

There are also now three sa(4) driver sysctl variables that let the
users see some sa(4) driver values. kern.cam.sa.%d.allow_io_split
shows whether I/O splitting is turned on. kern.cam.sa.%d.maxio shows
the maximum I/O size allowed by kernel configuration parameters
(e.g. MAXPHYS, DFLTPHYS) and the capabilities of the controller.
kern.cam.sa.%d.cpi_maxio shows the maximum I/O size supported by
the controller.

Note that a better long term solution would be to implement support
for chaining buffers, so that that MAXPHYS is no longer a limiting
factor for I/O size to tape and disk devices. At that point, the
controller and the tape drive would become the limiting factors.

sys/conf.h: Add a new cdev flag, SI_NOSPLIT, that allows a
driver to tell physio not to split up I/O.

sys/param.h: Bump __FreeBSD_version to 1000049 for the addition
of the SI_NOSPLIT cdev flag.

kern_physio.c: If the SI_NOSPLIT flag is set on the cdev, return
any I/O that is larger than si_iosize_max or
MAXPHYS, has more than one segment, or would have
to be split because of misalignment with EFBIG.
(File too large).

In the event of an error, print a console message to
give the user a clue about what happened.

scsi_sa.c: Set the SI_NOSPLIT cdev flag on the devices created
for the sa(4) driver by default.

Add tunables to control whether we allow I/O splitting
in physio(9).

Explain in the comments that allowing I/O splitting
will be deprecated for the sa(4) driver in FreeBSD
11.0.

Add sysctl variables to display the maximum I/O
size we can do (which could be further limited by
read block limits) and the maximum I/O size that
the controller can do.

Limit our maximum I/O size (recorded in the cdev's
si_iosize_max) by MAXPHYS. This isn't strictly
necessary, because physio(9) will limit it to
MAXPHYS, but it will provide some clarity for the
application.

Record the controller's maximum I/O size reported
in the Path Inquiry CCB.

sa.4: Document the block size behavior, and explain that
the option of allowing physio(9) to split the I/O
will disappear in FreeBSD 11.0.

Sponsored by: Spectra Logic


254759 24-Aug-2013 trasz

CTL changes required for iSCSI target, most notably LUN remapping
and a mechanism to allow CTL frontends for retrieving LUN options.

Reviewed by: ken (earlier version)


254595 21-Aug-2013 trasz

Fix the (unused for now) SCSI_PROTO_iSCSI define to match style(9).


254416 16-Aug-2013 ken

Add unmapped I/O and larger I/O support to the sa(4) driver.

We now pay attention to the maxio field in the XPT_PATH_INQ CCB,
and if it is set, propagate it up to physio via the si_iosize_max
field in the cdev structure.

We also now pay attention to the PIM_UNMAPPED capability bit in the
XPT_PATH_INQ CCB, and set the new SI_UNMAPPED cdev flag when the
underlying SIM supports unmapped I/O.

scsi_sa.c: Add unmapped I/O support and propagate the SIM's
maximum I/O size up.

Adjust scsi_tape_read_write() in the same way that
scsi_read_write() was changed to support unmapped
I/O. We overload the readop parameter with bits
that tell us whether it's an unmapped I/O, and we
need to set the CAM_DATA_BIO CCB flag. This change
should be backwards compatible in source and
binary forms.

MFC after: 1 week
Sponsored by: Spectra Logic


254378 15-Aug-2013 trasz

Turn comments about locking into actual lock assertions.

Reviewed by: ken
Tested by: ken
MFC after: 1 month


254329 14-Aug-2013 smh

Added 4K quirks for:-
* OCZ Agility 2 SSDs
* Marvell SSDs
* Intel X25-M Series SSDs


254058 07-Aug-2013 mav

Remove droping topology mutex after iterating 100 periphs in CAMGETPASSTHRU.
That is not so slow and so often operation to handle unneeded otherwise
xsoftc.xpt_generation and respective locking complications.


254052 07-Aug-2013 mav

Improve r253721 by reporting detected lack of BIO_FLUSH support to GEOM.
That prevents more of such requests from coming and errors from logging.


253987 06-Aug-2013 trasz

Remove dead code.


253960 05-Aug-2013 mav

MFprojects/camlock r249006:
Pass SIM pointer as an argument to camisr_runqueue() instead of doneq
pointer.


253958 05-Aug-2013 mav

MFprojects/camlock r249505:
Change CCB queue resize logic to be able safely handle overallocations:
- (re)allocate queue space in power of 2 chunks with 64 elements minimum
and never shrink it; with only 4/8 bytes per element size is insignificant.
- automatically reallocate the queue to double size if it is overflowed.
- if queue reallocation failed, store extra CCBs in unsorted TAILQ,
fetching them back as soon as some queue element is freed.

To free space in CCB for TAILQ linking, change highpowerq from keeping
high-power CCBs to keeping devices frozen due to high-power CCBs.

This encloses all pieces of queue resize logic inside of cam_queue.[ch],
removing some not obvious duties from xpt_release_ccb().


253803 30-Jul-2013 mav

Add NO_RC16 quirk to make da driver avoid using READ CAPACITY(16) command
if possible. Use it for Kingston JetFlash USB sticks, that are known to
return garbage in response to that command.


253752 28-Jul-2013 mav

Fix returning incorrect bio_resid value with failed BIO_DELETE requests.
Neither residual length reported for ATA/SCSI command nor one from another
BIO_DELETE request are in any way related to the value to be returned.


253724 27-Jul-2013 mav

Synchronize device cache on close only if there were some write operations.
While these operations are not really needed otherwise, at least for SCSI
they may cause extra errors if some other initiator holds write exclusive
reservation on the LUN (SYNCHRONIZE CACHE handled as "write" operation).


253722 27-Jul-2013 mav

Oops, revert unwanted part of r253721.


253721 27-Jul-2013 mav

Detect unsupported PREVENT ALLOW MEDIUM REMOVAL and SYNCHRONIZE CACHE(10)
to not spam devices with useless commands and logs with errors.


253549 22-Jul-2013 ken

CAM and mps(4) driver scanning changes.

Add a PIM_NOSCAN flag to the CAM path inquiry CCB. This tells CAM
not to perform a rescan on a bus when it is registered.

We now use this flag in the mps(4) driver. Since it knows what
devices it has attached, it is more efficient for it to just issue
a target rescan on the targets that are attached.

Also, remove the private rescan thread from the mps(4) driver in
favor of the rescan thread already built into CAM. Without this
change, but with the change above, the MPS scanner could run before
or during CAM's initial setup, which would cause duplicate device
reprobes and announcements.

sys/param.h:
Bump __FreeBSD_version to 1000039 for the inclusion of the
PIM_RESCAN CAM path inquiry flag.

sys/cam/cam_ccb.h:
sys/cam/cam_xpt.c:
Added a PIM_NOSCAN flag. If a SIM sets this in the path
inquiry ccb, then CAM won't rescan the bus in
xpt_bus_regsister.

sys/dev/mps/mps_sas.c
For versions of FreeBSD that have the PIM_NOSCAN path
inquiry flag, don't freeze the sim queue during scanning,
because CAM won't be scanning this bus. Instead, hold
up the boot. Don't call mpssas_rescan_target in
mpssas_startup_decrement; it's redundant and I don't
know why it was in there.

Set PIM_NOSCAN in path inquiry CCBs.

Remove methods related to the internal rescan daemon.

Always use async events to trigger a probe for EEDP support.
In older versions of FreeBSD where AC_ADVINFO_CHANGED is
not available, use AC_FOUND_DEVICE and issue the
necessary READ CAPACITY manually.

Provide a path to xpt_register_async() so that we only
receive events for our own SCSI domain.

Improve error reporting in cases where setup for EEDP
detection fails.

sys/dev/mps/mps_sas.h:
Remove softc flags and data related to the scanner thread.

sys/dev/mps/mps_sas_lsi.c:
Unconditionally rescan the target whenever a device is added.

Sponsored by: Spectra Logic
MFC after: 1 week


253370 15-Jul-2013 mav

Make some improvements to r253322 to really rescan target, not a bus.
Add there and in two more places checks for NULL on xpt_alloc_ccb_nowait().


253368 15-Jul-2013 ken

Fix an argument reversal in calls to scsi_read_element_status().

Reported by: Ulrich Spoerlein <uqs@FreeBSD.org>
MFC after: 3 days


253323 13-Jul-2013 mav

When printing opcode description, map T_NODEVICE to Direct Access Device to
handle REPORT LUNS, etc.


253322 13-Jul-2013 mav

Improve handling of 0x3F/0x0E "Reported LUNs data has changed" and 0x25/0x00
"Logical unit not supported" errors. First initiates specific target rescan,
second -- destroys specific LUN. That allows to automatically detect changes
in list of device LUNs. This mechanism doesn't work when target is completely
idle, but probably that is all what can be done without active polling.

Reviewed by: ken
Sponsored by: iXsystems, Inc.


253307 12-Jul-2013 scottl

Const-ify the new da_delete_functions.
Remove a redundant sanity check

Submitted by: Steven Hartland
Obtained from: Netflix
MFC after: 3 days


253274 12-Jul-2013 ken

Fix a problem with READ ELEMENT STATUS that occurs on some
changers that don't support the DVCID and CURDATA bits that were
introduced in the SMC spec.

These changers will return an Illegal Request type error if the
bits are set. This causes "chio status" to fail.

The fix is two-fold. First, for changers that claim to be SCSI-2
or older, don't set the DVCID and CURDATA bits for READ ELEMENT
STATUS. For newer changers (SCSI-3 and newer), we default to
setting the new bits, but back off and try the READ ELEMENT STATUS
without the bits if we get an Illegal Request type error.

This has been tested on a Qualstar TLS-8211, which is a SCSI-2
changer that does not support the new bits, and a Spectra T-380,
which is a SCSI-3 changer that does support the new bits. In the
absence of a SCSI-3 changer that does not support the bits, I
tested that with some error injection code. (The SMC spec says
that support for CURDATA is mandatory, and DVCID is optional.)

scsi_ch.c: Add a new quirk, CH_Q_NO_DVCID that gets set for
SCSI-2 and older libraries, or newer libraries that
report errors when the DVCID/CURDATA bits are set.

In chgetelemstatus(), use the new quirk to
determine whether or not to set DVCID and CURDATA.
If we get an error with the bits set, back off and
try without the bits. Set the quirk flag if the
read element status succeeds without the bits set.

Increase the READ ELEMENT STATUS timeout to 60
seconds after testing with a Spectra T-380. The
previous value was 10 seconds, and too short for
the T-380. This may be decreased later after
some additional testing and investigation.

Tested by: Andre Albsmeier <Andre.Albsmeier@siemens.com>
Sponsored by: Spectra Logic
MFC after: 3 days


253228 12-Jul-2013 scottl

Refactor the various delete methods out of dastart(). Cleans up a bunch
of style and adds more modularity and clarity.

Obtained from: Netflix
MFC after: 3 days


253091 09-Jul-2013 smh

Added 4K QUIRK for OCZ Vertex 4 SSDs

Submitted by: Borja Marcos <borjam@sarenet.es>
MFC after: 2 days


252684 04-Jul-2013 jkim

Make it little bit more C++ friendly. This explicit casting fixes some
ports, emulators/virtualbox-ose and sysutils/smartmontools for example.


252657 03-Jul-2013 smh

Bump disk(9) ABI version to signify the addition of d_delmaxsize by r249940.

Ensure that d_delmaxsize is always set, removing init to 0 which could cause
future issues if use cases change.

Allow kern.cam.da.X.delete_max (which maps to d_delmaxsize) to be increased
up to the calculated max after being reduced.

MFC after: 1 day
X-MFC-With: r249940


252569 03-Jul-2013 mav

Fix NULL-deference kernel panic on attempt of destroying non-existing
ramdisk-backed CTL LUN.


252382 29-Jun-2013 scottl

Introduce accessors for the ccb status word. Convert one (of many more)
modules to use it, will convert the others once the appropriate shed
color is selected by consensus.

Obtained from: Netflix
MFC after: 3 days


252250 26-Jun-2013 mav

Fix some UTF-8 chars slipped into r252204 via copy/paste.


252204 25-Jun-2013 mav

Add bunch of names for Seagate and HGST vennor-specififc ASC/ASCQ codes.


252045 20-Jun-2013 smh

Corrected ATA Passthrough defines from decimal to hex

Reviewed by: scottl
MFC after: 1 week


251989 19-Jun-2013 scottl

Fix an unfortunate typo with the compat shims

Obtained from: Netflix
MFC after: now


251837 17-Jun-2013 scottl

Add infrastructure for doing compatibility shims, as has been sorely
needed for the last 10 years. Far too much of the internal API is
exposed, and every small adjustment causes applications to stop working.
To kick this off, bump the API version to 0x17 as should have been done
with r246713, but add shims to compensate. Thanks to the shims, there
should be no visible change in application behavior.

I have plans to do a significant overhaul of the API to harnen it for
the future, but until then, I welcome others to add shims for older
versions of the API.

Obtained from: Netflix


251792 15-Jun-2013 mav

Restore use of polling mode for disk cache flush in case of kernel panic.
While I am not sure that any extra hardware access is a good idea after
panic, that is an existing behaviour that should better work correctly.


251683 13-Jun-2013 mav

Revert r251649:
ken@ noticed that with recently added d_gone() disk method GEOM already
holds reference on the periph, so we don't need another one.


251654 12-Jun-2013 mav

Make CAM return and GEOM DISK pass through new GEOM::lunid attribute.

SPC-4 specification states that serial number may be property of device,
but not a specific logical unit. People reported about FC storages using
serial number in that way, making it unusable for purposes of LUN multipath
detection. SPC-4 states that designators associated with logical unit from
the VPD page 83h "Device Identification" should be used for that purpose.
Report first of them in the new attribute in such preference order: NAA,
EUI-64, T10 and SCSI name string.

While there, make GEOM DISK properly report GEOM::ident in XML output also
using d_getattr() method, if available. This fixes serial numbers reporting
for SCSI disks in `geom disk list` output and confxml.

Discussed with: gibbs, ken
Sponsored by: iXsystems, Inc.
MFC after: 2 weeks


251649 12-Jun-2013 mav

Acquire periph reference when handling d_getattr() method call.

While GEOM in general has provider opened while sending BIO_GETATTR,
GEOM DISK does not really need to open disk to read medium-unrelated
attributes for own use.

Proposed by: ken


251479 07-Jun-2013 scottl

Simplify the checking of flags for cam_periph_mapmem(). This gets rid of
a lot of code redundancy and grossness at very minor expense.

Reviewed by: smh
Obtained from: Netflix
MFC after: 3 days


251061 28-May-2013 smh

Added missing SCSI quirks from r241784

Re-ordered SSD quirks alphabetically so they are easier to maintain.

Removed my email and PR reference from comments on each quirk.

Added quirks for more SSDs:
* Crucial M4
* Corsair Force GT
* Intel 520 Series
* Kingston E100 Series
* Samsung 830 Series

Reviewed by: pjd (mentor)
Approved by: pjd (mentor)
MFC after: 1 week


250967 24-May-2013 smh

Enforce validation on the selected delete method via sysctl.

This prevents users from selecting a delete method which may cause
corruption e.g. MPS WS16 on pre P14 firmware.

Reviewed by: pjd (mentor)
Approved by: pjd (mentor)
MFC after: 2 days


250792 18-May-2013 smh

Added output of device QUIRKS for CAM and AHCI devices during boot.

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 2 weeks


250557 12-May-2013 mav

Suppress error printing for "PREVENT ALLOW MEDIUM REMOVAL" on da open.
Change at r250208 exposed more errors here, hidden before. The same flag
is used in cd driver.


250532 11-May-2013 eadler

Intel's 320-series and 510-series SSDs advertise 512-byte sectors
sizes for both logical and physical. Add ADA_Q_4K quirks
for both.

PR: kern/178040
Submitted by: Jeremy Chadwick <jdc@koitsu.org>


250508 11-May-2013 mav

Disable sending Early R_OK on SiI3726/SiI3826 port multipliers.
With "cached read" HDD testing and multiple ports busy on a SATA
host controller, 3726/3826 PMP will very rarely drop a deferred
R_OK that was intended for the host. Symptom will be all 5 drives
under test will timeout, get reset, and recover.

Submitted by: Rich Futyma <rich.futyma@sanmina.com>
MFC after: 2 weeks


250460 10-May-2013 eadler

Fxi a bunch of typos.

PR: misc/174625
Submitted by: Jeremy Chadwick <jdc@koitsu.org>


250301 06-May-2013 mav

Rework r250298 in more correct way.


250298 06-May-2013 mav

Fix byte order of ATA WWN when converting it to SCSI LUN ID.


250208 03-May-2013 mav

Tune support for removable media in da driver:
- remove DA_FLAG_SAW_MEDIA flag, almost opposite to DA_FLAG_PACK_INVALID,
using the last instead.
- allow opening device with no media present, reporting zero media size
and non-zero sector size, as geom/notes suggests. That allow to read
device attributes and potentially do other things, not related to media.


250183 02-May-2013 smh

Enable CAM SCSI to choice ATA TRIM during autodetection and correct method
names after increasing the priority of ATA TRIM.

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 1 week


250181 02-May-2013 smh

Use the existence of ATA Information VPD to determine if we should attempt
to query ATA functionality via ATA Pass-Through (16) as this page is defined
as "must" for SATL devices, hence indicating that the device is at least
likely to support Pass-Through (16).

This eliminates errors produced by CTL when ATA Pass-Through (16) fails.

Switch ATA probe daerror call to SF_NO_PRINT to avoid errors printing out
for devices which return invalid errors.

Output details about supported and choosen delete method when verbose booted.

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 1 week


250180 02-May-2013 smh

Fix probe in progress check in dareprobe

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 1 week


250179 02-May-2013 smh

Update probe flow so that devices with lbp can also disable disksort.

Ensure that delete_available is reset so re-probes after a media change,
to one with different delete characteristics, will result in the correct
methods being flagged as available.

Make all ccb state changes use a consistent flow:
* free()
* xpt_release_ccb()
* softc->state = <new state>
* xpt_schedule()

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 1 week


250131 01-May-2013 eadler

Correct a few sizeof()s

Submitted by: swildner@DragonFlyBSD.org
Reviewed by: alfred


250033 28-Apr-2013 smh

Correct comment typo's
Add missing comment

Reviewed by: pjd (mentor)
Approved by: pjd (mentor)
MFC after: 2 weeks


250025 28-Apr-2013 mav

Add some cam_freeze_devq()'s missed at r249466.
This makes number of freezes match the number of releases.

Reported by: dim


249981 27-Apr-2013 mav

MFprojects/camlock r249542:
Remove ADA_FLAG_PACK_INVALID flag. Since ATA disks have no concept of media
change it only duplicates CAM_PERIPH_INVALID flag, so we can use last one.

Slightly cleanup DA_FLAG_PACK_INVALID use.


249980 27-Apr-2013 mav

MFprojects/camlock r249541:
Give periph validity flag own periph reference. That slightly simplifies
the release logic and covers hypothetical case if lock is dropped inside
the periph_oninval() method.


249941 26-Apr-2013 smh

Added automatic detection of non-rotating media which disables the
use of BIO queue sorting, hence optimising performance for devices
such as SSD's

Reviewed by: scottl
Approved by: pjd (mentor)
MFC after: 2 weeks


249940 26-Apr-2013 smh

Teach GEOM and CAM about the difference between the max "size" of r/w and delete
requests.

sys/geom/geom_disk.h:
- Added d_delmaxsize which represents the maximum size of individual
device delete requests in bytes. This can be used by devices to
inform geom of their size limitations regarding delete operations
which are generally different from the read / write limits as data
is not usually transferred from the host to physical device.

sys/geom/geom_disk.c:
- Use new d_delmaxsize to calculate the size of chunks passed through to
the underlying strategy during deletes instead of using read / write
optimised values. This defaults to d_maxsize if unset (0).

- Moved d_maxsize default up so it can be used to default d_delmaxsize

sys/cam/ata/ata_da.c:
- Added d_delmaxsize calculations for TRIM and CFA

sys/cam/scsi/scsi_da.c:
- Added re-calculation of d_delmaxsize whenever delete_method is set.

- Added kern.cam.da.X.delete_max sysctl which allows the max size for
delete requests to be limited. This is useful in preventing timeouts
on devices who's delete methods are slow. It should be noted that
this limit is reset then the device delete method is changed and
that it can only be lowered not increased from the device max.

Reviewed by: mav
Approved by: pjd (mentor)


249939 26-Apr-2013 smh

Added available delete methods discovery during device probe, including the
maximum sizes for said methods, which are used when processing BIO_DELETE
requests. This includes updating UNMAP support discovery to be based on
SBC-3 T10/1799-D Revision 31 specification.

Added ATA TRIM support to cam scsi devices via ATA Pass-Through(16)

sys/cam/scsi/scsi_da.c:
- Added ATA Data Set Management TRIM support via ATA Pass-Through(16)
as a delete_method

- Added four new probe states used to identity available methods and their
limits for the processing of BIO_DELETE commands via both UNMAP and the
new ATA TRIM commands.

- Renamed Probe states to better indicate their use

- Added delete method descriptions used when informing user of issues.

- Added automatic calculation of the optimum delete mode based on which
method presents the largest maximum request size as this is most likely
to result in the best performance.

- Added WRITE SAME max block limits

- Updated UNMAP range generation to mirror that used by ATA TRIM, this
optimises the generation of ranges and fixes a potential overflow
issue in the count when combining multiple BIO_DELETE requests

- Added output of warnings about short deletes. This should only ever
be triggered on devices that fail to correctly advertise their supported
delete modes / max sizes.

- Fixed WS16 requests being incorrectly limited to 65535 in length.

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 2 weeks


249937 26-Apr-2013 smh

Refactored scsi_xpt use of device_has_vpd to generic scsi_vpd_supported_page
so its available for use in generic scsi code.

This is a pre-requirement for using VPD queries to determine available SCSI
delete methods within scsi_da.

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 2 weeks


249934 26-Apr-2013 smh

Updated TRIM calculations in cam/ata to be based off ATA_DSM_* defines

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 2 weeks


249933 26-Apr-2013 smh

Added the ability to send ATA identify and Data Set Management (DSM) TRIM
commands to an ATA device attached via a SCSI control.

sys/cam/scsi/scsi_all.c:
- Added scsi_ata_identify, scsi_ata_trim
Which use ATA Pass-Through to send commands to the attached disk.

sys/cam/scsi/scsi_all.h:
- Added defines for all missing ATA Pass-Through commands values.

- Added scsi_ata_identify, scsi_ata_trim methods used in ATA TRIM
support.

- Added scsi_vpd_logical_block_prov structure used when querying for
the supported sizes UNMAP commands.

- Added scsi_vpd_block_limits structure used when querying for the
supported sizes of the UNMAP command.

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 2 weeks


249929 26-Apr-2013 smh

Removed unneeded tests in dadeletemethodset changing it to return void

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 2 weeks


249701 20-Apr-2013 ken

Fix compilation.

Pointy hat to: ken


249664 20-Apr-2013 sbruno

Expose CAM_BOOT_DELAY as a kernel conf item now.

This allows users who boot without loader to adjust their environments
around slightly buggy or slow hardware.

PR: kern/161809
Submitted by: rozhuk.im@gmail.com
MFC after: 2 weeks


249658 19-Apr-2013 ken

Update chio(1) and ch(4) to support reporting element designators.

This allows mapping a tape drive in a changer (as reported by
'chio status') to a sa(4) driver instance by comparing the
serial numbers.

The designators can be ASCII (which is printed out directly), binary
(which is printed in hex format) or UTF-8, which is printed in either
native UTF-8 format if the terminal can support it, or in %XX notation
for non-ASCII characters. Thanks to Hiroki Sato <hrs@> for the
explaining UTF-8 printing and example UTF-8 printing code.

chio.h: Modify the changer_element_status structure to add new
fields and definitions from the SMC3r16 spec.

Rename the original CHIOGSTATUS ioctl to OCHIOGTATUS and
define a new CHIOGSTATUS ioctl.

Clean up some tab/space issues.

chio.c: For the 'status' subcommand, print the designator field
if it is supplied by a device.

scsi_ch.h: Add new flags for DVCID and CURDATA to the READ
ELEMENT STATUS command structure.

Add a read_element_status_device_id structure
for the data fields in the new standard. Add new
unions, dt_or_obsolete and voltage_devid, to hold
and address data from either SCSI-2 or newer devices.

scsi_ch.c: Implement support for fetching device IDs with READ
ELEMENT STATUS data.

Add new arguments to scsi_read_element_status() to
allow the user to request the DVCID and CURDATA bits.
This isn't compiled into libcam (it's only an internal
kernel interface), so we don't need any special
handling for the API change.

If the user issues the new CHIOGSTATUS ioctl, copy all of
the available element status data out. If he issues the
OCHIOGSTATUS ioctl, we don't copy the new fields in the
structure.

Fix a bug in chopen() that would result in the peripheral
never getting unheld if chgetparams() failed.

Sponsored by: Spectra Logic
Submitted by: Po-Li Soong
MFC After: 1 week


249585 17-Apr-2013 gabor

- Corrrect mispellings of word useful

Submitted by: Christoph Mallon <christoph.mallon@gmx.de> (via private mail)


249582 17-Apr-2013 gabor

- Correct mispellings of the word occurrence

Submitted by: Christoph Mallon <christoph.mallon@gmx.de> (via private mail)


249481 14-Apr-2013 mav

Remove some more pieces of multilevel freeze mechanism, missed in r249466.


249470 14-Apr-2013 mav

Remove owner field from struct cam_ed, unused at least since FreeBSD 7.


249468 14-Apr-2013 mav

MFprojects/camlock r248982:
Stop abusing xpt_periph in random plases that really have no periph related
to CCB, for example, bus scanning. NULL value is fine in such cases and it
is correctly logged in debug messages as "noperiph". If at some point we
need some real XPT periphs (alike to pmpX now), quite likely they will be
per-bus, and not a single global instance as xpt_periph now.


249466 14-Apr-2013 mav

MFprojects/camlock r248890, r248897, r248898, r248900, r248903, r248905,
r248917, r248918, r248978, r249001, r249014, r249030:

Remove multilevel freezing mechanism, implemented to handle specifics of
the ATA/SATA error recovery, when post-reset recovery commands should be
allocated when queues are already full of payload requests. Instead of
removing frozen CCBs with specified range of priorities from the queue
to provide free openings, use simple hack, allowing explicit CCBs over-
allocation for requests with priority higher (numerically lower) then
CAM_PRIORITY_OOB threshold.

Simplify CCB allocation logic by removing SIM-level allocation queue.
After that SIM-level queue manages only CCBs execution, while allocation
logic is localized within each single device.

Suggested by: gibbs


249438 13-Apr-2013 mav

MFprojects/camlock r248894:
Use full freeze while PMP does hard reset. This is only cosmetical change.


249410 12-Apr-2013 trasz

Remove ctl(4) from GENERIC. Also remove 'options CTL_DISABLE'
and kern.cam.ctl.disable tunable; those were introduced as a workaround
to make it possible to boot GENERIC on low memory machines.

With ctl(4) being built as a module and automatically loaded by ctladm(8),
this makes CTL work out of the box.

Reviewed by: ken
Sponsored by: FreeBSD Foundation


249352 11-Apr-2013 mav

Do not sent 120 TEST UNIT READY requests on generic NOT READY statuses.

Some failing disks tend to return vendor-specific ASC/ASCQ codes with
NOT READY sense key. It caused extremely long recovery attempts, repeating
these 120 TURs (it takes at least 1 minute) for every I/O request.
Instead of that use default error handling, doing just few retries.

Reviewed by: ken, gibbs
MFC after: 1 month


249347 10-Apr-2013 ken

Add a callback to the ada(4) driver so that it knows when GEOM has released
references to it.

This is the functional equivalent to change r237518, which added this
functionality to the cd(4) and da(4) drivers.

This fix prevents a panic caused by GEOM calling adaopen() while the device
is going away. We now keep the device around until GEOM has finished
cleaning up its state.

ata_da.c: In adaregister(), add a d_gone callback to the GEOM disk
structure registered for the ada driver. Increment the
peripheral reference count for GEOM.

Add a new callback, adadiskgonecb(), that GEOM calls when
it is done with its resources. This callback releases the
reference acquired in adaregister().

Submitted by: Po-Li Soong
Sponsored by: Spectra Logic
MFC After: 5 days


249256 08-Apr-2013 ken

Fix a memory leak that showed up when we delete LUNs. The memory used for
the LUN was never freed.

ctl.c: Adjust ctl_alloc_lun() to make sure we don't clear the
CTL_LUN_MALLOCED flag.

Reported by: Sreenivasa Honnur <shonnur@chelsio.com>
Sponsored by: Spectra Logic
MFC after: 3 days


249224 07-Apr-2013 mav

Remove extra semicolons from CAM_SIM_[UN]LOCK() macros.


249213 06-Apr-2013 marius

- With the demise of !ATA_CAM, ATA_STATIC_ID is the only ata(4) related
option left but actually consumed by ada(4), so move it to opt_ada.h
and get rid of opt_ata.h.
- Fix stand-alone build of atacore(4) by adding opt_cam.h.
- Use __FBSDID.
- Use DEVMETHOD_END.
- Use NULL instead of 0 for pointers.


249205 06-Apr-2013 mav

Replicate r245306 from SCSI to ATA. The problem didn't appear so far,
covered by multilevel freeze mechanism, but it is better to be safe.


249199 06-Apr-2013 marius

Unbreak ATA_NO_48BIT_DMA with ATA_CAM by treating 48-bit DMA as an
optional property with PATA transport.

Reviewed by: mav
MFC after: 3 days


249194 06-Apr-2013 trasz

Make SYNCHRONIZE CACHE work with LUNs backed by device files (as opposed
to regular files, which already worked fine). With this change, it's no
longer neccessary to use "ctladm realsync off" workaround.


249108 04-Apr-2013 mav

MFprojects/camlock:
r249017:
Some cosmetic things:
- Unify device to target insertion inside xpt_alloc_device() instead of
duplicating it three times.
- Remove extra checks for empty lists of devices and targets on release
since zero refcount check also implies it.
- Reformat code to reduce indentation.

r249103:
- Add lock assertions to every point where reference counters are modified.
- When reference counters are reaching zero, add assertions that there are
no children items left.
- Add a bit more locking to the xptpdperiphtraverse().


249106 04-Apr-2013 mav

MFprojects/camlock r248931:
Replace some direct mutex operations with wrappers.

MFC after: 2 weeks


249105 04-Apr-2013 mav

MFprojects/camlock r248930:
Remove extra NULL checks. d_drv1 can never be NULL during periph life cycle.

MFC after: 2 weeks


249104 04-Apr-2013 mav

MFprojects/camlock r248928:
Move CAM_DEBUG_CDB messages from the point of queuing to the point of
sending to SIM. That allows to inspect real requests execution order,
respecting priorities, freezing, etc.

MFC after: 2 weeks


249102 04-Apr-2013 trasz

Since the CTL version in FreeBSD does not support High Availability,
ctl_is_single should always be set to 1. Make it so. Previously
it was always 0, because ctl_isc_start() never got to run.

Suggested by: ken


249099 04-Apr-2013 mav

Remove xpt_sim_opened(), the only consumer of which was atapicam, which is
now gone.


249091 04-Apr-2013 mav

Use xpt_lock_buses() instead of equivalent mtx_lock(&xsoftc.xpt_topo_lock)
to unify the code.


249083 04-Apr-2013 mav

Remove all legacy ATA code parts, not used since options ATA_CAM enabled in
most kernels before FreeBSD 9.0. Remove such modules and respective kernel
options: atadisk, ataraid, atapicd, atapifd, atapist, atapicam. Remove the
atacontrol utility and some man pages. Remove useless now options ATA_CAM.

No objections: current@, stable@
MFC after: never


249065 03-Apr-2013 trasz

Fix locking problem in ctl_maintenance_in() - one cannot use M_WAITOK or call
ctl_done() with mutex held.

Reviewed by: ken
Sponsored by: FreeBSD Foundation


249048 03-Apr-2013 mav

Add xpt_release_ccb()'s missed at r248872. That made `shutdown -p` stuck
on controller with small number of queue slots and several disks connected.


249028 02-Apr-2013 ken

Fix sending virtual scatter/gather lists from the CTL CAM frontend
peripheral.

Sponsored by: Spectra Logic


249026 02-Apr-2013 trasz

Don't directly dereference userland pointer; instead use kernel pointer
copied in from userspace. This fixes instant panic when creating CTL LUN
on sparc64. Not a security problem, since the API is root-only.

Reviewed by: ken
Sponsored by: FreeBSD Foundation


249019 02-Apr-2013 trasz

Fix comment formatting.


249012 02-Apr-2013 trasz

Remove unused code.

Reviewed by: ken


249009 02-Apr-2013 trasz

Make it possible to build CTL as a module.

Reviewed by: ken
Sponsored by: FreeBSD Foundation


249008 02-Apr-2013 trasz

Fix panic in the error path caused by recursive acquisition of XPT topology
lock.

Reviewed by: ken


248992 02-Apr-2013 smh

Added ATA Pass-Through support to CAM

sys/cam/scsi/scsi_all.c:
- Added scsi_ata_pass_16 method
Which use ATA Pass-Through to send commands to the attached disk.

sys/cam/scsi/scsi_all.h:
- Added defines for all missing ATA Pass-Through commands values.

- Added scsi_ata_pass_16 method.

- Fixed a comment typo while I'm here

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 2 weeks


248922 29-Mar-2013 smh

Adds the ability to enable / disable sorting of BIO requests queued within
CAM. This can significantly improve performance particularly for SSDs
which don't suffer from seek latencies.

The sysctl / tunable kern.cam.sort_io_queues provides the systems default
setting where:-
0 = queued BIOs are NOT sorted
1 = queued BIOs are sorted (default)

Each device gets its own sysctl kern.cam.<type>.<id>.sort_io_queue
Valid values are:-
-1 = use system default (default)
0 = queued BIOs are NOT sorted
1 = queued BIOs are sorted

Note: Additional patch will look to add automatic use of none sorted queues
for none rotating media e.g. SSD's

Reviewed by: scottl
Approved by: pjd (mentor)
MFC after: 2 weeks


248874 29-Mar-2013 marius

Unbreak compilation after r248868.


248872 29-Mar-2013 mav

Make pre-shutdown flush and spindown routines to not use xpt_polled_action(),
but execute the commands in regular way. There is no any reason to cook CPU
while the system is still fully operational. After this change polling in
CAM is used only for kernel dumping.


248868 29-Mar-2013 mav

Implement CAM_PERIPH_FOREACH() macro, safely iterating over the list of
driver's periphs, acquiring and releaseing periph references while doing it.

Use it to iterate over the lists of ada and da periphs when flushing caches
and putting devices to sleep on shutdown and suspend. Previous code could
panic in theory if some device disappear in the middle of the process.


248800 27-Mar-2013 mav

On SIM destruction free associated CCBs, preallocated inside xpt_get_ccb().
Before this change they were just leaked. Fortunately USB sticks now use
only one CCB, and so leak was only 2KB per detach, while other bigger SIMs
with much more allocated CCBs are rarely detached.

MFC after: 2 weeks


248695 25-Mar-2013 mav

Remove two bzero()s that are erasing only few more bytes then set later.


248520 19-Mar-2013 kib

Commit the removal of a whitespace to record the proper commit message
for the r248519:

For the cam-attached HBAs, allow the driver to specify that it accepts
the unmapped bio by the PIM_UNMAPPED flag. The CAM passes the
CAM_DATA_BIO data transfer type request for the unmapped bio, and the
driver could use the bus_dmamap_load_ccb() as a helper to
transparently handle the ccb.

Sponsored by: The FreeBSD Foundation
Reviewed by: scottl
Tested by: pho, scottl


248519 19-Mar-2013 kib

Support unmapped i/o for the md(4).

The vnode-backed md(4) has to map the unmapped bio because VOP_READ()
and VOP_WRITE() interfaces do not allow to pass unmapped requests to
the filesystem. Vnode-backed md(4) uses pbufs instead of relying on
the bio_transient_map, to avoid usual md deadlock.

Sponsored by: The FreeBSD Foundation
Tested by: pho, scottl


248515 19-Mar-2013 kib

Do not remap usermode pages into KVA for physio.

Sponsored by: The FreeBSD Foundation
Tested by: pho


248501 19-Mar-2013 kib

Assert that a ccb passed to cam_periph_mapmem() for XPT_SCSI_IO and
XPT_ATA_IO holds virtual buffer address.

Sponsored by: The FreeBSD Foundation
Tested by: pho


247814 04-Mar-2013 ken

Re-enable CTL in GENERIC on i386 and amd64, but turn on the CTL disable
tunable by default.

This will allow GENERIC configurations to boot on small memory boxes, but
not require end users who want to use CTL to recompile their kernel. They
can simply set kern.cam.ctl.disable=0 in loader.conf.

The eventual solution to the memory usage problem is to change the way
CTL allocates memory to be more configurable, but this should fix things
for small memory situations in the mean time.

UPDATING: Explain the change in the CTL configuration, and
how users can enable CTL if they would like to use
it.

sys/conf/options: Add a new option, CTL_DISABLE, that prevents CTL
from initializing.

ctl.c: If CTL_DISABLE is turned on, don't initialize.

i386/conf/GENERIC,
amd64/conf/GENERIC: Re-enable device ctl, and add the CTL_DISABLE
option.


247161 22-Feb-2013 mav

Hide SEMB port of the SiI3826 Port Multiplier by default to avoid extra
errors while it tries to talk via I2C to usually missing external SEP.
There is tunable to enable it back when needed.


247154 22-Feb-2013 mav

Add DA_Q_NO_PREVENT quirk for Kingston DataTraveler G3 1.00 USB flash.

PREVENT ALLOW MEDIUM REMOVAL commands return errors on these devices
without returning sense data. In some cases unrelated following commands
start to return errors too, that makes device to be dropped by CAM.


246713 12-Feb-2013 kib

Reform the busdma API so that new types may be added without modifying
every architecture's busdma_machdep.c. It is done by unifying the
bus_dmamap_load_buffer() routines so that they may be called from MI
code. The MD busdma is then given a chance to do any final processing
in the complete() callback.

The cam changes unify the bus_dmamap_load* handling in cam drivers.

The arm and mips implementations are updated to track virtual
addresses for sync(). Previously this was done in a type specific
way. Now it is done in a generic way by recording the list of
virtuals in the map.

Submitted by: jeff (sponsored by EMC/Isilon)
Reviewed by: kan (previous version), scottl,
mjacob (isp(4), no objections for target mode changes)
Discussed with: ian (arm changes)
Tested by: marius (sparc64), mips (jmallet), isci(4) on x86 (jharris),
amd64 (Fabian Keil <freebsd-listen@fabiankeil.de>)


246146 31-Jan-2013 smh

Format CDB output as 2 digit hex correcting the length

Approved by: pjd (mentor)
MFC after: 1 week


245891 24-Jan-2013 jh

Sanitize the element descriptor string before using it as a device name.

Reported and tested by: Vitalij Satanivskij
Reviewed by: gibbs, mav


245647 19-Jan-2013 kan

Do not pretend to have autosense data when no such data is available.

Make umass return an error code if SCSI sense retrieval request
has failed. Make sure scsi_error_action honors SF_NO_RETRY and
SF_NO_RECOVERY in all cases, even if it cannot parse sense bytes.

Reviewed by: hselasky (umass), scottl (cam)


245310 11-Jan-2013 mav

- Add missig xpt_schedule() call for cases when requested immediate CCB
priority is lower then payload/TUR one.

- Reduce TUR priority and avoid sending them if there are any other
outstanding commands, alike to DA driver.


245306 11-Jan-2013 mav

Do not schedule periph for payload/TUR requests if reprobe is in progress
to avoid sending extra READ CAPACITY requests by dastart(). Schedule periph
again on reprobe completion, or otherwise it may stuck indefinitely long.

This should fix USB explore thread hanging on device unplug, waiting for
periph destruction.

Reported by: hselasky


245253 10-Jan-2013 smh

Changed scsi_da device requests to use the sysctl tunable value for retry_count
and da_default_timeout where their current hardcoded values matched the current
default value for said tunables.

PR: kern/169976
Reviewed by: pjd (mentor)
Approved by: mav


245252 10-Jan-2013 smh

Updates delete_method sysctl changes to always maintain disk d_flags
DISKFLAG_CANDELETE. While this change makes this layer consistent
other layers such as UFS and ZFS BIO_DELETE support may not notice
any change made manually via these device sysctls until the device
is reopened via a mount.

Also corrected var order in dadeletemethodsysctl

PR: kern/169801
Reviewed by: pjd (mentor)
Approved by: mav
MFC after: 2 weeks


245251 10-Jan-2013 smh

Removes essentially unused variables from scsi_da probe setups

PR: kern/169835
Reviewed by: pjd (mentor)
Approved by: mav
MFC after: 2 weeks


245228 09-Jan-2013 ken

Make CTL work a little better with loading and unloading drivers.

Previously CTL would leave individual LUNs enabled in the target
driver, whether or not the port as a whole was enabled. It would
also leave the wildcard LUN enabled indefinitely.

This change means that CTL will enable and disable any active LUNs,
as well as the wildcard LUN, when enabling and disabling a port.

Also, fix a bug that could crop up due to an uninitialized CCB
type.

ctl.c: Before calling ctl_frontend_online(), run through
the LUN list and enable all active LUNs.

After calling ctl_frontend_offline(), run through
the LUN list and disble all active LUNs.

scsi_ctl.c: Before bringing a port online, allocate the
wildcard peripheral for that bus. And after taking
a port offline, invalidate the wildcard peripheral
for that bus.

Make sure that we hold the SIM lock around all
calls to xpt_action() and other transport layer
interfaces that require it.

Use CAM_SIM_{LOCK|UNLOCK} consistently to acquire
and release the SIM lock.

Update a number of outdated comments. Some of
these should have been fixed long ago.

Actually do LUN disbables now. The newer drivers
in the tree work correctly for this as far as I
know.

Initialize the CCB type to CTLFE_CCB_DEFAULT to
avoid a panic due to uninitialized memory.

Submitted by: Chuck Tuffli (partially)
MFC after: 1 week


244508 20-Dec-2012 mav

Make SES driver to not fall out on some errors in Additional Status page.
This allows CAM devices still get their physical paths even if status of
later elements it corrupted.

Sponsored by: iXsystems, Inc.


244418 19-Dec-2012 mav

Fix bug in r242720, that caused additional status page to not be used if
descriptor page is supported.


244052 09-Dec-2012 ken

Fix a couple of CTL locking issues and clean up some duplicated code.

ctl_frontend_cam_sim.c: Coalesce cfcs_online() and cfcs_offline()
into a single function since these were
identical except for one line.

Make sure we hold the SIM lock around path
creation, and calling xpt_rescan().

scsi_ctl.c: In ctlfe_onoffline(), make sure we hold the
SIM lock around path creation and free
calls, as well as xpt_action().

In ctlfe_lun_enable(), hold the SIM lock
around path and peripheral operations that
require it.

Sponsored by: Spectra Logic Corporation
MFC after: 1 week


244016 08-Dec-2012 ken

Make sure we hold the SIM lock when calling xpt_free_path().

Sponsored by: Spectra Logic Corporation
MFC after: 1 week


244015 08-Dec-2012 ken

Fix the CTL OOA queue dumping code so that it does not hold a mutex
while doing a copyout. That can cause a panic, because copyout
can trigger VM faults, and we can't handle VM faults while holding
a mutex.

The solution here is to malloc a separate buffer to hold the OOA
queue entries, so that we don't risk a VM fault while filling up
the buffer and we don't have to drop the lock. The other solution
would be to wire the user's memory while filling their buffer with
copyout, but that would have been a little more complex.

Also fix a debugging parenthesis issue in ctl_abort_task() pointed
out by Chuck Tuffli.

Sponsored by: Spectra Logic Corporation
MFC after: 1 week


244014 08-Dec-2012 ken

Fix a device departure bug for the the pass(4), enc(4), sg(4) and ch(4)
drivers.

The bug occurrs when a userland process has the driver instance
open and the underlying device goes away. We get the devfs
callback that the device node has been destroyed, but not all of
the closes necessary to fully decrement the reference count on the
CAM peripheral.

The reason is that once devfs calls back and says the device has
been destroyed, it is moved off to deadfs, and devfs guarantees
that there will be no more open or close calls. So the solution
is to keep track of how many outstanding open calls there are on
the device, and just release that many references when we get the
callback from devfs.

scsi_pass.c,
scsi_enc.c,
scsi_enc_internal.h: Add an open count to the softc in these
drivers. Increment it on open and
decrement it on close.

When we get a devfs callback to say that
the device node has gone away, decrement
the peripheral reference count by the
number of still outstanding opens.

Make sure we don't access the peripheral
with cam_periph_unlock() after what might
be the final call to
cam_periph_release_locked(). The
peripheral might have been freed, and we
will be dereferencing freed memory.

scsi_ch.c,
scsi_sg.c: For the ch(4) and sg(4) drivers, add the
same changes described above, and in
addition, fix another bug that was
previously fixed in the pass(4) and enc(4)
drivers.

These drivers were calling destroy_dev()
from their cleanup routine, but that could
cause a deadlock because the cleanup
routine could be indirectly called from
the driver's close routine. This would
cause a deadlock, because the device node
is being held open by the active close
call, and can't be destroyed.

Sponsored by: Spectra Logic Corporation
MFC after: 1 week


244001 07-Dec-2012 ken

Fix a panic during CAM EDT traversal.

The problem was a race condition between the EDT traversal used by
things like 'camcontrol devlist', and CAM peripheral driver
removal.

The EDT traversal code holds the CAM topology lock, and wants
to show devices that have been invalidated. It acquires a
reference to the peripheral to make sure the peripheral it is
examining doesn't go away.

However, because the peripheral removal code in camperiphfree()
drops the CAM topology lock to call the peripheral's destructor
routine, we can run into a situation where the EDT traversal
increments the peripheral reference count after free process is
already in progress. At that point, the reference count is
ignored, because it was 0 when we started the process.

Fix this race by setting a flag, CAM_PERIPH_FREE, that I previously
added and checked in xptperiphtraverse() and xptpdperiphtravsere(),
but failed to use. If the EDT traversal code sees that flag,
it will know that the peripheral free process has already started,
and that it should not access that peripheral.

Also, fix an inconsistency in the locking between
xptpdperiphtraverse() and xptperiphtraverse(). They now both
hold the CAM topology lock while calling the peripheral traversal
function.

cam_xpt.c: Change xptperiphtraverse() to hold the CAM topology
lock across calls to the traversal function.

Take out the comment in xptpdperiphtraverse() that
referenced the locking inconsistency.

cam_periph.c: Set the CAM_PERIPH_FREE flag when we are in the
process of freeing a peripheral driver.

Sponsored by: Spectra Logic Corporation
MFC after: 1 week


243571 26-Nov-2012 mav

Fix problem with the Samsung 840 PRO series SSD detection.
The device reports support for SATA Asynchronous Notification in its
IDENTIFY data, but returns error on attempt to enable that feature.
Make SATA XPT of CAM only report these errors, but not fail the device.

MFC after: 1 week


242720 07-Nov-2012 mav

Use information about suported diagnostic pages to avoid reading optional
Element Descriptor page if it is not supported. This removes one error
message from verbose logs during boot on systems with some enclosures.

Sponsored by: iXsystems, Inc.


242358 30-Oct-2012 trasz

Use M_ZERO instead of explicit memsets and bzeros.


242322 29-Oct-2012 trasz

Fix locking problem in disk_resize(); previously it would run without
topology lock, resulting in assertion when running with DIAGNOSTIC.

Reviewed by: mav (earlier version)


242175 27-Oct-2012 mav

Remove priority enforcement from xpt_ation(). It is not good and even not
safe in some cases to reduce CCB priority after it was scheduled with high
priority. This fixes reproducible deadlock when command sent through the
pass interface while ATA XPT recovers from command timeout.

Instead of that enforce priority at passioctl(). libcam provides no obvious
interface to specify CCB priority and so much (all?) code specifies zero
(highest) priority. This change limits pass CCBs priority to NORMAL run
level, allowing XPT to complete bus and device recovery after reset before
running any payload.


242174 27-Oct-2012 mav

Remove several uses of numeric priorities from immediate CCB setups.


242173 27-Oct-2012 mav

Remove one more numeric priority constant.


241952 23-Oct-2012 mav

Remove two more 'periph == NULL' checks missed in r241404.
This condition can never be true as functions are called from single place
and the checks just pollute the code and confuse Clang Static Analyzer.


241896 22-Oct-2012 kib

Remove the support for using non-mpsafe filesystem modules.

In particular, do not lock Giant conditionally when calling into the
filesystem module, remove the VFS_LOCK_GIANT() and related
macros. Stop handling buffers belonging to non-mpsafe filesystems.

The VFS_VERSION is bumped to indicate the interface change which does
not result in the interface signatures changes.

Conducted and reviewed by: attilio
Tested by: pho


241844 22-Oct-2012 eadler

remove duplicate semicolons where possible.

Approved by: cperciva
MFC after: 1 week


241784 20-Oct-2012 eadler

Adds 4K quirks for the some SSD's which all perform better when 4K
aligned and only except 4K deletes (TRIM).

PR: kern/169974
Submitted by: Steven Hartland <steven.hartland@multiplay.co.uk>
Tested by: ak
Reviewed by: mav
Approved by: cperciva (implicit)
MFC after: 1 week


241613 16-Oct-2012 eadler

Add support for samsung HM250JI

PR: usb/121474
Submitted by: Ben Stuyts <ben@altesco.nl>
Approved by: cperciva (implicit)
MFC after: 3 days


241580 15-Oct-2012 eadler

Add support for the USB DISK Pro PMAP.

This patch has sit for 6 years in the PR database.

PR: usb/96381
Submitted by: jhs
Reviewed by: mav
Approved by: cperciva (implicit)
MFC after: 3 days


241536 14-Oct-2012 mav

Add explicit check for not set time inside cam_periph_freeze_after_event().

System time is set later on boot process then initial bus scan by CAM.
Until that moment microtime() is equal to microuptime(), and if system
boots quickly, the value can be close to zero. That causes settle time
waiting even for buses that don't use reset during probe.

On my test system this reduces boot time by 1 second if USB enabled, or
by 4 seconds if USB disabled. CAM waited for ctl2cam0 bus "settle".


241510 13-Oct-2012 mav

Don't exclude XPT SIM from locking in xpt_create_path_unlocked().
We don't want xpt periph, device, target or bus disappeared because of
incorrect reference counting.


241509 13-Oct-2012 mav

Use xpt_create_path_unlocked() for initial debug path compilation because
we are not holding respective SIM lock.


241508 13-Oct-2012 mav

Extend SIM lock coverage during the bus registration process.


241504 13-Oct-2012 mav

Fix XPT_DEBUG paths operations locking:
- Extend the lock to cover xpt_path_release() for the new path.
- While xpt_action() is called while holding right SIM lock for the new
bus, the old path release may require different SIM lock. So we have
to temporary drop the new lock and get the old one.


241503 13-Oct-2012 mav

XPT_DEV_MATCH is probably the only xpt_action() method that is called
without holding SIM lock. It really doesn't need that lock, but adding it
removes that specific exception, allowing to assert locking there later.

Submitted by: ken@ (earlier version)


241488 12-Oct-2012 mav

Get SIM lock in several places while calling CAM functions.
This fixes several use-after-free panics on systems with SAS enclosures.

Submitted by: ken@, mav@


241485 12-Oct-2012 mav

Protect xpt_getattr() calls with the SIM lock and assert that.

Submitted by: ken@ (earlier version)


241456 11-Oct-2012 mav

Use separate malloc buckets for CAM devices, CCBs and paths. This will
make it easier to track down the source of any use after free problems.

Submitted by: ken@


241455 11-Oct-2012 mav

Don't duplicate path/ccb allocation code, use existing functions.


241444 11-Oct-2012 mav

Increase device CCB queue array size by CAM_RL_VALUES - 1 (4) elements.
It is required to store extra recovery requests in case of bus resets.
On ATA/SATA this fixes assertion panics on HEAD with INVARIANTS enabled or
possible memory corruptions otherwise if timeout/reset happens when device
CCB queue is already full.

Reported by: gibbs@
MFC after: 1 week


241410 10-Oct-2012 mav

There are SCSI conditions that are not an errors. In those cases cderror()
returns zero while request status is not CAM_REQ_CMP. That could cause
partial device attach or other unexpected results.

Found by: Clang Static Analyzer


241405 10-Oct-2012 mav

Really handle xpt_compile_path() error in xpt_bus_register() instead of
print error message and probably crash just after it on NULL dereference.

Found by: Clang Static Analyzer


241404 10-Oct-2012 mav

Remove 'periph == NULL' check from bunch of periph drivers.
This condition can never be true as functions are called from single place
and the checks just pollute the code and confuse Clang Static Analyzer.


241305 06-Oct-2012 avg

ata_da: set disk::d_ident from serial number

MFC after: 10 days


241028 28-Sep-2012 mav

Change queue overflow checks from DIAGNOSTIC+panic() to KASSERT() to make
them enabled on HEAD by default. It is probably better to do single compare
then hunt for unexpected memory corruption.


240993 27-Sep-2012 trasz

Remove useless NULL checks after M_WAITOK allocations.


240948 26-Sep-2012 trasz

Fix panic in CTL caused by trying to free invalid pointers passed
by the userland process via the IOCTL interface.

Reviewed by: ken@


240701 19-Sep-2012 tijl

Fix a panic when trying to play invalid audio tracks.


240521 14-Sep-2012 eadler

s/ is is / is /g
s/ a a / a /g

Approved by: cperciva
MFC after: 3 days


240325 10-Sep-2012 jhb

Remove some more NetBSD compat shims and other unused bits from these
drivers:
- Remove scsi_low_pisa.*, they were unused.
- Remove <compat/netbsd/physio_proc.h> and calls to the stubs in that
header. They were empty nops.
- Retire sl_xname and use device_get_nameunit() and device_printf() with
the underlying device_t instead.
- Remove unused {ct,ncv,nsp,stg}print() functions.
- Remove empty SOFT_INTR_REQUIRED() macro and the unused sl_irq member.


240172 06-Sep-2012 jhb

Remove NetBSD compat shims for drivers originally shared with NetBSD/pc98.
NetBSD/pc98 was never merged into the main NetBSD tree and is no longer
developed. Adding locking to these drivers would have made the compat
shims hard to impossible to maintain, so remove the shims to ease
future changes.

These changes were verified by md5. Some additional shims can be removed
that do affect the compiled results that I will probably do in another
round.

Approved by: nyan (tentatively)


239655 24-Aug-2012 jimharris

Fix scsi_da's BIO_DELETE->SCSI_UNMAP translation to use correct local
variable when determining various sizes related to SCSI UNMAP block
descriptor lists.

Sponsored by: Intel
Reviewed by: mav
MFC after: 3 days


239213 12-Aug-2012 mjacob

1. Remove SEN support. I doubt there are any working examples
of this hardware still running (close to twenty years now).

2. Quiesece and use ENC_VLOG instead of ENC_LOG for most
complaints. That is, they're visible with bootverbose, but
otherwise quiesced and not repeatedly spamming messages
with constant reminders that hardware in this space is
rarely fully compliant.

MFC after: 1 month


239212 12-Aug-2012 mjacob

Add missing VERIFY_10 definition.

MFC after: 1 month


238894 30-Jul-2012 bz

Remove opt_enc.h from files committed with r235911. enc(4) is the
'encapsulating interface' used with IPsec and has nothing to do with
storage 'enclosure' services.

MFC after: 3 days
Noticed while: debugging why enc(4) is no longer automatically created


238886 29-Jul-2012 mav

Implement media change notification for DA and CD removable media devices.
It includes three parts:
1) Modifications to CAM to detect media media changes and report them to
disk(9) layer. For modern SATA (and potentially UAS) devices it utilizes
Asynchronous Notification mechanism to receive events from hardware.
Active polling with TEST UNIT READY commands with 3 seconds period is used
for incapable hardware. After that both CD and DA drivers work the same way,
detecting two conditions: "NOT READY: Medium not present" after medium was
detected previously, and "UNIT ATTENTION: Not ready to ready change, medium
may have changed". First one reported to disk(9) as media removal, second
as media insert/change. To reliably receive second event new
AC_UNIT_ATTENTION async added to make UAs broadcasted to all periphs by
generic error handling code in cam_periph_error().
2) Modifications to GEOM core to handle media remove and change events.
Media removal handled by spoiling all consumers attached to the provider.
Media change event also schedules provider retaste after spoiling to probe
new media. New flag G_CF_ORPHAN was added to consumers to reflect that
consumer is in process of destruction. It allows retaste to create new
geom instance of the same class, while previous one is still dying.
3) Modifications to some GEOM classes: DEV -- to report media change
events to devd; VFS -- to handle spoiling same as orphan to prevent
accessing replaced media. PART class already handles spoiling alike to
orphan.

Reviewed by: silence on geom@ and scsi@
Tested by: avg
Sponsored by: iXsystems, Inc. / PC-BSD
MFC after: 2 months


238870 28-Jul-2012 mjacob

Handle a case where we had an SRR that pushed back the
data pointer. This is a temp fix that resubmits the
command, adjusted, so that the backend can fetch the
data again.

Sponsored by: Spectralogic
MFC after: 1 month


238740 24-Jul-2012 mav

Fix off by one error in ses_enc_desc_last_byte().


238739 24-Jul-2012 mav

Do not call ses_softc_cleanup() in case of configuration read failure.
Just free inclomplete daemon cache instead to let it retry next time.
Premature ses_softc_cleanup() caused NULL dereference when freed softc
was accessed later.


238596 18-Jul-2012 mav

Fix some typos in r238595.

Reported by: brueffer


238595 18-Jul-2012 mav

Add bunch of new ASC/ASCQ values from T10 site.


238437 14-Jul-2012 mjacob

The call to disk_resize causes a panic if DIAGNOSTIC is set.
Coping with that while the finest minds of our generation
figure out why.


238393 12-Jul-2012 brueffer

Add and utilize defines for the ATA device register.

PR: 169764
Submitted by: Steven Hartland <steven.hartland@multiplay.co.uk>
Reviewed by: mav
MFC after: 2 weeks


238382 11-Jul-2012 brueffer

Apply similar same change as in r238379:

Renamed the kern.cam.ada.ada_send_ordered sysctl and tunable to
kern.cam.ada.send_ordered, more in line with the other da sysctls/tunables.

Suggested by: kib


238379 11-Jul-2012 brueffer

Renamed the kern.cam.da.da_send_ordered sysctl and tunable to
kern.cam.da.send_ordered, more in line with the other da sysctls/tunables.

PR: 169765
Submitted by: Steven Hartland <steven.hartland@multiplay.co.uk>
Reviewed by: mav


238363 11-Jul-2012 brueffer

- fix description of SECURITY_FREEZE_LOCK (1)
- add missing underscores to SECURITY_DISABLE_PASSWORD

PR: 169763 (1)
Submitted by: Steven Hartland <steven.hartland@multiplay.co.uk>
Reviewed by: mav
MFC after: 1 week


238217 07-Jul-2012 trasz

Make the da(4) driver notify GEOM about LUN size change.

Reviewed by: mav
Sponsored by: FreeBSD Foundation


238200 07-Jul-2012 eadler

Remove variables which are initialized but never used thereafter
reported by gcc46 warning

Reviewed by: scottl
Approved by: cperciva
MFC after: 1 week


237726 28-Jun-2012 ken

Add a loader tunable, kern.cam.ctl.disable, that will disable
loading CTL. This may be useful in very low memory installations.

MFC after: 3 days


237689 28-Jun-2012 imp

Add a sysctl to set the cdrom timeout. Data recovery operations from
a CD or DVD drive with a damaged disc often benefit from a shorter
timeout. Also, when retries are set to 0, an application is expecting
errors and recovering them so do not print the error into the log.
The number of expected errors can literally be in the hundreds of
thousands which significantly slows data recovery.

Reviewed by: ken@ (but quite some time ago).


237682 28-Jun-2012 ken

Fix a typo in a panic() call.

PR: kern/169497
Submitted by: Steven Hartland <steven.hartland@multiplay.co.uk>
MFC after: 3 days


237601 26-Jun-2012 ken

Fix an issue that caused the kernel to panic inside CTL when trying
to attach to target capable HBAs that implement the old immediate
notify (XPT_IMMED_NOTIFY) and notify acknowledge (XPT_NOTIFY_ACK)
CCBs. The new API has been in place since SVN change 196008 in
2009.

The solution is two-fold: fix CTL to handle the responses from the
HBAs, and convert the HBA drivers in question to use the new API.

These drivers have not been tested with CTL, so how well they will
interoperate with CTL is unknown.

scsi_target.c: Update the userland target example code to use the
new immediate notify API.

scsi_ctl.c: Detect when an immediate notify CCB is returned
with CAM_REQ_INVALID or CAM_PROVIDE_FAIL status,
and just free it.

Fix a duplicate assignment.

aic79xx.c,
aic79xx_osm.c: Update the aic79xx driver to use the new API.
Target mode is not enabled on for this driver, so
the changes will have no practical effect.

aic7xxx.c,
aic7xxx_osm.c: Update the aic7xxx driver to use the new API.

sbp_targ.c: Update the firewire target code to work with the
new API.

mpt_cam.c: Update the mpt(4) driver to work with the new API.
Target mode is only enabled for Fibre Channel
mpt(4) devices.

MFC after: 3 days


237518 24-Jun-2012 ken

Fix a bug which causes a panic in daopen(). The panic is caused by
a da(4) instance going away while GEOM is still probing it.

In this case, the GEOM disk class instance has been created by
disk_create(), and the taste of the disk is queued in the GEOM
event queue.

While that event is queued, the da(4) instance goes away. When the
open call comes into the da(4) driver, it dereferences the freed
(but non-NULL) peripheral pointer provided by GEOM, which results
in a panic.

The solution is to add a callback to the GEOM disk code that is
called when all of its resources are cleaned up. This is
implemented inside GEOM by adding an optional callback that is
called when all consumers have detached from a provider, and the
provider is about to be deleted.

scsi_cd.c,
scsi_da.c: In the register routine for the cd(4) and da(4)
routines, acquire a reference to the CAM peripheral
instance just before we call disk_create().

Use the new GEOM disk d_gone() callback to register
a callback (dadiskgonecb()/cddiskgonecb()) that
decrements the peripheral reference count once GEOM
has finished cleaning up its resources.

In the cd(4) driver, clean up open and close
behavior slightly. GEOM makes sure we only get one
open() and one close call, so there is no need to
set an open flag and decrement the reference count
if we are not the first open.

In the cd(4) driver, use cam_periph_release_locked()
in a couple of error scenarios to avoid extra mutex
calls.

geom.h: Add a new, optional, providergone callback that
is called when a provider is about to be deleted.

geom_disk.h: Add a new d_gone() callback to the GEOM disk
interface.

Bump the DISK_VERSION to version 2. This probably
should have been done after a couple of previous
changes, especially the addition of the d_getattr()
callback.

geom_disk.c: Add a providergone callback for the disk class,
g_disk_providergone(), that calls the user's
d_gone() callback if it exists.

Bump the DISK_VERSION to 2.

geom_subr.c: In g_destroy_provider(), call the providergone
callback if it has been provided.

In g_new_geomf(), propagate the class's
providergone callback to the new geom instance.

blkfront.c: Callers of disk_create() are supposed to pass in
DISK_VERSION, not an explicit disk API version
number. Update the blkfront driver to do that.

disk.9: Update the disk(9) man page to include information
on the new d_gone() callback, as well as the
previously added d_getattr() callback, d_descr
field, and HBA PCI ID fields.

MFC after: 5 days


237478 23-Jun-2012 mav

Add scsi_extract_sense_ccb() -- wrapper around scsi_extract_sense_len().
It allows to remove number of duplicate checks from several places.


237452 22-Jun-2012 ken

Change 'camcontrol defects' to first probe a drive to find out how much
defect information it has before grabbing the full defect list.

This works around a bug with some Hitachi drives that generate data overrun
errors when they are asked for more defect data than they have.

The change is done in a spec-compliant way, so it should have no negative
impact on drives that don't have this issue.

This is based on work originally done at Sandvine.

scsi_da.h: Add a define for the maximum amount of data that can be
contained in a defect list.

camcontrol.c: Update the readdefects() function to issue an initial
command to determine the length of the defect list, and
then use that length in the request for the full defect
list.

camcontrol.8: Add a note that some drives will report 0 defects available
if you don't request either the PLIST or GLIST.

Submitted by: Mark Johnston <markjdb@gmail.com> (original version)
MFC after: 3 days


237446 22-Jun-2012 mav

Don't print SCSI Queue Full and CAM_REQUEUE_REQ statuses as errors if they
were handled and retried. They are part of normal operation for SCSI TCQ.

MFC after: 3 days


237401 21-Jun-2012 mav

Make cam_periph_hold() behavior consistent: drop taken reference and
return ENXIO if periph was invalidated while we were waiting for it.

MFC after: 1 week


237398 21-Jun-2012 mav

In camisr() clear CAM_SIM_ON_DONEQ flag after camisr_runqueue() purged SIM
done queue. Clearing it before caused extra SIM queueing in some cases.
It was invisible during normal operation, but during USB device unplug and
respective SIM destruction it could keep pointer on SIM without having
counted reference and as result crash the system by use afer free.

Reported by: hselasky
MFC after: 1 week


237336 20-Jun-2012 mav

Remove unused error variables in cdclose() and daclose().


237335 20-Jun-2012 mav

Check status of cam_periph_hold() inside cdclose(). If cd device was
invalidated while open, cam_periph_hold() will return error and won't
get the reference. Following reference release will crash the system.

Sponsored by: iXsystems, Inc.
MFC after: 3 days


237328 20-Jun-2012 ken

Fix several reference counting and object lifetime issues between
the pass(4) and enc(4) drivers and devfs.

The pass(4) driver uses the destroy_dev_sched() routine to
schedule its device node for destruction in a separate thread
context. It does this because the passcleanup() routine can get
called indirectly from the passclose() routine, and that would
cause a deadlock if the close routine tried to destroy its own
device node.

In any case, once a particular passthrough driver number, e.g.
pass3, is destroyed, CAM considers that unit number (3 in this
case) available for reuse.

The problem is that devfs may not be done cleaning up the previous
instance of pass3, and will panic if isn't done cleaning up the
previous instance.

The solution is to get a callback from devfs when the device node
is removed, and make sure we hold a reference to the peripheral
until that happens.

Testing exposed some other cases where we have reference counting
issues, and those were also fixed in the pass(4) driver.

cam_periph.c: In camperiphfree(), reorder some of the operations.

The peripheral destructor needs to be called before
the peripheral is removed from the peripheral is
removed from the list. This is because once we
remove the peripheral from the list, and drop the
topology lock, the peripheral number may be reused.
But if the destructor hasn't been called yet, there
may still be resources hanging around (like devfs
nodes) that haven't been fully cleaned up.

cam_xpt.c: Add an argument to xpt_remove_periph() to indicate
whether the topology lock is already held.

scsi_enc.c: Acquire an extra reference to the peripheral during
registration, and release it once we get a callback
from devfs indicating that the device node is gone.

Call destroy_dev_sched_cb() in enc_oninvalidate()
instead of calling destroy_dev() in the cleanup
routine.

scsi_pass.c: Add reference counting to handle peripheral and
devfs object lifetime issues.

Add a reference to the peripheral and the devfs
node in the peripheral registration.

Don't attempt to add a physical path alias if the
peripheral has been marked invalid.

Release the devfs reference once the initial
physical path alias taskqueue run has completed.

Schedule devfs node destruction in the
passoninvalidate(), and release our peripheral
reference in a new routine, passdevgonecb() once
the devfs node is gone. This allows the peripheral
to fully go away, and the peripheral destructor,
passcleanup(), will get called.

MFC after: 3 days
Sponsored by: Spectra Logic


237225 18-Jun-2012 mav

Remove never used CD/DA_FLAG_TAGGED_QUEUING flags.

MFC after: 1 week


236814 09-Jun-2012 mav

One more major cam_periph_error() rewrite to improve error handling and
reporting. It includes:
- removing of error messages controlled by bootverbose, replacing them
with more universal and informative debugging on CAM_DEBUG_INFO level,
that is now built into the kernel by default;
- more close following to the arguments submitted by caller, such as
SF_PRINT_ALWAYS, SF_QUIET_IR and SF_NO_PRINT; consumer knows better which
errors are usual/expected at this point and which are really informative;
- adding two new flags SF_NO_RECOVERY and SF_NO_RETRY to allow caller
specify how much assistance it needs at this point; previously consumers
controlled that by not calling cam_periph_error() at all, but that made
behavior inconsistent and debugging complicated;
- tuning debug messages and taken actions order to make debugging output
more readable and cause-effect relationships visible;
- making camperiphdone() (common device recovery completion handler) to
also use cam_periph_error() in most cases, instead of own dumb code;
- removing manual sense fetching code from cam_periph_error(); I was told
by number of people that it is SIM obligation to fetch sense data, so this
code is useless and only significantly complicates recovery logic;
- making ada, da and pass driver to use cam_periph_error() with new limited
recovery options to handle error recovery and debugging in common way;
as one of results, CAM_REQUEUE_REQ and other retrying statuses are now
working fine with pass driver, that caused many problems before.
- reverting r186891 by raj@ to avoid burning few seconds in tight DELAY()
loops on device probe, while device simply loads media; I think that problem
may already be fixed in other way, and even if it is not, solution must be
different.

Sponsored by: iXsystems, Inc.
MFC after: 2 weeks


236713 07-Jun-2012 mav

Add CAM_DEBUG_INFO debug messages for periph created/invalidated/destroyed
and for asyncs sent.


236712 07-Jun-2012 mav

To make CAM debugging easier, compile in some debug flags (CAM_DEBUG_INFO,
CAM_DEBUG_CDB, CAM_DEBUG_PERIPH and CAM_DEBUG_PROBE) by default.
List of these flags can be modified with CAM_DEBUG_COMPILE kernel option.
CAMDEBUG kernel option still enables all possible debug, if not overriden.

Additional 50KB of kernel size is a good price for the ability to debug
problems without rebuilding the kernel. In case where size is important,
debugging can be compiled out by setting CAM_DEBUG_COMPILE option to 0.


236691 06-Jun-2012 mav

Remove declaration of scsi_interpret_sense(), removed 11 years ago.


236689 06-Jun-2012 ken

Fix a memory leak in the kernel case in scsi_command_string().

Submitted by: Kashyap Desai <Kashyap.Desai@lsi.com>
MFC after: 3 days


236666 06-Jun-2012 mav

ATA/SATA controllers have no idea about protocol of the connected device
until transport will do some probe actions (at least soft reset).
Make ATA/SATA SIMs to not report bogus and confusing PROTO_ATA protocol.
Make ATA/SATA transport to fill that gap by reporting protocol to SIM with
XPT_SET_TRAN_SETTINGS and patching XPT_GET_TRAN_SETTINGS results if needed.


236639 05-Jun-2012 mav

Use default error handler when flushing disk caches.


236613 05-Jun-2012 mav

Tune and add some more CAM_DEBUG() points for the probe sequences.


236605 05-Jun-2012 mav

Replace #ifdef CAMDEBUG + if + panic() with single KASSERT().


236604 05-Jun-2012 mav

Do not reinvent a wheel and let default error handler do its job.


236602 05-Jun-2012 mav

Tune and add some missing CAM_DEBUG() points for better consistency.


236552 04-Jun-2012 mav

Remove some dead code that I doubt will ever be implemented.


236437 02-Jun-2012 mav

Rewrite enabling NCQ for SATA devices in a way more alike to SCSI TCQ.
This allows to control it with `camcontrol negotiate adaX -T (en|dis)able`
on the fly, same as for SCSI devices.

Sponsored by: iXsystems, Inc.


236426 01-Jun-2012 mjacob

Print FC PortID as a hex number. This makes it easy to
figure out domain, etc..

Zero ATIO and INOTify allocations. It makes for much
less guesswork when looking at the structure and
seeing 'deadc0de' present.

Reviewed by: kdm
MFC after: 2 weeks
Sponsored by: Spectralogic


236393 01-Jun-2012 mav

Use AC_GETDEV_CHANGED async to notify ada driver about DMA and NCQ status
change. Now that allows switching between PIO and DMA modes on the fly.


236283 30-May-2012 eadler

Add support for newer garmin devices

PR: kern/163932
Submitted by: Bartosz Fabianowski <freebsd@chillt.de>
Approved by: cperciva
MFC after: 1 week


236234 29-May-2012 mav

Allow to change number of openings (used tags) for ATA/SATA devices
via `camcontrol tags ... -N ...`. There is no need to tune it in
usual cases, but some users want to have it for debugging purposes.

MFC after: 2 weeks


236228 29-May-2012 mav

Plug request and references leak caused by race between invalidated
ond probe periph destruction and new incoming probe request.

This at least caused problems with SATA Port Multipliers hot-plug.

MFC after: 2 weeks


236138 27-May-2012 ken

Work around a race condition in devfs by changing the way closes
are handled in most CAM peripheral drivers that are not handled by
GEOM's disk class.

The usual character driver open and close semantics are that the
driver gets N open calls, but only one close, when the last caller
closes the device.

CAM peripheral drivers expect that behavior to be honored to the
letter, and the CAM peripheral driver code (specifically
cam_periph_release_locked_busses()) panics if it is done incorrectly.

Since devfs has to drop its locks while it calls a driver's close
routine, and it does not have a way to delay or prevent open calls
while it is calling the close routine, there is a race.

The sequence of events, simplified a bit, is:

- devfs acquires a lock
- devfs checks the reference count, and if it is 1, continues to close.
- devfs releases the lock

- 2nd process open call on the device happens here

- devfs calls the driver's close routine

- devfs acquires a lock
- devfs decrements the reference count
- devfs releases the lock

- 2nd process close call on the device happens here

At the second close, we get a panic in
cam_periph_release_locked_busses(), complaining that peripheral
has been released when the reference count is already 0. This is
because we have gotten two closes in a row, which should not
happen.

The fix is to add the D_TRACKCLOSE flag to the driver's cdevsw, so
that we get a close() call for each open(). That does happen
reliably, so we can make sure that our reference counts are
correct.

Note that the sa(4) and pt(4) drivers only allow one context
through the open routine. So these drivers aren't exposed to the
same race condition.

scsi_ch.c,
scsi_enc.c,
scsi_enc_internal.h,
scsi_pass.c,
scsi_sg.c:
For these drivers, change the open() routine to
increment the reference count for every open, and
just decrement the reference count in the close.

Call cam_periph_release_locked() in some scenarios
to avoid additional lock and unlock calls.

scsi_pt.c: Call cam_periph_release_locked() in some scenarios
to avoid additional lock and unlock calls.

MFC after: 3 days


235982 25-May-2012 mav

Add tunable/sysctl kern.cam.pmp.hide_special, controlling whether special
PMP ports such as PMP configuration or SEMB should be exposed or hidden.
These ports were always hidden before as useless and sometimes promatic.
But with updated ses driver supporting SEMB it is no longer so straight.
Keep ports hidden by default to avoid probe request ttimeouts if SEP is
not connected to PMP's SEMB via I2C, that is very often situation.


235980 25-May-2012 mav

Remove sleep() from invalidate call in ses driver, waiting for daemon
process exit. Instead use CAM's standard reference counting to prevent
periph going away until process won't complete. I think that sleep in
single CAM SWI thread is not a good idea and may lead to deadlocks if
daemon process waits for some command completion. Combined with recent
patch avoiding use of CAM SWI for ATA it just causes panics because of
sleeps prohibited in interrupt thread context.


235911 24-May-2012 mav

MFprojects/zfsd:
Revamp the CAM enclosure services driver.
This updated driver uses an in-kernel daemon to track state changes and
publishes physical path location information\for disk elements into the
CAM device database.

Sponsored by: Spectra Logic Corporation
Sponsored by: iXsystems, Inc.
Submitted by: gibbs, will, mav


235897 24-May-2012 mav

MFprojects/zfsd:
- Add low-level support for SATA Enclosure Management Bridge (SEMB)
devices -- SATA equivalents of the SCSI SES/SAF-TE devices.
- Add some utility functions for SCSI SAF-TE devices access.

Sponsored by: iXsystems, Inc.


235333 12-May-2012 mav

Add two functions xpt_batch_start() and xpt_batch_done() to the CAM SIM KPI
to allow drivers to handle request completion directly without passing
them to the CAM SWI thread removing extra context switch.
Modify all ATA/SATA drivers to use them.

Reviewed by: gibbs, ken
MFC after: 2 weeks


234821 29-Apr-2012 eadler

Add support for:
Olympus FE-210 camera
LG UP3S MP3 player
Laser MP3-2GA13 MP3

PR: usb/119201
Submitted by: Peter Jeremy <peterjeremy@optushome.com.au>
Approved by: cperciva
MFC after: 1 week


234414 18-Apr-2012 mav

Alike to SCSI make adaclose() to not return error if device gone.
This fixes KASSERT panic inside GEOM if kernel built with INVARIANTS.

MFC after: 1 week


234374 17-Apr-2012 trasz

Fix panic at boot with SD/MMC readers with no media present, introduced
at r234177. Note that this is a temporary fix, until I come up with something
prettier.


234177 12-Apr-2012 trasz

Refactor da(4) to remove one of two code paths used to query capacity
data.

Reviewed by: ken, mav (earlier version)
Sponsored by: The FreeBSD Foundation


233963 06-Apr-2012 ken

Change the SCSI INQUIRY peripheral qualifier that CTL reports for LUNs
that don't exist.

Anecdotal evidence indicates that it is better to return 011b (bad LUN)
than 001b (LUN offline). However, this change also gives the user a
sysctl/tunable, kern.cam.ctl.inquiry_pq_no_lun, to override the change
and return to the previous behavior. (The previous behavior was to
return 001b, or LUN offline.)

ctl.c: Change the default inquiry peripheral qualifier to 011b,
and add a sysctl and tunable to allow the user to change
it back to 001b if needed.

Don't insert a Copan copyright statement in the inquiry
data. The copyright statements on the files are
sufficient.

ctl_private.h: Add sysctl variable context to the CTL softc.

ctl_cmd_table.c,
ctl_frontend_internal.c,
ctl_frontend.c,
ctl_backend.c,
ctl_error.c: Include sys/sysctl.h.

MFC after: 3 days


233746 31-Mar-2012 mav

Be more conservative in using READ CAPACITY(16) command. Previous code
checked PROTECT bit in INQUIRY data for all SPC devices, while it is defined
only since SPC-3. But there are some SPC-2 USB devices were reported, that
have PROTECT bit set, return no error for READ CAPACITY(16) command, but
return wrong sector count value in response.

MFC after: 3 days


232604 06-Mar-2012 trasz

Add LUN resizing to CTL. Also make it possible to explicitly set
size when creating file-backed or device-backed LUN.

Reviewed by: ken (earlier version)
Sponsored by: The FreeBSD Foundation


232074 23-Feb-2012 dim

Use a better way to silence unneeded internal declaration warnings in
several sys/cam/ctl files.

Suggested by: ed
Reviewed by: ken
MFC after: 1 week


231745 15-Feb-2012 gibbs

Limit the ST3146855LW U320 drive to 55 tags to avoid command timeouts
under load.

Submitted by: Gelson Borsoi
MFC after: 1 day


231092 06-Feb-2012 emaste

Avoid panic from unlocking a not locked mutex (in some error cases).

Reviewed by: ken@


230921 02-Feb-2012 mav

Insert ordered command every 1/4 of the current command timeout, not 1/4
of the default one.

Without this change setting kern.cam.ada.default_timeout to 1 instead of 30
allowed me to trigger several false positive command timeouts under heavy
ZFS load on a SiI3132 siis(4) controller with 5 HDDs on a port multiplier.

MFC after: 1 week


230912 02-Feb-2012 mav

Make CAM ATA honor old hw.ata.ata_dma and hw.ata.atapi_dma tunables.

Even having more specific hint.ata.X.mode controls, global ones are
still could be useful from some points, including compatibility.

PR: kern/164651
MFC after: 1 week


230590 26-Jan-2012 ken

Add CAM infrastructure to allow reporting when a drive's long read capacity
data changes.

cam_ccb.h: Add a new advanced information type, CDAI_TYPE_RCAPLONG,
for long read capacity data.

cam_xpt_internal.h:
Add a read capacity data pointer and length to struct cam_ed.

cam_xpt.c: Free the read capacity buffer when a device goes away.
While we're here, make sure we don't leak memory for other
malloced fields in struct cam_ed.

scsi_all.c: Update the scsi_read_capacity_16() to take a uint8_t * and
a length instead of just a pointer to the parameter data
structure. This will hopefully make this function somewhat
immune to future changes in the parameter data.

scsi_all.h: Add some extra bit definitions to struct
scsi_read_capacity_data_long, and bump up the structure
size to the full size specified by SBC-3.

Change the prototype for scsi_read_capacity_16().

scsi_da.c: Register changes in read capacity data with the transport
layer. This allows the transport layer to send out an
async notification to interested parties. Update the
dasetgeom() API.

Use scsi_extract_sense_len() instead of
scsi_extract_sense().

scsi_xpt.c: Add support for the new CDAI_TYPE_RCAPLONG advanced
information type.

Make sure we set the physpath pointer to NULL after freeing
it. This allows blindly freeing it in the struct cam_ed
destructor.

sys/param.h: Bump __FreeBSD_version from 1000005 to 1000006 to make it
easier for third party drivers to determine that the read
capacity data async notification is available.

camcontrol.c,
mptutil/mpt_cam.c:
Update these for the new scsi_read_capacity_16() argument
structure.

Sponsored by: Spectra Logic


230544 25-Jan-2012 ken

Fix a bug introduced in r230000. We were eliminating all LUNs on a target
in response to CAM_DEV_NOT_THERE, instead of just the LUN in question.

This will now just eliminate the specified LUN in response to
CAM_DEV_NOT_THERE.

Reported by: Richard Todd <rmtodd@servalan.servalan.com>
MFC after: 3 days


230334 19-Jan-2012 ken

Quiet some clang warnings when compiling CTL.

ctl_error.c,
ctl_error.h: Take out the ctl_sense_format enumeration, and use
scsi_sense_data_type instead.

Remove ctl_get_sense_format() and switch ctl_build_ua()
over to using scsi_sense_data_type.

ctl_backend_ramdisk.c,
ctl_backend_block.c:
Use C99 structure initializers instead of GNU initializers.

ctl.c: Switch over to using the SCSI sense format enumeration
instead of the CTL-specific enumeration.

Submitted by: dim (partially)
MFC after: 1 month


230157 15-Jan-2012 avg

dadump: don't leak the periph lock on i/o error

Reported by: az
MFC after: 1 week


230053 13-Jan-2012 mav

Add BIO_DELETE support for SCSI Direct Access devices (da).

Depending on device capabilities use different methods to implement it.
Currently used method can be read/set via kern.cam.da.X.delete_method
sysctls. Possible values are:
NONE - no provisioning support reported by the device;
DISABLE - provisioning support was disabled because of errors;
ZERO - use WRITE SAME (10) command to write zeroes;
WS10 - use WRITE SAME (10) command with UNMAP bit set;
WS16 - use WRITE SAME (16) command with UNMAP bit set;
UNMAP - use UNMAP command (equivalent of the ATA DSM TRIM command).
The last two methods (UNMAP and WS16) are defined by SBC specification and
the UNMAP method is the most advanced one. The rest of methods I've found
supported in Linux, and as soon as they were trivial to implement, then
why not? Hope they will be useful in some cases.

Unluckily I have no devices properly reporting parameters of the logical
block provisioning support via respective VPD pages (0xB0 and 0xB2). So
all info I have/use now is the flag telling whether logical block
provisioning is supported or not. As result, specific methods chosen now
by trying different ones in order (UNMAP, WS16, DISABLE) and checking
completion status to fallback if needed. I don't expect problems from this,
as if something go wrong, it should just disable itself. It may disable
even too aggressively if only some command parameter misfit.

Unlike Linux, which executes each delete with separate request, I've
implemented here the same request aggregation as implemented in ada driver.
Tests on SSDs I have show much better results doing it this way: above
8GB/s of the linear delete on Intel SATA SSD on LSI SAS HBA (mps).

Reviewed by: silence on scsi@
MFC after: 2 month
Sponsored by: iXsystems, Inc.


230033 12-Jan-2012 ken

Silence some unnecessary verbosity.

Reported by: mav
MFC after: 1 month


230000 12-Jan-2012 ken

Fix a race condition in CAM peripheral free handling, locking
in the CAM XPT bus traversal code, and a number of other periph level
issues.

cam_periph.h,
cam_periph.c: Modify cam_periph_acquire() to test the CAM_PERIPH_INVALID
flag prior to allowing a reference count to be gained
on a peripheral. Callers of this function will receive
CAM_REQ_CMP_ERR status in the situation of attempting to
reference an invalidated periph. This guarantees that
a peripheral scheduled for a deferred free will not
be accessed during its wait for destruction.

Panic during attempts to drop a reference count on
a peripheral that already has a zero reference count.

In cam_periph_list(), use a local sbuf with SBUF_FIXEDLEN
set so that mallocs do not occur while the xpt topology
lock is held, regardless of the allocation policy of the
passed in sbuf.

Add a new routine, cam_periph_release_locked_buses(),
that can be called when the caller already holds
the CAM topology lock.

Add some extra debugging for duplicate peripheral
allocations in cam_periph_alloc().

Treat CAM_DEV_NOT_THERE much the same as a selection
timeout (AC_LOST_DEVICE is emitted), but forgo retries.

cam_xpt.c: Revamp the way the EDT traversal code does locking
and reference counting. This was broken, since it
assumed that the EDT would not change during
traversal, but that assumption is no longer valid.

So, to prevent devices from going away while we
traverse the EDT, make sure we properly lock
everything and hold references on devices that
we are using.

The two peripheral driver traversal routines should
be examined. xptpdperiphtraverse() holds the
topology lock for the entire time it runs.
xptperiphtraverse() is now locked properly, but
only holds the topology lock while it is traversing
the list, and not while the traversal function is
running.

The bus locking code in xptbustraverse() should
also be revisited at a later time, since it is
complex and should probably be simplified.

scsi_da.c: Pay attention to the return value from cam_periph_acquire().

Return 0 always from daclose() even if the disk is now gone.

Add some rudimentary error injection support.

scsi_sg.c: Fix reference counting in the sg(4) driver.

The sg driver was calling cam_periph_release() on close,
but never called cam_periph_acquire() (which increments
the reference count) on open.

The periph code correctly complained that the sg(4)
driver was trying to decrement the refcount when it
was already 0.

Sponsored by: Spectra Logic
MFC after: 2 weeks


229997 12-Jan-2012 ken

Add the CAM Target Layer (CTL).

CTL is a disk and processor device emulation subsystem originally written
for Copan Systems under Linux starting in 2003. It has been shipping in
Copan (now SGI) products since 2005.

It was ported to FreeBSD in 2008, and thanks to an agreement between SGI
(who acquired Copan's assets in 2010) and Spectra Logic in 2010, CTL is
available under a BSD-style license. The intent behind the agreement was
that Spectra would work to get CTL into the FreeBSD tree.

Some CTL features:

- Disk and processor device emulation.
- Tagged queueing
- SCSI task attribute support (ordered, head of queue, simple tags)
- SCSI implicit command ordering support. (e.g. if a read follows a mode
select, the read will be blocked until the mode select completes.)
- Full task management support (abort, LUN reset, target reset, etc.)
- Support for multiple ports
- Support for multiple simultaneous initiators
- Support for multiple simultaneous backing stores
- Persistent reservation support
- Mode sense/select support
- Error injection support
- High Availability support (1)
- All I/O handled in-kernel, no userland context switch overhead.

(1) HA Support is just an API stub, and needs much more to be fully
functional.

ctl.c: The core of CTL. Command handlers and processing,
character driver, and HA support are here.

ctl.h: Basic function declarations and data structures.

ctl_backend.c,
ctl_backend.h: The basic CTL backend API.

ctl_backend_block.c,
ctl_backend_block.h: The block and file backend. This allows for using
a disk or a file as the backing store for a LUN.
Multiple threads are started to do I/O to the
backing device, primarily because the VFS API
requires that to get any concurrency.

ctl_backend_ramdisk.c: A "fake" ramdisk backend. It only allocates a
small amount of memory to act as a source and sink
for reads and writes from an initiator. Therefore
it cannot be used for any real data, but it can be
used to test for throughput. It can also be used
to test initiators' support for extremely large LUNs.

ctl_cmd_table.c: This is a table with all 256 possible SCSI opcodes,
and command handler functions defined for supported
opcodes.

ctl_debug.h: Debugging support.

ctl_error.c,
ctl_error.h: CTL-specific wrappers around the CAM sense building
functions.

ctl_frontend.c,
ctl_frontend.h: These files define the basic CTL frontend port API.

ctl_frontend_cam_sim.c: This is a CTL frontend port that is also a CAM SIM.
This frontend allows for using CTL without any
target-capable hardware. So any LUNs you create in
CTL are visible in CAM via this port.

ctl_frontend_internal.c,
ctl_frontend_internal.h:
This is a frontend port written for Copan to do
some system-specific tasks that required sending
commands into CTL from inside the kernel. This
isn't entirely relevant to FreeBSD in general,
but can perhaps be repurposed.

ctl_ha.h: This is a stubbed-out High Availability API. Much
more is needed for full HA support. See the
comments in the header and the description of what
is needed in the README.ctl.txt file for more
details.

ctl_io.h: This defines most of the core CTL I/O structures.
union ctl_io is conceptually very similar to CAM's
union ccb.

ctl_ioctl.h: This defines all ioctls available through the CTL
character device, and the data structures needed
for those ioctls.

ctl_mem_pool.c,
ctl_mem_pool.h: Generic memory pool implementation used by the
internal frontend.

ctl_private.h: Private data structres (e.g. CTL softc) and
function prototypes. This also includes the SCSI
vendor and product names used by CTL.

ctl_scsi_all.c,
ctl_scsi_all.h: CTL wrappers around CAM sense printing functions.

ctl_ser_table.c: Command serialization table. This defines what
happens when one type of command is followed by
another type of command.

ctl_util.c,
ctl_util.h: CTL utility functions, primarily designed to be
used from userland. See ctladm for the primary
consumer of these functions. These include CDB
building functions.

scsi_ctl.c: CAM target peripheral driver and CTL frontend port.
This is the path into CTL for commands from
target-capable hardware/SIMs.

README.ctl.txt: CTL code features, roadmap, to-do list.

usr.sbin/Makefile: Add ctladm.

ctladm/Makefile,
ctladm/ctladm.8,
ctladm/ctladm.c,
ctladm/ctladm.h,
ctladm/util.c: ctladm(8) is the CTL management utility.
It fills a role similar to camcontrol(8).
It allow configuring LUNs, issuing commands,
injecting errors and various other control
functions.

usr.bin/Makefile: Add ctlstat.

ctlstat/Makefile
ctlstat/ctlstat.8,
ctlstat/ctlstat.c: ctlstat(8) fills a role similar to iostat(8).
It reports I/O statistics for CTL.

sys/conf/files: Add CTL files.

sys/conf/NOTES: Add device ctl.

sys/cam/scsi_all.h: To conform to more recent specs, the inquiry CDB
length field is now 2 bytes long.

Add several mode page definitions for CTL.

sys/cam/scsi_all.c: Handle the new 2 byte inquiry length.

sys/dev/ciss/ciss.c,
sys/dev/ata/atapi-cam.c,
sys/cam/scsi/scsi_targ_bh.c,
scsi_target/scsi_cmds.c,
mlxcontrol/interface.c: Update for 2 byte inquiry length field.

scsi_da.h: Add versions of the format and rigid disk pages
that are in a more reasonable format for CTL.

amd64/conf/GENERIC,
i386/conf/GENERIC,
ia64/conf/GENERIC,
sparc64/conf/GENERIC: Add device ctl.

i386/conf/PAE: The CTL frontend SIM at least does not compile
cleanly on PAE.

Sponsored by: Copan Systems, SGI and Spectra Logic
MFC after: 1 month


229395 03-Jan-2012 mav

Add support for CDRIOCGETBLOCKSIZE and CDRIOCSETBLOCKSIZE IOCTLs to control
sector size same as acd driver does. Together with r228808 and r228847 this
allows existing multimedia/vlc to play Audio CDs via CAM cd driver.

PR: ports/162190
MFC after: 1 week


229288 02-Jan-2012 mav

Remove unneeded checks for CAM_DEV_QFRZN after cam_periph_runccb() call.
cam_periph_runccb() since the beginning checks it and releases device queue.
After r203108 it even clears CAM_DEV_QFRZN flag after that to avoid double
release, so removed code is unreachable now.

MFC after: 1 month


228851 23-Dec-2011 mav

Report stripeoffset as zero not stripesize if physical block is zero
aligned, same as it is done for ATA.


228847 23-Dec-2011 mav

Addition to r228808:
READ CD is a 12 byte command. So fill additional bytes and update CDB length
when patching READ(10).

MFC after: 1 month


228846 23-Dec-2011 mav

Use READ CAPACITY(16) to get information about device physical sectors.
As soon as not all devices support READ CAPACITY(16), automatically fall
back to READ CAPACITY(10) if CAM_REQ_INVALID or SSD_KEY_ILLEGAL_REQUEST
status returned.

It also provides first bits of information about Logical Block Provisioning
(aka UNMAP/TRIM) support by the device.


228820 23-Dec-2011 mav

Merge to da driver quirks hinting 4K physical sector sizes for SATA disks
connected via SAS or USB. Unluckily I've found that SAS (mps) and USB-SATA
I have translate models in different ways, requiring twice more quirks.
Unluckily for Hitachi, their model names are trimmed on SAS, making
impossible to identify 4K sector drives that way.


228819 23-Dec-2011 mav

Update list of 4K physical sector hard drives.


228808 22-Dec-2011 mav

Make cd driver to handle Audio CDs, reporting their 2352 bytes sectors to
GEOM and using READ CD command for reading data, same as acd driver does.
Audio CDs identified by checking respective bit of the control field of
the first track in TOC.

This fixes bunch of error messages during boot (GEOM taste) with Audio CD
inserted and allows to grab Audio CD image using just dd.

MFC after: 1 month


228481 13-Dec-2011 ed

Change targ(4) to use cdevpriv, instead of multiple character devices.

Also update the manpage and the scsi_target example program accordingly.

Discussed on: scsi@
Tested by: Chuck Tuffli <chuck tuffli net>


228442 12-Dec-2011 mdf

Do not use the sometimes-reserved work 'bool' for a variable name.

MFC after: 2 weeks
Sponsored by: Isilon Systems, LLC


228344 08-Dec-2011 eadler

- Add support for Support SEAGATE DAT Scopion 130

PR: kern/141934
Submitted by: HASHI Hiroaki <hashiz@stenmark.meridiani.jp>
Approved by: sbruno@
MFC after: 1 week


228027 27-Nov-2011 marius

Move the scsi_da_bios_params() prototype from pc98_machdep.h to md_var.h
where the prototype for pc98_ata_disk_firmware_geom_adjust() also lives
in order to avoid an #ifdef'ed include in cam(4).


228022 27-Nov-2011 marius

For sparc64 also adjust the geometry of da(4) driven disks to not overflow
the 16-bit cylinders field of the VTOC8 disk label (at around 502GB). The
geometry chosen for disks above that limit allows to use disks up to 2TB,
which is the limit of the extended VTOC8 format. The geometry used for
disks smaller than the 16-bit cylinders limit stays the same as used by
cam_calc_geometry(9) for extended translation.
Thanks to Hans-Joerg Sirtl for providing hardware for testing this change.

MFC after: 3 days


227637 17-Nov-2011 mav

Introduce CAM_SIM_POLLED SIM flag, indicating that it works in polling mode.
It blocks CAM SWI usage on requests completion, unneeded because of polling
and denied during kernel dumping because of blocked scheduler.

Before r198899 there was periph flag CAM_PERIPH_POLLED, but that was wrong,
because there is whole SIM is polled or handled by SWI, not a single periph.

Tested by: kib
MFC after: 1 month


227489 13-Nov-2011 eadler

- fix duplicate "a a" in some comments

Submitted by: eadler
Approved by: simon
MFC after: 3 days


227309 07-Nov-2011 ed

Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.

The SYSCTL_NODE macro defines a list that stores all child-elements of
that node. If there's no SYSCTL_DECL macro anywhere else, there's no
reason why it shouldn't be static.


227293 07-Nov-2011 ed

Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.

This means that their use is restricted to a single C file.


225950 03-Oct-2011 ken

Add descriptor sense support to CAM, and honor sense residuals properly in
CAM.

Desriptor sense is a new sense data format that originated in SPC-3. Among
other things, it allows for an 8-byte info field, which is necessary to
pass back block numbers larger than 4 bytes.

This change adds a number of new functions to scsi_all.c (and therefore
libcam) that abstract out most access to sense data.

This includes a bump of CAM_VERSION, because the CCB ABI has changed.
Userland programs that use the CAM pass(4) driver will need to be
recompiled.

camcontrol.c: Change uses of scsi_extract_sense() to use
scsi_extract_sense_len().

Use scsi_get_sks() instead of accessing sense key specific
data directly.

scsi_modes: Update the control mode page to the latest version (SPC-4).

scsi_cmds.c,
scsi_target.c: Change references to struct scsi_sense_data to struct
scsi_sense_data_fixed. This should be changed to allow the
user to specify fixed or descriptor sense, and then use
scsi_set_sense_data() to build the sense data.

ps3cdrom.c: Use scsi_set_sense_data() instead of setting sense data
manually.

cam_periph.c: Use scsi_extract_sense_len() instead of using
scsi_extract_sense() or accessing sense data directly.

cam_ccb.h: Bump the CAM_VERSION from 0x15 to 0x16. The change of
struct scsi_sense_data from 32 to 252 bytes changes the
size of struct ccb_scsiio, but not the size of union ccb.
So the version must be bumped to prevent structure
mis-matches.

scsi_all.h: Lots of updated SCSI sense data and other structures.

Add function prototypes for the new sense data functions.

Take out the inline implementation of scsi_extract_sense().
It is now too large to put in a header file.

Add macros to calculate whether fields are present and
filled in fixed and descriptor sense data

scsi_all.c: In scsi_op_desc(), allow the user to pass in NULL inquiry
data, and we'll assume a direct access device in that case.

Changed the SCSI RESERVED sense key name and description
to COMPLETED, as it is now defined in the spec.

Change the error recovery action for a number of read errors
to prevent lots of retries when the drive has said that the
block isn't accessible. This speeds up reconstruction of
the block by any RAID software running on top of the drive
(e.g. ZFS).

In scsi_sense_desc(), allow for invalid sense key numbers.
This allows calling this routine without checking the input
values first.

Change scsi_error_action() to use scsi_extract_sense_len(),
and handle things when invalid asc/ascq values are
encountered.

Add a new routine, scsi_desc_iterate(), that will call the
supplied function for every descriptor in descriptor format
sense data.

Add scsi_set_sense_data(), and scsi_set_sense_data_va(),
which build descriptor and fixed format sense data. They
currently default to fixed format sense data.

Add a number of scsi_get_*() functions, which get different
types of sense data fields from either fixed or descriptor
format sense data, if the data is present.

Add a number of scsi_*_sbuf() functions, which print
formatted versions of various sense data fields. These
functions work for either fixed or descriptor sense.

Add a number of scsi_sense_*_sbuf() functions, which have a
standard calling interface and print the indicated field.
These functions take descriptors only.

Add scsi_sense_desc_sbuf(), which will print a formatted
version of the given sense descriptor.

Pull out a majority of the scsi_sense_sbuf() function and
put it into scsi_sense_only_sbuf(). This allows callers
that don't use struct ccb_scsiio to easily utilize the
printing routines. Revamp that function to handle
descriptor sense and use the new sense fetching and
printing routines.

Move scsi_extract_sense() into scsi_all.c, and implement it
in terms of the new function, scsi_extract_sense_len().
The _len() version takes a length (which should be the
sense length - residual) and can indicate which fields are
present and valid in the sense data.

Add a couple of new scsi_get_*() routines to get the sense
key, asc, and ascq only.

mly.c: Rename struct scsi_sense_data to struct
scsi_sense_data_fixed.

sbp_targ.c: Use the new sense fetching routines to get sense data
instead of accessing it directly.

sbp.c: Change the firewire/SCSI sense data transformation code to
use struct scsi_sense_data_fixed instead of struct
scsi_sense_data. This should be changed later to use
scsi_set_sense_data().

ciss.c: Calculate the sense residual properly. Use
scsi_get_sense_key() to fetch the sense key.

mps_sas.c,
mpt_cam.c: Set the sense residual properly.

iir.c: Use scsi_set_sense_data() instead of building sense data by
hand.

iscsi_subr.c: Use scsi_extract_sense_len() instead of grabbing sense data
directly.

umass.c: Use scsi_set_sense_data() to build sense data.

Grab the sense key using scsi_get_sense_key().

Calculate the sense residual properly.

isp_freebsd.h: Use scsi_get_*() routines to grab asc, ascq, and sense key
values.

Calculate and set the sense residual.

MFC after: 3 days
Sponsored by: Spectra Logic Corporation


224806 12-Aug-2011 mjacob

Fixes for sure bus reference miscounting and potential device and
target reference miscounts. It also adds a helper function to get
the current reference counts for components of cam_path for debug
aid. One minor style(9) change.

Partially Obtained from: Chuck Tuffli (Emulex)
Reviewed by: scsi@ (ken)
Approved by: re (kib)
MFC after: 1 month


224531 30-Jul-2011 mav

Higher-priority initialization request can eat request scheduling done from
adaclose(). Add immediate_priority check into adaschedule() to restore it.

Approved by: re (kib)
MFC after: 1 week


224497 29-Jul-2011 mav

Add control for ATA disk read-ahead, alike to the previously added write
cache control. Some controller BIOS'es tend to disable read-ahead, that
dramatically reduces read performance. Previously ata(4) always enabled
read-ahead unconditionally.

Approved by: re (kib)


224496 29-Jul-2011 mav

In some cases failed SATA disks may report their presence, but don't
respond to any commands. I've found that because of multiple command
retries, each of which cause 30s timeout, bus reset and another retry or
requeue for many commands, it may take ages to eventually drop the
failed device. The odd thing is that those retries continue even after
XPT considered device as dead and invalidated it.

This patch makes cam_periph_error() to block any command retries after
periph was marked as invalid. With that patch all activity completes in
1-2 minutes, just after several timeouts, required to consider device
death. This should make ZFS, gmirror, graid, etc. operation more robust.

Reviewed by: mjacob@ on scsi@

Approved by: re (kib)


224283 23-Jul-2011 mav

Do not try to execute FLUSHCACHE on close and print extra messages for
invalidated (considered lost) ada device. Exactly same already done for
the da devices.

Approved by: re (kib)
MFC after: 1 week


223557 26-Jun-2011 gibbs

cam/scsi/scsi_cd.c:
In cdregister(), hold the periph lock semaphore during changer
probe/configuration. This removes a window where an open of the
cd device may succeed before probe processing has completed.


223556 26-Jun-2011 gibbs

cam/cam_xpt.c:
In camisr_runqueue(), we need to run the sims queue regardless of
whether or not the current peripheral has more work to do. This
reverts a change mistakenly made in revision 223081.

Reported by: ache


223475 23-Jun-2011 mav

Fix ATAPI breakage introduced by r223443. It made SCSI commands to ATAPI
device to never complete, that caused probe process (system boot) stuck.


223448 22-Jun-2011 will

Return CAM_REQ_INVALID if the SCSI XPT receives an unsupported operation
via the XPT_DEV_ADVINFO CCB.

Reviewed by: ken


223443 22-Jun-2011 will

Plumb support for the device advanced information CCB in the ATA XPT.

This was previously done only for SCSI XPT in r223081, on which the change
in r223089 depended in order to respond to serial number requests. As a
result of r223089, da(4) and ada(4) devices register a d_getattr for geom to
use to obtain the information.

Reported by: ache
Reviewed by: ken


223277 18-Jun-2011 kib

Fix a typo in adagetattr() from r223089. In particular, this restores
the ability to use ahci(4) for kernel dumps.


223089 14-Jun-2011 gibbs

Plumb device physical path reporting from CAM devices, through GEOM and
DEVFS, and make it accessible via the diskinfo utility.

Extend GEOM's generic attribute query mechanism into generic disk consumers.
sys/geom/geom_disk.c:
sys/geom/geom_disk.h:
sys/cam/scsi/scsi_da.c:
sys/cam/ata/ata_da.c:
- Allow disk providers to implement a new method which can override
the default BIO_GETATTR response, d_getattr(struct bio *). This
function returns -1 if not handled, otherwise it returns 0 or an
errno to be passed to g_io_deliver().

sys/cam/scsi/scsi_da.c:
sys/cam/ata/ata_da.c:
- Don't copy the serial number to dp->d_ident anymore, as the CAM XPT
is now responsible for returning this information via
d_getattr()->(a)dagetattr()->xpt_getatr().

sys/geom/geom_dev.c:
- Implement a new ioctl, DIOCGPHYSPATH, which returns the GEOM
attribute "GEOM::physpath", if possible. If the attribute request
returns a zero-length string, ENOENT is returned.

usr.sbin/diskinfo/diskinfo.c:
- If the DIOCGPHYSPATH ioctl is successful, report physical path
data when diskinfo is executed with the '-v' option.

Submitted by: will
Reviewed by: gibbs
Sponsored by: Spectra Logic Corporation

Add generic attribute change notification support to GEOM.

sys/sys/geom/geom.h:
Add a new attrchanged method field to both g_class
and g_geom.

sys/sys/geom/geom.h:
sys/geom/geom_event.c:
- Provide the g_attr_changed() function that providers
can use to advertise attribute changes.
- Perform delivery of attribute change notifications
from a thread context via the standard GEOM event
mechanism.

sys/geom/geom_subr.c:
Inherit the attrchanged method from class to geom (class instance).

sys/geom/geom_disk.c:
Provide disk_attr_changed() to provide g_attr_changed() access
to consumers of the disk API.

sys/cam/scsi/scsi_pass.c:
sys/cam/scsi/scsi_da.c:
sys/geom/geom_dev.c:
sys/geom/geom_disk.c:
Use attribute changed events to track updates to physical path
information.

sys/cam/scsi/scsi_da.c:
Add AC_ADVINFO_CHANGED to the registered asynchronous CAM
events for this driver. When this event occurs, and
the updated buffer type references our physical path
attribute, emit a GEOM attribute changed event via the
disk_attr_changed() API.

sys/cam/scsi/scsi_pass.c:
Add AC_ADVINFO_CHANGED to the registered asynchronous CAM
events for this driver. When this event occurs, update
the physical patch devfs alias for this pass instance.

Submitted by: gibbs
Sponsored by: Spectra Logic Corporation


223084 14-Jun-2011 gibbs

sys/cam/scsi/scsi_da.c:
- Only attempt the closing synchronize cache on a disk
if it is still there.
- When a device is lost, report the number of outstanding
I/Os as they are drained.
- When a device is lost, return any unprocessed bios with
ENXIO instead of EIO.
- Filter asynchronous events, but always allow cam_periph_async()
to see them too.

Sponsored by: Spectra Logic Corporation


223081 14-Jun-2011 gibbs

Lay groundwork in CAM for recording and reporting physical path and
other device attributes stored in the CAM Existing Device Table (EDT).
This includes some infrastructure requried by the enclosure services
driver to export physical path information.

Make the CAM device advanced info interface accept store requests.

sys/cam/scsi/scsi_all.c:
sys/cam/scsi/scsi_all.h:
- Replace scsi_get_sas_addr() with a scsi_get_devid() which takes
a callback that decides whether to accept a particular descriptor.
Provide callbacks for NAA IEEE Registered addresses and for SAS
addresses, replacing the old function. This is needed because
the old function doesn't work for an enclosure address for a SAS
device, which is not flagged as a SAS address, but is NAA IEEE
Registered. It may be worthwhile merging this interface with the
devid match interface.
- Add a few more defines for some device ID fields.

sbin/camcontrol/camcontrol.c:
- Update for the CCB_DEV_ADVINFO interface change.

cam/cam_xpt_internal.h:
- Add the new fields for the physical path string to the CAM EDT.
cam/cam_ccb.h:
- Rename CCB_GDEV_ADVINFO to simply CCB_DEV_ADVINFO, and the ccb
structure to ccb_dev_advinfo.
- Add a flag that changes this CCB's action to store, rather than
the default, retrieve.
- Add a new buffer type, CDAI_TYPE_PHYS_PATH, for the new CAM EDT
physpath field.
- Remove the never-implemented transport & proto flags.
cam/cam_xpt.c:
cam/cam_xpt.h:
- Add xpt_getattr(), which provides a wrapper for fetching a device's
attribute using the GEOM strings as key. This method currently
supports "GEOM::ident" and "GEOM::physpath".

Submitted by: will
Reviewed by : gibbs

Extend the XPT_DEV_MATCH api to allow a device search by device ID.
As far as the API is concerned, device ID is a binary blob to be
interpreted by the transport layer. The SCSI implementation assumes
it is an array of VPD device ID descriptors.

sys/cam/cam_ccb.h:
Create a new structure, device_id_match_pattern, and
update the XPT_DEV_MATCH datastructures and flags so
that this pattern type can be used.

sys/cam/cam_xpt.c:
- A single pattern matching on both inquiry data and device
ID is invalid. Report any violators.
- Pass device ID match requests through to the new routine
scsi_devid_match(). The direct call of a SCSI routine is
a layering violation, but no worse than the one a few
lines up that checks inquiry data. Defer cleaning this
up until our future, larger, rototilling of CAM.
- Zero out cam_ed and cam_et nodes on allocation. Prior to
this change, device_id_len and device_id were not inialized,
preventing proper detection of the presence of this
information.

sys/cam/scsi/scsi_all.c:
sys/cam/scsi/scsi_all.h:
Add the scsi_match_devid() routine.

Add a helper function for extracting peripherial driver names

sys/cam/cam_periph.c:
sys/cam/cam_periph.h:
Add the cam_periph_list() method which fills an sbuf
with a comma delimited list of the peripheral instances
associated with a given CAM path.

Add a helper functions for SCSI commands used by the SES driver.

sys/cam/scsi/scsi_all.c:
sys/cam/scsi/scsi_all.h:
Add structure definitions and csio filling functions for
the receive diagnostic results and send diagnostic commands.

Misc CAM XPT cleanups.

sys/cam/cam_xpt.c:
Broadcast AC_FOUND_DEVICE and AC_PATH_REGISTERED
events at the time async event handlers are attached
even when registering just for events on a partitular
SIM. Previously, you had to register for these
events on all SIMs in the system in order to get
the initial broadcast even though subsequent device
and path arrivals would be delivered.

sys/cam/cam_xpt.c:
Remove SIM mutex held asserts from path accessors.
CAM paths are reference counted and it is this
reference count, not the sim mutex, that garantees
they are stable.

Sponsored by: Spectra Logic Corporation


223019 12-Jun-2011 mav

Do not report CFA devices as ATAPI, even though IDENTIFY data look alike.


222643 03-Jun-2011 mav

Increase maximum supported number of ranges per TRIM command from 256 to 512
to use full potential of Intel X25-M SSDs. On synthetic test with 32K ranges
it gives about 20% speedup, which probably costs more then 2K of RAM.


222628 02-Jun-2011 mav

When possible, join ranges of subsequest BIO_DELETE requests to handle more
(up to 2048 instead of 256 or even 64) of them with single TRIM request.

OCZ Vertex2/Vertex3 SSDs can handle no more then 64 ranges per TRIM request.
Due to lack of BIO_DELETE clustering now, it means that we could delete no
more then 2MB per request (on FS with 32K block) with limited request rate.
This change increases delete rate on Vertex2 from 250MB/s to 950MB/s.


222520 31-May-2011 mav

Add quirks to hint 4K physical sector (Advanced Format) for ATA disks not
reporting it properly (none? of known disks now).

Hitachi and WDC AF disks seem could be identified more or less formally.
For Seagate and Samsung enumerate some found models/series.
For other disks it can be forced with kern.cam.ada.X.quirks=1 tunable.


222339 27-May-2011 mav

Change new constant names to ones used by OpenSolaris.


222336 27-May-2011 mav

Add names for few more SES element types according SES-2 specification.


221585 07-May-2011 avg

scsi_cd: silence READ_TOC errors in CDIOREADTOCHEADER ioctl

An optical disk may not have a TOC (e.g. for blank media) and userland
software may legitimately try to use CDIOREADTOCHEADER to find out about
the TOC.

Silence from: scsi@
MFC after: 10 days


221384 03-May-2011 mav

Do not report legacy unit numbers (do not create legacy aliases) for disks
on port multiplier ports above first two. They don't fit into ATA_STATIC_ID
scheme and so can't be mapped properly. No need to pollute dev.


221201 29-Apr-2011 mav

Make CAM_DEBUG_CDB also dump ATA commands in addition to SCSI.


221071 26-Apr-2011 mav

- Add shim to simplify migration to the CAM-based ATA. For each new adaX
device in /dev/ create symbolic link with adY name, trying to mimic old ATA
numbering. Imitation is not complete, but should be enough in most cases to
mount file systems without touching /etc/fstab.
- To know what behavior to mimic, restore ATA_STATIC_ID option in cases
where it was present before.
- Add some more details to UPDATING.


220886 20-Apr-2011 mav

Add basic support for DMA-capable ATA disks on DMA-incapable controller.
This is really rare situation these days, but still may happen in embedded.


220786 18-Apr-2011 mav

Remove always false "< 0" check for unsgined int variable. This check is
also duplicate, as the value was already checked for 0 before decrementing.

Reported by: rpaulo


220785 18-Apr-2011 mav

Remove some used variables.

Found with: Clang Static Analyzer


220778 18-Apr-2011 mav

Remove some used variables.

Found with: Clang Static Analyzer


220690 16-Apr-2011 jh

Move a comment to the right place. The rearrange done in r208928 left
the comment to a wrong place.


220686 16-Apr-2011 jh

Move TUNABLE_INT_FETCH() out of the SIM lock to avoid sleeping while
holding the lock. The fix is analogous to r220618 for ada(4).

Reviewed by: mav


220650 15-Apr-2011 mav

Make ada(4) driver put ATA disks into sleep state on suspend.

Submitted by: jkim (original version)


220644 14-Apr-2011 mav

Make CAM report devices with ATA/SATA transport to devstat(9) as IDE.


220618 14-Apr-2011 mav

Fix typo in write_cache tunable name and move TUNABLE_INT_FETCH() out of
the SIM lock to fix WITNESS warning.

Reported by: jh


220616 14-Apr-2011 mav

Properly log few more ATA commands used by the kernel.


220602 13-Apr-2011 mav

Improve SATA Asynchronous Notification feature support in CAM:
- make SATA SIMs announce capabilities to handle SDB with Notification bit;
- make PMP driver honor this SIMs capability;
- make SATA XPT to negotiate and enable this feature for ATAPI devices.

This feature allows supporting SATA ATAPI devices to inform system about
some events happened, that may require attention. In my case this allows
LG GH22LS50 SATA DVR-RW drive to report tray open/close events. Events
reported to CAM in form of AC_SCSI_AEN async. Further they could be used
as a hints for checking device status and reporting media change to upper
layers, for example, via spoiling mechanism of GEOM.


220454 08-Apr-2011 mav

- Add kern.cam.ada.X.write_cache tunables/sysctls to control write caching
on per-device basis.
- While adding support for per-device sysctls, merge from graid branch
support for ADA_TEST_FAILURE kernel option, which opens few more sysctl,
allowing to simulate read and write errors for testing purposes.


220412 07-Apr-2011 mav

Make ada(4) driver to control device write cache, same as ata(4) does.
Add kern.cam.ada.write_cache sysctl/tunable to control it alike hw.ata.wc.


219241 03-Mar-2011 mjacob

Don't automatically send a START UNIT to sequential access devices-
this might cause them to load the tape unintentionally.

Reviewed by: gibbs
MFC after: 1 month


219075 26-Feb-2011 nwhitehorn

Missed a file in r219056: add disk description for da(4).


219056 26-Feb-2011 nwhitehorn

Add the disk ident and a human-meaningful description (here, the disk model
string) to the geom_disk config XML so that they are easily accessible from
userland.

MFC after: 1 week


219028 25-Feb-2011 netchild

Add some FEATURE macros for various features (AUDIT/CAM/IPC/KTR/MAC/NFS/NTP/
PMC/SYSV/...).

No FreeBSD version bump, the userland application to query the features will
be committed last and can serve as an indication of the availablility if
needed.

Sponsored by: Google Summer of Code 2010
Submitted by: kibab
Reviewed by: arch@ (parts by rwatson, trasz, jhb)
X-MFC after: to be determined in last commit with code from this project


218909 21-Feb-2011 brucec

Fix typos - remove duplicate "the".

PR: bin/154928
Submitted by: Eitan Adler <lists at eitanadler.com>
MFC after: 3 days


217875 26-Jan-2011 mav

In addition to r217444 ignore also ATA status errors on DMA Auto-Activation
enabling request. Some HP disks reported to return ABORT error there while
declaring support for this feature.


217874 26-Jan-2011 mav

Make device initialization sequence shorter when possible. Do not enable/
disable already enabled/disabled SATA features.


217586 19-Jan-2011 mdf

sysctl(8) should use the CTLTYPE to determine the type of data when
reading. (This was already done for writing to a sysctl). This
requires all SYSCTL setups to specify a type. Most of them are now
checked at compile-time.

Remove SYSCTL_*X* sysctl additions as the print being in hex should be
controlled by the -x flag to sysctl(8).

Succested by: bde


217444 15-Jan-2011 mav

Some old WD SATA disks report supported and enabled device-initiated
interface power management, but return ABORT error on attempt to disable
it. Make CAM SATA probe sequence ignore this error, as it is not fatal.


217369 13-Jan-2011 mdf

Add a 64-bit hex-printed sysctl(9) since there is at least one place in
the code that wanted it. It is named X64 rather than XQUAD since the
quad name is a historical abomination that should not be perpetuated.


217368 13-Jan-2011 mdf

Fix up a few more sysctl(9) mis-typing found in various LINT builds.


217265 11-Jan-2011 jhb

Remove unneeded includes of <sys/linker_set.h>. Other headers that use
it internally contain nested includes.

Reviewed by: bde


216361 10-Dec-2010 ken

Fix a few issues related to the XPT_GDEV_ADVINFO CCB.

camcontrol.c: In buildbusdevlist(), don't attempt to get call
getdevid() for an unconfigured device, even when the
verbose flag is set. The cam_open_btl() call will almost
certainly fail.

Probe for the buffer size when issuing the XPT_GDEV_ADVINFO
CCB. Probing for the buffer size first helps us avoid
allocating the maximum buffer size when it really may not
be necessary. This also helps avoid errors from
cam_periph_mapmem() if we attempt to map more than MAXPHYS.

cam_periph.c: In cam_periph_mapmem(), if the XPT_GDEV_ADVINFO CCB
shows a bufsiz of 0, we don't have anything to map,
so just return.

Also, set the maximum mapping size to MAXPHYS
instead of DFLTPHYS for XPT_GDEV_ADVINFO CCBs,
since they don't actually go down to the hardware.

scsi_pass.c: Don't bother mapping the buffer in XPT_GDEV_ADVINFO
CCBs if bufsiz is 0.


216088 30-Nov-2010 ken

Add Serial Management Protocol (SMP) passthrough support to CAM.

This includes support in the kernel, camcontrol(8), libcam and the mps(4)
driver for SMP passthrough.

The CAM SCSI probe code has been modified to fetch Inquiry VPD page 0x00
to determine supported pages, and will now fetch page 0x83 in addition to
page 0x80 if supported.

Add two new CAM CCBs, XPT_SMP_IO, and XPT_GDEV_ADVINFO. The SMP CCB is
intended for SMP requests and responses. The ADVINFO is currently used to
fetch cached VPD page 0x83 data from the transport layer, but is intended
to be extensible to fetch other types of device-specific data.

SMP-only devices are not currently represented in the CAM topology, and so
the current semantics are that the SIM will route SMP CCBs to either the
addressed device, if it contains an SMP target, or its parent, if it
contains an SMP target. (This is noted in cam_ccb.h, since it will change
later once we have the ability to have SMP-only devices in CAM's topology.)

smp_all.c,
smp_all.h: New helper routines for SMP. This includes
SMP request building routines, response parsing
routines, error decoding routines, and structure
definitions for a number of SMP commands.

libcam/Makefile: Add smp_all.c to libcam, so that SMP functionality
is available to userland applications.

camcontrol.8,
camcontrol.c: Add smp passthrough support to camcontrol. Several
new subcommands are now available:

'smpcmd' functions much like 'cmd', except that it
allows the user to send generic SMP commands.

'smprg' sends the SMP report general command, and
displays the decoded output. It will automatically
fetch extended output if it is available.

'smppc' sends the SMP phy control command, with any
number of potential options. Among other things,
this allows the user to reset a phy on a SAS
expander, or disable a phy on an expander.

'smpmaninfo' sends the SMP report manufacturer
information and displays the decoded output.

'smpphylist' displays a list of phys on an
expander, and the CAM devices attached to those
phys, if any.

cam.h,
cam.c: Add a status value for SMP errors
(CAM_SMP_STATUS_ERROR).

Add a missing description for CAM_SCSI_IT_NEXUS_LOST.

Add support for SMP commands to cam_error_string().

cam_ccb.h: Rename the CAM_DIR_RESV flag to CAM_DIR_BOTH. SMP
commands are by nature bi-directional, and we may
need to support bi-directional SCSI commands later.

Add the XPT_SMP_IO CCB. Since SMP commands are
bi-directional, there are pointers for both the
request and response.

Add a fill routine for SMP CCBs.

Add the XPT_GDEV_ADVINFO CCB. This is currently
used to fetch cached page 0x83 data from the
transport later, but is extensible to fetch many
other types of data.

cam_periph.c: Add support in cam_periph_mapmem() for XPT_SMP_IO
and XPT_GDEV_ADVINFO CCBs.

cam_xpt.c: Add support for executing XPT_SMP_IO CCBs.

cam_xpt_internal.h: Add fields for VPD pages 0x00 and 0x83 in struct
cam_ed.

scsi_all.c: Add scsi_get_sas_addr(), a function that parses
VPD page 0x83 data and pulls out a SAS address.

scsi_all.h: Add VPD page 0x00 and 0x83 structures, and a
prototype for scsi_get_sas_addr().

scsi_pass.c: Add support for mapping buffers in XPT_SMP_IO and
XPT_GDEV_ADVINFO CCBs.

scsi_xpt.c: In the SCSI probe code, first ask the device for
VPD page 0x00. If any VPD pages are supported,
that page is required to be implemented. Based on
the response, we may probe for the serial number
(page 0x80) or device id (page 0x83).

Add support for the XPT_GDEV_ADVINFO CCB.

sys/conf/files: Add smp_all.c.

mps.c: Add support for passing in a uio in mps_map_command(),
so we can map a S/G list at once.

Add support for SMP passthrough commands in
mps_data_cb(). SMP is a special case, because the
first buffer in the S/G list is outbound and the
second buffer is inbound.

Add support for warning the user if the busdma code
comes back with more buffers than will work for the
command. This will, for example, help the user
determine why an SMP command failed if busdma comes
back with three buffers.

mps_pci.c: Add sys/uio.h.

mps_sas.c: Add the SAS address and the parent handle to the
list of fields we pull from device page 0 and cache
in struct mpssas_target. These are needed for SMP
passthrough.

Add support for the XPT_SMP_IO CCB. For now, this
CCB is routed to the addressed device if it supports
SMP, or to its parent if it does not and the parent
does. This is necessary because CAM does not
currently support SMP-only nodes in the topology.

Make SMP passthrough support conditional on
__FreeBSD_version >= 900026. This will make it
easier to MFC this change to the driver without
MFCing the CAM changes as well.

mps_user.c: Un-staticize mpi_init_sge() so we can use it for
the SMP passthrough code.

mpsvar.h: Add a uio and iovecs into struct mps_command for
SMP passthrough commands.

Add a cm_max_segs field to struct mps_command so
that we can warn the user if busdma comes back with
too many segments.

Clear the cm_reply when a command gets freed. If
it is not cleared, reply frames will eventually get
freed into the pool multiple times and corrupt the
pool. (This fix is from scottl.)

Add a prototype for mpi_init_sge().

sys/param.h: Bump __FreeBSD_version to 900026 for the for the
inclusion of the XPT_GDEV_ADVINFO and XPT_SMP_IO
CAM CCBs.


215454 18-Nov-2010 mav

If HBA doesn't report user-enabled SATA capabilies (like ATA_CAM wrapper) -
handle all of them as disabled. This was original cause of the problem,
workarounded by r215453.

MFC after: 1 week


214989 08-Nov-2010 mav

When requesting sense data for SIM not doing it automatically (such as
ATAPI or USB), request only as much data as requested by consumer.
On the way back -- report how much sense data we have actually received.


214288 24-Oct-2010 mav

Make da driver to handle some probably broken Android devices, returning
zero media and sector size instead of "Medium not present" error,
until some confirmation button is tapped on device.


214279 24-Oct-2010 brucec

Mostly revert r203420, and add similar functionality into ada(4) since the
existing code caused problems with some SCSI controllers.

A new sysctl kern.cam.ada.spindown_shutdown has been added that controls
whether or not to spin-down disks when shutting down.
Spinning down the disks unloads/parks the heads - this is
much better than removing power when the disk is still
spinning because otherwise an Emergency Unload occurs which may cause damage
to the actuator.

PR: kern/140752
Submitted by: olli
Reviewed by: arundel
Discussed with: mav
MFC after: 2 weeks


212991 22-Sep-2010 mav

Decrease poll interval from 1000 to 100us. This significantly reduces
kernel dump time, especially with minidump.


212926 20-Sep-2010 mdf

Use destroy_dev_sched(9) instead of destroy_dev(9) in passcleanup() as
it is indirectly a d_close method.

Prompted by: kib
Reviewed by: mav
MFC after: 2 weeks


212160 02-Sep-2010 gibbs

Correct bioq_disksort so that bioq_insert_tail() offers barrier semantic.
Add the BIO_ORDERED flag for struct bio and update bio clients to use it.

The barrier semantics of bioq_insert_tail() were broken in two ways:

o In bioq_disksort(), an added bio could be inserted at the head of
the queue, even when a barrier was present, if the sort key for
the new entry was less than that of the last queued barrier bio.

o The last_offset used to generate the sort key for newly queued bios
did not stay at the position of the barrier until either the
barrier was de-queued, or a new barrier (which updates last_offset)
was queued. When a barrier is in effect, we know that the disk
will pass through the barrier position just before the
"blocked bios" are released, so using the barrier's offset for
last_offset is the optimal choice.

sys/geom/sched/subr_disk.c:
sys/kern/subr_disk.c:
o Update last_offset in bioq_insert_tail().

o Only update last_offset in bioq_remove() if the removed bio is
at the head of the queue (typically due to a call via
bioq_takefirst()) and no barrier is active.

o In bioq_disksort(), if we have a barrier (insert_point is non-NULL),
set prev to the barrier and cur to it's next element. Now that
last_offset is kept at the barrier position, this change isn't
strictly necessary, but since we have to take a decision branch
anyway, it does avoid one, no-op, loop iteration in the while
loop that immediately follows.

o In bioq_disksort(), bypass the normal sort for bios with the
BIO_ORDERED attribute and instead insert them into the queue
with bioq_insert_tail(). bioq_insert_tail() not only gives
the desired command order during insertion, but also provides
barrier semantics so that commands disksorted in the future
cannot pass the just enqueued transaction.

sys/sys/bio.h:
Add BIO_ORDERED as bit 4 of the bio_flags field in struct bio.

sys/cam/ata/ata_da.c:
sys/cam/scsi/scsi_da.c
Use an ordered command for SCSI/ATA-NCQ commands issued in
response to bios with the BIO_ORDERED flag set.

sys/cam/scsi/scsi_da.c
Use an ordered tag when issuing a synchronize cache command.

Wrap some lines to 80 columns.

sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
sys/geom/geom_io.c
Mark bios with the BIO_FLUSH command as BIO_ORDERED.

Sponsored by: Spectra Logic Corporation
MFC after: 1 month


211529 20-Aug-2010 mjacob

Revert r211434. Offline discussions have convinced me that this should
be left alone for now.


211434 17-Aug-2010 mjacob

Now is as good a time as any to find out if we induce breakage
by issueing aborts for any pending commands when we're decommssioning
a disk.

MFC after: 3 months


210779 02-Aug-2010 bcr

Fix two (very common) occurrences of s/sytem/system in comments.

Approved by: mav
MFC after: 3 days


210471 25-Jul-2010 mav

Export PCI IDs of ATA/SATA controllers through CAM and ata(4) layers to
GEOM. This information needed for proper soft-RAID's on-disk metadata
reading and writing.


209744 06-Jul-2010 mav

ATA device reset starts probe sequence from the beginning. If reset caused
by timeout/error of one of probe commands, process may continue infinitely.
Make CAM ATA more robust to faulty devices and false positive detections,
abort probe after two restarts on timeouts or ten on other errors.


209590 29-Jun-2010 mjacob

Don't lock buses around a call to xptperiphlistmatch- the buses will be
locked at appropriate places.

MFC after: 1 week
X-MFC: 208752


209188 14-Jun-2010 ken

For the target port groups structures, don't allocate the initial element.
This makes things easier for target implementations to calculate how many
elements they need to allocate.

Discussed with: mjacob, gibbs
MFC after: 1 week


208928 08-Jun-2010 mjacob

Rearrange how things are done to avoid dereferencing stale pointers in
the case of immediate unconfigure after configure. Hold the periph an
extra count while we have the task to create sysctl context outstanding
so that the periph doesn't go away unexpectedly.

Sponsored by: Panasas
Reviewed by: scsi@
MFC after: 1 month


208918 08-Jun-2010 mjacob

One byte off for scsi_target_group cdb.

MFC after: 2 weeks


208911 08-Jun-2010 mjacob

Implement the usage of Report Luns as part of SCSI probing for SCP3 or
better devices. This can be disabled on a per-device basis using quirks as
well.

This also handles the case where there is actually no connected LUN 0
(which can definitely be the case for storage arrays).

Reviewed by: scsi@
MFC after: 1 month


208905 08-Jun-2010 mjacob

Make additional definitions up to and including SPC-4. Add in definitions
for REPORT and SET TARGET PORT GROUP commands (foundations for future work).

Regularize opcodes to be upper case hex.

Pick *one* of tab or space after #define (tab) and stick with that.

MFC after: 2 weeks


208900 07-Jun-2010 mjacob

redfacedly noting a missing part of a patch.

Pointy Hat To: Me
MFC after: 2 Week
X-MFC: 208896


208896 07-Jun-2010 mjacob

Do a minor amount of stylifying. Also, get a Fibre Channel WWPN if one exists
for a da unit and create a sysctl OID for it.


208823 05-Jun-2010 mav

Add allocation error hadling.

Found with: Coverity Prevent(tm)
CID: 3897


208819 05-Jun-2010 mav

Fix double free on error.

Found with: Coverity Prevent(tm)
CID: 4573


208800 04-Jun-2010 avg

scsi_cd: pass correct pointer to free()

Found with: Coverity Prevent(tm)
CID: 2986
MFC after: 4 days


208752 02-Jun-2010 mjacob

Protect periph drivers list and rearrange things to minimize the chance of
stepping oneself during probing.

Don't blindly decrement a periph probe count.

Reviewed by: scsi@
Obtained from: Alexander Motin, Atillio Rao, Others
MFC after: 1 month


208582 26-May-2010 mjacob

Add a new primitive, XPT_SCAN_TGT, to cover the range between scanning a
whole bus (XPT_SCAN_BUS) and a single lun on that bus (XPT_SCAN_LUN).

It's less resource comsumptive than scanning a whole bus when the
caller knows only one target has changes.

Reviewed by: scsi@
Sponsored by: Panasas
MFC after: 1 month


208349 20-May-2010 marius

Change ad_firmware_geom_adjust() to operate on a struct disk * only and
hook it up to ada(4) also. While at it, rename *ad_firmware_geom_adjust()
to *ata_disk_firmware_geom_adjust() etc now that these are no longer
limited to ad(4).

Reviewed by: mav
MFC after: 3 days


208348 20-May-2010 marius

Remove unnecessary headers which were inherited from cam_xpt.c without
reason.

Reviewed by: mav
MFC after: 3 days


207938 11-May-2010 mjacob

Pick up the right change, not it's close cousin. The one
previously submitted was wrong.

Point hat: mjacob
X-MFC: 207933
MFC after: 1 week


207933 11-May-2010 mjacob

Deal sensibly with more than 26 sg devices. It isn't a complete
solution.

Sponsored by: Panasas
MFC after: 1 week


207499 02-May-2010 mav

Make SATA XPT negotiate and enable some additional SATA features, such as:
- device initiated power management (some devices support only this way);
- Automatic Partial to Slumber Transition (more power saving);
- DMA auto-activation (expected to slightly improve performance).
More features could be added later, when hardware supports.


207490 02-May-2010 mav

Add xpt_schedule_dev_sendq() call, lost at r203108. It is not needed in
usual operation, but required in some conditions to make queue running
after being shrinked.

MFC after: 3 days


207433 30-Apr-2010 mav

Revert r198705.
As scottl@ noticed, max_target/max_lun was intended to be only a hint for
existing bus scanner. Some FC/SAS SIMs report fake values there, that are
smaller then maximum supported IDs. In that case this check makes impossible
manual scan outside hinted range.

For ATA/SATA SIMs respective check was instead implemented at SIM level.
Newer SCSI SIMs expected to have these checks at driver or firmware level.
Some older SCSI SIMs have no this check and the issues will get back there.


207428 30-Apr-2010 mav

Report PMP absence using target 15, same as for precence (not a wildcard),
to not confuse target ID checks at SIMs.


207282 27-Apr-2010 mav

Update device identify data and serial number when device change detected.
Reprobe immediately following this should have fresh data.


207222 26-Apr-2010 mav

MFp4:
Move PI_TAG_ABLE check from ada driver to ATA XPT.


206648 15-Apr-2010 avg

scsi_cd: CD_FLAG_VALID_MEDIA is sufficient to set d_sectorsize and
d_mediasize

CD_FLAG_VALID_TOC is not required for setting those media properties.

PR: kern/145385
Submitted by: Juergen Lock <nox@jelal.kn-bremen.de>
a slightly different version
Tested by: Pavel Sukhoy <sukhoy@ripn.net>,
Markus Wild <m.wild@cybernet.ch>,
Juergen Lock <nox@jelal.kn-bremen.de>,
uqs
MFC after: 1 week


206112 02-Apr-2010 mjacob

Nullify our periph pointer in dacleanup to try and catch
race conditions in callbacks/downcalls.


206029 01-Apr-2010 mjacob

Add a couple missing basic mode page codes.

MFC after: 1 week


205993 31-Mar-2010 mjacob

For unhandled actions in xpt_action_default, remember to call
xpt_done for queued requests. This solves the problem of
indefinite hangs for unspecified transports when XPT_SCAN_BUS
is called.

A few minor cosmetics elsewhere.

MFC after: 1 week


205252 17-Mar-2010 mjacob

We actually can generate a host number.

MFC after: 1 month


204354 26-Feb-2010 mav

Make PUIS detection more strict. Previous implementation caused false
positives on VMWare's virtual CD-ROMs.


204353 26-Feb-2010 mav

Fix newlines broken at r204220.


204253 23-Feb-2010 mav

Make xpt_rescan() more correct, as it was before r197208: do not use
XPT_SCAN_LUN for wildcard LUN, fall back to XPT_SCAN_BUS.


204220 22-Feb-2010 mav

Virtualize transport part of periph announcement.


204195 22-Feb-2010 mav

Improve output for controllers that doesn't report SATA speed.


203931 15-Feb-2010 mav

Make CD driver a bit more robust and predictable to unreported errors.


203499 04-Feb-2010 mav

On probe error, if restart requested, skip any retries and recovery.
Just restart probe from the beginning immediately.


203440 03-Feb-2010 mav

Disable kern.cam.power_down ATM. It doesn't work fine on some controllers.


203421 03-Feb-2010 mav

MFp4:
Add Power Up In Stand-by feature support. Device with PUIS enabled
require explicit command to do initial spin-up. Mark that command
with CAM_HIGH_POWER flag, to allow CAM manage staggered spin-up.


203420 03-Feb-2010 mav

MFp4:
Make CAM to stop all attached devices on system shutdown.
It allows devices to park heads, reducing stress on power loss.
Add `kern.cam.power_down` tunable and sysctl to controll it.


203386 02-Feb-2010 mav

Change the way in which fake async events generated. Do not use
taskqueue for lock decoupling, as it causes unwanted races.


203385 02-Feb-2010 mav

- Use separate buffer for identify data fetching. We can't use main buffer
here if device already running, as data need to be formatted before use.
- Remove some saved_ccb variables. They are unused now.


203384 02-Feb-2010 mav

Some missed parts for r203376.


203376 02-Feb-2010 mav

- Give ATA/SATA SIMs info about ATAPI packet size, supported by device.
- Make ATA XPT to reject longer SCSI CDBs then supported by device, or
any SCSI CDBs, if device doesn't support ATAPI.


203108 28-Jan-2010 mav

MFp4: Large set of CAM inprovements.

- Unify bus reset/probe sequence. Whenever bus attached at boot or later,
CAM will automatically reset and scan it. It allows to remove duplicate
code from many drivers.
- Any bus, attached before CAM completed it's boot-time initialization,
will equally join to the process, delaying boot if needed.
- New kern.cam.boot_delay loader tunable should help controllers that
are still unable to register their buses in time (such as slow USB/
PCCard/ CardBus devices), by adding one more event to wait on boot.
- To allow synchronization between different CAM levels, concept of
requests priorities was extended. Priorities now split between several
"run levels". Device can be freezed at specified level, allowing higher
priority requests to pass. For example, no payload requests allowed,
until PMP driver enable port. ATA XPT negotiate transfer parameters,
periph driver configure caching and so on.
- Frozen requests are no more counted by request allocation scheduler.
It fixes deadlocks, when frozen low priority payload requests occupying
slots, required by higher levels to manage theit execution.
- Two last changes were holding proper ATA reinitialization and error
recovery implementation. Now it is done: SATA controllers and Port
Multipliers now implement automatic hot-plug and should correctly
recover from timeouts and bus resets.
- Improve SCSI error recovery for devices on buses without automatic sense
reporting, such as ATAPI or USB. For example, it allows CAM to wait, while
CD drive loads disk, instead of immediately return error status.
- Decapitalize diagnostic messages and make them more readable and sensible.
- Teach PMP driver to limit maximum speed on fan-out ports.
- Make boot wait for PMP scan completes, and make rescan more reliable.
- Fix pass driver, to return CCB to user level in case of error.
- Increase number of retries in cd driver, as device may return several UAs.


201990 10-Jan-2010 mav

- Report SATA in legacy emulation mode still as SATA.
- Make ATA XPT able to handle such case.


201758 07-Jan-2010 mbr

Remove extraneous semicolons, no functional changes.

Submitted by: Marc Balmer <marc@msys.ch>
MFC after: 1 week


201139 28-Dec-2009 mav

Add BIO_DELETE support to ada(4):
- For SSDs use TRIM feature of DATA SET MANAGEMENT command, as defined by
ACS-2 specification working draft.
- For CompactFlash use CFA ERASE command, same as ad(4) does.

With this patch, `newfs -E /dev/ada1` was able to restore write speed of
my heavily weared OCZ Vertex SSD (firmware 1.4) up to the initial level
for the most part of it's capacity. Previous 1.3 firmware, even reportiong
TRIM capabilty bit set, was not working, reporting ABORT error for every
DSM command.

I have no idea whether it is normal, but for some reason it takes 200ms
to handle any TRIM command on this drive, that was making delete extremely
slow. But TRIM command is able to accept long list of LBAs and the length of
that list seems doesn't affect it's execution time. Implemented request
clusting algorithm allowed me to rise delete rate up to reasonable numbers,
when many parallel DELETE requests running.


200969 24-Dec-2009 mav

Report stripe size only if physical sector size is not equal to logical.


200668 18-Dec-2009 mav

Remove duplicate devstat_start_transaction_bio() call. It is already called
from geom_disk. Dulicate call causes wrong queue depth and busy accounting.


200295 09-Dec-2009 mav

Clear result before requesting XPT_PATH_INQ.
Many SIMs doesn't fill maxio field yet.


200218 07-Dec-2009 mav

MFp4;
- Cleanup kernel messages, mostly PMP.
- Took references on devices, while PMP reinitializes them, to not let them
go and distort freeze reference counting.


200180 06-Dec-2009 mav

MFp4:
If we panicked with SIM lock held, do not try to flush caches.
Extra lock recursing will not make debugging easier.


200171 06-Dec-2009 mav

MFp4:
Introduce ATA_CAM kernel option, turning ata(4) controller drivers into
cam(4) interface modules. When enabled, this options deprecates all ata(4)
peripheral drivers (ad, acd, ...) and interfaces and allows cam(4) drivers
(ada, cd, ...) and interfaces to be natively used instead.

As side effect of this, ata(4) mode setting code was completely rewritten
to make controller API more strict and permit above change. While doing
this, SATA revision was separated from PATA mode. It allows DMA-incapable
SATA devices to operate and makes hw.ata.atapi_dma tunable work again.

Also allow ata(4) controller drivers (except some specific or broken ones)
to handle larger data transfers. Previous constraint of 64K was artificial
and is not really required by PCI ATA BM specification or hardware.

Submitted by: nwitehorn (powerpc part)


200036 02-Dec-2009 scottl

Fix several cases where the periph lock was held over malloc.

Submitted by: Jaakko Heinonen


200008 01-Dec-2009 mav

Add CAM_ATAIO_DMA ATA command flag to mark DMA protocol commands.
It is not needed for SATA controllers, but required for PATA.


199821 26-Nov-2009 mav

MFp4:
Improve ATA mode/SATA revision control.


199799 25-Nov-2009 mav

Fix small copu-paste bug.


199747 24-Nov-2009 mav

MFp4:
- Extend XPT-SIM transfer settings control API. Now it allows to report to
SATA SIM number of tags supported by each device, implement ATA mode and
SATA revision negotiation for both SATA and PATA SIMs.
- Make ahci(4) and siis(4) to use submitted maximum tag number, when
scheduling requests. It allows to support NCQ on devices with lower tags
count then controller supports.
- Make PMP driver to report attached devices connection speeds.
- Implement ATA mode negotiation between user settings, device and
controller capabilities.


199321 16-Nov-2009 mav

Disable PortMultiplier Async Notifications for time of ports reset.
They are useless at that time, but confuse Marvell AHCI.

Add quirk for SiI57XX Port Multipliers, to hide extra port.


199281 14-Nov-2009 mav

MFp4:
Some more missed parts from previous commits.


199280 14-Nov-2009 mav

MFp4:
Remove code that years ago was closing race between request submission
to SIM and device/SIM freeze. That race become impossible after moving from
spl to mutex locking, while this workaround causes some unexpected effects.


199279 14-Nov-2009 mav

MFp4:
Fix several device freeze counting bugs.


199263 14-Nov-2009 mav

MFp4:
Do not enable tagged queueing if controller reports 0 tags support.


199178 11-Nov-2009 mav

MFp4:
- Move tagged queueing control from ADA to ATA XPT. It allows to control
device command queue length correctly. First step to support < 32 tags.
- Limit queue for non-tagged devices by 2 slots for ahci(4) and siis(4).
- Implement quirk matching for ATA devices.
- Move xpt_schedule_dev_sendq() from header to source file.
- Move delayed queue shrinking to the more expected place - element freeing.
- Remove some SCSIsms in ATA.


198947 05-Nov-2009 mav

MFp4:
Implement device stats accounting for ATA commands.


198905 04-Nov-2009 mav

Fix protype.


198904 04-Nov-2009 mav

PMP commands use short format. PMP write doesn't return result.


198899 04-Nov-2009 mav

MFp4:
- Remove CAM_PERIPH_POLLED flag. It is broken by design. Polling can't be
periph flag. May be SIM, may be CCB, but now it works fine just without it.
- Remove check unused for at least five years. If we will ever have non-BIO
devices in CAM, this check is smallest of what we will need.
- If several controllers complete requests same time, call swi_sched()
only once.


198897 04-Nov-2009 mav

MFp4:
- Add support for sector size > 512 bytes and physical sector of several
logical sectors, introduced by ATA-7 specification.
- Remove some obsoleted code.


198849 03-Nov-2009 mav

MFp4:
Improve reporting ATA Status error details.


198832 02-Nov-2009 thompsa

Provide the same sanity check on the sector size in dagetcapacity as when the
disk is first probed. dagetcapacity is called whenever the disk is opened from
geom via d_open(), a zero sector size will cause geom to panic later on.


198782 02-Nov-2009 mav

The async callback could free the device. If it is a broadcast async,
it doesn't hold device reference, so take our own reference.

Submitted by: thompsa


198748 01-Nov-2009 mav

MFp4:
Fix reference counting bug, when device unreferenced before then
invalidated. To do it, do not handle validity flag as another
reference, but explicitly modify reference count each time flag is
modified.

Discovered by: thompsa


198708 31-Oct-2009 mav

MFp4:
- Reduce code duplication in ATA XPT and PMP driver.
- Move PIO size setting from ada driver to ATA XPT. It is XPT business
to negotiate transfer details. ada driver is now stateless.
- Report PIO size to SIM. It is required for correct PATA SIM operation.
- Tune PMP scan timings. It workarounds some problems with SiI.
- If reset hapens during PMP initialization - restart it.
- Introduce early-initialized periph drivers, which are used during initial
scan process. Use it for xpt, probe, aprobe and pmp. It gives pmp chance
to finish scan before mountroot and numerate devices in right order.


198705 31-Oct-2009 mav

MFp4:
Ensure target/lun passed from user-level supported on this bus.
Scanning unsupported IDs causes different issues from duplicate
devices to system crash.


198394 23-Oct-2009 mav

Make "Retrying Command" to be printed before actual retrying.
It should make debug/error log a bit more readable.


198389 23-Oct-2009 mav

MFp4:
Move Port Multiplier support code out of ATA XPT into pmp periph driver.
This is convinient, as PMP itself is a bus target and has own state.


198385 23-Oct-2009 mav

Fix the build.


198382 23-Oct-2009 mav

Replace most of priority numbers with defines. No logical changes.


198381 23-Oct-2009 mav

Remove some obsoleted comments.


198377 22-Oct-2009 mav

After thinking again, implement cam_ccbq_fini().
This is effectively NULL change, but makes this API a bit more consistent.


198372 22-Oct-2009 mav

cam_ccbq_fini() declared for 11 years, but never implemented. Remove it.


198356 22-Oct-2009 brueffer

Fix a memory leak in an error case.

PR: 138376
Submitted by: Patroklos Argyroudis <argp@census-labs.com>
Reviewed by: scottl
MFC after: 1 week


198333 21-Oct-2009 mav

MFp4:
Do not search for bus when it is not needed,


198331 21-Oct-2009 mav

MFp4:
Separate CAM_DEV_IDENTIFY_DATA_VALID flag from CAM_DEV_INQUIRY_DATA_VALID.
Add workaround for very old devices without support for mode setting.
Add some PATA bus scanning support.
Remove some SCSIsms.


198328 21-Oct-2009 mav

MFp4:
Add support for PIO-only devices.
Fix maxio values and 256 sectors transactions for 28bits commands.
Implement periodic ordered commands insertion, sames as da driver does.
Remove some SCSIsms.


198322 21-Oct-2009 mav

MFp4:
Report real max_target = 15. SIM doesn't need to know that target 15 is PMP.
It is XPT business.


197896 09-Oct-2009 pjd

Export disk serial numbers for adaX disks.

Reviewed by: mav
MFC after: 3 days


197541 27-Sep-2009 mav

Report SATA 3.x devices.


197421 22-Sep-2009 mav

MFp4:
If on sense request device returns no sence, give up and return,
or we may loop forever.


197332 19-Sep-2009 mjacob

Remember to unlock the peripheral prior to notifying the user. Make some
allocations M_NOWAIT so that we don't try and sleep with a nested non-sleepable
lock.

This makes the userland scsi_target begin to function again.

Obtained from: Sean Bruno
MFC after: 1 month


197208 15-Sep-2009 ken

Fix some instances where CAM rescans get hung up or take a long time to
complete.

Also, allow xpt_rescan() to rescan a LUN instead of a full bus.

MFC after: 3 days
Sponsored by: Copan Systems, Inc.


197134 12-Sep-2009 rwatson

Use C99 initialization for struct filterops.

Obtained from: Mac OS X
Sponsored by: Apple Inc.
MFC after: 3 weeks


196983 08-Sep-2009 scottl

Free the correct buffer in an error case.

Submitted by: phk


196970 08-Sep-2009 phk

Revert previous commit and add myself to the list of people who should
know better than to commit with a cat in the area.


196969 08-Sep-2009 phk

Add necessary include.


196903 06-Sep-2009 mav

MFp4:
Remove duplicate qfrozen_cnt variable from struct cam_ed.
ccbq.queue.qfrozen_cnt should be used instead.


196901 06-Sep-2009 mav

Remove unneeded CAM_SIM_MPSAFE check.


196900 06-Sep-2009 mav

s/bus %d/scbus%d/ in some messages to correct terminology.


196898 06-Sep-2009 mav

MFp4:
Report scbusX in xpt_announce_periph() to less confuse users by two
different bus addressing schemes.


196897 06-Sep-2009 mav

Avoid extra swi_sched() call, if this SIM is already queued.
It reduces overhead for coalesced command completions.


196824 04-Sep-2009 pjd

Make serial numbers of daX disks visible by GEOM.

No objections from: scottl
Obtained from: Wheel Sp. z o.o. (http://www.wheel.pl)


196659 30-Aug-2009 mav

Short ATA command format has 28bit address, not 36bit.
Rename ata_36bit_cmd() into ata_28bit_cmd(), while it didn't become legacy.

MFC after: 2 days


196657 30-Aug-2009 mav

ATA_FLUSHCACHE is a 36bit format command, not 48.


196568 26-Aug-2009 stas

- Add quirk for Sony DSC digital cameras. This umass devices fail
to attach without these quirks applied.

PR: usb/137035
URL: http://lists.freebsd.org/pipermail/freebsd-current/2009-August/010852.html
Reported by: Henri Hennebert <hlh@restart.be>, Andrey V. Elsukov <bu7cher@yandex.ru>
MFC after: 1 week


196353 18-Aug-2009 mav

Fix copy/paste bug, that requests data read during ATA device probe sequence
for ATA_SETFEATURES/ATA_SF_SETXFER command which by definition transfers no
data. Most of controllers are irrelevant to this bug, but some nVidia's
doesn't.

Tested on: current@
Approved by: re (kib)


196352 18-Aug-2009 mav

Fix iSCSI initiator and vpo driver operation, broken by CAM changes.

Reviewed by: scottl, Danny Braniss
Approved by: re (rwatson)


196008 01-Aug-2009 mjacob

Add 8Gb support (isp_2500). Fix a fair number of configuration and
firmware loading bugs.

Target mode support has received some serious attention to make it
more usable and stable.

Some backward compatible additions to CAM have been made that make
target mode async events easier to deal with have also been put
into place.

Further refinement and better support for NP-IV (N-port Virtualization)
is now in place.

Code for release prior to RELENG_7 has been stripped away for code clarity.

Sponsored by: Copan Systems

Reviewed by: scottl, ken, jung-uk kim
Approved by: re


195748 17-Jul-2009 mav

Fix copy-paste bug. Use regular non-polled mode for executing FLUSHCACHE
command on disk close.

Approved by: re (implicitly)


195688 14-Jul-2009 emaste

Change xpt_scan_bus to scsi_scan_bus and xpt_scan_lun to scsi_scan_lun
in comments and printfs to match new function names after refacoring.

Approved by: re


195685 14-Jul-2009 emaste

Fix leaks in probestart, probedone, and scsi_scan_bus. Also free
page_list using the matching malloc type for the allocation.

Approved by: re
Reviewed by: scottl [1]
MFC after: 1 week

[1] Original patch was against xpt_cam.c, prior to the cam refactoring.


195665 13-Jul-2009 mav

Fix copy-paste bug, enabling SIM PMP support, when it was not really found.

Approved by: re (implicitly)


195653 13-Jul-2009 mav

Rename ATA probe driver to "aprobe" to resolve name conflict with SCSI
and fix loading cam as module.

Approved by: re (implicitly)


195534 10-Jul-2009 scottl

Separate the parallel scsi knowledge out of the core of the XPT, and
modularize it so that new transports can be created.

Add a transport for SATA

Add a periph+protocol layer for ATA

Add a driver for AHCI-compliant hardware.

Add a maxio field to CAM so that drivers can advertise their max
I/O capability. Modify various drivers so that they are insulated
from the value of MAXPHYS.

The new ATA/SATA code supports AHCI-compliant hardware, and will override
the classic ATA driver if it is loaded as a module at boot time or compiled
into the kernel. The stack now support NCQ (tagged queueing) for increased
performance on modern SATA drives. It also supports port multipliers.

ATA drives are accessed via 'ada' device nodes. ATAPI drives are
accessed via 'cd' device nodes. They can all be enumerated and manipulated
via camcontrol, just like SCSI drives. SCSI commands are not translated to
their ATA equivalents; ATA native commands are used throughout the entire
stack, including camcontrol. See the camcontrol manpage for further
details. Testing this code may require that you update your fstab, and
possibly modify your BIOS to enable AHCI functionality, if available.

This code is very experimental at the moment. The userland ABI/API has
changed, so applications will need to be recompiled. It may change
further in the near future. The 'ada' device name may also change as
more infrastructure is completed in this project. The goal is to
eventually put all CAM busses and devices until newbus, allowing for
interesting topology and management options.

Few functional changes will be seen with existing SCSI/SAS/FC drivers,
though the userland ABI has still changed. In the future, transports
specific modules for SAS and FC may appear in order to better support
the topologies and capabilities of these technologies.

The modularization of CAM and the addition of the ATA/SATA modules is
meant to break CAM out of the mold of being specific to SCSI, letting it
grow to be a framework for arbitrary transports and protocols. It also
allows drivers to be written to support discrete hardware without
jeopardizing the stability of non-related hardware. While only an AHCI
driver is provided now, a Silicon Image driver is also in the works.
Drivers for ICH1-4, ICH5-6, PIIX, classic IDE, and any other hardware
is possible and encouraged. Help with new transports is also encouraged.

Submitted by: scottl, mav
Approved by: re


194990 25-Jun-2009 kib

Change the type of uio_resid member of struct uio from int to ssize_t.
Note that this does not actually enable full-range i/o requests for
64 architectures, and is done now to update KBI only.

Tested by: pho
Reviewed by: jhb, bde (as part of the review of the bigger patch)


194627 22-Jun-2009 scottl

Change cam_periph_ioctl() to take 'cmd' and a u_long instead of an
int. All of its callers pass in cmd as a u_long, so this has
always been a dangerous type demotion. It was spooted by clang/llvm
trying to do a type promotion and sign extension within
cam_periph_ioctl.

Submitted by: rdivacky


194189 14-Jun-2009 ed

Include <camlib.h> for cam_path_string().

Submitted by: Pawel Worach


193951 10-Jun-2009 kib

Adapt vfs kqfilter to the shared vnode lock used by zfs write vop. Use
vnode interlock to protect the knote fields [1]. The locking assumes
that shared vnode lock is held, thus we get exclusive access to knote
either by exclusive vnode lock protection, or by shared vnode lock +
vnode interlock.

Do not use kl_locked() method to assert either lock ownership or the
fact that curthread does not own the lock. For shared locks, ownership
is not recorded, e.g. VOP_ISLOCKED can return LK_SHARED for the shared
lock not owned by curthread, causing false positives in kqueue subsystem
assertions about knlist lock.

Remove kl_locked method from knlist lock vector, and add two separate
assertion methods kl_assert_locked and kl_assert_unlocked, that are
supposed to use proper asserts. Change knlist_init accordingly.

Add convenience function knlist_init_mtx to reduce number of arguments
for typical knlist initialization.

Submitted by: jhb [1]
Noted by: jhb [2]
Reviewed by: jhb
Tested by: rnoland


192019 12-May-2009 trasz

Remove dead code.

Found with: Coverity Prevent(tm)
CID: 3667


192016 12-May-2009 trasz

Add missing free(9) in error case.

Found with: Coverity Prevent(tm)
CID: 4224


192015 12-May-2009 trasz

Add missing 'break' statements.

Found with: Coverity Prevent(tm)
CID: 3936, 3937
Reviewed by: scottl@


191304 20-Apr-2009 ed

Get rid of the device index number stored in the sa(4) unit number.

The device index number stored in the unit number of sa(4) devices is
only used to print debug messages. Get rid of this index number and use
devtoname() to just print the entire device name.


191243 18-Apr-2009 ed

Remove unused SESUNIT() macro from ses(4).


190878 10-Apr-2009 thompsa

Revert r190676,190677

The geom and CAM changes for root_hold are the wrong solution for USB design
quirks.

Requested by: scottl


190677 03-Apr-2009 thompsa

Add interleaving root hold tokens from the CAM probe to disk_create and geom
provider tasting. This is needed for disk attachments that happen after threads
are running in the boot process.

Tested by: rnoland


188688 16-Feb-2009 scottl

GCC attacks!


188671 16-Feb-2009 scottl

Fix parallel SCSI negotiation in the CAM_NEW_TRAN_CODE world order.
Overzealous sanity checks were locking the sync_rate and offset values to
zero, thanks to a twisty maze of recursive code.


188670 16-Feb-2009 scottl

Instrument the probe state machine so that things like DV can be tracked.


188570 13-Feb-2009 scottl

In the case that the probe has determined that it can't query the device for
a serial number, fall through to the next case so that initial negotiation
still happens. Without this, devices were showing up with only 1 available
tag opening, leading to observations of very poor I/O performance.

This should fix problems reported with VMWare Fusion and ESX. Early
generation MPT-SAS controllers with SATA disks might also be affected.
HP CISS controllers are also likely affected, as are many other
pseudo-scsi disk subsystems.


188503 11-Feb-2009 jhb

Reorder dacleanup() and cdcleanup() slightly so that the sysctl context is
freed while the periph lock is not held. While here, wait until after
freeing the softc before reacquiring the periph lock.

Tested by: sbruno


188458 10-Feb-2009 jhb

Adding dynamic sysctls no longer requires Giant.

Submitted by: rdivacky


188395 09-Feb-2009 fjoe

cam_periph_alloc: fix "invalid periph name" error condition

Found with: Coverity Prevent(tm)
CID: 130


188345 08-Feb-2009 trasz

Remove an overzealous check.

Submitted by: das
Reviewed by: scottl
Approved by: rwatson (mentor, implicit)
Sponsored by: FreeBSD Foundation


187957 31-Jan-2009 bz

There is no need to initialize the variable here.

Submitted by: Christoph Mallon christoph.mallon@gmx.de
Reviewed by: kib (as part of a larger patch)
MFC after: 2 weeks


187718 26-Jan-2009 jhb

Now that mtx_sleep/msleep can accept Giant as the interlock, simplify the
CAM locking code slightly to no longer special case sleeping when a sim
uses Giant for its lock.

Tested by: trasz


187652 23-Jan-2009 trasz

Protect against NULL pointer dereference.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation


187651 23-Jan-2009 trasz

Don't leak memory when alloc fails.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation
Found with: Coverity Prevent(tm)
CID: 2908


187650 23-Jan-2009 trasz

Guard against NULL pointer dereference.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation
Found with: Coverity Prevent(tm)
CID: 1847


187649 23-Jan-2009 trasz

Guard against NULL pointer dereference.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation
Found with: Coverity Prevent(tm)
CID: 130


187247 14-Jan-2009 trasz

Add missing 'break' statement.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation
Found with: Coverity Prevent(tm)
CID: 3667


187245 14-Jan-2009 trasz

Fix use after free.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation
Found with: Coverity Prevent(tm)
CID: 3712


187244 14-Jan-2009 trasz

Remove unused variable.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation
Found with: Coverity Prevent(tm)
CID: 3665


187243 14-Jan-2009 trasz

Add missing 'break' statement.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation
Found with: Coverity Prevent(tm)
CID: 3927


187028 10-Jan-2009 trasz

Don't call destroy_dev(9) with a mutex held. While here, shuffle
things around so the periph destructors look alike. Based on a patch
by Jaakko Heinonen.

Submitted by: Jaakko Heinonen
Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation


186905 08-Jan-2009 trasz

Make "kldunload atapicam" return EBUSY instead of deadlocking when a device
created by atapicam is being kept opened or mounted. This is probably just
a temporary solution until we invent something better.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation
Reported by: Jaakko Heinonen


186891 08-Jan-2009 raj

cam: Retry TEST UNIT READY command if not successful.

This fixes problems with discovering some USB devices that are very slow to
respond during initialisation.

When a USB device is inserted, CAM performs the sequence:
1) INQUIRY
2) INQUIRY (second time with other parameters)
3) TEST UNIT READY
4) READ CAPACITY

Before this change CAM didn't check if TEST UNIT READY was successful and went
on blindly to the next state and sent READ CAPACITY. If the device was still
not ready by then, CAM ended with error message. This patch adds checking for the
status of TEST UNIT READY command and retrying up to 10 times with 0.5 sec
interval.

Submitted by: Grzegorz Bernacki gjb ! semihalf dot com
Reviewed by: scottl


186882 08-Jan-2009 imp

Make it possible to override the number of retries for the CD media.
When trying to read scratched or damaged CDs and DVDs, the default
mechanism is sub-optimal. Programs like ddrescue do much better if
you turn off retries entirely, since their algorithms are designed
scan big areas fast, then winnow the areas down. Turning off retries
speeds these programs up by as much as 20x, since the drive is able to
'stream past' many small errors...

The sysctl/tunable kern.cam.cd.retry_count controls this. That
defaults to '4' (for a total of 5 attempts). Setting to 0 turns off
all retry attempts.

Reviewed by: scottl@


186424 23-Dec-2008 remko

Add quirk for the Storcase InfoStation 12bay
SATA to FC SAN.

PR: 129858
Submitted by: Nick Triantos <nick-freebsd at triantos dot com>
MFC after: 1 week


186396 22-Dec-2008 scottl

Fix a comment to reflect what really happens.


186371 21-Dec-2008 scottl

Fix refcount locking in cd, pass, and sg periphs.


186320 19-Dec-2008 trasz

Fix cam_sim_free() wakeup condition and add mtx_asserts.

Submitted by: Christoph Mallon
Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation


186319 19-Dec-2008 trasz

Periph driver fixes, second try.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation


186318 19-Dec-2008 trasz

Move mtx_assert lower, when we can be sure that the pointer
to the mutex is valid.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation


186219 17-Dec-2008 trasz

Revert r186186 for now; it breaks stuff.

Approved by: rwatson (mentor)


186186 16-Dec-2008 trasz

Fix locking in periph drivers - don't try to unlock periph
that was already deallocated.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation


186185 16-Dec-2008 trasz

Add SIM refcounting. This is slightly different from what DragonFly
does - in DragonFly, it's cam_sim_release() what actually frees the
SIM; cam_sim_free does nothing more than calling cam_sim_release().
Here, we drain in cam_sim_free, waiting for refcount to drop to zero.
We cannot do the same think DragonFly does, because after cam_sim_free
returns, client would destroy the sim->mtx, and CAM would trip over
an initialized mutex.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation


186184 16-Dec-2008 trasz

Get rid of dead_sim. There is no way to make it work - any attempt
to actually use it would panic on mtx operation, as dead_sim doesn't
have a proper mutex. Even if it had a properly initialized mutex,
it wouldn't have properly locked and owned one.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation


184205 23-Oct-2008 des

Retire the MALLOC and FREE macros. They are an abomination unto style(9).

MFC after: 3 months


183397 27-Sep-2008 ed

Replace all calls to minor() with dev2unit().

After I removed all the unit2minor()/minor2unit() calls from the kernel
yesterday, I realised calling minor() everywhere is quite confusing.
Character devices now only have the ability to store a unit number, not
a minor number. Remove the confusion by using dev2unit() everywhere.

This commit could also be considered as a bug fix. A lot of drivers call
minor(), while they should actually be calling dev2unit(). In -CURRENT
this isn't a problem, but it turns out we never had any problem reports
related to that issue in the past. I suspect not many people connect
more than 256 pieces of the same hardware.

Reviewed by: kib


183381 26-Sep-2008 ed

Remove unit2minor() use from kernel code.

When I changed kern_conf.c three months ago I made device unit numbers
equal to (unneeded) device minor numbers. We used to require
bitshifting, because there were eight bits in the middle that were
reserved for a device major number. Not very long after I turned
dev2unit(), minor(), unit2minor() and minor2unit() into macro's.
The unit2minor() and minor2unit() macro's were no-ops.

We'd better not remove these four macro's from the kernel, because there
is a lot of (external) code that may still depend on them. For now it's
harmless to remove all invocations of unit2minor() and minor2unit().

Reviewed by: kib


183145 18-Sep-2008 sbruno

Add a new cam_status CAM_SCSI_IT_NEXUS_LOST. This will be used by future patches
for target mode that are forthcoming.

Reviewed by: Scott Long
MFC after: 2 days


182433 29-Aug-2008 scottl

Fix a locking mistake in daopen(). If the open fails, which can happen
because the media was removed, the periph would get its refcount dropped
and ultimately freed before getting unlocked. This created a dangling
pointer that was easy to trip over. This fixes a common source of
crashes with removaable media, but problems remain and will get tracked
down.


181791 16-Aug-2008 ken

SCSI_DELAY is specified in milliseconds, not seconds.

Submitted by: Andre Albsmeier <Andre.Albsmeier@siemens.com>
MFC after: 1 week


181381 07-Aug-2008 jkim

Update SCSI opcodes and ASCs from t10.org.

http://www.t10.org/lists/1spc-lst.htm

Note opcodes for scanner and communication devices are taken from the previous
revision because they are not listed in the files any more.
Also, note newly added ASCs are all marked with 'XXX TBD' and take SS_RDEF action
for now. Some ASCs need SS_TUR for error recovery or SS_FATAL to prevent further
retrials. We should deal with them later.

Reviewed by: scottl, ken


181126 01-Aug-2008 emaste

Fix whitespace.


180389 09-Jul-2008 remko

Add quirk for the Samsung YP-U3

PR: 125398
Submitted by: Tino Engel <goaengel at gmx dot net>
Approved by: imp (mentor, implicit)
MFC after: 1 week


177304 17-Mar-2008 scottl

Locking in the ses_ioctl handler doesn't have to be so strict because
the referenced data is only obtained/changed in the device open handler,
and the ioctl handler can only run after the open handler. Also fix a
few nearby style issues.

Submitted by: Matt Jacob


176623 27-Feb-2008 scottl

When probing a newly found device, don't automatically assume that the
device supports retrieving a serial number. Instead, first query the
list of VPD pages it does support, and only query the serial number if
it's supported, else silently move on. This eliminates a lot of noise
during verbose booting, and will likely eliminate the need for most
NOSERIAL quirks.


176577 26-Feb-2008 scottl

Add a missing unlock to an error path fro XPT_DEBUG handling.


176426 20-Feb-2008 scottl

Fix a couple of locking mistakes in the ses_ioctl path.

Submitted by: Matt Jacob


176204 12-Feb-2008 raj

Fix typo.

Approved by: cognet (mentor)


175766 28-Jan-2008 brueffer

Correct the kernel config hint in a printf statement.

Submitted by: R.Mahmatkhanov <cvs-src@yandex.ru>
Reviewed by: scottl
Approved by: rwatson (mentor)
MFC after: 3 days


175246 12-Jan-2008 maxim

o Correct EasyMP3 EM732X usb 2.0 flash mp3 player revision:
it's 1.00 not 1.0.

PR: usb/96546
Submitted by: Eugene Grosbein
MFC after: 1 month


175054 02-Jan-2008 obrien

style(9)


174898 25-Dec-2007 rwatson

Add a new 'why' argument to kdb_enter(), and a set of constants to use
for that argument. This will allow DDB to detect the broad category of
reason why the debugger has been entered, which it can use for the
purposes of deciding which DDB script to run.

Assign approximate why values to all current consumers of the
kdb_enter() interface.


174654 16-Dec-2007 scottl

Add a missing mutex unlock.

Reported by: Michael Jung


174534 11-Dec-2007 davidxu

Add quirks for Netac Onlydisk 2000 USB disk.


173639 15-Nov-2007 scottl

Fix a change in the previous commit that was actually a type-o.


172836 20-Oct-2007 julian

Rename the kthread_xxx (e.g. kthread_create()) calls
to kproc_xxx as they actually make whole processes.
Thos makes way for us to add REAL kthread_create() and friends
that actually make theads. it turns out that most of these
calls actually end up being moved back to the thread version
when it's added. but we need to make this cosmetic change first.

I'd LOVE to do this rename in 7.0 so that we can eventually MFC the
new kthread_xxx() calls.


172605 12-Oct-2007 scottl

Add a bunch of definitions and structures to support newer drivers.


171529 21-Jul-2007 kan

Do not forget to cam_periph_unhold the peripheral before exiting
due to error.

PR: kern/114636
Submitted by: Tijl Coosemans
Approved by: re (hrs)


171142 01-Jul-2007 imp

After talking with njl@, change this wildcard entry to be a bit less wild.

Approved by: re (blanket)


171118 30-Jun-2007 imp

Quirk for WD Mybook. Seems they do not like serial number queries.

Submitted by: Jason Harris
PR: 107495
Approved by: re@ (blanket)


171116 30-Jun-2007 imp

Quirk for ChipsBnk usb stick

Submitted by: Mark Andrews
PR: 103702
Approved by: re@ (blanket)


171115 30-Jun-2007 imp

Add quirk for JoyFly 128mb USB Flash Drive

submitted by: Toni Schmidbauer
PR: 96133
Approved by: re@ (blanket)


171109 30-Jun-2007 imp

quirk for I/O Magic USB flash drive "Giga Bank"

Submitted by: Jeff Anton
PR: 108810
Approved by: re@ (blanket)


171108 30-Jun-2007 imp

Samsung MP0402H quirk

Submitted by: Gipsy<wint3r@securimail.com>
PR: 108427
Approved by: re@ (blanket)


171106 30-Jun-2007 imp

Add support for JNC MP3 Player

Submitted by: User & <dhenin@cypries.cyclopes.org>
PR: 94439
Approved by: re (blanket)


171102 30-Jun-2007 imp

Philips USB Key Audio KEY013

Submitted by: Arnoud Engelfriet
PR: 68412
Approved by: re (blanket)


171075 28-Jun-2007 imp

Support for iRiver U10 USB connection

PR: 92306
Submitted by: Soren Dossing
Approved by: re (blanket)


171072 28-Jun-2007 imp

Quirk for Denver MP3 player usb.

Submitted by: Ed Schouten
PR: 107101
Approved by: re (blanket for device supprot)


170872 17-Jun-2007 scottl

Prepare for future integration between CAM and newbus. xpt_bus_register
now takes a device_t to be the parent of the bus that is being created.
Most SIMs have been updated with a reasonable argument, but a few exceptions
just pass NULL for now. This argument isn't used yet and the newbus
integration likely won't be ready until after 7.0-RELEASE.


170831 16-Jun-2007 scottl

Revert an accidental change from the previous rev.


170830 16-Jun-2007 scottl

Work around the other uses of M_WAITOK.


170829 16-Jun-2007 scottl

Work around a malloc locking problem.


170485 10-Jun-2007 mjacob

Commit for Nate his "guidelines for submitting quirks".


170289 04-Jun-2007 dwmalone

Despite several examples in the kernel, the third argument of
sysctl_handle_int is not sizeof the int type you want to export.
The type must always be an int or an unsigned int.

Remove the instances where a sizeof(variable) is passed to stop
people accidently cut and pasting these examples.

In a few places this was sysctl_handle_int was being used on 64 bit
types, which would truncate the value to be exported. In these
cases use sysctl_handle_quad to export them and change the format
to Q so that sysctl(1) can still print them.


170118 29-May-2007 mjacob

Add a placeholder document to be filled out by Nate which will describe
in detail the procedure for getting device quirks into the CAM subsystem.


170116 29-May-2007 mjacob

Back out 1.212 at Nate's request in order to go through the
actual formal process he's trying to get established for quirks..


170080 29-May-2007 mjacob

Use the Hitachi 2.5" HD, 120 GB as a USB device.

Submitted by: Joakim Bentholm`
MFC after: 3 days


169901 23-May-2007 cognet

Remove duplicate includes.

Submitted by: Cyril Nguyen Huu <cyril ci0 org>


169687 18-May-2007 mjacob

Zero scsi_readcapacity allocations so we can really
tell if there has been data returned (for some broken
residual checking points).

MFC after: 3 days


169607 16-May-2007 scottl

Release the bus reference that is acquired when doing a CAMIOCOMMAND
ioctl. This should make SIM removal a bit more robust.


169606 16-May-2007 scottl

Remove an assertion in xpt_print_path() that makes debugging code much more
difficult.


169605 16-May-2007 scottl

Add a helper function for registering async callbacks. Besides
eliminating a lot of duplicated code, this also fixes a locking edge case.


169562 14-May-2007 scottl

Eliminate the use of M_TEMP.


169071 27-Apr-2007 scottl

Only schedule the xpt_finishconfig_task once. This fixes some potential
panics on boot.


168982 23-Apr-2007 scottl

Remove obsolete headers. Move kernel specific headers under #ifdefs


168882 19-Apr-2007 scottl

Retire the spl() markers. Add in some minor missed locking as a result.


168876 19-Apr-2007 scottl

Inline cam_periph_lock|unlock to make debugging easier. Use more
CAM_SIM_LOCK() more uniformly.


168874 19-Apr-2007 scottl

Fix a leaked lock in dashutdown.


168872 19-Apr-2007 scottl

Avoid problems with make_dev.


168865 19-Apr-2007 scottl

Zero the CCBs when mallocing them.


168864 19-Apr-2007 scottl

Split the camisr into per-SIM done queues. This optimizes the locking a
little bit and allows for direct dispatch of the doneq from certain
contexts that would otherwise face recursive locking problems.


168832 18-Apr-2007 scottl

Missed locking the dump and shutdown entry points in the scsi_da driver.


168831 18-Apr-2007 scottl

Revert a driver API change to xpt_alloc_ccb that isn't necessary. Fix a
couple of associated error checks.


168797 17-Apr-2007 scottl

Don't delete the devalias, as per the man page.

Submitted by: jmg


168788 16-Apr-2007 scottl

For the XPT_SASYNC_CB operation, only decouple the broadcast to the bus
and device lists instead of decoupling the whole operation. This avoids
problems with SIMs going away.


168787 16-Apr-2007 scottl

Drop the topology lock before calling the periph oninvalidate and dtor
vectors.


168786 16-Apr-2007 scottl

Drop the periph/sim lock when calling disk_destroy().


168785 16-Apr-2007 scottl

Destroy the devalias before destroying the dev.


168752 15-Apr-2007 scottl

Remove Giant from CAM. Drivers (SIMs) now register a mutex that CAM will
use to synchornize and protect all data objects that are used for that
SIM. Drivers that are not yet MPSAFE register Giant and operate as
usual. RIght now, no drivers are MPSAFE, though a few will be changed
in the coming week as this work settles down.

The driver API has changed, so all CAM drivers will need to be recompiled.
The userland API has not changed, so tools like camcontrol do not need to
be recompiled.


168598 10-Apr-2007 scottl

A fix for the SG_GET_TIMEOUT function slipped into a previous commit by
accident. Remove the text describing the problem as it is no longer
relevant. Also give real implementations for the GET and SET ioctls.


168527 09-Apr-2007 scottl

Make use of M_ZERO in various malloc calls.


168526 09-Apr-2007 scottl

Fix a logic bug that slipped in at the last minute and apparently escaped
testing.


168477 07-Apr-2007 scottl

Add the CAM 'SG' peripheral device. This device implements a subset of the
Linux SCSI SG passthrough device API. The intention is to allow for both
running of Linux apps that want to talk to /dev/sg* nodes, and to facilitate
porting of apps from Linux to FreeBSD. As such, both native and linuxolator
entry points and definitions are provided.

Caveats:
- This does not support the procfs and sysfs nodes that the Linux SG
driver provides. Some Linux apps may rely on these for operation,
others may only use them for informational purposes.
- More ioctls need to be implemented.
- Linux uses a naming scheme of "sg[a-z]" for devices, while FreeBSD uses a
scheme of "sg[0-9]". Devfs aliasis (symlinks) are automatically created
to link the two together. However, tools like camcontrol only see the
native names.
- Some operations were originally designed to return byte counts or other
data directly as the syscall return value. The linuxolator doesn't appear
to support this well, so this driver just punts for these cases.

Now that the driver is in place, others are welcome to add missing
functionality. Thanks to Roman Divacky for pushing this work along.


167591 15-Mar-2007 mjacob

A silly buglet found by Coverity- check the return value from
cam_periph_acquire.


167082 27-Feb-2007 jhb

Use tsleep() rather than msleep() with a NULL mtx.


166896 23-Feb-2007 mjacob

Add an xpt_rescan function and a thread that will field
rescan requests. The purpose of this is to allow a SIM
(or other entities) to request a bus rescan and have it
then fielded in a different (process) context from the
caller.

There are probably better ways to accomplish this, but
it's a very small change that helps solve a number of
problems.

Reviewed by: Justin, Ken and Scott.
MFC after: 2 weeks


166861 21-Feb-2007 n_hibma

Reduce the noise when plugging in (USB) mass storage devices, like a 4 port
flash card reader.
Also remove an 'Opened da0 -> <random number>' which is not needed on a daily
basis (available through bootverbose).

Reviewed by: phk, ken
MFC after: 1 week


166196 23-Jan-2007 imp

Use the more specific 'EM732X' designation rather than * to disable sync
cache commands, per request from njl@.


166166 22-Jan-2007 imp

Add quirk for EasyMP3 EM732X usb 2.0 flash mp3 player.
(It appears that the quirk proceedures link has disappeared and that
this PR complied with it, if there's a problem, please contact me).

PR: usb/96546


165456 21-Dec-2006 mjacob

fix botch


165448 21-Dec-2006 mjacob

Pay attention to return value from xpt_bus_register in xpt_init.

Obtained from: Xin Li (Coverity)
MFC after: 3 days


165066 10-Dec-2006 mjacob

Make cam_xpt's pronouncements match camcontrol
(Tagged -> Command) Queueing.


164906 05-Dec-2006 mjacob

Add an xpt_print function to reduce most of the xpt_print_path/printf
pairs. Convert the core code to use it.

Reviewed by: scsi (various folks weighing in with good advice)
MFC after: 2 weeks


164894 04-Dec-2006 mjacob

Initial cut at Basic Domain Validation- just add some states to
traverse through during probing.

Reviewed by: scsi (scottl)


164844 03-Dec-2006 mjacob

Remove CTS_SPI_FLAGS_TAG_ENB. Nobody is using it and at least one
author can't remember why it was there.

The CTS_SCSI_FLAGS_TAG_ENB remains in place, and makes sense, and is
checked all over the place.

The CTS_SPI_FLAGS_TAG_ENB was probably an attempt to distinguish
protocol and transport tag capabilities. At the very least this can
be confusing and prone to many bugs, so let's just assume that the
transport tag case just flows from the protocol (and vice versa)
for now.


164624 26-Nov-2006 maxim

o Style: remove a w/space before a comma.


164623 26-Nov-2006 maxim

o Style(9): trim eol w/spaces, w/spaces to tabs, kill an empty line.


164622 26-Nov-2006 maxim

o Add a quirk for X-Micro Flash Disk.

PR: usb/96901
Submitted by: Szalai Andras
Reviewed by: nate (a half of year ago)
MFC after: 3 weeks


164082 07-Nov-2006 mjacob

XPT_GET_TRAN_SETTINGS can fail- so check for an error and
don't blindly assume it succeeded.


164055 07-Nov-2006 mjacob

Fix the hanging chad if the NEW_TRAN_CODE change and change the
qualifier to force async from cur_spi to spi.


163931 03-Nov-2006 njl

Remove extra whitespace


163923 02-Nov-2006 mjacob

Add a tunable that allows one to turn off the automatic sending of
the ORDERED tag. This recoups significant performance gains for many
arrays.

The default is still to send out the ORDERED tag periodically.

Reviewed by: scsi (justin+timeout)


163896 02-Nov-2006 mjacob

2nd and final commit that moves us to CAM_NEW_TRAN_CODE
as the default.

Reviewed by multitudes.


163834 31-Oct-2006 pjd

Implement BIO_FLUSH handling for da(4), amr(4), ata(4) and ataraid(4).

Sponsored by: home.pl


163816 31-Oct-2006 mjacob

The first of 3 major steps to move the CAM layer forward to using
the CAM_NEW_TRAN_CODE that has been in the tree for some years now.

This first step consists solely of adding to or correcting
CAM_NEW_TRAN_CODE pieces in the kernel source tree such
that a both a GENERIC (at least on i386) and a LINT build
with CAM_NEW_TRAN_CODE as an option will compile correctly
and run (at least with some the h/w I have).

After a short settle time, the other pieces (making
CAM_NEW_TRAN_CODE the default and updating libcam
and camcontrol) will be brought in.

This will be an incompatible change in that the size of structures
related to XPT_PATH_INQ and XPT_{GET,SET}_TRAN_SETTINGS change
in both size and content. However, basic system operation and
basic system utilities work well enough with this change.

Reviewed by: freebsd-scsi and specific stakeholders


163101 07-Oct-2006 flz

Add a SCSI da(4) quirk for Rekam USB Camera.

PR: usb/98713
Submitted by: Alex <goo@t72.ru>
MFC after: 3 days


163097 07-Oct-2006 flz

Add SCSI da(4) quirk for the iRiver H10.

PR: usb/102547
Submitted by: Sven Esbjerg <freebsd-pr@xbsd.net>
MFC after: 3 days


162938 01-Oct-2006 mjacob

Put a bit of hysteresis into both BUSY SCSI status returns
and CAM_RESRC_UNAVAIL returns. Delay a tunable amount for
either between retries.

This came up because the MPT IOC was returning "IOC out of
resources" for some user and this caused a CAM_RESRC_UNAVAIL
return. Putting a bit of delay between retries helped them
out.

There was some discussion that an async event should be used
to clear CAM_RESRC_UNAVAIL. That's probably a better notion
eventually.

Reviewed by: scsi@freebsd.org (ade, scott)
MFC after: 1 week


162365 16-Sep-2006 mjacob

Don't allow attachment of disks that could cause GEOM to panic.


162362 16-Sep-2006 mjacob

New Dell 1950/2950 SES backplane drops off the bus if you poke
at greater then lun 0.

MFC after: 1 week


162218 11-Sep-2006 mjacob

null commit to provide commit message to previous
at the request of Sam Leffler: The previous commit
established min and maxtags for VMware pseudo disks
to fix a submitted PR.


162217 11-Sep-2006 mjacob

PR: 103130
Submitted by: Shusuke Shinomiya
MFC after: 1 day


161506 21-Aug-2006 ken

Implement 'camcontrol reportluns'. This allows users to send the SCSI
REPORT LUNS command to a device.

camcontrol.[c8]: Implement reportluns. This tries to print the LUNs
out in a reasonable format. Only the periph
addressing method has been tested, since very little
hardware that I know of supports the other methods.

scsi_all.[ch]: Revamp the report luns CDB structure and helper
functions. This constitutes a little bit of an API
change, but since the old CDB length was 10 bytes,
and the REPORT LUNS CDB length is actually 12 bytes,
it's clear that no one was using this API in the
first place.

MFC After: 1 week


161290 14-Aug-2006 jhb

access only has 2 esses.

MFC after: 3 days


160345 14-Jul-2006 delphij

Drop Giant before returning in error path, thus eliminates
two mutex leaks.

Submitted by: Beyond Luo <fedora ercist iscas ac cn>
PR: kern/100046
Reviewed by: ken, scottl


159941 26-Jun-2006 mjacob

Grumble. VMWare ESX and VMWare WorkStation have *slightly* different
inquiry data (pointlessly different I might add). Pick the common
parts.

MFC after: 1 day


159914 24-Jun-2006 mjacob

VMware disk volumes are only on LUN 0, and
some VMware HBAs have known bugs with commands
sent to other than LUN 0.

MFC after: 1 day


159311 05-Jun-2006 mjacob

Add PIM_SEQSCAN for HBA misc flags and code that understands
what to do with it.

This forces us to scan targets sequentially, not in parallel.
The reason we might want to do this is that SPI negotiation
might not work right at the SIM level if we try to do it
in parallel. We *could* fix this for each SIM where this is
broken, but it's a lot harder to do that when we can simply
ask CAM to probe sequentially.

If PIM_SEQSCAN is not set (default), the original behaviour for
probing is unchanged.

LUN probing is still done in parallel for each target in either
case.

While we're at it, clean up some resource leakage for error
cases.

Reviewed by: ken, scott, scsi@
MFC after: 1 week


159086 30-May-2006 mjacob

Handle some of the inquiry flags that have come into
usage as of SPC2r20. Specifically, handle the BQueue
flag which will indicate that a device supports the
Basic Queueing model (no Head of Queue or Ordered tags).
When this flag is set, SID_CmdQueue is clear. This has
causes FreeBSD to assume that the device did not support
tagged operations.

MFC after: 1 month


158885 24-May-2006 mjacob

Forced commit - last checkin got away from me.

This version of scsi_target.c removes all SMP locking until
we have a lock-aware CAM stack. This allows us to use KNOTE
without a panic at least.

It's not yet clear whether target mode is working yet or not.

Discussed with: Scott, Ken, Nate, Justin


158884 24-May-2006 mjacob

Sorry- last delta was checked in by mistake.


158883 24-May-2006 mjacob

Make physical buffers in cam_periph_mapmem owned by the kernel in case we
return to user space w/o waiting for I/O to complete.

I tried to get several folks who know this code better than me to review it
with no luck. I *do* know that w/o this code, using the SCSI target driver
panics in userret (if it doesn't panic in knote first).


158651 16-May-2006 phk

Since DELAY() was moved, most <machine/clock.h> #includes have been
unnecessary.


157856 18-Apr-2006 mjacob

Actually check to see if XPT_CALC_GEOMETRY had an error
and pick a bogus geometry if it had so we don't later
get a divide by zero trap.


157854 18-Apr-2006 mjacob

Do more guarding against zero divide traps for the geom subroutine.


157806 17-Apr-2006 maxim

o Do not double i/o stats for cd(4) already acounted in g_disk_done().

PR: kern/95707
Submitted by: Andre Albsmeier
Reviewed by: phk
MFC after: 2 weeks


156852 18-Mar-2006 joerg

Add reference to PR to TOSHIBA TransMemory quirk entry.


156844 18-Mar-2006 flz

- Add a PR number for future reference.

Approved by: njl


156692 13-Mar-2006 joerg

Add the TOSHIBA TransMemory USB sticks to the list of devices that
hate "Synchronize cache" commands.

MFC after: 1 day


155063 30-Jan-2006 flz

- Add a scsi_da.c and a umass.c quirk for Genesys 6-in-1 Card Reader.

Reported by: anders on freebsd-usb@
Tested by: anders
Approved by: ssouhlal
MFC after: 3 days


154831 26-Jan-2006 flz

Add Product IDs :
- Sandisk Cruzer Micro 128MB [5]
- DANE-ELEC zMate 512MB USB flash drive [7]
- Attache 256MB USB 2.0 Flash Drive [8]
- Sandisk Cruzer Micro 256MB [9]

Add scsi_da.c quirks :
- Samsung USB key 128Mb [1]
- Kingston DataTraveler 2.0 [2]
- Creative MuVo Slim [3]
- United MP 5512 Portable MP3 Player [4]
- Sandisk Cruzer Micro 128MB [5], [9]
- PNY USB Flash keys [6], [7], [8]

Add umass.c quirks :
- Sandisk Cruzer Micro 128MB [5]
- DANE-ELEC zMate 512MB USB flash drive [7]
- Attache 256MB USB 2.0 Flash Drive [8]
- Sandisk Cruzer Micro 256MB [9]

PR: usb/90081 [1],
usb/89196 [2],
kern/86131 [3],
usb/80487 [4],
usb/75970 [5],
usb/75578 [6],
usb/72344 [7],
usb/65436 [8],
usb/70835 [9]
Submitted by: Henri-Pierre CHARLES <hpc@prism.uvsq.fr> [1],
Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua> [2],
Erich Rickheit KSC <rickheit-fbp@numachi.com> [3],
tnu@chania.di.uoa.gr [4],
Bram Abbekerk <bram@abbekerk.demon.nl> [5],
Thomas Pornin <pornin@bolet.org> [6],
parv <parv@pair.com> [7],
Peter D. Quilty <pdquilty@adelphia.net> [8],
Raymundo M. Vega <rvega@ms-smtp-03-eri0.socal.rr.com> [9]
Approved by: iedowse
MFC after: 3 days


154593 20-Jan-2006 mjacob

CAM_NEW_TRAN_CODE placeholders for SAS support.

Reviewed by: nate, ken, justin
MFC after: 1 month


154504 18-Jan-2006 mjacob

Fix ioctl to not get swallowed by ioctl code (i.e., make sure the darned
code sticks within 8 bits)

MFC after: 1 week


154360 14-Jan-2006 mjacob

Incorporate the O_NONBLOCK open semantics of Linux and Solaris. This allows
an application to upon a tape (yea, even the non-control device) even if
it cannot establish a mount session. If the open cannot establish a mount
session and O_NONBLOCK was specified, the tape becomes 'open pending mount'.
All I/O operations that would require access to a tape thereafter until
a close attempt to initiate the mount session. If the mount session succeeds,
the tape driver transitions to full open state, else returns an appropriate
I/O error (ENXIO).

At the same time, add a change that remembers whether tape is being opened
read-only. If so, disallow 'write' operations like writing filemarks that
bypass the normal read-only filtering operations that happen in the write(2)
syscall.

Reviewed by: ken, justin, grog
MFC after: 2 weeks
Suggested by: The Bacula Team


154297 13-Jan-2006 mnag

Allow to use Time DPA20B 1GB MP3 Player [1]
Allow to use Qware BeatZkey! Pro [2]

PR: usb/81846 [1], usb/79164 [2]
Submitted by: Ruben de Groot <rdg@bzerk.org> [1], Radek Kozlowski <radek@raadradd.com> [2]
Approved by: njl
MFC: 1 week


154207 11-Jan-2006 iedowse

When deregistering a bus, attempt to flush out all outstanding
operations before returning. Point the bus at a dummy cam_sim
structure so that any CCBs will complete immediately with a
CAM_DEV_NOT_THERE status, and ensure that any xpt_schedule() calls
on the bus's devices will immediately call the peripheral's
periph_start() routine. Also repeat the async messages because
devices that were part of the way through being probed may appear
after the original AC_LOST_DEVICE was sent, and would otherwise
never go away.

These changes make it possible to deregister a bus and free the SIM
at most stages during bus probing without the usual crashes in
camisr(). In particular, plugging in a umass device and then
unplugging it as soon as the first probe messages appeared would
almost always result in a crash. Now the device just goes away with
a few CAM errors and all references to the CAM bus, target and
device are dropped correctly.


154119 08-Jan-2006 iedowse

There should be no need to retry when the CCB status code is
CAM_LUN_INVALID or CAM_TID_INVALID. Retries were being triggered
here when a umass device was unplugged, and while the retries
themselves are probably harmless, they complicated finding the real
SIM removal problems.


153529 19-Dec-2005 pjd

Style nit.


153527 19-Dec-2005 pjd

Allow to use TransFlash drive, which can be found in Motorola E398 Mobile Phone.

PR: usb/89889
Submitted by: Wojciech A. Koszek <dunstan@freebsd.czest.pl>
MFC after: 1 week


152565 18-Nov-2005 jdp

Fix a bug that caused some /dev entries to continue to exist after
the underlying drive had been hot-unplugged from the system. Here
is a specific example. Filesystem code had opened /dev/da1s1e.
Subsequently, the drive was hot-unplugged. This (correctly) caused
all of the associated /dev/da1* entries to be deleted. When the
filesystem later realized that the drive was gone it closed the
device, reducing the write-access counts to 0 on the geom providers
for da1s1e, da1s1, and da1. This caused geom to re-taste the
providers, resulting in the devices being created again. When the
drive was hot-plugged back in, it resulted in duplicate /dev entries
for da1s1e, da1s1, and da1.

This fix adds a new disk_gone() function which is called by CAM when a
drive goes away. It orphans all of the providers associated with the
drive, setting an error condition of ENXIO in each one. In addition,
we prevent a re-taste on last close for writing if an error condition
has been set in the provider.

Sponsored by: Isilon Systems
Reviewed by: phk
MFC after: 1 week


150201 16-Sep-2005 mjacob

Make the exploring of all luns supported by an HBA more of a
tunable (until we get REPORT LUNS in place).

If we're probing luns, and each probe succeeds, we keep going past
lun 7 if we're a SCSI3 or better device (until we fail to probe).

If we're probing luns, and a probe fails, we only keep going if
we're quirked *for* it (CAM_QUIRK_HILUNS), and if we're not quirked
*against* it (CAM_QUIRK_NOHILUNS), or we're a SCSI3 or better device
and the tunable (kern.cam.cam_srch_hi) is set non-zero.

Reviewed by: nate@rootlabs.org, gibbs@scsiguy.com, ken@kdm.com, scottl@samsco.org
MFC after: 1 week


148868 08-Aug-2005 rwatson

Merge the dev_clone and dev_clone_cred event handlers into a single
event handler, dev_clone, which accepts a credential argument.
Implementors of the event can ignore it if they're not interested,
and most do. This avoids having multiple event handler types and
fall-back/precedence logic in devfs.

This changes the kernel API for /dev cloning, and may affect third
party packages containg cloning kernel modules.

Requested by: phk
MFC after: 3 days


147730 01-Jul-2005 ssouhlal

Fix the recent panics/LORs/hangs created by my kqueue commit by:

- Introducing the possibility of using locks different than mutexes
for the knlist locking. In order to do this, we add three arguments to
knlist_init() to specify the functions to use to lock, unlock and
check if the lock is owned. If these arguments are NULL, we assume
mtx_lock, mtx_unlock and mtx_owned, respectively.

- Using the vnode lock for the knlist locking, when doing kqueue operations
on a vnode. This way, we don't have to lock the vnode while holding a
mutex, in filt_vfsread.

Reviewed by: jmg
Approved by: re (scottl), scottl (mentor override)
Pointyhat to: ssouhlal
Will be happy: everyone


147723 01-Jul-2005 avatar

- Providing fine-grained malloc statistic by replacing M_DEVBUF with
module-specific malloc types. These should help us to pinpoint the
possible memory leakage in the future.
- Implementing xpt_alloc_ccb_nowait() and replacing all malloc/free based
CCB memory management with xpt_alloc_ccb[_nowait]/xpt_free_ccb. Hopefully
this would be helpful if someday we move the CCB allocator to use UMA
instead of malloc().

Encouraged by: jeffr, rwatson
Reviewed by: gibbs, scottl
Approved by: re (scottl)


147571 24-Jun-2005 avatar

Fixing a memory leak in xpt_release_device(), which can be quickly
(depends on how many memory you have) observed through "tar -tvf /dev/sa0."

Without this patch, RELENG_5 and HEAD panics with something like:

kmem_malloc(4096): kmem_map too small: 42258432 total allocated

RELENG_4 doesn't panic but spews following errors:

camq_init: - cannot malloc array!

Reviewed by: gibbs, scottl
Approved by: re (scottl)
MFC after: 3 days


147176 09-Jun-2005 pjd

Add a quirk for my pen-drive.


146108 11-May-2005 kan

Do not initialize path variable with useless value just before
xpt_create_path overwrites it anyway.

Noticed by: Coverity Prevent analysis tool


145916 05-May-2005 dwhite

Add quirk for TEAC USB floppy drives.


145050 14-Apr-2005 mjacob

Make sure we look at the correct sub op codes when
deciding whether it's an operation we can perform
via the control device.

PR: kern/72010
MFC after: 1 week


145049 14-Apr-2005 mjacob

Take constructive advice from njl && reformat
previously added quirks slightly.


145048 14-Apr-2005 njl

Quirk for ZICPlay USB MP3 Player.

PR: kern/75057
Submitted by: Aurelien Nephtali <aurelien.nephtali wanadoo.fr>


145046 14-Apr-2005 mjacob

Apply quirk.

PR: 57469
Submitted by: walter@pelissero.de
MFC after: 1 week


145045 14-Apr-2005 mjacob

Applied conservative version of suggested quirk.

PR: 57468
Submitted by: walter@pelissero.de
MFC after: 1 week


145044 14-Apr-2005 mjacob

Apply quirk suggested by submitter.

PR: 75486
Submitted by: no_bs@web.de
MFC after: 1 week


145042 14-Apr-2005 mjacob

The divide by zero panic must have been due to a bogus
period value. I suppose the BT adapter driver should be
fixed, but more importantly we should protect against
dividing by zero.

PR: kern/75603
MFC after: 1 week


144430 31-Mar-2005 sam

avoid use after free

Submitted by: gibbs
Reviewed by: mdodd
Approved by: Coverity Prevent analysis tool


144429 31-Mar-2005 sam

avoid use after free

Submitted by: gibbs
Reviewed by: mdodd
Noticed by: Coverity Prevent analysis tool


144389 31-Mar-2005 phk

Explicitly hold a reference to the cdev we have just cloned. This
closes the race where the cdev was reclaimed before it ever made it
back to devfs lookup.


144135 26-Mar-2005 ken

Fix a problem with the cd(4) driver -- the CAMGETPASSTHRU ioctl wouldn't
succeed if there was no media in the drive.

This was broken in rev 1.72 when the media check was added to cdioctl().

For now, check the ioctl group to decide whether to check for media or not.
(We only need to check for media on CD-specific ioctls.)

Reported by: bland
MFC after: 3 days


144132 26-Mar-2005 ken

Fix a place where we were referencing a pointer after it had been freed.

Submitted by: "Henry Miller" <hank@blackhole.com>
MFC after: 3 days


144030 23-Mar-2005 gibbs

Restore queue depth settings across tag disable events. The system often
disables tag queuing temporarily in order to allow controllers a window
to safely perform transfer negotiation with non-compliant devices. Before
this change, CAM would restore the queue depth to the controller specified
maximum or device quirk level rather than any depth determined by reactions
to QUEUE FULL/BUSY events or an explicit user setting.

During device probe, initialize the flags field for XPT_SCAN_BUS.
The uninitialized value often confused CAM into not bothering to
issue an AC_FOUND_DEVICE async event for new devices. The reason
this bug wasn't reported earlier is that CAM manually announces
devices after the initial system bus scans.

MFC: 3 days


143839 19-Mar-2005 scottl

Don't free the SIM object twice.

Submitted by: Coverity Prevent analysis tool


142159 21-Feb-2005 scottl

Reference a pointer correctly when copying to it's location.

Submitted by: Coverity Prevent analysis tool


142158 20-Feb-2005 scottl

Check the correct periph pointer after search for it.

Submitted by: Coverity Prevent analysis tool


142157 20-Feb-2005 scottl

Protect against trying to free a non-existant peripheral.

Submitted by: Coverity Prevent analysis tool
MFC After: 3 days


141713 12-Feb-2005 scottl

Remove a shadow declaration of 'error' that caused certain tests to be
pointless.

Submitted by: Coverity Prevent analysis tool


141566 09-Feb-2005 scottl

Provide locking for the ccb_bioq. This allows xpt_done() to be called without
Giant held. In camisr(), move the ccb_bioq elements to a temporary local list
and then process the elements off of that list. This enables the list to be
processed by only taking the ccb_bioq_lock once and only for a very short
time.

ccb_bioq_lock is a leaf mutex, so it's fine to call xpt_done() with other
locks held. This is just a very minor step in the work to lock CAM, but
it allows us to avoid some messy locking/unlock dances in certain drivers.


141031 30-Jan-2005 sobomax

Boot away another stackgap (one of the lest ones in linuxlator/i386) by
providing special version of CDIOCREADSUBCHANNEL ioctl(), which assumes that
result has to be placed into kernel space not user space. In the long run
more generic solution has to be designed WRT emulating various ioctl()s
that operate on userspace buffers, but right now there is only one such
ioctl() is emulated, so that it makes little sense.

MFC after: 2 weeks


140799 25-Jan-2005 mr

Add quirk for easyRAID ER5 alias areca ARC-6010.
It reports itself as SCSI-3 but doesnt like getting probed on high luns
because it hangs hard after finding itself again on lun 32...

Suggested by: Kenneth Merry


140644 22-Jan-2005 mjacob

This is a somewhat imperfect means to try and bring FreeBSD forward in
its ability to automatically scan and attach luns for modern storage
which has luns in the 0..1000 range, not 0..7.

The correct thing would be to do REPORT LUNS for devices whose LUN0
version shows a version >= SCSI3, but lacking that we should be able
to search higher than LUN 7 if we're >= SCSI3 with no ill effects.

This change keeps all of the QUIRK_HILUNS quirks, obeys the QUIRK_NOLUNS,
and introduces a QUIRK_NOHILUNS which will keep searches above LUN 7
happening for devices that report >= SCSI3 compliance. I doubt the latter
will be needed, but you never know.

This allowed me to randomly scan and attach > 500 disks at a time in
a situation where quirking for QUIRK_HILUNS wasn't practical (the
vendor id and product id changes of the virtualization changes
constantly).

Reviewed by: ken@freebsd.org, scottl@freebsd.org, gibbs@freebsd.org
MFC after: 2 weeks


140608 22-Jan-2005 mjacob

Don't pass unadulterated unit numbers to make_dev and its ilk- if you
have more than 256 units, you die. Horribly. Convert them using
unit2minor.

MFC after: 1 week


139743 05-Jan-2005 imp

Start each of the license/copyright comments with /*-


137844 18-Nov-2004 gibbs

Correct another location where inquiry length as calculated from the
inquiry additional length field is off by one.

MFC: 3 days


137842 18-Nov-2004 gibbs

Correct an off-by-one in the calculation of the inquiry buffer length
to request from devices during the "long inquiry" portion of our probe.
This same bug was fixed in the 4.x stream a few years ago, but the fix
was never propogated to -current.

This fix is slightly different than in -stable:

o Use offsetof() instead of a hard coded constant so as the make
the code more self-explainatory.

o Round odd long inquiry lengths up so as to avoid tickling ignore
wide residue bugs in broken parallel SCSI devices running with a
wide transfer negotiation.

MFC: 3 days


136481 13-Oct-2004 bms

Remove references to the second byte of a CCB containing the LUN, as this
is valid only for SCSI-2 and older devices.
Rename the second byte of the VERIFY CCB from 'lun' to 'byte2'.

Submitted by: ken
MFC after: 2 weeks


136423 12-Oct-2004 bms

Add necessary data structures and definitions for the 12-byte SCSI
commands READ_FORMAT_CAPACITIES, WRITE_AND_VERIFY, and VERIFY.

Reviewed by: ken, scottl
Source: USB Mass Storage UFI Specification v1.0
MFC after: 2 weeks


136132 05-Oct-2004 scottl

Remove the camnet swi and CAM_PERIPH_NET. It has never been used, and given
that netowrk-over-scsi never really took off, there is little chance that
it will ever be needed.


134824 05-Sep-2004 phk

For removable devices without media we set a zero mediasize but a non-zero
sectorsize in order to avoid a lot of checks around various divisions etc.

Enforce the sectorsize being > 0 with a KASSERT on successful open.

Fix scsi_cd.c to return 2k sectors when no media inserted.


134530 30-Aug-2004 gibbs

Correct a typo in a comment: alloation->allocation

Reported by: Jens Schweikhardt <schweikh@schweikhardt.net>


134479 29-Aug-2004 des

Remove the HW_WDOG option; it serves no purpose.

MFC after: 3 days


133741 15-Aug-2004 jmg

Add locking to the kqueue subsystem. This also makes the kqueue subsystem
a more complete subsystem, and removes the knowlege of how things are
implemented from the drivers. Include locking around filter ops, so a
module like aio will know when not to be unloaded if there are outstanding
knotes using it's filter ops.

Currently, it uses the MTX_DUPOK even though it is not always safe to
aquire duplicate locks. Witness currently doesn't support the ability
to discover if a dup lock is ok (in some cases).

Reviewed by: green, rwatson (both earlier versions)


133662 13-Aug-2004 mjacob

When printing out an unknown sense code we should print it in hex, not
decimal.

Reviewed by: gibbs, nate, kdm


133601 12-Aug-2004 sanpei

add support Frontier Labs NEX IA+ Digital Audio Player with USB CF card reader/writer

PR: kern/70158
Submitted by: Bernd Strau. <no_bs@web.de>
MFC after: 1 week


133321 08-Aug-2004 sanpei

Add support iRiver iFP MP3 player

PR: kern/54881, i386/63941, kern/66124
Submitted by: Magnus <bsdhead.at.spray.dot.se@FreeBSD.org>,
Dmitry Dyomin <old@old.com.ua>,
Dmitry Sivachenko <mitya@demos.su>
MFC after: 1 week


132339 18-Jul-2004 sanpei

Quirk for SEGRAND NP-900 USB MP3Player

PR: kern/64563
Submitted by: Kunitada Kokubun <unix_grandy@yahoo.co.jp>
MFC after: 1 week


132199 15-Jul-2004 phk

Do a pass over all modules in the kernel and make them return EOPNOTSUPP
for unknown events.

A number of modules return EINVAL in this instance, and I have left
those alone for now and instead taught MOD_QUIESCE to accept this
as "didn't do anything".


131910 10-Jul-2004 marcel

Update for the KDB framework:
o Call kdb_enter() instead of Debugger().


130866 21-Jun-2004 ps

Revert rev 1.140, it was a bit pre-mature.


130864 21-Jun-2004 ps

Add a quirk for ciss to stop trying to read the serial number off
of logical volumes.


130640 17-Jun-2004 phk

Second half of the dev_t cleanup.

The big lines are:
NODEV -> NULL
NOUDEV -> NODEV
udev_t -> dev_t
udev2dev() -> findcdev()

Various minor adjustments including handling of userland access to kernel
space struct cdev etc.


130585 16-Jun-2004 phk

Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.


130200 07-Jun-2004 scottl

Reformat the comments for cam_hdr so that they can be read.


128840 02-May-2004 njl

Quirk for Neuros USB audio device.

PR: kern/63645
Submitted by: Aron Stansvik <elvstone@osdever.net>


128426 19-Apr-2004 mux

The opt_da.h file doesn't exist anymore since the DA_OLD_QUIRKS option
has been removed. Unbreak the build by not including it anymore.


128416 19-Apr-2004 njl

Add miscellaneous USB device quirks.

PR: kern/53067
PR: kern/54737
PR: kern/54786
PR: kern/57046

MFC after: 1 day


128415 19-Apr-2004 njl

Remove all quirks hidden under DA_OLD_QUIRKS.


126348 28-Feb-2004 cperciva

Compare the *number* of patterns to zero, not the *pointer* to the
patterns. (These lines are correct the other two times they appear.)

Reported by: "Ted Unangst" <tedu@coverity.com>
Approved by: rwatson (mentor), ken (scsi)


126104 22-Feb-2004 cperciva

Check that periph is non-NULL before dereferencing it.

Reported by: "Ted Unangst" <tedu@coverity.com>
Approved by: rwatson (mentor), ken (scsi@)


126080 21-Feb-2004 phk

Device megapatch 4/6:

Introduce d_version field in struct cdevsw, this must always be
initialized to D_VERSION.

Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing
four D_NOGIANT flags and adding 145 D_NEEDGIANT flags.


126076 21-Feb-2004 phk

Device megapatch 1/6:

Free approx 86 major numbers with a mostly automatically generated patch.

A number of strategic drivers have been left behind by caution, and a few
because they still (ab)use their major number.


125975 18-Feb-2004 phk

Change the disk(9) API in order to make device removal more robust.

Previously the "struct disk" were owned by the device driver and this
gave us problems when the device disappared and the users of that device
were not immediately disappearing.

Now the struct disk is allocate with a new call, disk_alloc() and owned
by geom_disk and just abandonned by the device driver when disk_create()
is called.

Unfortunately, this results in a ton of "s/\./->/" changes to device
drivers.

Since I'm doing the sweep anyway, a couple of other API improvements
have been carried out at the same time:

The Giant awareness flag has been flipped from DISKFLAG_NOGIANT to
DISKFLAG_NEEDSGIANT

A version number have been added to disk_create() so that we can detect,
report and ignore binary drivers with old ABI in the future.

Manual page update to follow shortly.


124645 18-Jan-2004 johan

Fix type in comment, 's/writtent/written/'

PR: 56954
Submitted by: Dan Langille <dan@langille.org>


123285 08-Dec-2003 ps

Move the ciss quirk to the right section, also update the comment
stating that the controllers do not support SYNC CACHE since ciss
only supports a small subset of the scsi spec.


123283 08-Dec-2003 ps

ciss doesn't like scsi SYNC CACHE. turn it off


123083 01-Dec-2003 obrien

SS_FATAL|ENXIO rather than SS_RDEF for illegal track mode.
This reduces the 90+ lines boot output of spewage GEOM does for my
Plextor SCSI burner.

Submitted by: scottl
Approved by: scottl


122352 09-Nov-2003 tanimura

- Implement selwakeuppri() which allows raising the priority of a
thread being waken up. The thread waken up can run at a priority as
high as after tsleep().

- Replace selwakeup()s with selwakeuppri()s and pass appropriate
priorities.

- Add cv_broadcastpri() which raises the priority of the broadcast
threads. Used by selwakeuppri() if collision occurs.

Not objected in: -arch, -current


122347 09-Nov-2003 scottl

Sprinkle GIANT_REQUIRED asserts around the xpt layer to aid with locking the
SCSI drivers.


122307 08-Nov-2003 scottl

Don't be so chatty when performing manual sense. This should make ATAPICAM
devices a lot more quiet.


121602 27-Oct-2003 ken

In camperiphdone(), make sure we check for fatal errors and bail out
instead of retrying them blindly.

This should fix some of the problems people have been having with cdrom
drives taking a long time to probe. This should also eliminate the need
for the initial TUR in cdsize().

cam_periph.c: Don't keep retrying if the error we get back is a fatal
error. This should help us detect the transition from
"Logical unit not ready, cause not reportable" to "Medium
not present" in the "TUR many" handler. (The TUR many
handler gets triggered for Logical unit not ready, cause
not reportable errors.)

scsi_cd.c: Remove the initial test unit ready in cdsize(). Hopefully
it isn't necessary after the above change.

Submitted by: gibbs (mostly)
Tested by: peter
MFC After: 2 weeks


121209 18-Oct-2003 phk

Use bio_offset instead of bio_blkno


121194 18-Oct-2003 phk

There is no need to muck about with the B_PHYS flag here. We never even
get close to DEV_STRATEGY() which is the only place it is relevant.


120906 08-Oct-2003 thomas

(dacleanup, dasysctlinit): Defend against calling sysctl_ctx_free on
an uninitialized sysctl_ctx, using flag DA_FLAG_SCTX_INIT. This
prevents a panic encoutered with some umass units that probe correctly
but fail to attach. Same problem, and same fix, as scsi_cd.c rev. 1.86.

Reviewed by: njl, ken


120884 07-Oct-2003 thomas

(cdcleanup): Defend against calling sysctl_ctx_free before the sysctl_ctx
has been initialized.
(cdsysctlinit): Set flag CD_FLAG_SCTX_INIT after sysctl_ctx has been
initialized.

This resolves a panic encountered when a cd drive is sucessfully probed
but fails to attach.

Reviewed by: ken


120854 06-Oct-2003 phk

Add disk_destroy() call to detach processing.

Add short tempered TUR to cdsize() as a workaround.


120663 02-Oct-2003 simokawa

Be kind to 64bit architectures.


120601 30-Sep-2003 simokawa

- Pick up a correct path_id for the bus on AC_PATH_REGISTERED.
- Call cam_periph_invalidate() only if the periph is found.


120599 30-Sep-2003 phk

GEOMify.


120426 25-Sep-2003 simokawa

Detach black hole device on AC_PATH_DEREGISTERED.


120314 21-Sep-2003 thomas

(scsi_request_sense): Set allocation length in REQUEST_SENSE CCB.

Reviewed by: ken


120313 21-Sep-2003 thomas

(camperiphdone): When the cam_periph layer performs sense recovery,
completion of recovery is indicated by positioning the CAM_AUTOSNS_VALID
bit in the status field of the CCB, not in the flags field.
This fixes an endless loop of sense recovery actions.

Reviewed by: ken


120019 13-Sep-2003 mjacob

I forgot whom I got this from- only set single initiator buffered mode
if we've recorded in our softc that we should set it.


119994 11-Sep-2003 phk

Disable the use of cloning use in floppy and CD drivers.

This commit puts the relevant code snippets under #ifdef GONE_IN_5
(rather than #ifndef BURN_BRIDGES) thereby disabling the code now.

The code wil be entirely removed before 5.2 unless we find reasons
why this would be a bad idea.

Approach suggested by: imp


119957 10-Sep-2003 alc

In case vmapbuf() fails, release all of the held resources.

Submitted by: tegge


119761 05-Sep-2003 phk

Put the device cloning functions for disk-drivers under #ifndef BURN_BRIDGES.

For the floppy driver, use fdcontrol to manipulate density selection.

For the CD drivers, the 'a' and 'c' suffix is without actual effect and
any applications insisting on it can be satisfied with a symlink:
ln -s /dev/cd0 /dev/cd0a

Ongoing discussion may result in these pieces of code being removed before
the 5-stable branch as opposed to after.


119742 04-Sep-2003 njl

Calling KNOTE with locks held may result in recursion when it calls back
into targreadfilt(). Unlock around calls to notify_user(). If an application
is sending CCBs while the endpoint is shutting down, this may result in
incomplete disable. A more complete solution will come with a "dying" flag.

Submitted by: simokawa


119741 04-Sep-2003 njl

Upon receiving a CCB for a LUN that is not enabled, be sure to unlock the
softc on exit.

Submitted by: simokawa


119728 04-Sep-2003 njl

Remove the quirk for the FujiFilm camera. Submitter indicates it is now
working without the quirk.

PR:
Submitted by: guido
Reviewed by:
Approved by:
Obtained from:
MFC after: 30 days


119718 03-Sep-2003 ken

Unbreak buildworld. sys/taskqueue.h is a kernel-only include.

Pointy Hat to: ken


119708 03-Sep-2003 ken

Move dynamic sysctl(8) variable creation for the cd(4) and da(4) drivers
out of cdregister() and daregister(), which are run from interrupt context.

The sysctl code does blocking mallocs (M_WAITOK), which causes problems
if malloc(9) actually needs to sleep.

The eventual fix for this issue will involve moving the CAM probe process
inside a kernel thread. For now, though, I have fixed the issue by moving
dynamic sysctl variable creation for these two drivers to a task queue
running in a kernel thread.

The existing task queues (taskqueue_swi and taskqueue_swi_giant) run in
software interrupt handlers, which wouldn't fix the problem at hand. So I
have created a new task queue, taskqueue_thread, that runs inside a kernel
thread. (It also runs outside of Giant -- clients must explicitly acquire
and release Giant in their taskqueue functions.)

scsi_cd.c: Remove sysctl variable creation code from cdregister(), and
move it to a new function, cdsysctlinit(). Queue
cdsysctlinit() to the taskqueue_thread taskqueue once we
have fully registered the cd(4) driver instance.

scsi_da.c: Remove sysctl variable creation code from daregister(), and
move it to move it to a new function, dasysctlinit().
Queue dasysctlinit() to the taskqueue_thread taskqueue once
we have fully registered the da(4) instance.

taskqueue.h: Declare the new taskqueue_thread taskqueue, update some
comments.

subr_taskqueue.c:
Create the new kernel thread taskqueue. This taskqueue
runs outside of Giant, so any functions queued to it would
need to explicitly acquire/release Giant if they need it.

cd.4: Update the cd(4) man page to talk about the minimum command
size sysctl/loader tunable. Also note that the changer
variables are available as loader tunables as well.

da.4: Update the da(4) man page to cover the retry_count,
default_timeout and minimum_cmd_size sysctl variables/loader
tunables. Remove references to /dev/r???, they aren't used
any longer.

cd.9: Update the cd(9) man page to describe the CD_Q_10_BYTE_ONLY
quirk.

taskqueue.9: Update the taskqueue(9) man page to describe the new thread
task queue, and the taskqueue_swi_giant queue.

MFC after: 3 days


119465 25-Aug-2003 njl

Remove quirk for Apacer Handydrive. Kevin Oberman <oberman@es.net> reports
that it works without the quirk. This and any other quirk changes will be
MFCd after the release unless they fix a known problem.

MFC after: 1 month


119461 25-Aug-2003 njl

Sort quirks into sections.


119308 22-Aug-2003 njl

Add the DA_Q_NO_PREVENT quirk which keeps da(4) from sending PREVENT/ALLOW
commands. Add a quirk for the Creative Nomad MuVo USB device that uses
it as well as NO_SYNCHRONIZE_CACHE.

PR: kern/53094
Submitted by: Richard Nyberg <rnyberg@it.su.se>
MFC after: 3 days


119279 22-Aug-2003 njl

Quirk for Jungsoft NEXDISK USB flash key. Fails to mount without
NO_SYNCHRONIZE_CACHE.

PR: kern/54737
Submitted by: David Thiel <lx@redundancy.redundancy.org>
MFC after: 3 days


119275 22-Aug-2003 njl

Add quirks for the EXATELECOM i-Bead mp3 player.

PR: kern/51675
Submitted by: Nicolas Jombart <ecu@ipv42.net>
MFC after: 3 days


118556 06-Aug-2003 njl

Remove all USB quirks that only specify DA_Q_NO_6_BYTE. They are no longer
needed. Other USB quirks remain in hopes that user testing will reveal
which ones are also no longer needed.

Courtesy of: USENIX lunch break


118546 06-Aug-2003 njl

Remove unused cmd6workaround() calls.

MFC after: 1 day


118179 29-Jul-2003 njl

Fix the new DA_OLD_QUIRKS option for normal and module compiles.

Pointed out by: bde


118140 29-Jul-2003 njl

Deprecate USB and Firewire quirks. We should now never send 6 byte commands
to such devices. If a device fails due to this commit, add:
options DA_OLD_QUIRKS
to the kernel config and recompile. Then send the output of "camcontrol
inquiry da0" to scsi@freebsd.org so the quirk can be re-enabled.


118105 28-Jul-2003 njl

Add a PATH_INQ flag, PIM_NO_6_BYTE, which indicates the SIM never wishes to
receive 6 byte commands. Add a check for this flag to da(4) and cd(4) so
that they honor it. This is a quick workaround for many devices (especially
USB) that require da(4) quirks to operate. The more complete approach is
to finish the new transport code which will be aware of the SCSI version a
transport implements.

MFC after: 1 day


117739 18-Jul-2003 thomas

Reference PR for IntelligentStick quirk entry.

PR: kern/53005


117690 17-Jul-2003 thomas

Add quirk entry for IntelligentStick disc-on-key USB devices.
Reported by Samuel Tardieu <sam@rfc1149.net>.

Reviewed by: roberto
MFC after: 1 week


116351 14-Jun-2003 njl

Merge common XPT_CALC_GEOMETRY functions into a single convenience function.
Devices below may experience a change in geometry.

* Due to a bug, aic(4) never used extended geometry. Changes all drives
>1G to now use extended translation.
* sbp(4) drives exactly 1 GB in size now no longer use extended geometry.
* umass(4) drives exactly 1 GB in size now no longer use extended geometry.

For all other controllers in this commit, this should be a no-op.

Looked over by: scottl


116350 14-Jun-2003 njl

Merge common XPT_CALC_GEOMETRY functions into a single convenience function.
Devices below may experience a change in geometry.

* Due to a bug, aic(4) never used extended geometry. Changes all drives
>1G to now use extended translation.
* sbp(4) drives exactly 1 GB in size now no longer use extended geometry.
* umass(4) drives exactly 1 GB in size now no longer use extended geometry.

For all other controllers in this commit, this should be a no-op.

PR:
Submitted by:
Looked over by: scottl
Approved by:
Obtained from:
MFC after:


116162 10-Jun-2003 obrien

Use __FBSDID().


116161 10-Jun-2003 obrien

Use __FBSDID().


115660 02-Jun-2003 mjacob

Check in some months long pending minor debug output changes.

Clarify that the implicit fallthrough was *not* intentional (thanks, Poul!)
and reorganize the code so a correct fallthrough (with /* FALLTHROUGH */)
occurs.


115608 01-Jun-2003 phk

Remove unused variables.
Remove break after return.
Add XXX comment where intent is unclear.

Found by: FlexeLint


115606 01-Jun-2003 phk

Add /* FALLTHROUGH */

Found by: FlexeLint


115562 31-May-2003 phk

Add /* FALLTHROUGH */
Move /* FALLTHROUGH */ to correct location.
Remove unused variable(s).

Found by: FlexeLint


115561 31-May-2003 phk

Add /* FALLTHROUGH */
Remove unused variable(s).
Order switch in canonical order.

Found by: FlexeLint


115476 31-May-2003 phk

Add /* FALLTHROUGH */

Found by: FlexeLint


115464 31-May-2003 phk

Use symbolic constants instead of "4".
Use arrays instead of relying on struct packing.

Identical md5(scsi_ch.o).


115454 31-May-2003 phk

Don't use return(foo(...)); in a function returning void.

Found by: FlexeLint


115031 15-May-2003 njl

Add a quirk for OTi USB flash key.

PR: kern/51825
Approved by: re (rwatson)


114559 03-May-2003 ken

Fix three problems in large (>2TB) device handling:
- Make sure we don't release the READ CAPACITY CCB twice
- If we have a device that needs a 16 byte READ CAPACITY command, make
sure we call xpt_schedule() so we can get a CCB.
- Don't unlock the peripheral until we're fully probed.

Many thanks to Julian Elischer for providing hardware and testing this.

Tested by: julian


114388 01-May-2003 ken

Fix compile errors on ia64 in dagetcapacity. Set block_len and maxsector
to 0 initially. It seems that the ia64 backend isn't as "smart" as the
i386 backend, which realized that those variables were only set or used
when error == 0, and thus were not used uninitialized.


114294 30-Apr-2003 phk

Use %j instead of %q in printf to unbreak sparc64.


114261 30-Apr-2003 ken

Add support to CAM for devices with more than 2^32 blocks. (2TB if you're
using 512 byte blocks).

cam_ccb.h: Bump up volume_size and cylinders in ccb_calc_geometry to
64 bits and 32 bits respectively, so we can hold larger
device sizes. cylinders would overflow at about 500GB.
Bump CAM_VERSION for this change. Note that this will
require a recompile of all applications that talk to the
pass(4) driver.

scsi_all.c: Add descriptions for READ/WRITE(16), update READ/WRITE(12)
descriptions, add descriptions for SERVICE ACTION IN/OUT.
Add a new function, scsi_read_capacity_16(), that issues
the read capacity service action. (Necessary for arrays
larger than 2^32 sectors.) Update scsi_read_write() to use
a 64 bit LBA and issue READ(16) or WRITE(16) if necessary.
NOTE the API change. This should be largely transparnet
to most userland applications at compile time, but will
break binary compatibility. The CAM_VERSION bump, above,
also serves the purpose of forcing a recompile for any
applications that talk to CAM.

scsi_all.h: Add 16 byte READ/WRITE structures, structures for 16 byte
READ CAPACITY/SERVICE ACTION IN. Add scsi_u64to8b() and
scsi_8btou64.

scsi_da.c: The da(4) driver probe now has two stages for devices
larger than 2TB. If a standard READ CAPACITY(10) returns
0xffffffff, we issue the 16 byte version of read capacity
to determine the true array capacity. We also do the same
thing in daopen() -- use the 16 byte read capacity if the
device is large enough.

The sysctl/loader code has also been updated to accept
16 bytes as a minimum command size.


114216 29-Apr-2003 kan

Deprecate machine/limits.h in favor of new sys/limits.h.
Change all in-tree consumers to include <sys/limits.h>

Discussed on: standards@
Partially submitted by: Craig Rodrigues <rodrigc@attbi.com>


114130 27-Apr-2003 njl

SCSI Quirks for:
Casio QV-R3 USB camera, which appears to use a Pentax chipset
M-Systems DiskOnKey USB flash key
Feiya "slider" dual-slot flash reader
SmartDisk (Mitsumi) USB floppy drive

PR: kern/46545, kern/47793, kern/50020, kern/50226


113391 12-Apr-2003 phk

Remove the unused ioctl routine.


113186 06-Apr-2003 alc

Sufficient access checks are performed by vmapbuf() that calling useracc()
is pointless. Remove the calls to useracc().


112946 01-Apr-2003 phk

Use bioq_flush() to drain a bio queue with a specific error code.
Retain the mistake of not updating the devstat API for now.

Spell bioq_disksort() consistently with the remaining bioq_*().

#include <geom/geom_disk.h> where this is more appropriate.


112668 26-Mar-2003 ken

Clean up dynamically allocated sysctl variables when we run dacleanup() and
cdcleanup(). This fixes sysctl problems ("can't re-use a leaf") when
someone adds another peripheral at the same unit number. (e.g. rescan da0,
it goes away, then rescan again and da0 comes back, but since we haven't
cleaned up the sysctl variables from the last da0 instance, we can't
register the variables for the new instance under the same name.)

Reported by: njl
Tested by: njl


112288 15-Mar-2003 phk

Run a revision of the devstat interface:

Kernel:

Change statistics to use the *uptime() timescale (ie: relative to
boottime) rather than the UTC aligned timescale. This makes the
device statistics code oblivious to clock steps.

Change timestamps to bintime format, they are cheaper.

Remove the "busy_count", and replace it with two counter fields:
"start_count" and "end_count", which are updated in the down and
up paths respectively. This removes the locking constraint on
devstat.

Add a timestamp argument to devstat_start_transaction(), this will
normally be a timestamp set by the *_bio() function in bp->bio_t0.
Use this field to calculate duration of I/O operations.

Add two timestamp arguments to devstat_end_transaction(), one is
the current time, a NULL pointer means "take timestamp yourself",
the other is the timestamp of when this transaction started (see
above).

Change calculation of busy_time to operate on "the salami principle":
Only when we are idle, which we can determine by the start+end
counts being identical, do we update the "busy_from" field in the
down path. In the up path we accumulate the timeslice in busy_time
and update busy_from.

Change the byte_* and num_* fields into two arrays: bytes[] and
operations[].

Userland:

Change the misleading "busy_time" name to be called "snap_time" and
make the time long double since that is what most users need anyway,
fill it using clock_gettime(CLOCK_MONOTONIC) to put it on the same
timescale as the kernel fields.

Change devstat_compute_etime() to operate on struct bintime.

Remove the version 2 legacy interface: the change to bintime makes
compatibility far too expensive.

Fix a bug in systat's "vm" page where boot relative busy times would
be bogus.

Bump __FreeBSD_version to 500107

Review & Collaboration by: ken


112262 15-Mar-2003 phk

Don't use the devstat->busy_count for state decisions in the device
drivers. Doing so imposes atomicity and locking constraints on the
devstat API.

By: ken


112260 15-Mar-2003 phk

Call devstat_start_transaction_bio() instead of devstat_start_transaction()


112076 11-Mar-2003 njl

Quirk for SanDisk ImageMate II compact flash reader

PR: kern/47877
Submitted by: Mike Durian <durian@boogie.com>
MFC after: 3 days


112075 11-Mar-2003 njl

Quirk for Pentax Optio 230 USB camera. Note that other products probably
use the underlying AsahiOptical USB chip and thus this quirk may need to
be generalized in the future.

PR: kern/46369
Submitted by: Tim Vanderhoek <vanderh@ecf.utoronto.ca>
MFC After: 3 days


112006 08-Mar-2003 phk

Allocate the devstat structure with devstat_new_entry().


111979 08-Mar-2003 phk

Centralize the devstat handling for all GEOM disk device drivers
in geom_disk.c.

As a side effect this makes a lot of #include <sys/devicestat.h>
lines not needed and some biofinish() calls can be reduced to
biodone() again.


111821 03-Mar-2003 phk

Make nokqfilter() return the correct return value.

Ditch the D_KQFILTER flag which was used to prevent calling NULL pointers.


111815 03-Mar-2003 phk

Gigacommit to improve device-driver source compatibility between
branches:

Initialize struct cdevsw using C99 sparse initializtion and remove
all initializations to default values.

This patch is automatically generated and has been tested by compiling
LINT with all the fields in struct cdevsw in reverse order on alpha,
sparc64 and i386.

Approved by: re(scottl)


111571 26-Feb-2003 phk

msg


111504 25-Feb-2003 phk

NO_GEOM cleanup:

Move to "struct disk *" centric api.


111220 21-Feb-2003 phk

NO_GEOM cleanup:

Retire the "d_dump_t" and use the "dumper_t" type instead.

Dumper_t takes a void * as first arg which is more general than the
dev_t taken by d_dump_t. (Remember: we could have net-dumpers if
somebody wrote us one!)

Define the convention for GEOM controlled disk devices to be that the
first argument to the dumper function is the struct disk pointer.

Change device drivers accordingly.


111216 21-Feb-2003 phk

NO_GEOM cleanup:

Change the argument to disk_destroy() to be the same struct disk * as
disk_create() takes.

This enables drivers to ignore the (now) bogus dev_t which disk_create()
returns.


111206 21-Feb-2003 ken

Fix ATAPI/USB/Firewire CDROM drive handling in cd(4) and hopefully fix
a number of related problems along the way.

- Automatically detect CDROM drives that can't handle 6 byte mode
sense and mode select, and adjust our command size accordingly.
We have to handle this in the cd(4) driver (where the buffers are
allocated), since the parameter list length is different for the
6 and 10 byte mode sense commands.

- Remove MODE_SENSE and MODE_SELECT translation removed in ATAPICAM
and in the umass(4) driver, since there's no way for that to work
properly.

- Add a quirk entry for CDROM drives that just hang when they get a 6
byte mode sense or mode select. The reason for the quirk must be
documented in a PR, and all quirks must be approved by
ken@FreeBSD.org. This is to make sure that we fully understand why
each quirk is needed. Once the CAM_NEW_TRAN_CODE is finished, we
should be able to remove any such quirks, since we'll know what
protocol the drive speaks (SCSI, ATAPI, etc.) and therefore whether
we should use 6 or 10 byte mode sense/select commands.

- Change the way the da(4) handles the no_6_byte sysctl. There is
now a per-drive sysctl to set the minimum command size for that
particular disk. (Since you could have multiple disks with
multiple requirements in one system.)

- Loader tunable support for all the sysctls in the da(4) and cd(4)
drivers.

- Add a CDIOCCLOSE ioctl for cd(4) (bde pointed this out a long
time ago).

- Add a media validation routine (cdcheckmedia()) to the cd(4)
driver, to fix some problems bde pointed out a long time ago. We
now allow open() to succeed no matter what, but if we don't detect
valid media, the user can only issue CDIOCCLOSE or CDIOCEJECT
ioctls.

- The media validation routine also reads the table of contents off
the drive. We use the table of contents to implement the
CDIOCPLAYTRACKS ioctl using the PLAY AUDIO MSF command. The
PLAY AUDIO TRACK INDEX command that we previously used was
deprecated after SCSI-2. It works in every SCSI CDROM I've tried,
but doesn't seem to work on ATAPI CDROM drives. We still use the
play audio track index command if we don't have a valid TOC, but
I suppose it'll fail anyway in that case.

- Add _len() versions of scsi_mode_sense() and scsi_mode_select() so
that we can specify the minimum command length.

- Fix a couple of formatting problems in the sense printing code.

MFC after: 4 weeks


111119 19-Feb-2003 imp

Back out M_* changes, per decision of the TRB.

Approved by: trb


110730 11-Feb-2003 phk

Announce our ability to do DFLTPHYS sized transfers.


110599 09-Feb-2003 njl

Quirk for Lexar Media Jumpdrive

PR: kern/47006
Tested by: George Hartzell <hartzell@kestrel.alerce.com>
MFC after: 1 week


110517 07-Feb-2003 phk

Rename bio_linkage to the more obvious bio_parent.
Add bio_t0 timestamp, and include <sys/time.h> where needed


110232 02-Feb-2003 alfred

Consolidate MIN/MAX macros into one place (param.h).

Submitted by: Hiten Pandya <hiten@unixdaemons.com>


110116 30-Jan-2003 phk

NO_GEOM cleanup: retire disk_invalidate()


109759 23-Jan-2003 njl

Remove redundant printf from targbhasync() since all places that return an
error do their own, more useful printf.


109623 21-Jan-2003 alfred

Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.


109577 20-Jan-2003 gibbs

Add definitions for the task management codes sent in SPI4
command information units.


109572 20-Jan-2003 dillon

Close the remaining user address mapping races for physical
I/O, CAM, and AIO. Still TODO: streamline useracc() checks.

Reviewed by: alc, tegge
MFC after: 7 days


109345 16-Jan-2003 njl

kernel:
* Fix a bug where devices weren't cleaned up on close(): CAM_REQ_CMP != 0

user:
* Increase timeout in usermode to CAM_TIME_INFINITY. The initiator is in
charge of timeouts and the value was in ms, not seconds.
* Bring two debugging printfs under the debug flag
* Clean up man page to show increased testing on isp(4)

Submitted by: gibbs (bugfixes)


109160 13-Jan-2003 njl

Quirk for Sony USB disk-on-key device.

PR: kern/46386
Submitted by: dillon
MFC after: 3 days


108814 06-Jan-2003 peter

Back out last commit.


108784 06-Jan-2003 peter

Move dashutdown from SHUTDOWN_PRI_DEFAULT to SHUTDOWN_PRI_FIRST.
Otherwise, the scsi devices that it is trying to issue commands to may
have gone away. This is what caused shutdown to hang on ia64 systems
with mpt scsi controllers. The bus system has torn down the device tree
and reset the mpt controller etc, and suddenly along comes dashutdown
and wants to issue a few more scsi commands.... <HANG!>

This shouldn't work on i386 either, but it seems to work solely due
to luck.


108470 30-Dec-2002 schweikh

Fix typos, mostly s/ an / a / where appropriate and a few s/an/and/
Add FreeBSD Id tag where missing.


108059 18-Dec-2002 njl

Quirk for Memorybird pen drive

PR: kern/34712
Submitted by: Oliver Fromme <olli@lurza.secnetix.de>
MFC after: 3 days


107943 16-Dec-2002 trhodes

The HP DAT 40 tape drive should be able to handle variable block sizes.
But for some reason the block size is different when a different type of
tape is placed in the drive. This commit fixes that.

PR: 46209
Submitted by: Alex Wang <alex@alexwang.com>
Approved by: mjacob


107790 12-Dec-2002 yar

Clear the "device open" flag in daopen() before returning a error,
so the device won't stay marked as open whereas it isn't.

Approved by: re, njl
MFC after: 1 week


107386 29-Nov-2002 yar

Release the reference to the peripheral if returning a error.
That reference is to be held only if daopen() has been successful
and until daclose() releases it. daclose() won't be called if
daopen() has failed, though.

Approved by: re, njl
MFC after: 1 week


107240 25-Nov-2002 njl

Remove unnecessary includes and add sys/{lock,mutex}.h

Submitted by: bde
Approved by: re (previously)


107196 23-Nov-2002 njl

Whitespace cleanup that was missed by quirks commit 1.114


107193 23-Nov-2002 njl

Allow acd(4) and cd(4) to support old behavior for CDRIOC*SPEED ioctls.
If the value from the user is less than 177, assume it is a multiple of
a single speed CDROM and convert to KB/sec.

No complaints from: sos
Reviewed by: ken
Approved by: re
MFC after: 1 day


107192 23-Nov-2002 njl

Update quirks, adding PR references and fixing a capitalization mismatch.

PR: kern/45494
Approved by: re


107178 22-Nov-2002 njl

New SCSI target emulator code

This code allows a user program to enable target mode on a SIM and
then emulate any number of devices (disks, tape drives, etc.) All
decisions about device behavior (UA, CA, inquiry response) are left
to the usermode program and the kernel driver is merely a conduit
for CCBs. This enables multiple concurrent target emulators, each
using its own backing store and IO model.

Also included is a user program that emulates a disk (RBC) using a
file as a backing store. This provides functionality similar to
md(4) at the CAM layer.

Code has been tested on ahc(4) and should also work on isp(4) (and
other SIMs that gain target mode support). It is a complete rewrite
of /sys/cam/scsi_target* and /usr/share/examples/scsi_target.

Design, comments from: gibbs
Supported by: Cryptography Research
Approved by: re


106902 14-Nov-2002 imp

Panic message strings do not need a trailing \n.

Reviewed by: ken


106890 14-Nov-2002 imp

Panic message should end with \n.

Reviewed by: ken a while ago.


106696 09-Nov-2002 alfred

Fix instances of macros with improperly parenthasized arguments.

Verified by: md5


105421 18-Oct-2002 njl

* Add CDRIOC{READ,WRITE}SPEED ioctls to cd(4). Units are in KB/sec.
* Change atapi-cd ioctls to use the same units.
* Change burncd, cdcontrol to convert CDROM speed to KB/sec before
calling the ioctl. Add a "max" speed option for their command lines.

This change does not break ABI but does change the units passed through
the ioctl so 3rd party software that uses cdrio.h will have to convert
(most likely by multiplying CDROM speed by 177 to get KB/s).

PR: kern/36845
Submitted by: Philipp Mergenthaler <p@i609a.hadiko.de> (CAM ioctls)
Reviewed by: sos, ken
MFC after: 1 month


105378 18-Oct-2002 pirzyk

Backout my previous "brain cramp" commit.

Requested by: Most developers
Apologies to: Most developers, with special note to <ken@kdm.org>
Collabroation in the future with: Kenneth D. Merry <ken@kdm.org>


105363 17-Oct-2002 pirzyk

Changed the scsi mode command to use 10 bytes scsi commands instead
of the 6 byte ones. This helps with using a IDE cdrom behind a USB
interface.

PR: kern/43885


105343 17-Oct-2002 njl

Quirk for HP 315 USB Digital Camera

Submitted by: Keith White <kwhite@uottawa.ca>
PR: kern/41010

MFC after: 1 week


104880 11-Oct-2002 phk

Trapdoor access to cd%da and cd%c so they still work, but do not let them
show up in /dev.


104877 11-Oct-2002 phk

Use malloc(9)'s M_ZERO rather than explicit bzero(9) call.


104681 08-Oct-2002 ken

Fix the location of the length bytes in the 12-byte read/write CDB
structure. This has been broken since 1998, but probably hasn't been
noticed because it takes a read/write of 64K blocks (32MB with 512 byte
blocks) to trigger using the 12 byte read/write CDB in scsi_read_write().

Submitted by: "Moore, Eric Dean" <emoore@lsil.com>
MFC after: 3 days


104611 07-Oct-2002 phk

Correctly convert to appropriate blocksize.

note to self:
Never check block-size sensitive patches on Sun compatible CD drives.

Sponsored by: DARPA & NAI Labs.


104456 04-Oct-2002 phk

Unhook the SCSI CD driver from the disk "mini-layer" and/or GEOM.

SCSI disks are too square pegs for the round holes in both of these.

And since atapi-cd has clearly shown that there are better acccess
models for CD media than trying to pretend to be a classical disk,
we stop the masquerade rather than patch up the costume.

But do implement the DIOCGMEDIASIZE and DIOCGSECTORSIZE so it will
be possible to manually attach to GEOM, should some the need arise.

Ideally, this driver should do media-detection and call make_dev()
when a CD is inserted and destroy_dev() when it is removed, this
would allow our future devd(8) to automount etc etc but coding that
takes SCSI-clue beyond anything I posses.

Tested on: sparc64


104421 03-Oct-2002 ken

Fix style problems in the quirk entry section.

MFC after: 2 weeks


104301 01-Oct-2002 sobomax

Add quirks for DaisyTechnology PhotoClip camera.

Submitted by: Olexander Kunitsa <kunia@istc.kiev.ua>
MFC after: 3 days


104200 30-Sep-2002 guido

Add quirk for Apacer HandyDrive

MFC after: 1 week


104094 28-Sep-2002 phk

Be consistent about "static" functions: if the function is marked
static in its prototype, mark it static at the definition too.

Inspired by: FlexeLint warning #512


103870 23-Sep-2002 alfred

use __packed.


103818 23-Sep-2002 mjacob

A SCSI_DELAY of zero is a legitimate value to have.
The notion that you must "always" have a delay is at best misinformed.


103817 23-Sep-2002 mjacob

Note that the large Hitachi's are also CAM_QUIRK_HILUNS


103714 20-Sep-2002 phk

(This commit touches about 15 disk device drivers in a very consistent
and predictable way, and I apologize if I have gotten it wrong anywhere,
getting prior review on a patch like this is not feasible, considering
the number of people involved and hardware availability etc.)

If struct disklabel is the messenger: kill the messenger.

Inside struct disk we had a struct disklabel which disk drivers used to
communicate certain metrics to the disklayer above (GEOM or the disk
mini-layer). This commit changes this communication to use four
explicit fields instead.

Amongst the benefits is that the fields do not get overwritten by
wrong or bogus on-disk disklabels.

Once that is clear, <sys/disk.h> which is included in the drivers
no longer need to pull <sys/disklabel.h> and <sys/diskslice.h> in,
the few places that needs them, have gotten explicit #includes for
them.

The disklabel inside struct disk is now only for internal use in
the disk mini-layer, so instead of embedding it, we malloc it as
we need it.

This concludes (modulus any mistakes) the series of disklabel related
commits.

I belive it all amounts to a NOP for all the rest of you :-)

Sponsored by: DARPA & NAI Labs.


103687 20-Sep-2002 phk

Don't use dkunit() to find out unit, we already have our softc pointer
where we can find it.

Don't call dkpart() just to print the result, it is constant.

Sponsored by: DARPA & NAI Labs.


102862 02-Sep-2002 brooks

Make SCSI_DELAY setable at boot time and runtime via the
kern.cam.scsi_delay tunable/sysctl.

Reviewed by: mdodd, njl


102496 27-Aug-2002 njl

Add \n to various printfs. grep shows these should be the last ones.


102443 26-Aug-2002 gibbs

Adjust scsi_calc_syncparam() to the exception table changing from 10ths to
100ths of ns. This should correct a problem with camcontrol "ignoring"
requests to negotiate to slower speeds.


102412 25-Aug-2002 charnier

Replace various spelling with FALLTHROUGH which is lint()able


102342 24-Aug-2002 peter

Add some \n's to printf()s


102341 24-Aug-2002 peter

Fix unit wiring. Also, change the variable "hit" to "wired" so that it
is more obvious.

Obtained from: gibbs/ken


101998 16-Aug-2002 njl

Updates to cmd6workaround:
* Only update cdb in place if not CDB_POINTER
* Correctly check for QFRZ before restarting CCB
* More accurate printf message
* style(9) changes at end

Patch tested successfully on Maxtor 4 G120J6 GAK8.


101942 15-Aug-2002 njl

Remove cam_extend.[ch] after all references to them were removed.

PR: kern/39809
Approved by: gibbs


101940 15-Aug-2002 njl

Remove usage of cam_extend.c, replace with dev->si_drv1

PR: kern/39809
Approved by: gibbs


98449 19-Jun-2002 robert

Correct spelling of 'supplied'.

PR: misc/39528


98026 07-Jun-2002 mjacob

If we boot verbose, then print out 'interesting' CAM errors that otherwise
would hide problems (like Selection Timeout).


97882 05-Jun-2002 gibbs

Add the 160MHz syncrate to scsi_calc_syncrate() sync period exception table.


97881 05-Jun-2002 gibbs

scsi_message.h:
Include PPR option bits defined in SPI4.

scsi_iu.h:
Add data structures releated to parallel SCSI information units
for use in SPI4 packetized protocol.


97825 04-Jun-2002 mjacob

Add REPORT LUNS basic infrastructure.


97513 29-May-2002 dillon

PR: kern/38208
X-MFC after: immediate w/ release eng approval.


96959 19-May-2002 dillon

Add a Quirk entry for the USB SimpleTech UCF-100 compact flash reader.
Note that even with the quirk entry the reader typically only works if
the USB device is recognized by UHCI instead of the generic OHCI driver.


95333 24-Apr-2002 mjacob

Make Veritas Storage Appliance a HILUNS device.

MFC after: 1 day


95302 23-Apr-2002 marcel

Remove unused static variable quantum.


93505 01-Apr-2002 ken

Fix 3 of the four problems with my last indentation fix. ("fixing" the
fourth would be a divergence from the prevailing style.)

Thanks to bde for catching this.

Pointed out by: bde


93502 01-Apr-2002 ken

Fix an indentation problem.


93493 31-Mar-2002 phk

DA (scsi) and AD (ata) diskdrivers:
Make the dump routine do just writing of data.


93059 24-Mar-2002 simokawa

Maxtor Personal Storage 3000XT (Firewire) hangs upon
serial number probing.

MFC after: 1 week


93038 23-Mar-2002 simokawa

Automatically detect devices that do not support READ(6)/WRITE(6)
and upgrade to using 10 byte cdbs.

As far as I tested, this works efficiently for most of the
SBP-II/Firewire devices but most of the umass devices still need
ad-hoc work around because umass-sim doesn't return any SCSI errors.

A sysctl nob is also added for the last resort.
I hope we don't need DA_Q_NO_6_BYTE quirks anymore.

Reviewed by: gibbs
MFC after: 1 week


92770 20-Mar-2002 alfred

Remove __P.


92072 11-Mar-2002 phk

Mark some arguments __unused.


92052 11-Mar-2002 simokawa

Add support for Simplified Direct Access Device in scsi_op_desc().


91406 27-Feb-2002 jhb

Simple p_ucred -> td_ucred changes to start using the per-thread ucred
reference.


91062 22-Feb-2002 phk

GC: BIO_ORDERED going away.


91016 21-Feb-2002 simokawa

- Add support for Simplified Direct Access Device, mostly for
Firewire/SBP-II devices.

- Add quirk for Logitec USB/Firewire HDD.

MFC after: 3 days.


90868 18-Feb-2002 mike

o Move NTOHL() and associated macros into <sys/param.h>. These are
deprecated in favor of the POSIX-defined lowercase variants.
o Change all occurrences of NTOHL() and associated marcros in the
source tree to use the lowercase function variants.
o Add missing license bits to sparc64's <machine/endian.h>.
Approved by: jake
o Clean up <machine/endian.h> files.
o Remove unused __uint16_swap_uint32() from i386's <machine/endian.h>.
o Remove prototypes for non-existent bswapXX() functions.
o Include <machine/endian.h> in <arpa/inet.h> to define the
POSIX-required ntohl() family of functions.
o Do similar things to expose the ntohl() family in libstand, <netinet/in.h>,
and <sys/param.h>.
o Prepend underscores to the ntohl() family to help deal with
complexities associated with having MD (asm and inline) versions, and
having to prevent exposure of these functions in other headers that
happen to make use of endian-specific defines.
o Create weak aliases to the canonical function name to help deal with
third-party software forgetting to include an appropriate header.
o Remove some now unneeded pollution from <sys/types.h>.
o Add missing <arpa/inet.h> includes in userland.

Tested on: alpha, i386
Reviewed by: bde, jake, tmm


90848 18-Feb-2002 bsd

Add NO_6_BYTE quirk entry for the LaCie Ltd. 105311 80 Gig USB2 drive.

Submitted by: Brian Schellenberger <bts@babbleon.org>


90484 10-Feb-2002 phk

Remove spurious ';'

Obtained from: ~bde/sys.dif.gz


90015 31-Jan-2002 sobomax

Add support of PhotoClip USB Camera (http://www.myphotoclip.com):
- Vendor&Device IDs for USB product,
- quirk for SCSI CAM.

PR: 34481
Submitted by: Olexander Kunytsa <kunia@x-telecom.net>
MFC in: 3 days


89114 09-Jan-2002 msmith

Define the kern.cam sysctl in the cam layer, rather than multiply in several
peripheral drivers. Remove Ken's comment to the effect that this needed
to be done.

Staticise camnet_ih and cambio_ih.


89113 09-Jan-2002 msmith

Staticise a debugging variable.

Submitted by: non


89105 08-Jan-2002 sobomax

Add quirk for DIVA USB Mp3 Player.

PR: kern/33638
Submitted by: Olexander Kunytsa <kunia@x-telecom.net>
MFC after: 3 days
(pending re's approval)


88975 07-Jan-2002 kbyanc

Extend Olympus E-100RS quirk to cover entire E series of digital cameras.


88900 05-Jan-2002 jhb

Change the preemption code for software interrupt thread schedules and
mutex releases to not require flags for the cases when preemption is
not allowed:

The purpose of the MTX_NOSWITCH and SWI_NOSWITCH flags is to prevent
switching to a higher priority thread on mutex releease and swi schedule,
respectively when that switch is not safe. Now that the critical section
API maintains a per-thread nesting count, the kernel can easily check
whether or not it should switch without relying on flags from the
programmer. This fixes a few bugs in that all current callers of
swi_sched() used SWI_NOSWITCH, when in fact, only the ones called from
fast interrupt handlers and the swi_sched of softclock needed this flag.
Note that to ensure that swi_sched()'s in clock and fast interrupt
handlers do not switch, these handlers have to be explicitly wrapped
in critical_enter/exit pairs. Presently, just wrapping the handlers is
sufficient, but in the future with the fully preemptive kernel, the
interrupt must be EOI'd before critical_exit() is called. (critical_exit()
can switch due to a deferred preemption in a fully preemptive kernel.)

I've tested the changes to the interrupt code on i386 and alpha. I have
not tested ia64, but the interrupt code is almost identical to the alpha
code, so I expect it will work fine. PowerPC and ARM do not yet have
interrupt code in the tree so they shouldn't be broken. Sparc64 is
broken, but that's been ok'd by jake and tmm who will be fixing the
interrupt code for sparc64 shortly.

Reviewed by: peter
Tested on: i386, alpha


88765 01-Jan-2002 jedgar

Add support for Nikon Coolpix E775 and E885 cameras.

PR: 33407 (E885)
Submitted by: Brian Behlendorf <brian@hyperreal.org> (E885)


87983 15-Dec-2001 non

o Add KLD support for scsi_low.
o Add KLD dependency of ncv, nsp and stg drivers to scsi_low.

Submitted by: takawata


87582 10-Dec-2001 non

Remove PAO3 dependent part where I missed to remove at last commit.


87577 09-Dec-2001 iedowse

Add a NO_6_BYTE quirk for the D-series olympus digital cameras.

PR: kern/31250
Submitted by: Bryan Liesner <bleez@bellatlantic.net>


86940 27-Nov-2001 ken

Bring the probe inquiry code in line with the SCSI spec.

It is legal to have a device with device type 0x1f, that just means
that the device is of unknown type. Instead, only check the peripheral
qualifier when deciding whether or not to reject a device based on its
inquiry information.

Tested by: julian
MFC after: 3 weeks


86913 26-Nov-2001 iedowse

Back out 1.88 (NO_SYNC_CACHE quirk for Infortrend IFT-3102). Since
this device properly reports that the sync cache command is
unsupported, the bug is that we still complain about it on the
console.

Noticed by: gibbs


86633 19-Nov-2001 dg

Disabled tagged commands for Hitachi Jura-C series with J8A8 firmware.

PR: 23536
Submitted by: amagai@nue.org


86623 19-Nov-2001 iedowse

Back out revision 1.117; the correct solution is to upgrade the
firmware on the drive in question. The pattern also matched far
too many Hitachi drives.

Spotted by: dg


86564 19-Nov-2001 iedowse

Hitachi DK32 disks have problems with tagged queuing under load.

PR: kern/23536
Submitted by: Y.Amagai <amagai@nue.org>
MFC after: 1 week


86503 17-Nov-2001 mjacob

Be very generous with timeouts for synchronize cache. We may wait a very long
time in the cases where it really sends the drive out to lunch, but it also
allows us to catch very wierd edge cases of strange drives that might take
a very long time (emulated disk drives over a network, e.g.).


86502 17-Nov-2001 iedowse

The Infortrend IFT-3102 multihost U2 SCSI to U2 SCSI controller
doesn't support the synchronise cache command.

PR: kern/21752
Submitted by: Nick R. Colakovic <nickc@corp.firstindustrial.com>
MFC after: 1 week


86500 17-Nov-2001 iedowse

Add quirk for Fujitsu M2513A MO drives. These drives hang at various
operations due to the synchronize cache command.

PR: kern/21674
Submitted by: W.Scholten <whs@xs4all.nl>
MFC after: 1 week


86313 13-Nov-2001 ps

Fix a signed bug in the crashdump code for systems with > 2GB of ram.

Reviewed by: peter


86177 07-Nov-2001 kbyanc

Add quirk for Minolta 2330 Zoom digital camera.

Submitted by: Jan Stocker <Jan.Stocker@t-online.de>


86174 07-Nov-2001 kbyanc

Add quirk for Nikon Coolpix 995.

Submitted by: Jos Vissers <jos@tunix.nl>


86161 06-Nov-2001 kbyanc

Fix bug in scsi_read_write() where it might use 6-byte commands when
10/12-byte-specific flags where specified.

Reviewed by: ken
MFC after: 1 day


86115 05-Nov-2001 kbyanc

Add quirk entry for Olympus E-100RS digital camera. This and the existing
quirk regarding the C- series makes me suspect that all Olympus models have
the same quirks, but I cannot prove it.

Submitted by: Bernd Walter <ticso@cicely8.cicely.de>


85962 03-Nov-2001 non

Remove PAO3 dependent part.
This will not affect either -current nor -stable.


84953 15-Oct-2001 scottl

Add a quirk entry so that the Maxtor 3000LE USB drive will work.

Submitted by: merry, Randy Bush <randy@psg.com>
MFC after: 3 days


83974 26-Sep-2001 rwatson

o Modify access control code for the CAM SCSI pass-through device to
use securelevel_gt() instead of direct securelevel variable test.

Obtained from: TrustedBSD Project


83917 25-Sep-2001 rwatson

s/securelvel/securelevel/


83657 19-Sep-2001 scottl

Add a quirk entry for the Sony CLIE memory stick device. This will become
useful once ATAPI support is turned on in the umass driver.


83473 14-Sep-2001 mjacob

The code that sees a drive (at mount time) not in buffered mode and
attempts to set buffered mode was printing out "unable to set buffered
mode" no matter what. Oops.

Spotted by: Joerg Wunsch <joerg_wunsch@uriah.heep.sax.de>
MFC after: 3 weeks


83366 12-Sep-2001 julian

KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED
make the kernel aware that there are smaller units of scheduling than the
process. (but only allow one thread per process at this time).
This is functionally equivalent to teh previousl -current except
that there is a thread associated with each process.

Sorry john! (your next MFC will be a doosie!)

Reviewed by: peter@freebsd.org, dillon@freebsd.org

X-MFC after: ha ha ha ha


82850 03-Sep-2001 ken

Attach to a CD device even when the SCSI status is 'busy'.

Reported by: Thomas Quinot <thomas@cuivre.fr.eu.org>
MFC after: 3 weeks


82826 02-Sep-2001 n_hibma

Add quirk entry for FujiFilm camera.

Submitted by: Guido van Rooij <guido@gvr.org>


82787 02-Sep-2001 n_hibma

Add quirks for Kingbyte USB Pen drive.

Submitted by: Eugene M. Kim <gene@nttmcl.com>
PR: 29530


82592 30-Aug-2001 mjacob

Take CAM_REQUEUE_REQ out of the class of things we were trying to honor
retry count on.

MFC after: 4 weeks


82575 30-Aug-2001 mjacob

Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases.
Clear residual counts after a successful samount (the user doesn't
care that we got an N-kbyte residual on our test read).

Change a lot of error handling code.

1. If we end up in saerror, check more carefully about the kind of
error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write
command, we'll be handling this in saerror. If it isn't a read/write
command, check to see whether this is just an EOM/EOP check condition-
if it is, just set residual and return normally. A residual and
then a NO SENSE check condiftion with the ASC of 0 and ASCQ of
between 1 and 4 are normal 'signifying' events, not errors per se,
and we shouldn't give the command to cam_periph_error to do something
relatively unpredictable with.

2. If we get a Bus Reset, had a BDR sent, or get the cam status of
CAM_REQUEUE_REQ, check the retry count on the command. The default
error handler, cam_periph_error, doesn't honor retry count in these
cases. This may change in the future, but for now, make sure we
set EIO and return without calling cam_periph_error if the retry
count for the command with an error is zero.

3. Clean up the pending error case goop and handle cases more
sensibly.

The rules are:

If command was a Write:

If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is
propagated and we set ENOSPC as the error.

Else if we got an EOM condition- just mark EOM pending.

And set a residual of zero. For the longest time I was just
propagating residual from the sense data- but my tape
comparison tests were always failing because all drives I
tested with actually *do* write the data anyway- the EOM
(early warning) condition occurred *prior* to all of the
data going out to media- that is, it was still buffered by
the drive. This case is described in SCSI-2, 10.2.14,
paragraph #d for the meaning of 'information field'. A
better fix for this would be to issue a WFM command of zero
to cause the drive to flush any buffered data, but this
would require a fairly extensive rewrite.

Else if the command was a READ:

If we got a SSD_KEY_BLANK_CHECK-
If we have a One Filemark EOT model- mark EOM as pending,
otherwise set EIO as the erorr.
Else if we found a Filemark-
If we're in Fixed Block mode- mark EOF pending.

If we had an ILI (Incorrect Length Indicator)-
If the residual is less than zero, whine about tape record
being too big for user's buffer, otherwise if we were in
Fixed Block mode, mark EIO as pending.

All 'pending' conditions mean that the command in question completes
without error indication. It had succeeded, but a signifying event
occurred during its execution which will apply to the *next* command
that would be exexcuted. Except for the one EOM case above, we always
propagate residual.

Now, way back in sastart- if we notice any of the PENDING bits set,
we don't run the command we've just pulled off the wait queue. Instead,
we then figure out it's disposition based upon a previous command's
association with a signifying event.

If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete
the command with residual set to the request count (not data moved,
but no error). We continue on.

If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in
Fixed Block mode- in which case we traverse all waiting buffers (which
we can get in fixed block mode because physio has split things up) and
mark them all as no error, but no data moved and complete them.

If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error
and complete it.

Then we clear all of the pending state bits- we're done.

MFC after: 4 weeks


82384 27-Aug-2001 kbyanc

Add interfaces for SCSI LOG SELECT and LOG SENSE commands.

Reviewed by: ken


82106 21-Aug-2001 n_hibma

Add quirks for the Olympus Digital Camera.

PR: 26295

Add quirks for the Microtech CameraMate.


81448 10-Aug-2001 phk

Eliminate the hot-spare 'r' in Arrray.

Submitted by: Søren Schrøder <sch@chaos.dk>


80578 30-Jul-2001 mjacob

Kill the command (don't rerun it) if we had an AUTOSENSE failure.
If we had an AUTOSENSE failure, we don't know what SENSE DATA
we had for a CHECK CONDITION. It's far better to assume failure
in this case.


80577 30-Jul-2001 mjacob

(Forced commit- last one missed the comments)

Handle both old and new TARGIOALLOCUNIT/TARGIOFREEUNIT cases- the new
one allows us to specify inquiry data we want to use.

Handle more of the CAM_DIS_DISCONNECT case.


80576 30-Jul-2001 mjacob

(Forced commit- last commit was inadvertant in that it missed the comments)

Move TARGCTLIOALLOCUNIT to OTARGCTLIOALLOCUNIT, TARGCTLIOFREEUNIT
to OTARGCTLIOFREEUNIT and redefine old associated structure to be
old_ioc_alloc_unit- deprecation but preservation of binaries.

Add new structure for same- but this one contains a pointer to
user defined INQUIRY data so you can define what the target
device looks like to the outside world.


80575 30-Jul-2001 mjacob

backout last commit- inadvertant


80574 30-Jul-2001 mjacob

scsi_targetio.h


80573 30-Jul-2001 mjacob

Propagate CAM_DIS_DISCONNECT on through:

1. If we get frozen, unfreeze for disable disconnects.
2. Put CAM_DIS_DISCONNECT commands at the head of the work queue
(we have a target still connected and we can't run anything else
until this command completes).

If we had an error sending the last CTIO, unfreeze the queue anyway.


80033 20-Jul-2001 n_hibma

Support for USB floppies based upon SMSC USB FDD controller.

PR: 28877
Submitted by: Larry Baird <lab@gta.com>
MFC after: 1 week


79697 14-Jul-2001 non

Catch up with NetBSD/pc98.
o Much cleanly separate NetBSD(XS) / FreeBSD(CAM) codes.
o Improve tagged queing support (full QTAG).
o Improve quirk support.
o Improve parity error retry.
o Impliment wide negotheation.
o Cmd link support.
o Add copyright of CAM part.
o Change for CAM_NEW_TRAN_CODE.
o Work around for buggy KME UJDCD450.

o stg: add disconnet condition.
o nsp: use suspend I/O.
and more. I thank Honda-san.

conf/options.pc98: add CT_USE_RELOCATE_OFFSET and CT_BUS_WEIGHT
dev/{ct,ncv,nsp,stg}/*_{pccard,isa}.c: add splcam() before calling
attach/detach functions.

Tested by: bsd-nomads
Obtained from: NetBSD/pc98


79575 11-Jul-2001 dd

Call disk_destroy in cdcleanup() as appropriate.

PR: 24596
Reviewed by: ken


79483 09-Jul-2001 mjacob

Add SYSCTL ints for default normal I/O timeout && retry counts.

This is useful if you want to dynamically move into a Fibre Channel
or Multi-initiator environment that happens to be particularly noisy
and ugly that requires a lot of retries (with shorter I/O timeouts)
for commands destried by LIPs or Bus Resets.

Reviewed by: deafening silence on audit && scsi on the retry counts
MFC after: 2 weeks


79177 04-Jul-2001 mjacob

Check the void * argument in the AC_FOUND_DEV case against NULL. Whether
correctly or not, this sometimes is propagated up via XPT.


79100 02-Jul-2001 mjacob

A slightly more complete change to timeouts:

1. Add SA_IO_TIMEOUT as an option (4 minutes default) to cover reads,
writes, wfm, test unit ready.

2. Add internal SCSIOP_TIMEOUT (e.g., for mode sense) at 1 minute. This
should not require an option, but is cleaner to parameterize.

MFC after: 1 week


79094 02-Jul-2001 lars

Reviewed by: Matthew Jacob
Changed the timeout to wait for writing of filemarks to complete from 1
minute to 3 minutes. This should probably be enhanced to be a sysctl variable.


78710 24-Jun-2001 mjacob

cleanup some of the XPORT_FC code


78709 24-Jun-2001 mjacob

Add a transport settings variant for Fibre Channel.


78230 15-Jun-2001 peter

Fix warnings:
1267: warning: suggest parentheses around comparison in operand of &
2087: warning: unused variable `li'


78135 12-Jun-2001 peter

Hints overhaul:
- Replace some very poorly thought out API hacks that should have been
fixed a long while ago.
- Provide some much more flexible search functions (resource_find_*())
- Use strings for storage instead of an outgrowth of the rather
inconvenient temporary ioconf table from config(). We already had a
fallback to using strings before malloc/vm was running anyway.


77810 06-Jun-2001 non

Sorry, an "ARCHIVE Python 06408" does not need SA_QUIRK_NOCOMP.


77710 04-Jun-2001 mjacob

first blush at some FC path inquiry settings


77709 04-Jun-2001 mjacob

Do NOLUNS dance for oddball Exabyte. We *really* need to do this as hints.

Correct match for A5000 SES instance.

PR: 19887
MFC after: 2 weeks


77708 04-Jun-2001 mjacob

first blush at some FC path inquiry settings


77581 01-Jun-2001 non

Add a quirk entry for ARCHIVE Python 06408.

Approved by: mjacob


77254 27-May-2001 ken

Print out the asc/ascq and description even when both the asc and ascq
are zero. This is so that users will see the "no addtional sense" printout
and know that they have the full sense information.


76650 15-May-2001 jhb

Remove unneeded includes of sys/ipl.h and machine/ipl.h.


76362 08-May-2001 phk

Exploit recent improvements in the disk minilayer to simplify error
handling a bit.

Dogmatic lingupurists can celebrate that a number of gotos got removed.

Reviewed by: mjacob, ken


76322 06-May-2001 phk

Actually biofinish(struct bio *, struct devstat *, int error) is more general
than the bioerror().

Most of this patch is generated by scripts.


76293 05-May-2001 joerg

Add q quirk for the old SONY SMO drive i've been sitting upon in my
private tree for too long now. This (pre SCSI-2) drive returns a
mystic code when the medium is inserted but not spun up.


76192 01-May-2001 ken

Fix up unit attention and selection timeout handling in various peripheral
drivers.

- change daprevent() to set CAM_RETRY_SELTO and SF_RETRY_UA when it calls
cam_periph_runccb().
- change the pt(4) driver to ignore unit attentions
- change the targ(4) driver to retry selection timeouts
- clean up a few formatting glitches in the targ(4) driver

Reviewed by: gibbs


76162 30-Apr-2001 ken

Add sense key table entries for DATA PROTECT and BLANK CHECK. This will
prevent scsi_sense_desc() from deferencing a NULL pointer when a drive
happens to return one of these sense keys.

Reported by: Michael Samuel <michael@miknet.net>


76158 30-Apr-2001 ken

In camperiphscsisenseerror(), don't return an error when the error action
is SS_NOP.

Submitted by: joerg


76153 30-Apr-2001 ken

Fix an errant search and replace that broke SCSI start unit commands.

This should fix automatic spinups as well as 'camcontrol start'.


75840 22-Apr-2001 joerg

Fix the `tape drive spinning indefinately upon mt stat' problem.

With the recent changes in the CAM error handling, some problems in
the error handling of sa(4) have been uncovered. Basically, a number
of conditions that are not actually errors have been mistreated as
genuine errors. In particular:

. Trying to read in variable length mode with a mismatched blocksize
between the on-tape (virtual) blocks and the read(2) supplied buffer
size, causing an ILI SCSI condition, have caused an attempt to retry
the supposedly `errored' transfer, causing the tape to be read
continuously until it eventually hit EOM. Since by default any
simple mt(1) operation does an initial test read, an `mt stat' was
sufficient to trigger this bug.

Note that it's Justin's opinion that treating a NO SENSE as an EIO
is another bug in CAM. I feel not authorized to fix cam_periph.c
without another confirmation that i'm on the right track, however.

. Hitting a filemark caused the read(2) syscall to return EIO, instead
of returning a `short read'. Note that the current fix only solves
this problem in variable length mode. Fixed length mode uses a
different code path, and since i didn't grok all the intentions behind
that handling, i did not touch it (IOW: it's still broken, and you get
an EIO upon hitting a filemark).

The solution is to keep track of those conditions inside saerror(),
and upon completion to not call cam_periph_error() in that case. We
need to make sure that the device gets unfrozen if needed though (in
case of actual errors, cam_periph_error() does this on our behalf).

Not objected by: mjacob (who currently doesn't have the time to
review the patch)


75549 16-Apr-2001 ken

Fix an off-by-2 error in periphdriver_register(). The read side of the
bcopy would go off the end of the array by two elements, which sometimes
causes a panic if it happens to cross into a page that isn't mapped.

Submitted by: gibbs
Reviewed by: peter


75190 04-Apr-2001 mjacob

If we have and error and are booting verbosely, don't be complaining
if this was a non-retryable selection timeout- wading through 256 targets
worth of Fibre Channel 'selection timeouts' is tedious at best.


75030 31-Mar-2001 murray

comment typo: subsytem -> subsystem

PR: 26219
Submitted by: Andre <andre@akademie3000.de>, chern@osd.bsdi.com


74914 28-Mar-2001 jhb

Catch up to header include changes:
- <sys/mutex.h> now requires <sys/systm.h>
- <sys/mutex.h> and <sys/sx.h> now require <sys/lock.h>


74890 28-Mar-2001 ps

Last commit was broken.. It always prints '[CTRL-C to abort]'.
Move duplicate code for printing the status of the dump and checking
for abort into a separate function.

Pointy hat to: me


74841 27-Mar-2001 ps

Change the dump routines to only abort if control-c is pressed.
If any other key is pressed, print a message stating that control-c
is how to abort.

Reviewed by: peter


74840 27-Mar-2001 ken

Rewrite of the CAM error recovery code.

Some of the major changes include:

- The SCSI error handling portion of cam_periph_error() has
been broken out into a number of subfunctions to better
modularize the code that handles the hierarchy of SCSI errors.
As a result, the code is now much easier to read.

- String handling and error printing has been significantly
revamped. We now use sbufs to do string formatting instead
of using printfs (for the kernel) and snprintf/strncat (for
userland) as before.

There is a new catchall error printing routine,
cam_error_print() and its string-based counterpart,
cam_error_string() that allow the kernel and userland
applications to pass in a CCB and have errors printed out
properly, whether or not they're SCSI errors. Among other
things, this helped eliminate a fair amount of duplicate code
in camcontrol.

We now print out more information than before, including
the CAM status and SCSI status and the error recovery action
taken to remedy the problem.

- sbufs are now available in userland, via libsbuf. This
change was necessary since most of the error printing code
is shared between libcam and the kernel.

- A new transfer settings interface is included in this checkin.
This code is #ifdef'ed out, and is primarily intended to aid
discussion with HBA driver authors on the final form the
interface should take. There is example code in the ahc(4)
driver that implements the HBA driver side of the new
interface. The new transfer settings code won't be enabled
until we're ready to switch all HBA drivers over to the new
interface.

src/Makefile.inc1,
lib/Makefile: Add libsbuf. It must be built before libcam,
since libcam uses sbuf routines.

libcam/Makefile: libcam now depends on libsbuf.

libsbuf/Makefile: Add a makefile for libsbuf. This pulls in the
sbuf sources from sys/kern.

bsd.libnames.mk: Add LIBSBUF.

camcontrol/Makefile: Add -lsbuf. Since camcontrol is statically
linked, we can't depend on the dynamic linker
to pull in libsbuf.

camcontrol.c: Use cam_error_print() instead of checking for
CAM_SCSI_STATUS_ERROR on every failed CCB.

sbuf.9: Change the prototypes for sbuf_cat() and
sbuf_cpy() so that the source string is now a
const char *. This is more in line wth the
standard system string functions, and helps
eliminate warnings when dealing with a const
source buffer.

Fix a typo.

cam.c: Add description strings for the various CAM
error status values, as well as routines to
look up those strings.

Add new cam_error_string() and
cam_error_print() routines for userland and
the kernel.

cam.h: Add a new CAM flag, CAM_RETRY_SELTO.

Add enumerated types for the various options
available with cam_error_print() and
cam_error_string().

cam_ccb.h: Add new transfer negotiation structures/types.

Change inq_len in the ccb_getdev structure to
be "reserved". This field has never been
filled in, and will be removed when we next
bump the CAM version.

cam_debug.h: Fix typo.

cam_periph.c: Modularize cam_periph_error(). The SCSI error
handling part of cam_periph_error() is now
in camperiphscsistatuserror() and
camperiphscsisenseerror().

In cam_periph_lock(), increase the reference
count on the periph while we wait for our lock
attempt to succeed so that the periph won't go
away while we're sleeping.

cam_xpt.c: Add new transfer negotiation code. (ifdefed
out)

Add a new function, xpt_path_string(). This
is a string/sbuf analog to xpt_print_path().

scsi_all.c: Revamp string handing and error printing code.
We now use sbufs for much of the string
formatting code. More of that code is shared
between userland the kernel.

scsi_all.h: Get rid of SS_TURSTART, it wasn't terribly
useful in the first place.

Add a new error action, SS_REQSENSE. (Send a
request sense and then retry the command.)
This is useful when the controller hasn't
performed autosense for some reason.

Change the default actions around a bit.

scsi_cd.c,
scsi_da.c,
scsi_pt.c,
scsi_ses.c: SF_RETRY_SELTO -> CAM_RETRY_SELTO. Selection
timeouts shouldn't be covered by a sense flag.

scsi_pass.[ch]: SF_RETRY_SELTO -> CAM_RETRY_SELTO.

Get rid of the last vestiges of a read/write
interface.

libkern/bsearch.c,
sys/libkern.h,
conf/files: Add bsearch.c, which is needed for some of the
new table lookup routines.

aic7xxx_freebsd.c: Define AHC_NEW_TRAN_SETTINGS if
CAM_NEW_TRAN_CODE is defined.

sbuf.h,
subr_sbuf.c: Add the appropriate #ifdefs so sbufs can
compile and run in userland.

Change sbuf_printf() to use vsnprintf()
instead of kvprintf(), which is only available
in the kernel.

Change the source string for sbuf_cpy() and
sbuf_cat() to be a const char *.

Add __BEGIN_DECLS and __END_DECLS around
function prototypes since they're now exported
to userland.

kdump/mkioctls: Include stdio.h before cam.h since cam.h now
includes a function with a FILE * argument.

Submitted by: gibbs (mostly)
Reviewed by: jdp, marcel (libsbuf makefile changes)
Reviewed by: des (sbuf changes)
Reviewed by: ken


74810 26-Mar-2001 phk

Send the remains (such as I have located) of "block major numbers" to
the bit-bucket.


74368 16-Mar-2001 ken

Fix inquiry length detection for the ses(4) driver. It was using the
inq_len member of the ccb_getdev structure, but we've never filled that
value in..

So we now get the length from the inquiry data returned by the drive.
(Since we will fetch as much inquiry data as the drive claims to support.)

Reviewed by: mjacob
Reported by: Andrzej Tobola <san@iem.pw.edu.pl>


74222 13-Mar-2001 ken

In xpt_set_transfer_settings(), force async if either the period or the
offset is set to 0.

Re-arrange the DT limiting code so that we don't end up setting the period
to 0xa if the user really wants async. The previous behavior seemed to
confuse the aic(4) driver.

PR: kern/22733
Reviewed by: gibbs


73025 25-Feb-2001 non

o Support AUTO SENSE correctly.
o Offset and period in synch messages and width negotiation should be
done for per target not per lun. Move these from *lun_info to
*targ_info.
o Change in handling XPT_RESET_DEV and XPT_GET_TRAN_SETTINGS .
o Change CAM_* xpt_done return values.
o Busy loop did not timeout. Change this to timeout as original NetBSD/pc98.

Reviewed by: bsd-nomads ML


72992 24-Feb-2001 gibbs

In the SCSI_NO_SENSE_STRINGS case, properly fill the table with the
asc and ascq pair rather than asc, asc.

PR: 25291
Submitted by: Stephen Ferrari <sferrari@yahoo.com>


72850 22-Feb-2001 mjacob

Restore a print_sense=FALSE that got nuked by accident in last delta.
Noticed by: Dan Nelson <dnelson@emsphone.com>


72804 21-Feb-2001 mjacob

Use the correct device names (now that we have devfs to embarrass us).
PR: 25254


72375 11-Feb-2001 mjacob

1. The key SSD_KEY_RECOVERED_ERROR is not an error at all and should
not be retried. It is an indication that there was an error that was
corrected during the execution of the command. This is per ANSI SCSI2
spec.

It's possible that these should also be noted to the console (as indicative,
perhaps, of growing media defect lists in drives), but the default of
printing errors out if bootverbose in this case is probably enough.

Also, there'd been a missing ERESTART for that clause anyway.

2. If you have an ABORTED COMMAND, it's almost invariably a SCSI parity
error. You should never be silent about these since users should do something
about this if it occurs (moving that power cord *away* from the SCSI cable is
always a good first start). This should print irrespective of bootverbose
because it's an actual real error even if we retry a transmission.

Reviewed by: audit@freebsd.org, gibbs@freebsd.org


72238 09-Feb-2001 jhb

- Catch up to the new swi API changes:
- Use swi_* function names.
- Use void * to hold cookies to handlers instead of struct intrhand *.
- In sio.c, use 'driver_name' instead of "sio" as the name of the driver
lock to minimize diffs with cy(4).


72119 07-Feb-2001 peter

Change the peripheral driver list from a linker set to module driven
driver registration. This should allow things like da, sa, cd etc to be
in seperate KLD's to the cam core and make them preloadable.


72012 04-Feb-2001 phk

Another round of the <sys/queue.h> FOREACH transmogriffer.

Created with: sed(1)
Reviewed by: md5(1)


71999 04-Feb-2001 phk

Mechanical change to use <sys/queue.h> macro API instead of
fondling implementation details.

Created with: sed(1)
Reviewed by: md5(1)


71772 29-Jan-2001 ken

Back out rev 1.102. The IBM DNES drives work fine for me, jedgar and other
folks.

My guess is that reducing the number of tags is just masking the real
problem for the PR submitter. I'll re-open the PR and see if I can work
with the submitter to diagnose the problem.

PR: 21139


71752 28-Jan-2001 ken

Fix region code reporting.

Reported by: Andrew Gordon <arg@arg1.demon.co.uk>


71508 24-Jan-2001 jhb

#ifdef a local variable only used in debugging code.

Reviewed by: -scsi


71507 24-Jan-2001 jhb

Const'ify cam_sim.sim_name to quiet warnings.

Reviewed by: -scsi


71493 24-Jan-2001 mjacob

"Rejected with status" is better than "Rejected for status".


71421 23-Jan-2001 joerg

Mark the (ancient) MaxOptix Tahiti 1 drive as a known rogue that would
respond to all LUNs.

Reviewed by: ken


71268 19-Jan-2001 mjacob

Make some attempt to accomodate kern/24221- propate residual to mt_resid
even if it might overflow.

If we do a read or set of hardware or logical block position, we also
clear Tape Frozen status.


71117 16-Jan-2001 mjacob

Add tags quirk for IBM DNES drives.

PR: 21139
Obtained from: campt@miralink.com


71087 16-Jan-2001 mjacob

Use the residual from a spacing operation to try and figure out where
we *really* are.

It should be noted that there is a degenerate case where soft tape
location will be lost (not causing a frozen state- but causing
the loss of reporting fileno/blockno)- that's where you backspace
over a filemark- you stop backspacing as soon as you cross the
filemark, but you have no idea what the record number now is because
you have no idea how many records you are into the file you just
backed into. Such is life.

While I'm at it, also pick up residuals from writing filemarks.

PR: 24222


71086 16-Jan-2001 mjacob

Get rid of those pesky "driver mistake" messages... destroy the create_d dev_t
when you take down the device.

Reviewed by: audit@freebsd.org (Warner, Justin)


71082 15-Jan-2001 mjacob

Fix PR 24220 by using the periph private field0 for a CCB for not
only CCB type but also extra flags- one of which can be "position
updated".

In other changes: Add in a SA_QUIRK_NO_CPAGE quirk so that it's possible
to avoid using a (broken) device's implementation of he DEVICE COMPRESSION
page.

Also do a couple of printout cleanups.

As per some discussion on FreeBSD-scsi, skip doing tape flushing
if we're reading tape logical block location (MTIOCRDSPOS).


70992 13-Jan-2001 nyan

Check __i386__, not i386.


70946 12-Jan-2001 steve

Spell declarations correctly.


70832 09-Jan-2001 wollman

select() DKI is defined in <sys/selinfo.h> now.


70780 08-Jan-2001 n_hibma

Add the 'No 6 byte commands' quirk for the Yano ATAPI USB bridge.

Submitted by: Iwasa Kazmi <kzmi@ca2.so-net.ne.jp>


70032 14-Dec-2000 imp

Generalize quirk for Sony Memory Sticks. Any device that starts with
MS will be treated as having this quirk. In the event that we falsely
identify one that doesn't need it, no harm will be done. Ken
suggested that we make this more generic since there may be more
needed in the future.

Reported by: TERAMOTO Masahiro <teramoto@comm.eng.osaka-u.ac.jp>
PR: kern/23378
Reviewed by: ken


69979 13-Dec-2000 non

Move `#include <sys/devicestat.h>' into #ifdef/#endif to keep
comaptibility with NetBSD/pc98.


69729 07-Dec-2000 phk

Add needed include of <sys/devicestat.h>


69577 04-Dec-2000 joerg

Turn off the load_eject bit in cdstartunit(). It causes an `Invalid
field in CDB' error when attempting to start a caddy-type CD drive,
since those drives apparently in general refuse to load a medium. Since
we never advertised the feature to load the medium upon calling
cdstartunit() (i. e. upon receipt of a CDIOCSTART ioctl command), nobody
should have relied on it. Besides, nobody noticed so far at all that
this command is failing for caddy-type drives... Only few applications
seem to use it at all (among them is workman, which made me notice it).

Reviewed by: ken


68500 08-Nov-2000 mjacob

Add special quirk for this ancient Viper drive. This is all creeping
driver bloat -I really *have* to do a quirk table that can be loaded
by the loader.

Submitted by: Hellmuth Michaelis <hm@kts.org>


68403 06-Nov-2000 gibbs

Fix async notifications for listners registered to wildcard nodes. For
example, a client registered to receive specific events for bus 0, target *,
lun *, was not receiving notifications.

Reviewed by: ken@FreeBSD.org


68294 04-Nov-2000 ken

Fix a problem with the previous revision (1.42) that showed up with audio
CDs.

With audio CDs, you can't just do a READ(10) call on most drives without
first setting the blocksize with a mode select command. The disklabel code
does a read of the first sector of the media to find a label if it exists.

This caused drives to return an error when an audio CD was in the drive,
due to the problem described above.

The solution is to read the table of contents on the CD, and only attempt
to read the disklabel if the first track is a data track.

This works on all the various CD and DVD media I have tried, but further
testing (especially with Video CDs and other mode 2 media) will be
needed to determine if this is a universal solution.


68116 31-Oct-2000 mjacob

1. Oops on last commit: note a few SCSI-3 items for data compression page.
2. Change copyright to me- per practive of scsi_sa.c that Justin had
me do a while back.


68114 31-Oct-2000 mjacob

scsi_sa.h


68108 31-Oct-2000 gibbs

Treat engine inquiry the same as path inquiry in xptioctl().
Return ENOTSUP for any opcode that is not supported by the XPT
device.

Add back a missing local declaration that seems to have been deleted
by my last commit.


68085 31-Oct-2000 gibbs

0x03F -> 0x3F for consistancy with the rest of the file.


68084 31-Oct-2000 gibbs

Allow async transfer negotiation updates to modify tagging behavior.
The XPT uses this to prevent tags from being used on parallel SCSI
interfaces immediately after a bus reset or BDR so that controllers
have an oportunity to renegotiate without tag messages in the way.
Somehow this got disabled... the functionality has been here for
quite some time.

Noticed by: my SCSI bus analyzer


68009 30-Oct-2000 scottl

Allow XPT_PATH_INQ to be performed on the XPT device, as per the CAM spec.
Return ENOTSUP for XPT_ENG_INQ and XPT_ENG_EXEC when performed on the XPT
device.

Reviewed by: gibbs


67964 30-Oct-2000 non

Remove unused #includes.

Submitted by: phk@FreeBSD.ORG


67932 30-Oct-2000 phk

Remove unused #includes

Reviewed by: ken


67928 30-Oct-2000 ken

Write support for the cd(4) driver.

This allows writing to DVD-RAM, PD and similar drives that probe as CD
devices. Note that these are randomly writeable devices, not
sequential-only devices like CD-R drives, which are supported by cdrecord.

Add a new flag value for dsopen(), DSO_COMPATLABEL. The cd(4) driver now
uses this flag instead of the DSO_NOLABELS flag. The DSO_NOLABELS always
used a "fake" disklabel for the entire disk, provided by the caller.

With the DSO_COMPATLABEL flag, dsopen() will first search the media for a
label, and if it finds a label, it will use that label. Otherwise it will
use the fake disklabel provided by the caller. This provides backwards
compatibility, since we will still have labels for ISO9660 media.

It also provides new functionality, since you can now have a regular BSD
disklabel on read-only media, or on writeable media (e.g. DVD-RAM).

Bruce and I both think that we should eventually (in a few years) get
away from using disklabels for ISO9660 media, and just use the whole disk
device (/dev/cd0). At that point disklabel handling in the cd(4) driver
could follow the "normal" model, as used in the da(4) driver.

Also, clean up the path in a couple of places in cdregister(). (Thanks to
Nick Hibma for catching that bug.)

Reviewed by: bde


67888 29-Oct-2000 dwmalone

Add the use of M_ZERO to some malloc calls.

Submitted by: josh@zipperup.org
Submitted by: Robert Drehmel <robd@gmx.net>
Approved by: gibbs


67882 29-Oct-2000 phk

Remove unneeded #include <sys/proc.h> lines.


67847 29-Oct-2000 non

Changed not to use struct isa_device in the argument of scsi_low_activate().
You will not need COMPAT_OLDISA in config file.
This interface may have to change in future.


67752 28-Oct-2000 ken

Add a quirk entry for Nakamichi MJ-* changers. The changer in question is
a <NAKAMICH MJ-5.16S 1.06>.

Submitted by: Kevin Van Maren <vanmaren@fast.cs.utah.edu>


67723 27-Oct-2000 mjacob

Add usage of M_ZERO to malloc calls where the result was just bzeroed.

PR: 22186
Submitted (partially) by: josh@zipperup.org


67708 27-Oct-2000 phk

Convert all users of fldoff() to offsetof(). fldoff() is bad
because it only takes a struct tag which makes it impossible to
use unions, typedefs etc.

Define __offsetof() in <machine/ansi.h>

Define offsetof() in terms of __offsetof() in <stddef.h> and <sys/types.h>

Remove myriad of local offsetof() definitions.

Remove includes of <stddef.h> in kernel code.

NB: Kernelcode should *never* include from /usr/include !

Make <sys/queue.h> include <machine/ansi.h> to avoid polluting the API.

Deprecate <struct.h> with a warning. The warning turns into an error on
01-12-2000 and the file gets removed entirely on 01-01-2001.

Paritials reviews by: various.
Significant brucifications by: bde


67551 25-Oct-2000 jhb

- Overhaul the software interrupt code to use interrupt threads for each
type of software interrupt. Roughly, what used to be a bit in spending
now maps to a swi thread. Each thread can have multiple handlers, just
like a hardware interrupt thread.
- Instead of using a bitmask of pending interrupts, we schedule the specific
software interrupt thread to run, so spending, NSWI, and the shandlers
array are no longer needed. We can now have an arbitrary number of
software interrupt threads. When you register a software interrupt
thread via sinthand_add(), you get back a struct intrhand that you pass
to sched_swi() when you wish to schedule your swi thread to run.
- Convert the name of 'struct intrec' to 'struct intrhand' as it is a bit
more intuitive. Also, prefix all the members of struct intrhand with
'ih_'.
- Make swi_net() a MI function since there is now no point in it being
MD.

Submitted by: cp


67468 23-Oct-2000 non

Add PC-Card/ISA SCSI host adpater drivers from NetBSD/pc98
(a NetBSD port for NEC PC-98x1 machines). They are ncv for NCR 53C500,
nsp for Workbit Ninja SCSI-3, and stg for TMC 18C30 and 18C50.

I thank NetBSD/pc98 and bsd-nomads people.

Obtained from: NetBSD/pc98


67345 20-Oct-2000 n_hibma

Add the quirk entry for the Sony Memory Stick Adapter.

Add NO_SYNQ_CACHE to the Sony DSC camera entry.


67320 19-Oct-2000 jhb

Quiet a silly warning.

Pointy-hat to: ps


67247 17-Oct-2000 ps

Implement write combining for crashdumps. This is useful when
write caching is disabled on both SCSI and IDE disks where large
memory dumps could take up to an hour to complete.

Taking an i386 scsi based system with 512MB of ram and timing (in
seconds) how long it took to complete a dump, the following results
were obtained:

Before: After:
WCE TIME WCE TIME
------------------ ------------------
1 141.820972 1 15.600111
0 797.265072 0 65.480465

Obtained from: Yahoo!
Reviewed by: peter


67164 15-Oct-2000 phk

Remove unneeded #include <machine/clock.h>


67159 15-Oct-2000 peter

Slight cleanup - this is logically equivalent code but means one less
use of the evil resource_locate() function.


66927 10-Oct-2000 n_hibma

Add a quirk entry for the USB Sony DSC drive.


66698 05-Oct-2000 jhb

- Heavyweight interrupt threads on the alpha for device I/O interrupts.
- Make softinterrupts (SWI's) almost completely MI, and divorce them
completely from the x86 hardware interrupt code.
- The ihandlers array is now gone. Instead, there is a MI shandlers array
that just contains SWI handlers.
- Most of the former machine/ipl.h files have moved to a new sys/ipl.h.
- Stub out all the spl*() functions on all architectures.

Submitted by: dfr


66678 05-Oct-2000 mjacob

Grab the ccb *after* writing filemarks.

PR: 21723
Submitted by: razuwaev@relex.ru


66677 05-Oct-2000 mjacob

Don't do destroy_dev on devices which were just aliases.


66266 22-Sep-2000 gibbs

Remove duplicate FreeBSD RCSID.


66172 21-Sep-2000 mjacob

Remove unneeded include
(from phk@freebsd.org)


65861 14-Sep-2000 mjacob

With the help of 'Eric Christeson <echriste@ssesco.com>', determined
that QIC 525 really should be 512 byte fixed blocksize.


65838 14-Sep-2000 mjacob

Follow the hints from PHK's new messages- only make_dev for a device
once. Alias names use the make_dev_alias function.


65822 13-Sep-2000 jhb

- Remove the inthand2_t type and use the equivalent driver_intr_t type from
newbus for referencing device interrupt handlers.
- Move the 'struct intrec' type which describes interrupt sources into
sys/interrupt.h instead of making it just be a x86 structure.
- Don't create 'ithd' and 'intrec' typedefs, instead, just use 'struct ithd'
and 'struct intrec'
- Move the code to translate new-bus interrupt flags into an interrupt thread
priority out of the x86 nexus code and into a MI ithread_priority()
function in sys/kern/kern_intr.c.
- Remove now-uneeded x86-specific headers from sys/dev/ata/ata-all.c and
sys/pci/pci_compat.c.


65225 29-Aug-2000 ken

Change the "Duplicate Wired Device entry" printout in camperiphnextunit to
also mention the peripheral name, bus, target and lun of the device we
attempted to put in that slot. This gives the user a little more
information about what is going on.

Tested by: Andre Albsmeier <andre.albsmeier@mchp.siemens.de>
Discussed with: gibbs


65224 29-Aug-2000 ken

Add quirk entries from Andre Albsmeier to disable the sync cache command
for the Quantum "MAVERICK 540S" and "LPS525S".

Also, add common string variables, since we seem to have a few Quantum and
Micropolis drives in here.

Fix the 'quantum' variable usage in scsi_all.c that likely got broken when
someone staticized things in cam_xpt.c. (That particular problem would
cause Quantum Fireball ST drives to not get spun up if they were not
already spinning.)

Submitted by: Andre Albsmeier <andre.albsmeier@mchp.siemens.de>


65061 24-Aug-2000 peter

Quick fix. <sys/conf.h> now depends on <sys/time.h>, which is not present
when libcam is building this in userland.


64621 13-Aug-2000 n_hibma

CAM, the module: scbus, da, cd, and st wrapped in one module.

Make the umass driver depend on this module.

Makes it possible to compile the kernel without SCSI support and load it
when for example a USB floppy is conencted.


64419 08-Aug-2000 mjacob

Don't attempt to actually read SAF-TE temperature objects- nobody seems
to be obeying the original spec as to what the numeric value means.

Temperature flags are unaffected- these are still the 'pseudo-thermometers'
and overtemp/undertemp warnings will be caught and translated to SES objects
here.

PR: 20475


64383 08-Aug-2000 ken

The Yamaha CDR100 doesn't seem to like multi-LUN probing.

PR: kern/20347
Submitted by: Andre Albsmeier <andre.albsmeier@mchp.siemens.de>


64382 08-Aug-2000 kbyanc

This is an overhaul of the mode page handling in camcontrol as well as
related patches. These include:
* Mode page editting can be scripted. This involves two
things: first, if stdin is not a tty, changes are read from
stdin rather than invoking $EDITOR. Second, and more
importantly, not all modepage entries must be included in the
change set. This means that camcontrol can now gracefully handle
more intrusive editting from the $EDITOR, including removal or
rearrangement of lines. It also means that you can do stuff
like:
# echo "WCE: 1" | camcontrol modepage da3 -m 8 -e
# newfs /dev/da3
# echo "WCE: 0" | camcontrol modepage da3 -m 8 -e
* Range-checking on user-supplied input values. modeedit.c now
uses the field width specifiers to determine the maximum
allowable value for a field. If the user enters a value larger
than the maximum, it clips the value to the max and warns the
user. This also involved patching cam_cmdparse.c to be more
consistent with regards to the "count" parameter to arg_put
(previously is was the length of strings and 1 for all integral
types). The cam_cdbparse(3) man page was also updated to reflect
the revised semantics.
* In the process, I removed the 64 entry limit on mode pages (not
that we were even close to hitting that limit). This was a nice
side-effect of the other changes.
* Technically, the new mode editting functionality allows editting
of character array entries in mode pages (type 'c' or 'z'),
however since buff_encode doesn't grok them it is currently
useless.
* Camcontrol gained two new options related to mode pages: -l and
-b. The former lists all available mode pages for a given
device. The latter forces mode page display in binary format
(the default when no mode page definition was found in
scsi_modes).
* Added support for mode page names to scsi_modes. Allows names to
be displayed alongside mode numbers in the mode page
listing. Updated scsi_modes to use the new functionality. This
also adds the semicolon into the scsi_modes syntax as an
optional mode page definition terminator. This is needed to name
pages without providing a page format definition.
* Updated scsi_all.h to include a structure describing mode page
headers.
* Added $FreeBSD$ line to scsi_modes.

Inspired by: dwhite
Reviewed by: ken


64058 31-Jul-2000 n_hibma

Support for the Panasonic / Matshita USB FDD.

Submitted by: SAKIYAMA Nobuo <sakichan@lares.dti.ne.jp>
PR: kern/20300


63456 18-Jul-2000 gibbs

scsi_all.c:
Clean up the comments related to the high speed
sync rate table for SPI.

scsi_message.h:
Bring in some SCSI3 message terminology. All SCSI2 names
are still preserved for backwards compatibility.


63455 18-Jul-2000 gibbs

cam_ccb.h:
Bring back the CAM_NEGOTIATE ccb flag. This flag indicates
that SPI transfer negotiation should occur concurrently with the
execution of this CCB. The flag is not yet used by the XPT but
is required for proper support of multi-initiator configurations
where topology scans cannot rely on a bus reset to invalidate
prior negotiations.

cam_xpt.c:
Don't allow DT transmission rates to be specified for devices
that don't have the DT feature listed in their inquiry data.


63289 17-Jul-2000 mjacob

Preserve CAM_DIS_DISCONNECT as passed up from SIM (like
CAM_TAG_ACTION_VALID and CAM_DIR_MASK). Remove redundant
CAM_DEBUG line. Spiff up CAM_DEBUG printout for commands
and move the printout up to the top where we can see it,
even for the pending_ua/pending_ca cass. Add missing
newline in a CAM_DEBUG.


63287 17-Jul-2000 mjacob

Whoops- forgot to commit this other pearl from Justin- only set or
clear CAM_TAG_ACTION_VALID if this is an XPT_SCSI_IO CCB (otherwise,
the peripheral driver knows best...)..
Obtained from:gibbs@freebsd.org


63190 14-Jul-2000 mjacob

Don't, when doing cam_fill_ctio, add a SIMPLE Q tag unless
TAG_ACTION_VALID is set.


63174 14-Jul-2000 mjacob

Pick up some changes from Justin (add tagged queing support, remember
to splx(s) if cam_extend_get fails and we return ENXIO, reset ccb flags
when we push ATIOs back to the SIM, do some data increment fixes, set
priority of command based on whether CAM_DIS_DISCONNECT is set and related
changes).

Add in some more CAM_DEBUG_PERIPH debug statements and also add in support
for TARGIODEBUG which then will enable or disable CAM_DEBUG_PERIPH tracing
for an instance.


63173 14-Jul-2000 mjacob

Add a TARGIODEBUG ioctl to allow for CAM_DEBUG_PERIPH tracing on
an opened target instance.


63172 14-Jul-2000 mjacob

Properly initialize softc. Do some minor SCSI_CDB6_LEN changes.
Obtained from:gibbs@freebsd.org


63171 14-Jul-2000 mjacob

Add SCSI_CDB6_LEN macro (where 0 ==> 256).
Obtained from:gibbs@freebsd.org


63065 13-Jul-2000 dg

Quirk entry for TeraSolutions TRC-22 RAID controller to keep mintags
from dropping below 55 due to temporary resource shortages.


62828 08-Jul-2000 mjacob

Use %p to print a pointer.


61763 18-Jun-2000 mjacob

Fix breakage where we never were attaching SES devices because inq_len
was not being set > 0.


61234 04-Jun-2000 ken

Disable multi-lun probing on Hitachi DK31* drives.

PR: misc/18793
Submitted by: Paul Haddad <paul@pth.com>


61074 29-May-2000 dfr

Brucify the pmap_enter_temporary() changes.


61036 28-May-2000 dfr

Add a new pmap entry point, pmap_enter_temporary() to be used during
dumps to create temporary page mappings. This replaces the use of CADDR1
which is fairly x86 specific.

Reviewed by: dillon


60938 26-May-2000 jake

Back out the previous change to the queue(3) interface.
It was not discussed and should probably not happen.

Requested by: msmith and others


60833 23-May-2000 jake

Change the way that the queue(3) structures are declared; don't assume that
the type argument to *_HEAD and *_ENTRY is a struct.

Suggested by: phk
Reviewed by: phk
Approved by: mdodd


60806 22-May-2000 joerg

Apply a `fixup' to the blocksize gathered from the device after a READ
CAPACITY operation. SCSI-3 mandates this to be 2048, but some older
drives like my old Plasmon CD-R report weird numbers between 2048 and
up to 2352 bytes depending on the mode of the last track etc. This in
turn confuses stuff like the slice code since it refuses to work with
devices that do not have a blocksize which is a multiple of 512 bytes.

Reviewed by: ken


60767 21-May-2000 ken

Implement a new camcontrol function, 'camcontrol format'.

libcam/Makefile: Add scsi_da.c to libcam for the new
scsi_format_unit() function.

camcontrol.8: Update the man page for the new format
functionality, and take out the examples section
describing how to do it with 'camcontrol cmd'.

camcontrol.c: New format functionality. Note that unlike the
rest of the camcontrol subcommands, this one is
interactive by default. Because of the potential
destructiveness of the format command, I thought
it necessary to get confirmation from the user
before spamming a disk. You can disable the
interactive behavior, and the status meter with
command line arguments.

scsi_da.c: Add the new scsi_format_unit() cdb building
function and use #ifdef _KERNEL to make this file
compile in both the kernel and userland. The
format unit function is currently only defined in
the non-kernel case, because nothing in the kernel
is using it. If that changes, it should be
un-ifdefed and compiled in both cases.

scsi_da.h: New function declaration, CDB structure and format
data structures.

Thanks to Nick Hibma for providing some valuable input on these changes.


60755 21-May-2000 peter

Implement an optimization of the VM<->pmap API. Pass vm_page_t's directly
to various pmap_*() functions instead of looking up the physical address
and passing that. In many cases, the first thing the pmap code was doing
was going to a lot of trouble to get back the original vm_page_t, or
it's shadow pv_table entry.

Inspired by: John Dyson's 1998 patches.

Also:
Eliminate pv_table as a seperate thing and build it into a machine
dependent part of vm_page_t. This eliminates having a seperate set of
structions that shadow each other in a 1:1 fashion that we often went to
a lot of trouble to translate from one to the other. (see above)
This happens to save 4 bytes of physical memory for each page in the
system. (8 bytes on the Alpha).

Eliminate the use of the phys_avail[] array to determine if a page is
managed (ie: it has pv_entries etc). Store this information in a flag.
Things like device_pager set it because they create vm_page_t's on the
fly that do not have pv_entries. This makes it easier to "unmanage" a
page of physical memory (this will be taken advantage of in subsequent
commits).

Add a function to add a new page to the freelist. This could be used
for reclaiming the previously wasted pages left over from preloaded
loader(8) files.

Reviewed by: dillon


60422 12-May-2000 ken

Add support for the DVD ioctl interface.


60235 09-May-2000 mjacob

Some prettifying for the quirk comments.

Add a SA_QUIRK_NO_MODESEL type and use it for the OnStream real SCSI
device (not the broken one). This one is still broken in that it can't
be set to the same fixed block size it reports [ unflattering comments
about this company elided ].

If we're unable to set buffered mode on, complain, but drive on. It's
not a fatal error to not be in buffered mode.


60168 07-May-2000 n_hibma

*sigh* I must have been on something that night. Make xpt_periph an
extern with the original in cam_xpt.c instead of replicating
xpt_periph in all the sources using it (and hence not initialising it)


60041 05-May-2000 phk

Separate the struct bio related stuff out of <sys/buf.h> into
<sys/bio.h>.

<sys/bio.h> is now a prerequisite for <sys/buf.h> but it shall
not be made a nested include according to bdes teachings on the
subject of nested includes.

Diskdrivers and similar stuff below specfs::strategy() should no
longer need to include <sys/buf.> unless they need caching of data.

Still a few bogus uses of struct buf to track down.

Repocopy by: peter


59883 02-May-2000 mjacob

Add in include of <machine/clock.h> which defines DELAY.


59874 01-May-2000 peter

Add $FreeBSD$


59760 29-Apr-2000 phk

Remove unneeded #include <sys/kernel.h>


59368 18-Apr-2000 phk

Remove unneeded <sys/buf.h> includes.

Due to some interesting cpp tricks in lockmgr, the LINT kernel shrinks
by 924 bytes.


59365 18-Apr-2000 phk

Don't include <sys/buf.h> twice.


59275 16-Apr-2000 phk

Overlooked a s/b_act/bio_queue/ substitution due to targ not being in LINT.

Spotted by: mjacob


59249 15-Apr-2000 phk

Complete the bio/buf divorce for all code below devfs::strategy

Exceptions:
Vinum untouched. This means that it cannot be compiled.
Greg Lehey is on the case.

CCD not converted yet, casts to struct buf (still safe)

atapi-cd casts to struct buf to examine B_PHYS


58972 03-Apr-2000 n_hibma

Add a hack to cam that makes the cam_xpt available to the rest of the
kernel. Justin agress that there is no other reasonable alternative to
do automatic rescans on connect.

The problem is that when a new device attaches to a SIM (SCSI host
controller) we need to send a XPT_SCAN_BUS command to the SIM using
xpt_action. This requires however that there is a peripheral available
to take the command (otherwise xpt_done and later bomb). The RESCAN
ioctl uses the same periph.

This enables a USB mass storage drive to do an automatic rescan on
connection of the drive.

The automatic dropping of a CAM entry on disconnection was already
working (asynchronous event).

The next thing to do is find someone to commit a change to vpo to do the
same thing. Just port umass_cam_rescan and friends across to that
driver.

Approved by: gibbs


58934 02-Apr-2000 phk

Move B_ERROR flag to b_ioflags and call it BIO_ERROR.

(Much of this done by script)

Move B_ORDERED flag to b_ioflags and call it BIO_ORDERED.

Move b_pblkno and b_iodone_chain to struct bio while we transition, they
will be obsoleted once bio structs chain/stack.

Add bio_queue field for struct bio aware disksort.

Address a lot of stylistic issues brought up by bde.


58921 02-Apr-2000 ken

Fix two problems in the ch(4) driver.

- Mike Smith discovered a panic in the changer probe code if the probe
command (mode sense) fails. So we need to release the CCB used in the
probe before we unlock the peripheral. (i.e. the same fix mjacob put in
the CD and DA drivers)

- A newline was missing in a warning message. (PR kern/17512)

PR: kern/17512
Submitted by: Louis Mamakos <louie@uu.net> (newline fix)


58345 20-Mar-2000 phk

Remove B_READ, B_WRITE and B_FREEBUF and replace them with a new
field in struct buf: b_iocmd. The b_iocmd is enforced to have
exactly one bit set.

B_WRITE was bogusly defined as zero giving rise to obvious coding
mistakes.

Also eliminate the redundant struct buf flag B_CALL, it can just
as efficiently be done by comparing b_iodone to NULL.

Should you get a panic or drop into the debugger, complaining about
"b_iocmd", don't continue. It is likely to write on your disk
where it should have been reading.

This change is a step in the direction towards a stackable BIO capability.

A lot of this patch were machine generated (Thanks to style(9) compliance!)

Vinum users: Greg has not had time to test this yet, be careful.


58252 18-Mar-2000 gibbs

o clear the ccb_flags field before sending an accept target I/O ccb to
an HBA. Garbage in this field confuses the driver in targdone().

o When completing a CCB on behalf of a user process, we need to
*de-queue* the ccb from our pending ccb list, not queue it again.

o All continue target I/O operations need to have a timeout set.
We use 5 seconds throughout this driver.

o Remove some logging printfs.

o During abort processing, remove ccbs that are on the pending queue
from the pending queue, not the work queue.


58251 18-Mar-2000 mjacob

Per Justin's request- remove his name from Copyright.


58123 15-Mar-2000 n_hibma

Add a quirk entry for Y-E Data USB floppy drive.
Driver follows in the next few days.


58111 15-Mar-2000 n_hibma

Various typo's.

One minor nit. The speed was displayed wrong when below 1Mb/s.


57581 29-Feb-2000 mjacob

Some minor fixing - final for 4.0. Debugging messages toned down a bit.
Approved: jkh


57349 20-Feb-2000 ken

Fix 'camcontrol inquiry'. The inquiry data structure changes (increased to
256 bytes) caused it to break on many devices.

The SCSI spec says that for commands with 8-bit length fields, a value of 0
means 256 bytes. As it turns out, many devices don't deal with that
properly. Some interpret the 0 as 0, and return no data. Others return
more than 256 bytes of data, and cause an overrun.

The fix is to tell the device we've only allocated SHORT_INQUIRY_LENGTH (36
bytes) of inquiry data, instead of sizeof(struct scsi_inquiry_data).

camcontrol.c: Change inq_len in the call to scsi_inquiry() to
SHORT_INQUIRY_LENGTH, and add a long comment
explaining the reason for the change.

scsi_all.h: Add a comment above the definitinon of
SHORT_INQUIRY_LENGTH alerting people that it is
both the initial probe inquiry length, and the
minimum amount of data needed for scsi_print_inquiry()
to function.

scsi_all.c: Add a comment about SHORT_INQUIRY_LENGTH being the
minimum amount of data needed for
scsi_print_inquiry() to function.

Reviewed by: gibbs
Approved by: jkh
Reported by: "John W. DeBoskey" <jwd@unx.sas.com>


56981 03-Feb-2000 mjacob

Add a quirk type (and one for ARCHIVE Python's) that disables the
dummy read at sa_mount that attempts to latch up density. This breaks
on at least one drive and sends it into the weeds.

Approved: jkh


56614 25-Jan-2000 mjacob

Because we added 4 bytes to the inquiry data size, we need to
rev the CAM revision too. Tsk.
Submitted by: ken@freebsd.org


56601 25-Jan-2000 mjacob

Redo the SHORT INQUIRY length stuff to be a bit cleaner.
Obtained from:gibbs@freebsd.org


56596 25-Jan-2000 ken

When autosense fails, make sure we retry the command.

PR: kern/15975
Submitted by: Carl Mascott <cmascott@world.std.com>, n_hibma


56595 25-Jan-2000 mjacob

Propagate sense data through from SIM (if there) and mark the CTIO
that there's sense to send with status (if the SIM does it), and
then clear any pending contingent allegiance state for this initiator
if the SIM actually did send the sense data.

Widen MAX_INITITATORS to 256- that's still not quite right, but will
accomodate the widest Fibre Channel support in FreeBSD now.

Obtained from:(partially) gibbs@freebsd.org


56594 25-Jan-2000 mjacob

Propagate sense data through from SIM (if there) and mark the CTIO
that there's sense to send with status (if the SIM does it).
Reviewed by: gibbs@freebsd.org


56593 25-Jan-2000 mjacob

Go for the gusto and do the full 256 bytes for inquiry data.
Obtained from:gibbs@freebsd.org


56470 23-Jan-2000 peter

A minimal update to the device wiring code so that it looks at the
dynamic resource tables rather than relying on a duplicated cam-specific
table generated by config(8) in ioconf.c. This was a major holdup to
getting loader / userconfig driven configuration of scsi wiring.


56382 21-Jan-2000 mjacob

Clean up some of the SAF-TE matching code. Add
a few missing newlines in printouts.


56148 17-Jan-2000 mjacob

Do the minor changes needed because of change to ccb_getdev structure.
JKH Trading Stamps applied.

Reviewed by: gibbs@freebsd.org, ken@freebsd.org


56147 17-Jan-2000 mjacob

Increase size of the scsi_inquiry_data structure to it's nearly
full size. Define a SHORT_INQUIRY_LENGTH for use during initial
probing (covers the size used previously). Define some SPC-2 related
fields (and define the revision code for SPC-2) which includes some
further SPI-3 defines. Don't go all the way (256 bytes) for the structure-
stop 4 bytes short- because we haven't auditted the source base to find
any u_int8_t potential overflow issues. Add RBC (single byte device)
and OCR (Optical Character Reader) device type codes.

Approved by JKH.

Reviewed by: gibbs@freebsd.org, ken@freebsd.org


56146 17-Jan-2000 mjacob

Remove garbage collected tags from their usage in the ccb_getdev
structure. Remove usage of the (now gone) pd_type tag of same.

Add an extra probing state such that if we successfully run an
initial inquiry (36 bytes), rerun another one with a longer data
size as informed by the 'additional length' field in the first
returned inquiry data (making sure not to get bigger than the
actual scsi_inquiry_data structure- which has also been modified-
see separate checkin of scsi_all.h). This allows devices such
as SAF-TE devices (which have identifying marks in offsets 48-53
in inquiry data) to be successfully found without special case
inquiry commands. There are also a lot of other things such as
version codes that are coming in in the SPC2 specification that it
would be useful to get our hands on.

Reviewed by: gibbs@freebsd.org, ken@freebsd.org


56145 17-Jan-2000 mjacob

Shift bits for CAM flags so that the top bit isn't set in an enum
(at request of Ken Merry). Garbage collect items out of the ccb_getdev
structure and and a length field so that consumes will know how much
of the inq_data tag is valid. Clean up a few misspellings. Add
a CAM_SEND_STATUS target mode flag.

All of this necessitated a CAM_VERSION bump.

JHK approved.

Reviewed by: gibbs@freebsd.org, ken@freebsd.org


56143 17-Jan-2000 mjacob

Add a CAM_SENT_STATUS for use in target mode. JHK approved.
Reviewed by: gibbs@freebsd.org, ken@freebsd.org


56136 17-Jan-2000 mjacob

Do not propagate the ENCI_SVALID bit for overall enclosure status
to userland apps- they get confused.


56130 17-Jan-2000 mjacob

Add in SAF-TE handling code and do some minor consistency cleanups.


56073 15-Jan-2000 mjacob

buglet fix


56070 15-Jan-2000 mjacob

Do a wad of cleanup and put into place at least *one* functional
portion of SES retrieval (native SES itself) and implement all
the appropriate ioctls. Seems to work...


56069 15-Jan-2000 mjacob

Move the kernel specific stuff into scsi_ses.c. Redo the ioctls
to be more platform independent. Add a ses_hlptxt structure definition
and retrieval ioctl for when we are able to retrieve object help text

SES Objects can have up to 64 KBytes of associated 'help' text- the
Sun A5000 uses this, for example, to give physical location information
(e.g., 'left power supply').


56053 15-Jan-2000 mjacob

add SEND/RECEIVE diagnostic opcodes, SEND is a Mandatory command


56031 15-Jan-2000 mjacob

Remove inclusion of dkbad.h- seems like a bug, but I had a stale
dkbad.h in /usr/include/sys- the local build process shouldn't have
been happy with that, but not finding dkbad.h in ../../sys. Hmm.


56027 15-Jan-2000 mjacob

add functional but stub SES/SAF-TE driver


55995 14-Jan-2000 gibbs

Clean up the xpt_sim creation to mirror how HBA drivers perform this task.

Clean up node creation in the EDT so that initialization follows member
declaration.

Sort registered paths by pathid so that we probe busses in order of
ascending pathid. This makes hardwiring of busses without wiring
individual targets do what the user expects. (submitted by tegge@FreeBSD.org)

Fix an EDT node leak. Target nodes would never go away.

Implement xpt_bus_deregister().
(prodded by some patches from T. Ichinoseki, but implemented differently.)


55328 03-Jan-2000 mjacob

Widen width of tag && initiator ids to u_int
(from u_int8_t) in ccb_accept_tio structure. This
matches usage elsewhere and also allows me to
overload the tag id with the RX_ID for fibre
channel target mode.
Reviewed by: gibbs@freebsd.org


55251 30-Dec-1999 mjacob

Change error message make sense and add a missing
periph_release on a failed open so that the periph
dtor for it will get called when we deallocate the
instance from targioctl.


55248 29-Dec-1999 mjacob

Restore this driver to a working state. The control device has
to be created at init time. The unit devices are created at
ctor when new instances are created and bound and destroyed
when that instance is closed. As such, there is just s single
static control dev_t for this driver (the per-unit dev_t's are
still in the softc).

When we have decommissionable periph drivers, a destroy_device
on the control device will have to called.


55206 29-Dec-1999 peter

Change #ifdef KERNEL to #ifdef _KERNEL in the public headers. "KERNEL"
is an application space macro and the applications are supposed to be free
to use it as they please (but cannot). This is consistant with the other
BSD's who made this change quite some time ago. More commits to come.


55205 29-Dec-1999 peter

Change #ifdef KERNEL to #ifdef _KERNEL in the public headers. "KERNEL"
is an application space macro and the applications are supposed to be free
to use it as they please (but cannot). This is consistant with the other
BSD's who made this change quite some time ago. More commits to come.


54896 20-Dec-1999 mjacob

Make sure we don't look at an edt entry that could go away when we try
and figure out whether to probe higher than logical unit 7.
Obtained from:gibbs@freebsd.org


54685 16-Dec-1999 obrien

Add FAST-80 timing to the scsi syncrates table.

Submitted by: Gerard Roudier <groudier@club-internet.fr>


54572 13-Dec-1999 mjacob

minor comment update


54451 11-Dec-1999 ken

Quirk all Pioneer changers as changers up front, instead of waiting for the
second LUN to show up.

mjacob's change (which is correct) in rev 1.21 of cam_periph.c to elminiate
infinite retries of the SCSI busy status bit seems to have broken probing
of Pioneer changers that aren't already quirked.

The right way to fix this is probably to change things around so we can
guarantee 100% sequential probing of LUN-based changers even if they aren't
quirked. This should fix things for now, though.


54279 08-Dec-1999 ken

Revamp the devstat priority system. All disks now have the same priority.
The same goes for CD drivers and tape drivers. In systems with mixed IDE
and SCSI, devices in the same priority class will be sorted in attach
order.

Also, the 'CCD' priority is now the 'ARRAY' priority, and a number of
drivers have been modified to use that priority.

This includes the necessary changes to all drivers, except the ATA drivers.
Soren will modify those separately.

This does not include and does not require any change in the devstat
version number, since no known userland applications use the priority
enumerations.

Reviewed by: msmith, sos, phk, jlemon, mjacob, bde


54246 07-Dec-1999 ken

Recognize the Pioneer CD-ROM DRM-6324X as a changer.

PR: kern/15198
Submitted by: Don Lewis <truckman@FreeBSD.org>


54105 04-Dec-1999 mjacob

Add back in a prefatory TUR when the tape is *not* mounted. This seems
to help with some older tape drives.


54099 03-Dec-1999 mjacob

Correct some botched timeout defines. Allocate only 8KB for the test read
in samount. Make things a lot quieter in samount (and other places). Fix
ridiculous and not so ridiculous bugs in compression related code in both
sagetparams and sasetparams.


53522 21-Nov-1999 mjacob

Don't clear the SA_FLAG_TAPE_LOCKED prior to calling
saprevent when we're doing an OFFLINE ioctl- saprevent
won't unlock the door, which then causes the unload to
fail on some units.

If we've already unloaded the tape, don't try and rewind and
unload in saclose. This is a slightly riskier change because
we're now going to depend on SA_FLAG_TAPE_MOUNTED to say whether
we've really unloaded the tape. This involved changing the
setting in sadone for tape errors to SA_FLAG_TAPE_FROZEN (which
is more accurate anyway-if you get an EIO you've probably lost
tape position anyway) where it used to just clear the mounted
flag.


53520 21-Nov-1999 mjacob

Add make_dev functions. Tested with only one changer (sigh- all my others
are broken).
Submitted by: ken@freebsd.org


53283 17-Nov-1999 mjacob

Fix a couple of boo-boos in the last delta.


53259 17-Nov-1999 mjacob

Fix for 11815 (at mount time do a throwaway read of the front of the
tape to force the drive to do a media access so it knows what media
may be inserted).

Also Ken's make_dev patches- relatively untested.


53258 17-Nov-1999 ken

Get rid of some trailing commas in enumerated types that cause gcc to
complain when some warnings are turned on.

Requested by: Bertrand Petit <elrond@phoe.frmug.org>


53257 17-Nov-1999 ken

Convert the xpt, pass, pt and target drivers to use the new
make_dev()/destroy_dev() interface.


52703 31-Oct-1999 ken

Fix Bus Device Resets from userland, and specifically from camcontrol.

camcontrol was setup to use the old scheme of going through the xpt(4)
device, which never worked properly (and has been disabled for a while).

camcontrol now sends BDRs through the pass(4) device, and XPT_RESET_DEV
CCBs are put on the device queue in the transport layer, as they should be.

Submitted by: luoqi
Reviewed by: ken


52644 30-Oct-1999 phk

Change useracc() and kernacc() to use VM_PROT_{READ|WRITE|EXECUTE} for the
"rw" argument, rather than hijacking B_{READ|WRITE}.

Fix two bugs (physio & cam) resulting by the confusion caused by this.

Submitted by: Tor.Egge@fast.no
Reviewed by: alc, ken (partly)


52635 29-Oct-1999 phk

useracc() the prequel:

Merge the contents (less some trivial bordering the silly comments)
of <vm/vm_prot.h> and <vm/vm_inherit.h> into <vm/vm.h>. This puts
the #defines for the vm_inherit_t and vm_prot_t types next to their
typedefs.

This paves the road for the commit to follow shortly: change
useracc() to use VM_PROT_{READ|WRITE} rather than B_{READ|WRITE}
as argument.


52575 27-Oct-1999 mjacob

Mark path for deallocation only *after* you've successfully allocated it.


52326 16-Oct-1999 mjacob

Put an upper bound on the number of BUSY status retries we'll do (use the
retry count for the ccb). This is probably not quite the right thing, but it
is better than silently hanging on (possibly broken) h/w which is what we
do now.

Reviewed by:Justin/Ken: they weren't entirely happy about it but didn't say no.


52324 16-Oct-1999 mjacob

Protect xpt_run_dev_sendq in xpt_release_devq_device with splsoftcam. This
seems to handle the case of timeouts firing during probe but after a device
has gone away. It really does help.
Obtained from:gibbs@freebsd.org


51957 05-Oct-1999 n_hibma

Removal of sys/device.h

- Move intrhook stuff into kernel.h
- Remove all occurrences of #device <device.h>
- Add kernel.h were necessary (nowhere)
- delete device.h

This file contained the structures for cfdata (old style config) and is no
longer used. It was included by most drivers.

It confuses the remote debugger as the definition of 'struct device' in
device.h is found before the one in bus_private.h.


51875 02-Oct-1999 mjacob

Another 1FM@EOD quirk (from mike@sentex.net for a Seagate STT20000),
and add a config option that allows one to default to 1FM@EOD for tapes
otherwise unquirked or unknown as to which to prefer. Note that tcopy
will be broken for these tapes until tcopy is fixed.


51836 01-Oct-1999 phk

Introduce the disk mini-layer and devstat_end_transaction_buf() in cam/scsi.

Somewhat reviewed by: ken


51744 28-Sep-1999 mjacob

Ooops- forgot to commit this.
PR: 14009
Submitted by: jreynold@primenet.com


51658 25-Sep-1999 phk

Remove five now unused fields from struct cdevsw. They should never
have been there in the first place. A GENERIC kernel shrinks almost 1k.

Add a slightly different safetybelt under nostop for tty drivers.

Add some missing FreeBSD tags


51196 12-Sep-1999 phk

Remove unneeded disk-related includes.


51092 08-Sep-1999 phk

Don't register a block major for tapes.

Reviewed by: mjacob


50511 28-Aug-1999 phk

We don't need to pass the diskname argument all over the diskslice/label
code, we can find the name from any convenient dev_t


50477 28-Aug-1999 peter

$Id$ -> $FreeBSD$


50270 24-Aug-1999 bde

Cast pointers to uintptr_t instead of casting them to u_long. Don't
depend on gcc's feature of casting lvalues. Cosmetic.


50254 23-Aug-1999 phk

Convert DEVFS hooks in (most) drivers to make_dev().

Diskslice/label code not yet handled.

Vinum, i4b, alpha, pc98 not dealt with (left to respective Maintainers)

Add the correct hook for devfs to kern_conf.c

The net result of this excercise is that a lot less files depends on DEVFS,
and devtoname() gets more sensible output in many cases.

A few drivers had minor additional cleanups performed relating to cdevsw
registration.

A few drivers don't register a cdevsw{} anymore, but only use make_dev().


50253 23-Aug-1999 bde

Use devtoname() to print dev_t's instead of casting them to long or u_long
for misprinting in %lx format.


50107 21-Aug-1999 msmith

Implement a new generic mechanism for attaching handler functions to
events, in order to pave the way for removing a number of the ad-hoc
implementations currently in use.

Retire the at_shutdown family of functions and replace them with
new event handler lists.

Rework kern_shutdown.c to take greater advantage of the use of event
handlers.

Reviewed by: green


50073 20-Aug-1999 ken

Fix short timeout problems with the pt(4) driver:

- increase the default timeout from 10 seconds to 60 seconds
- add a new kernel option, SCSI_PT_DEFAULT_TIMEOUT, that lets users specify
the default timeout for the pt driver to use
- add two new ioctls, one to get the timeout for a given pt device, the
other to set the timeout for a given pt device. The idea is that
userland applications using the device can set the timeout to suit their
purposes. The ioctls are defined in a new header file, sys/ptio.h

PR: 10266
Reviewed by: gibbs, joerg


49982 17-Aug-1999 billf

Welcome devtoname(), to most likely be used when printing information
about a dev_t.

printf("%x", dev) now becomes printf("%s", devtoname(dev)) because
printing actual information about the device is much more useful then
printing a pointer to an address that would never help the developer debug.

Submitted by: phk, bde


49936 16-Aug-1999 gibbs

Bump CAM version number.


49929 16-Aug-1999 gibbs

Checkpoint work on handling error conditions.

Handle errors reported through immediate notify ccbs. This includes
bus resets, BDR messages, and abort messages.

Properly setup CA conditions for errors such as uncorectable parity
in data phases, reselection failure, and IDE message received.

Add a mechanism for stalling the queue of transactions to a particular
initiator while a CA is in progress. Since we don't yet support
tagged I/O, this is largely just for show right now.

Properly bzero our softc at init time (oops).

Add more documentation on what all of the queues in our softc do.


49928 16-Aug-1999 gibbs

xpt_release_devq now takes a count.


49927 16-Aug-1999 gibbs

Implement the guts of the XPT_ABORT function code.

Clear residuals for XPT_TARGET_IO/XPT_CONT_TARGET_IO calls just
as we do for XPT_SCSI_IO calls.

Make xpt_release_devq a proper reciprocal of xpt_freeze_devq by
allowing the caller to decrement the count more than once per call.

Change the semantics of xpt_path_cmp to return 1 for a match
with a wildcard from path1 and 2 for a match with wildcards
from path2. This change doesn't affect most callers as they
only check for >=0 (exact match or one containing a wildcard).

When cleaning up a device node, ensure that there are no timeouts
outstanding that reference it.


49926 16-Aug-1999 gibbs

Add another flag for debugging just peripheral drivers. The whole debugging
mechanism should be completely revamped, but this will serve for the time
being.

Take advantage of some new behavior in xpt_path_comp which allows the
caller to determine which path, if any, had wildcards in it that allowed
for a match to succeed. We can now use this to filter out wildcard
nodes in the EDT.

Make the amount of time we pause after writing a debug message
configurable.


49925 16-Aug-1999 gibbs

Add another command characteristic flag for commands that are queued
on physical devices as oposed to just in the XPT. This is used to
mark XPT_SCSI_IO, XPT_RESET_DEV, XPT_ENG_EXEC, XPT_TARGET_IO, and
XPT_CONT_TARGET_IO function codes.

Change tag_id and init_id to be u_int from u_int8_t. Some topologies
supported by CAM support much larger ID and tag ID address spaces
than parallel SCSI.

Kill some unused fields in the IMMED_NOTIFY ccb type.


49897 16-Aug-1999 mjacob

Put in a limit (8) for lun width- do not exceed probing this unless a device
is quirked for allowing it. This will allow SCSI cards to specify their true
correct lun width (32 for Qlogic SCSI, 16 or 65536 for Qlogic Fibre Channel)
without crippling the system because of f/w breakage of a lot of drives.
Reviewed by: gibbs@freebsd.org


49862 16-Aug-1999 gibbs

Fix a long standing bug in the camq teardown code.


49856 15-Aug-1999 mjacob

Move initialization of announce_buf up to make
sure it is initialized in all cases.


49771 14-Aug-1999 phk

Spring cleaning around strategy and disklabels/slices:

Introduce BUF_STRATEGY(struct buf *, int flag) macro, and use it throughout.
please see comment in sys/conf.h about the flag argument.

Remove strategy argument from all the diskslice/label/bad144
implementations, it should be found from the dev_t.

Remove bogus and unused strategy1 routines.

Remove open/close arguments from dssize(). Pick them up from dev_t.

Remove unused and unfinished setgeom support from diskslice/label/bad144 code.


49558 09-Aug-1999 phk

Merge the cons.c and cons.h to the best of my ability. alpha may or
may not compile, I can't test it.


48750 11-Jul-1999 jmg

disable tag queing for the MICROP 4421-07 drive. It's an old 2gig drive.

convert MICROP to a static string


48668 07-Jul-1999 mjacob

Fix my complete botch. I hope. Tested this time


48612 06-Jul-1999 mjacob

suggestions from bde to clean up last checkin slighty


48532 03-Jul-1999 mjacob

Make the change similar to that suggested by Nick Hibma to avoid divide by
zero traps. I actually can't believe that this compiler is *sooooo* stupid
that it did a divide when there was 1024L*1024L instead of a right shift by
20. When we get quad type modifiers in kernel printf we can change to this
too (to avoid overflow on > terabyte disk sizes).


48520 03-Jul-1999 peter

A minor tweak to shut up gcc (on the Alpha) for two (false) warnings.

How it can think that something that is initialized at declaration can
be used while uninitialized is beyond me.


48410 01-Jul-1999 peter

int/long printf format problems on the Alpha.


48225 26-Jun-1999 mckusick

Convert buffer locking from using the B_BUSY and B_WANTED flags to using
lockmgr locks. This commit should be functionally equivalent to the old
semantics. That is, all buffer locking is done with LK_EXCLUSIVE
requests. Changes to take advantage of LK_SHARED and LK_RECURSIVE will
be done in future commits.


48192 24-Jun-1999 mjacob

Quirk Tandberg 4100 like Tandberg 4200.
PR: 11675
Reviewed by: msmith@FreeBSD.ORG
Submitted by: blank@uni-trier.de


48053 20-Jun-1999 mjacob

Quirk NOLUNS cabletron device.
PR: 11677
Submitted by: "Matthew N. Dodd" <winter@jurai.net>


47640 31-May-1999 phk

Simplify cdevsw registration.

The cdevsw_add() function now finds the major number(s) in the
struct cdevsw passed to it. cdevsw_add_generic() is no longer
needed, cdevsw_add() does the same thing.

cdevsw_add() will print an message if the d_maj field looks bogus.

Remove nblkdev and nchrdev variables. Most places they were used
bogusly. Instead check a dev_t for validity by seeing if devsw()
or bdevsw() returns NULL.

Move bdevsw() and devsw() functions to kern/kern_conf.c

Bump __FreeBSD_version to 400006

This commit removes:
72 bogus makedev() calls
26 bogus SYSINIT functions

if_xe.c bogusly accessed cdevsw[], author/maintainer please fix.

I4b and vinum not changed. Patches emailed to authors. LINT
probably broken until they catch up.


47625 30-May-1999 phk

This commit should be a extensive NO-OP:

Reformat and initialize correctly all "struct cdevsw".

Initialize the d_maj and d_bmaj fields.

The d_reset field was not removed, although it is never used.

I used a program to do most of this, so all the files now use the
same consistent format. Please keep it that way.

Vinum and i4b not modified, patches emailed to respective authors.


47519 25-May-1999 mjacob

Add TDC 3800 to quirk list for fixed mode device.
PR:11866
Submitted by: Helge Oldach hmo@sep.hamburg.com


47509 25-May-1999 gibbs

Run xpt_action at splsoftcam() so that it cannot be re-entered by our SWI.
The XPT doesn't have a problem with this itself, but some controllers
drivers may have been caught off guard by the old behavior.

XPT_CONT_TARGET_IO is also a valid ccb type for cam_periph_unmapmem.


47497 25-May-1999 ken

Fix the read/write permission checks in cam_periph_mapmem(). If we're
writing, we want to be able to read the buffer. If we're reading, we want
to be able to write to the buffer.

PR: kern/11870
Submitted by: Andrew Mobbs <amobbs@allstor-sw.co.uk>


47434 23-May-1999 gibbs

Rely on the statistics in XPT_GDEV_STATS instead of the versions still
retained in XPT_GDEV_TYPE for binary compatibility. Mark the legacy
structure values for removal when we bump the major CAM revision.


47413 22-May-1999 gibbs

Add a default async handler funstion to cam_periph.c to remove duplicated
code in all initiator type peripheral drivers.

scsi_target.c:
Release ATIO structures that wind up in the 'unkown command queue'
for consumption by our userland counterpart, back to the controller
when the exception for that command is cleared.


47412 22-May-1999 gibbs

Add the XPT_PATH_STATS and XPT_GDEV_STATS function codes. These ccb
types allow the reporting of error counts and other statistics. Currently
we provide information on the last BDR or bus reset as well as active
transaction inforamtion, but this will be expanded as more information is
added to aid in error recovery.

Use the 'last reset' information to better handle bus settle delays.
Peripheral drivers now control whether a bus settle delay occurs and
for how long. This allows target mode peripheral drivers to avoid
having their device queue frozen by the XPT for what shoudl only be
initiator type behavior.

Don't perform a bus reset if the target device is incapable of performing
transfer negotiation (e.g. Fiber Channel).

If we don't perform a bus reset but the controller is capable of transfer
negotiations, force negotiations on the first transaction to go to the
device. This ensures that we aren't tripped up by a left over negotiation
from the prom, BIOS, loader, etc.

Add a default async handler funstion to cam_periph.c to remove duplicated
code in all initiator type peripheral drivers.

Allow mapping of XPT_CONT_TARGET_IO ccbs from userland. They are
itentical to XPT_SCSI_IO ccbs as far as data mapping is concerned.


47282 18-May-1999 gibbs

Make xpt_path_comp work on wildcarded paths again.


47020 11-May-1999 mjacob

Quirk this drive- all luns show up the same.
Submitted by: Stephen McKay <syssgm@detir.qld.gov.au>


46962 11-May-1999 mjacob

Add a SA_FLAG_COMP_SUPP flag (to quirk compression as
SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below).
Add a queue_count field to softc.

Add HP T20* Travan-5 like tape device as a FIXED/512 type device.
Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device.
Change VIPER 2525 to 1024 byte blocksize. It's possible other
drives should change too, but see below..

Change argument to sagetparams to be pointer to a sa_comp_t union-
this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION
page. In general compression now tries to use the DATA COMPRESSION
page and if that fails tries the DEVICE CONFIGURATION page.

Change close routine to not rewind tape if there's a failure in either
writing filemarks or in backing over one of two filemarks for a 2FM
at EOT tape- instead mark the tape as 'frozen' and print a message
saying that either an OFFLINE or REWIND or an MTEOM command is needed
to clear this state (all bring certainty back to tape position). Fix
sastrategy to not allow I/O to a frozen tape.

Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT
model for a tape drive (you can now dynamically change whether it's
a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks
something to handle the QIC drives we don't know about. Correctly propagate
record of compression algorithm back. Clear FROZEN flag for EOM, REWIND
and OFFLINE (and RETENSION and ERASE) cases.

Fix an egregious bug in sadone that had left the device queue frozen
for deferred (for fixed mode case) errors.

Add comment in samount about how useless the test unit ready is for
invalidating a mount (this has to be fixed later).

Fix residual calculation (per Eivind) in saerror so that negative values
for tape records being too large for the supplied buffer get caught. Do
some other saerrro cleanup.

Per Ken && Justin, add my name to copyright comment.


46952 11-May-1999 mjacob

Quirk NOLUNS CALIPER CP150.


46950 11-May-1999 mjacob

Make clear that the DATA COMPRESSION page is a SCSI-3 entity- not a SCSI-2
entity. Add the Device Configuration page data structure- this structure
should be used if you fail to fetch the DATA COMPRESSION page. Make a union
type of a mode header, a device configuration page and the data compression
page.

Add a couple of QIC density defines (QIC 2G/QIC 4GB).


46747 09-May-1999 ken

Add a facility in the CAM error handling code to retry selection timeouts.
If the client requests that the error recovery code retry a selection
timeout, it will be retried after half a second. The delay is to give the
device time to recover.

For most of these drivers, I only added selection timeout retries where
they were also retrying unit attention type errors. The sa(4) driver calls
saerror() in a number of places, but most of them don't request retrying
unit attentions.

Also, bump the default minimum CD changer timeout from 2 to 5 seconds and
the maximum timeout from 10 to 15 seconds. Some Pioneer changers seem to
have trouble with the shorter timeout.

Reviewed by: gibbs


46625 07-May-1999 phk

Introduce two functions: physread() and physwrite() and use these directly
in *devsw[] rather than the 46 local copies of the same functions.

(grog will do the same for vinum when he has time)


46581 06-May-1999 ken

Add a number of interrelated CAM feature enhancements and bug fixes.

NOTE: These changes will require recompilation of any userland
applications, like cdrecord, xmcd, etc., that use the CAM passthrough
interface. A make world is recommended.

camcontrol.[c8]:
- We now support two new commands, "tags" and "negotiate".

- The tags commands allows users to view the number of tagged
openings for a device as well as a number of other related
parameters, and it allows users to set tagged openings for
a device.

- The negotiate command allows users to enable and disable
disconnection and tagged queueing, set sync rates, offsets
and bus width. Note that not all of those features are
available for all controllers. Only the adv, ahc, and ncr
drivers fully support all of the features at this point.
Some cards do not allow the setting of sync rates, offsets and
the like, and some of the drivers don't have any facilities to
do so. Some drivers, like the adw driver, only support enabling
or disabling sync negotiation, but do not support setting sync
rates.

- new description in the camcontrol man page of how to format a disk
- cleanup of the camcontrol inquiry command
- add support in the 'devlist' command for skipping unconfigured devices if
-v was not specified on the command line.
- make use of the new base_transfer_speed in the path inquiry CCB.
- fix CCB bzero cases

cam_xpt.c, cam_sim.[ch], cam_ccb.h:

- new flags on many CCB function codes to designate whether they're
non-immediate, use a user-supplied CCB, and can only be passed from
userland programs via the xpt device. Use these flags in the transport
layer and pass driver to categorize CCBs.

- new flag in the transport layer device matching code for device nodes
that indicates whether a device is unconfigured

- bump the CAM version from 0x10 to 0x11

- Change the CAM ioctls to use the version as their group code, so we can
force users to recompile code even when the CCB size doesn't change.

- add + fill in a new value in the path inquiry CCB, base_transfer_speed.
Remove a corresponding field from the cam_sim structure, and add code to
every SIM to set this field to the proper value.

- Fix the set transfer settings code in the transport layer.

scsi_cd.c:

- make some variables volatile instead of just casting them in various
places
- fix a race condition in the changer code
- attach unless we get a "logical unit not supported" error. This should
fix all of the cases where people have devices that return weird errors
when they don't have media in the drive.

scsi_da.c:

- attach unless we get a "logical unit not supported" error

scsi_pass.c:

- for immediate CCBs, just malloc a CCB to send the user request in. This
gets rid of the 'held' count problem in camcontrol tags.

scsi_pass.h:

- change the CAM ioctls to use the CAM version as their group code.

adv driver:

- Allow changing the sync rate and offset separately.

adw driver

- Allow changing the sync rate and offset separately.

aha driver:

- Don't return CAM_REQ_CMP for SET_TRAN_SETTINGS CCBs.

ahc driver:

- Allow setting offset and sync rate separately

bt driver:

- Don't return CAM_REQ_CMP for SET_TRAN_SETTINGS CCBs.

NCR driver:

- Fix the ultra/ultra 2 negotiation bug
- allow setting both the sync rate and offset separately

Other HBA drivers:
- Put code in to set the base_transfer_speed field for
XPT_GET_TRAN_SETTINGS CCBs.

Reviewed by: gibbs, mjacob (isp), imp (aha)


46437 04-May-1999 gibbs

Don't touch a path after we've free'd it.


45963 23-Apr-1999 gibbs

Release bus entries in the EDT when a path is released.
Null out path entries when the path is released to catch bugs.
Free our configuration hook when we're done with it.


45897 21-Apr-1999 peter

Stage 1 of a cleanup of the i386 interrupt registration mechanism.
Interrupts under the new scheme are managed by the i386 nexus with the
awareness of the resource manager. There is further room for optimizing
the interfaces still. All the users of register_intr()/intr_create()
should be gone, with the exception of pcic and i386/isa/clock.c.


45845 19-Apr-1999 gibbs

Use macros for accessing the head of the heap so that code
is isolated from implementation details of the heap.


45844 19-Apr-1999 gibbs

cam_periph.c:
Move handling of CAM_AUTOSENSE_FAIL into block dealing with
all other scsi status errors.

cam_queue.c:
cam_queue.h:
Fix 'off by one' heap bug in a more efficient manner. Since
heap algorithms like to deal with indexes started from 1,
offset our heap array pointer at allocation time to make this
so for a C environment. This makes the implementation of the
algorithm a bit more efficient.

cam_xpt.c:
Use macros for accessing the head of the heap so that code
is isolated from implementation details of the heap.


45752 18-Apr-1999 mjacob

Make WangTek 51000 a fixed block device.
PR: kern/11194
Obtained from:naddy@mips.rhein-neckar.de


45739 17-Apr-1999 peter

Well folks, this is it - The second stage of the removal for build support
for LKM's..


45442 07-Apr-1999 gibbs

Remove camq_regen(). We already perform modular comparisons
for generation counts, so no further steps to deal with generation
count wrap are required.


45441 07-Apr-1999 gibbs

Remove camq_regen(). We already perform modular comparisons
for generation counts, so no further steps to deal with generation
count wrap are required.

Fix an off by one problem in the camq heap code.


45359 06-Apr-1999 peter

Use PHOLD/PRELE rather than P_PHYSIO.


44731 14-Mar-1999 ken

Disable tagged queueing for the IBM DCAS drives. These drives have poor
write performance when tagged queueing is enabled.

Although the PR was submitted for the 4 gig version of this drive, the
assumption is that the 2 gig version has the same problem. Therefore
tagged queueing is disabled for both.

Also, update the comment for the Western Digital Enterprise drives to note
that the best performance for those drives is achieved when tagged queueing
is disabled and write caching is enabled.

PR: kern/10398
Submitted by: Hideaki Okada <hokada@isl.melco.co.jp>


44661 11-Mar-1999 jkh

People who wanted the "tagged opening" message can boot -v. The rest
of us, who appear to have complained incessantly about this message since
it appeared, can now stop.


44567 07-Mar-1999 ken

The 4 gig version of the Seagate Medalist Pro seems to have the same
trouble with tagged queueing as the 6.5 gig version.

So, I've added a quirk entry for it to limit it to two outstanding
transactions at a time, just like the 6.5G version. While I'm at it, add a
quirk for the 9G version of the drive, since it most likely has the same
problem.

Submitted by: Jeremy Lea <reg@shale.csir.co.za>


44504 05-Mar-1999 gibbs

Implement the control device for the "targ" target mode processor target
emulator so that instances can be dynamically added and removed from the
system.

Properly reference count peripheral instances so they are cleaned up when
destroyed by the control device.

Set a timeout for test unit ready commands. Before it was uninitialized
and could cause us to drop off the bus when no real timeout had occurred.


44503 05-Mar-1999 gibbs

Silence errors.

Reduce the number of accept target I/O entries we allow to better
exercise the resource shortage handling code in controller drivers.


44502 05-Mar-1999 gibbs

Silence complaints about synchronize cache requests that fail with illegal
request.


44501 05-Mar-1999 gibbs

xpt_done has no reason to take a volatile ccb *.


44500 05-Mar-1999 gibbs

Protect access to the EDT with splcam() to protect against corruption
caused by temporary EDT allocations performed by controller drivers in
their interrupt routiens.

Reference count bus entries in the EDT in preparation for support for
dynamic controller arrival and departure.

Have children of the EDT hold references to their parents.

Correct routing of the XPT_IMMED_NOTIFY ccb type for use in
target mode applications.

Fix a few cases where the generation count for EDT data members was
not being updated when a modification occurred.

splcam() problem Noticed by: Tor Egge <tegge@FreeBSD.org>


44499 05-Mar-1999 gibbs

Add constants and macros for dealing with XPT opcode group types.


44354 01-Mar-1999 mjacob

+Match against T4000* for HP QIC quirks (not T4000S* where it doesn't then
catch a T4000s)
+ Set *some* kind of error at EOM if we're in fixed mode and have pending errs.
Do not clear the ERR_PENDING bit if more buffers are queued.
+ Release the start_ccb in this case also, else we hang forever on rewinding.
+ Any kind of error for load to BOT in samount should then cause an attempt
to use REWIND to come back to BOT. Do the initial load command quietly.
+ In samount, if we succeed, set the relative position markers.


44300 26-Feb-1999 ken

Add a quirk entry for the Seagate Medalist Pro 6 gig drive. It seems this
drive has very poor write performance (1.4MB/sec vs. 12MB/sec) with anything
more than two oustanding transactions.

So, this limits the number of tagged commands to two for that drive.
Thanks to Paul van der Zwan for doing a whole lot of testing to confirm
this.

Reported by: Paul van der Zwan <paulz@trantor.xs4all.nl>


44117 18-Feb-1999 ken

Fix sync rate and transfer rate printouts in xpt_announce_periph().
Sync rates like 4.032MHz were getting printed as 4.32MHz.

Also, add a quirk entry for the 18G Quantum Atlas III. Like most other
recent Quantum drives, it bogusly reports queue full. Thanks to Andre
Albsmeier <andre.albsmeier@mchp.siemens.de> for the Atlas III inquiry
information.

Reviewed by: gibbs


43879 11-Feb-1999 gibbs

Completely set information in the transaction description before performing
a selwakeup for it. Cosmetic.


43819 10-Feb-1999 ken

Add a prioritization field to the devstat_add_entry() call so that
peripheral drivers can determine where in the devstat(9) list they are
inserted.

This requires recompilation of libdevstat, systat, vmstat, rpc.rstatd, and
any ports that depend on the devstat code, since the size of the devstat
structure has changed. The devstat version number has been incremented as
well to reflect the change.

This sorts devices in the devstat list in "more interesting" to "less
interesting" order. So, for instance, da devices are now more important
than floppy drives, and so will appear before floppy drives in the default
output from systat, iostat, vmstat, etc.

The order of devices is, for now, kept in a central table in devicestat.h.
If individual drivers were able to make a meaningful decision on what
priority they should be at attach time, we could consider splitting the
priority information out into the various drivers. For now, though, they
have no way of knowing that, so it's easier to put them in an easy to find
table.

Also, move the checkversion() call in vmstat(8) to a more logical place.

Thanks to Bruce and David O'Brien for suggestions, for reviewing this, and
for putting up with the long time it has taken me to commit it. Bruce did
object somewhat to the central priority table (he would rather the
priorities be distributed in each driver), so his objection is duly noted
here.

Reviewed by: bde, obrien


43651 05-Feb-1999 mjacob

quiet the alpha compiler


43636 05-Feb-1999 mjacob

Extend unit numbers to a full 10 bits (split into sections
of the minor). Establish and use a control mode open. Control
mode opens may open the device without locking, but are prohibited
from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT
works, but the clearing of latched error status is contingent
upon whether another application has the device open, in which
case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY
and MTCOMP also require a periph aquire.

Relative fileno and blkno are tracked. Note that just about any
error will make these undefined, and if you space to EOD or use
hardware block positioning, these are also lost until the next
UNLOAD or REWIND.

Driver state is also tracked and recorded in the unit softc
to be passed back in mt_dsreg for a MTIOCGET call.
Thanks to Dan Strick for suggesting this.

Reintroduce 2 filemarks at EOD for all but QIC devices. I
really think it's wrong, but there is a lot of 3rd party
software that depends upon this (not the least of which is
tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices
can be marked as only being able to do 1 FM at EOD.

At samount time force a load to BOT if we aren't mounted. If the
LOAD command fails, use the REWIND command (e.g., for the IBM 3590
which for some gawdawful reason doesn't support the LOAD (to BOT)
command).

Also at samount time, if you don't know fixed or variable, try to
*set* to one of the known fixed (or variable, for special case)
density codes. We only have to do this once per boot, so it's not
that painful. This is another way to try and figure out the wierd
QIC devices without having to quirk everything in the universe.

A substantial amount of cleanup as to what operations can and what
operations cannot be retried. Don't retry space operations if they
fail- it'll just lead to lossage.

Not yet done is invalidating mounts correctly after errors. ENOTIME.


43635 05-Feb-1999 mjacob

add QIC 525,320,1320,3080 codes


43295 27-Jan-1999 dillon

Fix warnings preparing for -Wall -Wcast-qual

Also disable one usb module in LINT due to fatal compilation errors,
temporary.


42957 21-Jan-1999 dillon

This is a rather large commit that encompasses the new swapper,
changes to the VM system to support the new swapper, VM bug
fixes, several VM optimizations, and some additional revamping of the
VM code. The specific bug fixes will be documented with additional
forced commits. This commit is somewhat rough in regards to code
cleanup issues.

Reviewed by: "John S. Dyson" <root@dyson.iquest.net>, "David Greenman" <dg@root.com>


42920 20-Jan-1999 mjacob

put it back the way it was


42909 20-Jan-1999 mjacob

temporary fix so alpha stays working while configure code is fixed


42872 20-Jan-1999 ken

By popular demand, back out the CONNER CFP* quirk entry, and return it to
its original form. (Originally, it only applied to the CFP 2107.)

Hopefully we can come to some conclusion about which Conner drives are
broken for tagged queueing.


42838 19-Jan-1999 ken

The Samsung WN34324U is broken for tagged queueing.

PR: kern/9535
Submitted by: NAKAJI Hiroyuki <nakaji@zeisei.dpri.kyoto-u.ac.jp>


42823 19-Jan-1999 ken

Generalize the quirk entry for the Conner CFP* drives. It did just cover
the CFP2107, but it appears (not surprisingly) that the 1 gig and 4 gig
versions of that drive have the same problem with tagged queueing.

Also, fix the problem reported in PR kern/9482. The XPT_DEV_MATCH case in
xptioctl() wasn't putting a proper path in the CCB before it called
xpt_action(). When CAMDEBUG is defined, and CAM_DEBUG_TRACE debugging is
turned on, the CAM_DEBUG statement at the beginning of xpt_action would end
up deferencing a NULL path pointer. That of course caused a panic.

My solution is to just stick the xpt peripheral's path in the CCB.

PR: kern/9482
Reviewed by: gibbs


42818 19-Jan-1999 peter

Call the xpt_init() hook during at the start of the configure() process
via SYSINIT(). This gets a little closer to making cam useable as a
module.


42735 16-Jan-1999 mjacob

Sascha Blank <blank@uni-trier.de> convinced me I was an
idiot about testing SA_QUIRK_2FM in samount. Fixed.

Removed the NORRLS quirk (to save quirk space) and left
the behaviour of being quiet about failed reserve/release
(failed due Illegal Request) the same.

Added a SF_QUIET_IR for prevent/allow for the same purposes.


42716 16-Jan-1999 mjacob

More bandaids. One important one from Sascha Blank
(<blank@fox.uni-trier.de>) about quirks being set as
arithmetic values, not as bitfields. Add HP, Kennedy
and M4 1/2" reel quirk entries.

Do a lot of gratuitous source changing.

Audit all functions that build ccbs for the tape driver
and decide whether each one can be retried or not.

Still to do is some more state management post errors.


42654 14-Jan-1999 jdp

Replace includes of <sys/kernel.h> with includes of
<sys/linker_set.h> in those files that use only the linker set
definitions.


42651 14-Jan-1999 gibbs

Add support for wildcard device entries in the EDT. The target mode
'Black Hole' device uses this feature to schedule itself against any
target or lun attached to a controller that receives an unwanted request
from an initiator instead of having an instance per potential target/lun
request.

Use the wildcard entries to simplify wildcard async callback storage.

Don't announce devices twice to peripheral drivers. The devices will
be announced as soon as the AC_PATH_REGISTERED event is registered by
the peripheral driver, so no manaul push of this event is required.

Reviewed by: Kenneth Merry <ken@FreeBSD.org>


42650 14-Jan-1999 gibbs

The target mode 'Black Hole' device. This peripheral driver provides inquiry
data and sense information for target mode devices for which no other
peripheral driver is attached. This simplifies the task of dealing with
luns that are not otherwise enabled for target mode if the controller
does not have firmware that automatically deals with this case (e.g.
the aic7xxx driver).


42648 14-Jan-1999 gibbs

Properly handle transfers that only consume partial buffers.


42590 12-Jan-1999 eivind

Make dsopen() and dsioctl() use cdstrategy1 instead of cdstrategy.
This silence the warnings and makes it more obvious where the bugs
have to be fixed.


42563 12-Jan-1999 mjacob

Clean up and fix quirk table (was missing necessary wildcards) and add a couple
from the old driver. Change format of quirk table to have a preferred block
size for devices that need to be QUIRK_FIXED- this is loaded into the
last_media_blocksize tag at saregister time and will be used in the first
samount case.

Change sasetparams to take a sense_flags argument so that probe time testing
can be quieter (e.g. with SF_NO_PRINT).

Fix a couple of silly bugs in the fixed/variable determination in samount- one
was where there was a check against 'guessing' AND the density code being
default density- *SMACK* - you're only guessing if you find the media code
to be *other* than default density. Second bug was a test against current
blocksize being zero- should be a test against whether current blocksize
is not equal to the last blocksize if you had wanted to be fixed (suppose
you came up in fixed, but not the preferred size?). And if you don't
know what the fixed size should be, select 512 as the starting point,
not BLKDEV_IOSIZE (reality wins). Finally, in doing the test set to variable
mode, make sasetparams non-chatty.


42533 11-Jan-1999 mjacob

Make HP T4000S quirk to FIXED mode


42531 11-Jan-1999 eivind

Add 'static' to the declaration, too.


42378 07-Jan-1999 mjacob

Like the problems just fixed in scsi_da.c, make sure
to release the probe ccb before taking down the periph.
Also, don't do cdscheduling if you're not going to
attach the device after all.
Reviewed by: ken@freebsd.org


42377 07-Jan-1999 mjacob

A better fix to avoid race conditions between failed probes
and peripheral removal.
Obtained from:gibbs@freebsd.org


42363 07-Jan-1999 ken

The Quantum Atlas III evidently has an identical problem to the Atlas II.
It keeps returning queue full until we have reduced the number of tagged
openings to the minimum.

So, put in a quirk entry with the same work-around. This quirk entry is
only for the 9G Atlas III, once someone comes up with inquiry information
for the 18G version of that drive, we can quirk it as well.

Submitted by: "Johan Granlund" <johan@granlund.nu>


42319 05-Jan-1999 ken

The Conner CFP2107 is a fixed-media drive, not removable media. This fixes
the quirk that disables tagged queueing for those drives.

Also, silence a warning by disabling xpt_for_all_targets() and
xpt_for_all_periphs(). These two functions are not currently used, but
they should not be removed. They're part of a set of functions that
provide a way to execute a function for every {bus,target,device,periph} in
the system.

If anyone needs to use either function in the future, they can be
un-#ifdefed.


42317 05-Jan-1999 mjacob

Add a quirk that disables SYNCHRONIZE CACHE
PR: 8882
Obtained from: Hellmuth Michaelis hm@kts.org


42271 03-Jan-1999 mjacob

Temporary workaround (bandaid) for case where you have READ
CAPACITY fail for a non-removable media device. There's a race
condition where the device entry is removed and then
xpt_release_ccb is called which attempts to give back the ccb
to a device that's now gone. In this bandaid release the ccb
early and then remember to not call xpt_release_ccb later.


42130 28-Dec-1998 mjacob

Force ARCHIVE Vipers to be FIXED


42038 24-Dec-1998 mjacob

a more correct change that should meet the sniff test


42036 24-Dec-1998 mjacob

Unstaticize swi_camnet && swi_cambio so Alpha kernels can build again.


42033 23-Dec-1998 mjacob

you can retry SYNC CACHE on UA errors


42017 22-Dec-1998 eivind

Staticize.

Reviewed by: gibbs


42009 22-Dec-1998 mjacob

Add a quirk NORRLS (no reserve/release) which can (and
will) get set for the devices that don't actually support
reserve/release (so we don't keep trying it).

Add softc storage and manage storing last I/O and CTL
commands that had errors (for correlative purposes).

In saclose clear the 'MOUNTED' bit if we either rewind or
unload (yes, this shouldn't be necessary since the next open
should catch whether a tape change occurred, but I'm having
some questions about that actually working so this is
safer for the moment). Oh, forgot to mention in previous
commit messages that some of the failures particularly at
close time cause the tape to be ejected (for the sake
of safety)- all this prior to redoing the state machine
(which is in progress) which will try and handle this better.

Complete the addition of the setmark support
(from Martin.Birgmeier@aon.at).


41948 19-Dec-1998 mjacob

1) Fix some serious bugs (1 botch on my part which caused a filemark to be
written even it the tape was opened readonly- 2 botches in deferred error
handling for FIXED LENGTH mode which caused panic && hand resp.). Fixed
a memory leak in sa_mount.
2) Fixed an annoying bug when turning of compression to actually reflect
this for future status calls.
3) Implement the MTIOCERRSTAT call where latched control and I/O residuals
and sense data are returned to the application asking for them.


41918 18-Dec-1998 mjacob

Add in block position/block locate functions.


41917 18-Dec-1998 mjacob

Add structures and function definitions pertinent for hardware locate support.


41910 17-Dec-1998 gibbs

Correct the definition of the changer device capabilities page. The
previous definition confused some reserved bytes for exchange capabilities.


41907 17-Dec-1998 mjacob

Add some tape specific density codes- only enough of them here to recognize
some specific older units so we can choose 2FM@EOD or FIXED blocksize
quirks.


41906 17-Dec-1998 mjacob

Several changes having to do blocksize- mostly to force variable as the default.
Attempt to determine (at mount time if not done so already) via density code
whether a device should default to fixed mode or not. Attempts to set to
variable that fail will cause fixed to be selected.

Similarly, the '2 filemarks at EOM' quirk is now determined (or attempted to
be determined) via density code. Some as yet not entirely tested code for
coping with 2FM@EOD position is now also in place.


41886 17-Dec-1998 gibbs

Correctly track allocated accept target I/O ccbs so that they can be
aborted prior to disabling our lun. This requires a second set of
links since we use the ones in the ccb_hdr during normal operations.

Nuke some unused variables.


41885 16-Dec-1998 ken

At Justin's request, limit the size of buffers that can be mapped into
and out of kernel address space (via the pass(4) and xpt(4) peripheral
drivers) to 64K (DFLTPHYS). Some controllers, like the Adaptec 1542,
don't support more than 64K transactions.

We plan on eventually having the capability of limiting this size based
on min(MAXPHYS, controller max), but since that capability isn't here yet,
limit things to the lowest common denominator.


41877 16-Dec-1998 ken

Probable fix for the "cdda2wav" panics that various people have been
reporting since this past summer. (I think Daniel O'Conner was the first.)

The problem appears to have been something like this:

- cdda2wav by default passes in a buffer that is close to the 128K MAXPHYS
limit.
- many times, the buffer is not page aligned
- vmapbuf() truncates the address, so that it is page aligned
- that causes the total size of the buffer to be greater than MAXPHYS,
which of course is a bad thing.

Here's a quote from the PR (kern/9067):

==================
In particular, note bp->b_bufsize = 0x0001f950 and bp->b_data = 0xf2219960
(which does not start on a page boundary). vunmapbuf() loops through all
the pages without any difficulty until addr reaches 0xf2239000, and then
the panic occurs. This seems to indicate that we are exceeding MAXPHYS
since we actually started from the middle of a page (the data is being
transfered to a non page aligned location).

To complete the description, note that the system call originates from
ReadCddaMMC12() (in scsi_cmds.c of cdda2wav) with a request to read 55
audio sectors of 2352 bytes (which is calculated to fall under MAXPHYS).
This in turn ends up calling scsi_send() (in scsi-bsd.c) which calls
cam_fill_csio() and cam_send_ccb(). This results in a CAMIOCOMMAND ioctl
with a ccb function code of XPT_SCSI_IO.
==================

The fix is to change the size check in cam_periph_mapmem() so that it is
like the one in minphys(). In particular, it is something like:

if ((buffer_length + (buf_ptr & PAGE_MASK)) > MAXPHYS)
buffer is too big

My fix is based on the one in the PR, but I cleaned up a fair number of
things in cam_periph_mapmem(). The checks for each buffer to be mapped
are now in a separate loop from the actual mapping operation. With the new
arrangement, we don't have to bother with unmapping any previously mapped
buffers if one of the checks fails.

Many thanks to James Liu for tracking this down. I'd appreciate it if some
vm-savvy folks would look this over. I believe this fix is correct, but I
could be wrong.

PR: kern/9067 (also, kern/8112)
Reviewed by: gibbs
Submitted by: "James T. Liu" <jtliu@phlebas.rockefeller.edu>


41815 15-Dec-1998 gibbs

Enable/Disable our lun on open/close. Track resources kept at the controller
level so they can be reclaimed before attempting to disable our lun.
Correctly free descriptors. Add periph locking and spl protection
around open and close.


41814 15-Dec-1998 gibbs

Wire up the XPT_ABORT and XPT_RESET_DEV ccb function codes so they can
be delivered to controller drivers.

Adjust for changes to the ccb_hdr list types in cam_queue.h


41813 15-Dec-1998 gibbs

Add definitions for TAILQ, LIST, and SLIST ccb_hdr queues.


41708 12-Dec-1998 gibbs

Return ENODEV instead of EINVAL when a particular exchange or move
operation exceeds the capabilities of the changer device.


41674 11-Dec-1998 mjacob

Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.

At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).

When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).

Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).

Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.

Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).


41671 11-Dec-1998 gibbs

Convert dadump to use reasonable data types so that some casting is unecessary.


41670 11-Dec-1998 gibbs

Do not attempt to retry commands that fail with ILLEGAL REQUEST status.


41645 10-Dec-1998 gibbs

Convert debugging printfs to the CAM_DEBUG macro.

Allow sync transfers if the controller supports it. Wide will follow
as soon as I get the kinks worked out of wide target transfers in the
aic7xxx driver (currently the only target mode driver in the tree).


41644 10-Dec-1998 gibbs

Expand the hba_misc fied in the Path Inquiry ccb to allow a controller driver
to specify that it does not provide initiator services (PIM_NOINITIATOR)
and that the initial bus reset for device probing should be avoided
(PIM_NOBUSRESET).

Modify the XPT layer to honor these flags.


41550 06-Dec-1998 mjacob

use CAM_DEBUG_XPT to track XPT; correct a misspelling


41549 06-Dec-1998 mjacob

print the appropriate SCSI revision (with CCS as a proper name for the announce message


41546 05-Dec-1998 mjacob

Add a CAM_DEBUG_XPT define (to debug XPT layer only). Add a CAM_DEBUGGED
macro to be like the CAM_DEBUG macro but to instead provide a predicate
result.


41542 05-Dec-1998 mjacob

Add in named SID field revision names (including CCS).
Add in named defines for DEFAULT and NOCHANGE densities (for sequential
access devices).


41514 04-Dec-1998 archie

Examine all occurrences of sprintf(), strcat(), and str[n]cpy()
for possible buffer overflow problems. Replaced most sprintf()'s
with snprintf(); for others cases, added terminating NUL bytes where
appropriate, replaced constants like "16" with sizeof(), etc.

These changes include several bug fixes, but most changes are for
maintainability's sake. Any instance where it wasn't "immediately
obvious" that a buffer overflow could not occur was made safer.

Reviewed by: Bruce Evans <bde@zeta.org.au>
Reviewed by: Matthew Dillon <dillon@apollo.backplane.com>
Reviewed by: Mike Spengler <mks@networkcs.com>


41458 02-Dec-1998 ken

"Fix" a problem with the Quantum Viking. It appears that this drive does
not like the 6-byte read and write commands! It returns illegal request,
with the field pointer pointing to byte 9 of a 6 byte CDB.

In any case, the work around is to put in a quirk mechanism that makes sure
that we don't send 6-byte reads or writes to this device. It's rather sad
that this is necessary. You'd think that they would be able to get
something that basic to work right in their firmware...

Reviewed by: gibbs
Reported by: Adam McDougall <bsdx@spawnet.com>


41351 26-Nov-1998 joerg

...nor does this old TDC3620 like to be asked for compression.

But well, now it's running again!


41330 25-Nov-1998 joerg

This old firmware of the TDC3620 hangs the SCSI bus upon serial
number requests. Don't ask it so.


41297 22-Nov-1998 ken

Fix a few problems that Bruce noticed about a month ago, and fix oup one
other problem.

- Hold onto splsoftcam() in the peripheral driver open routines until we
have locked the periph. This eliminates a race condition.

- Disallow opening the pass driver when securelevel > 1.

- If a user tries to open the pass driver with O_NONBLOCK set, return
EINVAL instead of ENODEV. (noticed by gibbs)


40912 04-Nov-1998 ken

Generalize the quirk entry that disables multi-lun probing for Sony CDROM
drives. It seems that quite a few (possibly all?) of their drives respond
to inquiries on multiple luns. Hopefully we can detect problems like this
in the probe phase at some point. For now, this is a pretty functional
solution.


40603 22-Oct-1998 ken

Fix a problem with the way we handled device invalidation when attaching
to a device failed.

In theory, the same steps that happen when we get an AC_LOST_DEVICE async
notification should have been taken when a driver fails to attach. In
practice, that wasn't the case.

This only affected the da, cd and ch drivers, but the fix affects all
peripheral drivers.

There were several possible problems:
- In the da driver, we didn't remove the peripheral's softc from the da
driver's linked list of softcs. Once the peripheral and softc got
removed, we'd get a kernel panic the next time the timeout routine
called dasendorderedtag().
- In the da, cd and possibly ch drivers, we didn't remove the
peripheral's devstat structure from the devstat queue. Once the
peripheral and softc were removed, this could cause a panic if anyone
tried to access device statistics. (one component of the linked list
wouldn't exist anymore)
- In the cd driver, we didn't take the peripheral off the changer run
queue if it was scheduled to run. In practice, it's highly unlikely,
and maybe impossible that the peripheral would have been on the
changer run queue at that stage of the probe process.

The fix is:
- Add a new peripheral callback function (the "oninvalidate" function)
that is called the first time cam_periph_invalidate() is called for a
peripheral.

- Create new foooninvalidate() routines for each peripheral driver. This
routine is always called at splsoftcam(), and contains all the stuff
that used to be in the AC_LOST_DEVICE case of the async callback
handler.

- Move the devstat cleanup call to the destructor/cleanup routines, since
some of the drivers do I/O in their close routines.

- Make sure that when we're flushing the buffer queue, we traverse it at
splbio().

- Add a check for the invalid flag in the pt driver's open routine.

Reviewed by: gibbs


40417 15-Oct-1998 gibbs

Add a mechanism to send a non-tagged transaction even if a device is
currently operating in a tagged mode. The SIM driver should determine
if a device is in tag mode by looking at the CAM_TAG_ACTION_VALID flag
in the ccb header. If the flag is set, the tag_action field is either
a SCSI II tag message (simple, ordered, head) or CAM_TAG_ACTION_NONE
to specify that no tagging should be performed.


40401 15-Oct-1998 ken

Fix several potential buffer overrun conditions. These changes have been
tested both in the kernel and in userland. Also, fix a couple of printf
warnings that show up when CAMDEBUG is defined.

Reviewed by: imp
Partially submitted by: imp


40398 15-Oct-1998 ken

Clean up some unused variables.

Reviewed by: ken
Submitted by: phk


40363 14-Oct-1998 ken

Narrow the quirk entry for the Seagate Elite 9 a bit to just cover drives
with 71* firmware revisions. Scott Mace <smace@intt.ORG> reports that
drives with 00* firmware revisions do tagged queueing just fine.


40360 14-Oct-1998 ken

Disable tagged queueing for the Seagate Elite 9GB drives. They tend to get
hung up when you send tags to them too quickly. (CAM is able to recover
from the problem, but this just avoids it altogether.)

Reviewed by: gibbs
Reported by: Bret Ford <bford@uop.cs.uop.edu>
and: Martin Renters <martin@tdc.on.ca>


40324 13-Oct-1998 ken

Disable cache syncs for a broken NEC drive.

Reviewed by: gibbs
Submitted by: Blaz Zupan <blaz@gold.amis.net>


40318 13-Oct-1998 ken

Fix a bug in the error recovery code. It was possible to have more than
one error recovery action oustanding for a given peripheral.

This is bad for several reasons. The first problem is that the error
recovery actions would likely be to fix the same problem. (e.g., we
queue 5 CCBs to a disk, and the first one comes back with 0x04,0x02. We
start error recovery, and the second one comes back with the same status.
Then the third one comes back, and so on. Each one causes the drive to get
nailed with a start unit, when we really only need one.)

The other problem is that we only have space to store one CCB while we're
doing error recovery. The subsequent error recovery actions that got
started were over-writing the CCBs from previous error recovery actions,
but we still tried to call the done routine N times for N error recovery
actions. Each call to dadone() was done with the same CCB, though. So on
the second one, we got a "biodone: buffer not busy" panic, since the buffer
in question had already been through biodone().

In any case, this fixes things so that any any given time, there's only one
error recovery action outstanding for any given peripheral driver.

Reviewed by: gibbs
Reported by: Philippe Regnauld <regnauld@deepo.prosa.dk>
[ Philippe wins the "bug finder of the week" award ]


40313 13-Oct-1998 ken

Fix a bug in the scan lun code that showed up when we did the following
sequence of things:

- spin up a disk
- send an async event to refresh the inquiry data
- run through xpt_scan_lun() to re-probe the device
- eventually finish the probe, but panic in xpt_done() because the
periph pointer wasn't set.

Reviewed by: gibbs
Reported by: Philippe Regnauld <regnauld@deepo.prosa.dk>


40286 13-Oct-1998 dg

Fixed two potentially serious classes of bugs:

1) The vnode pager wasn't properly tracking the file size due to
"size" being page rounded in some cases and not in others.
This sometimes resulted in corrupted files. First noticed by
Terry Lambert.
Fixed by changing the "size" pager_alloc parameter to be a 64bit
byte value (as opposed to a 32bit page index) and changing the
pagers and their callers to deal with this properly.
2) Fixed a bogus type cast in round_page() and trunc_page() that
caused some 64bit offsets and sizes to be scrambled. Removing
the cast required adding casts at a few dozen callers.
There may be problems with other bogus casts in close-by
macros. A quick check seemed to indicate that those were okay,
however.


40271 12-Oct-1998 ken

Add a "dummy light" (actually two dummy lights) to catch people who don't
have the passthrough device configured in their kernel.

This will hopefully reduce the number of people complaining that they can't
get {camcontrol, xmcd, tosha, cdrecord, etc.} to work.

Reviewed by: gibbs


40263 12-Oct-1998 ken

Add quirk entries to disable the synchronize cache command for Micropolis
2217's (reported by Matthew Jacob in NetBSD PR kern/6027) and Fujitsu
M2954's (reported by Tom Jackson).

Some of the Fujitsus at least hang when they get a cache sync command.
(Others just return illegal request.)

Also, make error printing in dashutdown() a little more selective. Don't
print any error when the sense key is illegal request. Drives that don't
support the synchronize cache command usually return illegal request.
Also, make sure the scsi status is check condition before going into
scsi_sense_print().

Reviewed by: gibbs


40262 12-Oct-1998 ken

Bring over a quirk entry from the old SCSI code for a Chinon CDROM drive
that returns track numbers in BCD.

Reviewed by: gibbs


40194 10-Oct-1998 gibbs

If the bus delay is >= 2 seconds, notify the user that we are waiting
for devices to settle. This will hopefully allay any 'first installation'
fears that the machine has hung.


40051 08-Oct-1998 ken

Add the quirk entry framework to handle disabling the synchronize cache
command on drives that don't like it. Right now, there's just a bogus
quirk entry in the table that doesn't do anything, but that should be
changed once we get actual inquiry data for drives that don't like the
synchronize cache command.

Also, add a shutdown hook that runs through all direct access peripherals
and runs a synchronize cache on them if they're still open, and if
synchronize cache isn't disabled via a quirk entry.

Add a synchronize cache call at the end of dadump() (again, conditionalized
on the quirk entry), so we can insure that the disk cache contents get
flushed to physical media after a dump.

Check the new quirk entry in daclose() to decide whether or not to
synchronize the cache for a disk at final close.

Reviewed by: gibbs


40025 07-Oct-1998 gibbs

Add a quirk entry for the CFP2107, another drive with broken
tagged queuing support.

Ensure that we report that a device supports tagged queuing even if
the system is waiting a "command count delay" before starting to use
them.

If a user disables disconnects on a device ensure that tagged queuing
is also turned off. We did the right thing during initial configuration,
but could be confused by manual changes.


40021 07-Oct-1998 imp

Up the read capacity timeout from 20 seconds to 60 seconds to keep my
JAZ drive happy. This shouldn't impact fast drives, and will keep cam
from failing on very slow ones (that are spinning up, say). 20
seconds was almost long enough, but not in all cases.

Suggested by: gibbs


40020 07-Oct-1998 ken

Some fixes for the CD and DA drivers from bde. (and some of my own as
well) Among them:

[ cd driver ]
1. Old labeling code was still there.
2. Error handling for dsopen() was broken (no test for the `error'
returned by dsopen(); bogus test of an `error' that is known to be 0).
3. cdopen() closed the physical device after certain errors although there
may still be open partitions on it.
4. cdclose() closed the physical device although there may still be open
partitions on it.
5. Some printf format fixes was incomplete or missing.
6. cdioctl() truncated unit numbers mod 256.
7. cdioctl() was missing locking.

[ da driver ]
1. daclose() closed the physical device although there may still be open
partitions on it. This was fixed many years ago in sd.c rev.1.57.
2. A minor optimization (the dk_slices != NULL test) in sdopen() became
uglier in daopen(). It is not worth doing. da only regressed compared
with od and my version of sd, since I never committed the change to sd.
daopen() should probably do less if some partition is already open.
This is not addressed by the diffs.
[ ... ]
5. "opt_hw_wdog.h" was not included, so the HW_WDOG code was unreachable.

- Added a getdev CCB call in the cdopen() and daopen() calls so that the
vendor name and device name are available for the disklabel. (suggested
by bde)

- Removed vestigal devfs support in both drivers, since we can't properly
work with devfs yet. (ask bde for details on this)

- Cleaned up the probe code in both drivers in the failure cases. There
were a number of things wrong here. The peripheral driver instances
weren't getting properly cleaned up. Sometimes the wrong probe message
would get printed out (with the failure message appended), so it wasn't
very clear that we failed to attach. SCSI sense information was printed,
even when the error in question wasn't a SCSI error. I put similar fixes
into the changer driver in revision 1.2 of scsi_ch.c.

Reviewed by: gibbs
Submitted by: bde (partially)


40007 06-Oct-1998 ken

Disable multi-lun probing and serial number inquiries for the Exabyte 8200.


39904 02-Oct-1998 ken

Fix a printf format warning that shows up when CAMDEBUG is defined.


39903 02-Oct-1998 ken

Add a new CAM debugging mode, CAM_DEBUG_CDB. This causes the kernel to
print out a one line description/dump of every SCSI CDB sent to a
particular debugging target or targets.

This is a good bit more useful than the other debugging modes, I think.

Change some things in LINT to note the availability of this new option.

Fix an erroneous argument to scsi_cdb_string() in scsi_all.c

Reviewed by: gibbs


39885 02-Oct-1998 ken

Modify the changer driver so it can handle (hopefully!) changers that need
block descriptors enabled on mode sense commands.

Basically, we try sending a mode sense with block descriptors disabled (the
previous default), and if it fails, we try sending the mode sense with
block descriptors enabled. If that works, we note that in a runtime quirk
entry, so we don't bother disabling block descriptors again for the device.

This problem was first reported by Chris Jones <cjones@honors.montana.edu>
on one of the NetBSD lists, but I'd imagine that some FreeBSD users would
have run into it eventually as well, since our changer driver is derived
form the NetBSD changer driver.

Also, change some of the probe logic so that we do the right thing in the
case of a failure to attach.

Fix a memory leak in chgetparams().

Add a couple of inline helper functions to scsi_all.h to correctly return
the start of a mode page.

NetBSD PR: kern/6214
Reviewed by: gibbs


39884 02-Oct-1998 ken

Patches from DES to create three new kernel config options to control
timeouts in the SA driver (timeouts for space, rewind and erase). Folks
can lengthen the timeouts if their hardware is especially slow, or shorten
them if they want to be notified of errors a little sooner.

Also, get rid of two OD driver options. The od driver has been made
obsolete by the da driver.

Reviewed by: ken, gibbs
Submitted by: Dag-Erling Coidan Smørgrav <des@FreeBSD.ORG>


39787 29-Sep-1998 ken

In the bootverbose case, print out error messages for all errors that will
not be retried again, even if the SF_NO_PRINT flag is set.

Reviewed by: gibbs


39758 29-Sep-1998 bde

Fixed printf format errors. u_long is not necessarily suitable for casting
pointers to, and %d is not suitable for printing uint32_t's.


39657 25-Sep-1998 gibbs

Correct problems with xpt_set_transfer_settings and async transfer
negotiation changes with wildcarded paths.


39633 24-Sep-1998 gibbs

Fix a few problems with the tag delay code:

- Tagged devices were limited to one transaction (oops)
- We revert to untagged with a tag delay if the user changed the
transfer negotiation values (via perhaps camcontrol some day).
- xpt_async did not use the expanded path in some cases which could
cause a panic.


39580 23-Sep-1998 ken

Treat not ready errors (asc 0x04) as non-fatal errors for attach. We
already allowed medium not present type errors (0x3a), but some Philips and
HP WORM drives return 0x04,0x00 when you issue a read capacity without
media in the drive.


39579 23-Sep-1998 gibbs

Allow 5 untagged commands to go to a device before enabling tags after
enabling transfer negotiations, a BDR, or a bus reset to allow the controller
driver to negotiate without tagged messages getting in the way. Some
devices are confused by attempts to negotiate and tag at the same time.
Some controllers (e.g. BT MultiMaster with certain firmware revs) will
never negotiate if you don't give them an untagged "window" to perform
negotiation in.

Bump the maximum tag count to 255. The system reclaims unused tag space
as the tag count is dropped anyway, so we might as well try the max.

We should probably use a larger type than u_int8_t to hold our tag value
as SCSI over certain mediums allows for higher values.

Reviewed by: Kenneth Merry <ken@FreeBSD.org>


39573 22-Sep-1998 ken

Add several quirks:

Western Digital Enterprise drives have sorry performance (1.5MB/sec versus
8MB/sec) when doing tagged queueing. Disable tagged queueing for them.

Submitted by: Andrew Gallatin <gallatin@cs.duke.edu>

Some Sony CDROM drives don't like it when we probe more than one LUN.

Verified by: Jean-Marc Zucconi <jmz@FreeBSD.ORG>

Some Sony CD-R's don't like multi-LUN probing either.

Submitted by: Parag Patel <parag@cgt.com>


39552 22-Sep-1998 gibbs

cam.c:
Clear up trailing NULs in cam_strvis.

cam_xpt.c:
Nuke an experimental quirk entry for the Toshiba 3401. The real
problem with this device turned out to be a bug in the aic7xxx
driver that was fixed months ago.

Add a quirk entry to inhibit multiple lun scanning and serial number
probing of DPT RAID volumes. My DPT controller hangs up solid when
I do either of these things to a RAID 1 volume.


39531 20-Sep-1998 ken

Some fixes to the CD driver that may fix PR kern/7996. The data direction
flags on some of the operations in the driver weren't quite right. Also,
clean up scsi_cd.h, change u_char to u_int8_t.

I'm surprised this problem didn't show up sooner. (the code has been in
there almost a year and a half)

PR: 7996
Reviewed by: ken
Submitted (mostly) by: gibbs


39514 20-Sep-1998 gibbs

Don't invalidate devices due to unexpected unit attention errors. In
a perfect world, we'd notice the UA and do some device validation to ensure
that the device hasn't changed. We may get this before the year ends,
but not before 3.0R. This change gives the adminstrator ample ammunition
to take off a foot or two, but hey this *is* UN*X.


39513 20-Sep-1998 gibbs

cam_xpt.c:
Add quirk entry for a Samsung drive that doesn't like experiencing
the queue full condition.

Bump the timeouts for all probe activities to 60s. We don't know
what the seletion timeout (or equivelent on other mediums) is
for controllers, which can make the transactions at the tail
end of a parallel probe take a while to complete. The DPT
seems to be a card that takes a long time to see a selection timeout.

cam_periph.c:
Don't call a device "gone" after a single selection timeout. We
need to come up with a better policy. Until that time, you'll
have to manually re-scan a bus via camcontrol for the system to
decide that a device is really gone. This should give devices
experiencing temporary insanity to escape death.


39504 20-Sep-1998 gibbs

Only deregister out configuration hook manually if there are no SCSI
busses to configure.


39477 19-Sep-1998 gibbs

Don't leave the device queue in a frozen state if the Synchronize Cache
command on close fails.


39471 19-Sep-1998 ken

Fix error recovery in scsi_interpret_sense(). It turns out that ERESTART
wasn't getting sent back for most errors, even if there were retries left
on the command. I'm not sure how I ever let this slip by before...

In any case, we now send back ERESTART if there are retries left for the
command, and send back the default error code when there are no retries
left.

Reviewed by: gibbs


39466 18-Sep-1998 ken

Fix the CAM code so that people can compile kernels with the CD driver but
without the DA driver.

The problem was that the CD driver depended on scsi_read_write() and
scsi_start_stop(), which were defined in scsi_da.c.

I moved both functions, and their associated data structures and defines
from scsi_da.* to scsi_all.*. This is technically the "wrong" thing to do
since those commands are really only for direct-access type devices, not
for all SCSI devices. I think, though, that the advantage (allowing people
to compile kernels without the disk driver) outweighs any architectural
purity arguments.

PR: kern/7969
Reviewed by: gibbs


39460 18-Sep-1998 ken

Change the Atlas II quirk entries so they work with differential Atlas
II's. Also, add a quirk entry for the 2 gig Atlas II.

Partially Submitted by: Ted Buswell <tbuswell@mediaone.net>


39442 17-Sep-1998 ken

Fix a formatting error.

Fix a problem reported by bde: setting SCSI_DELAY to 0 doesn't work. Now,
when the user sets SCSI_DELAY to 0, we re-set it to the minimum allowable
bus settle delay (100ms).

Fix a potential panic in xptfinishconfigfunc() if the CCB passed in is
NULL. Reported by, I think, Nicolas Souchu. Fix a memory leak in the same
function (we created a path, but didn't free it) by allocating the getdev
CCB and path on the stack.

Reviewed by: gibbs


39388 16-Sep-1998 ken

Some Alpha patches for CAM from Doug Rabson.

Reviewed by: gibbs
Submitted by: dfr


39360 16-Sep-1998 gibbs

Properly allocate our, per lun, probe peripheral softc from
the TEMP malloc pool.

Noticed by: Don Lewis <Don.Lewis@tsc.tdk.com>


39317 16-Sep-1998 ken

Check to make sure that this device is opened read-write, not just read
only. Previously, if the device was chmoded 644, someone could open it
with the O_RDONLY flag and issue any ioctl to the device.

Reviewed by: imp, gibbs


39310 15-Sep-1998 gibbs

Correct printf format bugs.


39213 15-Sep-1998 gibbs

SCSI Peripheral drivers for CAM:

da - Direct Access Devices (disks, optical devices, SS disks)
cd - CDROM (or devices that can act like them, WORM, CD-RW, etc)
ch - Medium Changer devices.
sa - Sequential Access Devices (tape drives)
pass - Application pass-thru driver
targ - Target Mode "Processor Target" Emulator
pt - Processor Target Devices (scanners, cpus, etc.)

Submitted by: The CAM Team


39212 15-Sep-1998 gibbs

CAM Transport Layer (XPT).

Submitted by: The CAM Team