svn commit: r368525 - in head: lib/libmt usr.bin/mt

2020-12-10 Thread Kenneth D. Merry
Author: ken
Date: Thu Dec 10 21:06:06 2020
New Revision: 368525
URL: https://svnweb.freebsd.org/changeset/base/368525

Log:
  Add the LTO-9 density code to libmt and the mt(1) man page.
  
  These values are taken directly from the density report from an
  IBM LTO-9 tape drive.  (Using mt getdensity)
  
  A LTO-9 drive stores 18TB raw (45TB with compression) on an LTO-9 tape.
  
  lib/libmt/mtlib.c:
  Add the LTO-9 density code, and bpmm/bpi values.
  
  usr.bin/mt/mt.1:
  Add the LTO-9 density code, bpmm/bpi values and number of
tracks.  Bump the man page date.
  
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/lib/libmt/mtlib.c
  head/usr.bin/mt/mt.1

Modified: head/lib/libmt/mtlib.c
==
--- head/lib/libmt/mtlib.c  Thu Dec 10 20:45:08 2020(r368524)
+++ head/lib/libmt/mtlib.c  Thu Dec 10 21:06:06 2020(r368525)
@@ -648,6 +648,7 @@ static struct densities {
{ 0x5C, 19107,  485318, "LTO-7" },
{ 0x5D, 19107,  485318, "LTO-M8" },
{ 0x5E, 20669,  524993, "LTO-8" },
+   { 0x60, 23031,  584987, "LTO-9" },
{ 0x71, 11800,  299720, "3592A1 (encrypted)" },
{ 0x72, 11800,  299720, "3592A2 (encrypted)" },
{ 0x73, 13452,  341681, "3592A3 (encrypted)" },

Modified: head/usr.bin/mt/mt.1
==
--- head/usr.bin/mt/mt.1Thu Dec 10 20:45:08 2020(r368524)
+++ head/usr.bin/mt/mt.1Thu Dec 10 21:06:06 2020(r368525)
@@ -29,7 +29,7 @@
 .\"@(#)mt.18.1 (Berkeley) 6/6/93
 .\" $FreeBSD$
 .\"
-.Dd March 4, 2019
+.Dd December 10, 2020
 .Dt MT 1
 .Os
 .Sh NAME
@@ -525,6 +525,7 @@ Value  WidthTracksDensity Code Typ
 0x5C   12.7  (0.5) 3584  19,107 (485,318)   C   LTO-7
 0x5D   12.7  (0.5) 5376  19,107 (485,318)   C   LTO-M8   14
 0x5E   12.7  (0.5) 6656  20,669 (524,993)   C   LTO-8
+0x60   12.7  (0.5) 8960  23,031 (584,987)   C   LTO-9
 0x71   12.7  (0.5)  512  11,800 (299,720)   C   3592A1 (encrypted)
 0x72   12.7  (0.5)  896  11,800 (299,720)   C   3592A2 (encrypted)
 0x73   12.7  (0.5) 1152  13,452 (341,681)   C   3592A3 (encrypted)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r363260 - head/sys/cam

2020-07-16 Thread Kenneth D. Merry
Author: ken
Date: Thu Jul 16 20:43:28 2020
New Revision: 363260
URL: https://svnweb.freebsd.org/changeset/base/363260

Log:
  Hold the mutex when releasing a callout.
  
  In xpt_release_device(), callout_stop() was being called without
  holding the mutex (send_mtx) that is used to protect the callout.
  
  So, move the mtx_unlock() call so that it is protected.
  
  MFC after:1 week
  Sponsored by: Spectra Logic

Modified:
  head/sys/cam/cam_xpt.c

Modified: head/sys/cam/cam_xpt.c
==
--- head/sys/cam/cam_xpt.c  Thu Jul 16 20:36:22 2020(r363259)
+++ head/sys/cam/cam_xpt.c  Thu Jul 16 20:43:28 2020(r363260)
@@ -4959,15 +4959,17 @@ xpt_release_device(struct cam_ed *device)
devq = bus->sim->devq;
mtx_lock(>send_mtx);
cam_devq_resize(devq, devq->send_queue.array_size - 1);
-   mtx_unlock(>send_mtx);
 
KASSERT(SLIST_EMPTY(>periphs),
("destroying device, but periphs list is not empty"));
KASSERT(device->devq_entry.index == CAM_UNQUEUED_INDEX,
("destroying device while still queued for ccbs"));
 
+   /* The send_mtx must be held when accessing the callout */
if ((device->flags & CAM_DEV_REL_TIMEOUT_PENDING) != 0)
callout_stop(>callout);
+
+   mtx_unlock(>send_mtx);
 
xpt_release_target(device->target);
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r355299 - head/sys/cam/scsi

2019-12-02 Thread Kenneth D. Merry
Author: ken
Date: Mon Dec  2 19:57:39 2019
New Revision: 355299
URL: https://svnweb.freebsd.org/changeset/base/355299

Log:
  Fix a hang introduced in r351599.
  
  My changes in 351599 (kindly committed by avg) made the cd(4) media check
  asynchronous to avoid a sleep while holding a mutex.
  
  There was a difficult to reproduce bug with those changes that caused a
  hang on boot on some single processor machines/VMs.  Leandro Lupori
  managed to reproduce the bug, diagnose it, and supplied a patch!  Here is
  his analysis, from the PR:
  
  ==
  I was able to reproduce the problem described in comment#14.
  
  Actually, I wasn't trying to reproduce it, I just started seeing it a few
  weeks ago, in CURRENT.
  
  I can reproduce it consistently, by using QEMU to run a PowerPC64 VM with a
  single core/thread (-smp 1).
  
  It happens only when there is no media in the emulated CD-ROM, a device
  that QEMU adds by default, unless -nodefaults is specified in command line.
  
  I've debugged it and this is what I've found:
  
  1- After the CD probe is successful, GEOM will try to open the device,
  which will end up calling cdcheckmedia(), that sets CD state to
  CD_STATE_MEDIA_PREVENT.
  2- Next, scsi_prevent() is executed and succeeds, the CD_FLAG_DISC_LOCKED
  flag is set and CD state moves to CD_STATE_MEDIA_SIZE.
  3- Next, scsi_read_capacity() is executed and fails, state is set to
  CD_STATE_MEDIA_ALLOW, cdmediaprobedone() is called and wakes up
  cdcheckmedia().
  4- Then, when cdstart() is invoked to process CD_STATE_MEDIA_ALLOW, it
  first checks if CD_FLAG_DISC_LOCKED is set, and if so skips directly to
  CD_STATE_MEDIA_SIZE state. This will repeat the steps of bullet 3, entering
  an infinite MEDIA_SIZE command loop.
  
  When there is a least another core/thread, the GEOM thread that performed
  the initial cdopen() will get scheduled again, closing the CD device, that
  will call cdprevent(PR_ALLOW) that clears the CD_FLAG_DISC_LOCKED flag and
  breaks the loop.
  
  So, apparently, the problem is CD_STATE_MEDIA_ALLOW being skipped when
  CD_FLAG_DISC_LOCKED is set. If I understand correctly, in this case, the
  state should be advanced to CD_STATE_MEDIA size only when the current state
  is CD_STATE_MEDIA_PREVENT.
  =
  
  PR:   kern/219857
  Submitted by: Leandro Lupori 
  MFC after:1 week

Modified:
  head/sys/cam/scsi/scsi_cd.c

Modified: head/sys/cam/scsi/scsi_cd.c
==
--- head/sys/cam/scsi/scsi_cd.c Mon Dec  2 19:57:20 2019(r355298)
+++ head/sys/cam/scsi/scsi_cd.c Mon Dec  2 19:57:39 2019(r355299)
@@ -1032,7 +1032,8 @@ cdstart(struct cam_periph *periph, union ccb *start_cc
 * If the CD is already locked, we don't need to do this.
 * Move on to the capacity check.
 */
-   if ((softc->flags & CD_FLAG_DISC_LOCKED) != 0) {
+   if (softc->state == CD_STATE_MEDIA_PREVENT
+&& (softc->flags & CD_FLAG_DISC_LOCKED) != 0) {
softc->state = CD_STATE_MEDIA_SIZE;
xpt_release_ccb(start_ccb);
xpt_schedule(periph, CAM_PRIORITY_NORMAL);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r348247 - head/sys/dev/isp

2019-05-24 Thread Kenneth D. Merry
Author: ken
Date: Fri May 24 17:58:29 2019
New Revision: 348247
URL: https://svnweb.freebsd.org/changeset/base/348247

Log:
  Fix FC-Tape bugs caused in part by r345008.
  
  The point of r345008 was to reset the Command Reference Number (CRN)
  in some situations where a device stayed in the topology, but had
  changed somehow.
  
  This can include moving from a switch connection to a direct
  connection or vice versa, or a device that temporarily goes away
  and comes back.  (e.g. moving to a different switch port)
  
  There were a couple of bugs in that change:
  - We were reporting that a device had not changed whenever the
Establish Image Pair bit was not set.  That is not quite correct.
Instead, if the Establish Image Pair bit stays the same (set or
not), the device hasn't changed in that way.
  
  - We weren't setting PRLI Word0 in the port database when a new
device arrived, so comparisons with the old value for the
Establish Image Pair bit weren't really possible.  So, make sure
PRLI Word0 is set in the port database for new devices.
  
  - We were resetting the CRN whenever the Establish Image Pair bit
was set for a device, even when the device had stayed the same
and the value of the bit hadn't changed.  Now, only reset the
CRN for devices that have changed, not devices that sayed the
same.
  
  The result of all of this was that if we had a single FC device on
  an FC port and it went away and came back, we would wind up
  correctly resetting the CRN.
  
  But, if we had multiple devices connected via a switch, and there
  was any change in one or more of those devices, all of the devices
  that stayed the same would also have their CRN values reset.
  
  The result, from a user standpoint, is that the tape drives, etc.
  would all start to time out commands and the initiator would send
  aborts.
  
  sys/dev/isp/isp.c:
In isp_pdb_add_update(), look at whether the Establish
Image Pair bit has changed as part of the check to
determine whether a device is still the same.   This was
causing erroneous change notifications.  Also, when
creating a new port database entry, initialize the
PRLI Word 0 values.
  
  sys/dev/isp/isp_freebsd.c:
In isp_async(), in the changed/stayed case, instead of
looking at the Establish Image Pair bit to determine
whether to reset the CRN, look at the command value.
(Changed vs. Stayed.)  Only reset the CRN for devices
that have changed.
  
  Sponsored by: Spectra Logic
  MFC after:3 days

Modified:
  head/sys/dev/isp/isp.c
  head/sys/dev/isp/isp_freebsd.c

Modified: head/sys/dev/isp/isp.c
==
--- head/sys/dev/isp/isp.c  Fri May 24 17:19:06 2019(r348246)
+++ head/sys/dev/isp/isp.c  Fri May 24 17:58:29 2019(r348247)
@@ -3251,7 +3251,8 @@ isp_pdb_add_update(ispsoftc_t *isp, int chan, isp_pdb_
if (lp->portid == pdb->portid &&
lp->handle == pdb->handle &&
lp->prli_word3 == pdb->prli_word3 &&
-   ((pdb->prli_word0 & PRLI_WD0_EST_IMAGE_PAIR) == 0)) {
+   ((pdb->prli_word0 & PRLI_WD0_EST_IMAGE_PAIR) ==
+(lp->prli_word0 & PRLI_WD0_EST_IMAGE_PAIR))) {
if (lp->state != FC_PORTDB_STATE_NEW)
lp->state = FC_PORTDB_STATE_VALID;
isp_prt(isp, ISP_LOG_SANCFG,
@@ -3282,6 +3283,7 @@ isp_pdb_add_update(ispsoftc_t *isp, int chan, isp_pdb_
lp->probational = 0;
lp->state = FC_PORTDB_STATE_NEW;
lp->portid = lp->new_portid = pdb->portid;
+   lp->prli_word0 = lp->new_prli_word0 = pdb->prli_word0;
lp->prli_word3 = lp->new_prli_word3 = pdb->prli_word3;
lp->handle = pdb->handle;
lp->port_wwn = wwpn;

Modified: head/sys/dev/isp/isp_freebsd.c
==
--- head/sys/dev/isp/isp_freebsd.c  Fri May 24 17:19:06 2019
(r348246)
+++ head/sys/dev/isp/isp_freebsd.c  Fri May 24 17:58:29 2019
(r348247)
@@ -3789,7 +3789,7 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
xpt_async(AC_CONTRACT, fc->path, );
}
 
-   if ((lp->new_prli_word0 & PRLI_WD0_EST_IMAGE_PAIR) &&
+   if ((cmd == ISPASYNC_DEV_CHANGED) &&
(crn_reset_done == 0))
isp_fcp_reset_crn(isp, bus, tgt, /*tgt_set*/ 1);
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r345008 - head/sys/dev/isp

2019-03-11 Thread Kenneth D. Merry
Author: ken
Date: Mon Mar 11 14:21:14 2019
New Revision: 345008
URL: https://svnweb.freebsd.org/changeset/base/345008

Log:
  Fix CRN resets in the isp(4) driver in certain situations.
  
  The Command Reference Number (CRN) is part of the FC-Tape features
  that we enable when talking to tape drives.  It starts at 1, and
  goes to 255 and wraps around to 1.  There are a number of reset
  type conditions that result in the CRN getting reset to 1.  These
  are detailed in section 4.10 (table 8) of the FCP-4r02b specification.
  
  One of the conditions is when a PRLI (Process Login) is sent by
  the initiator, and the Establish Image Pair bit is set in Word 0
  of the PRLI.
  
  Previously, the isp(4) driver core sent a notification via
  isp_async() that the target had changed or stayed in place, but
  there was no indication of whether a PRLI was sent and whether the
  Establish Image Pair bit was set.
  
  The result of this was that in some situations, notably
  switching back and forth between a direct connection and a switch
  connection to a tape drive, the isp(4) driver would fail to reset
  the CRN in situations that require it according to the spec.  When
  the CRN isn't reset in a situation that requires it, the tape drive
  then rejects every subsequent command that is sent to the drive.
  It is assuming that the commands are being sent out of order.
  
  So, modify the isp(4) driver to include Word 0 of the PRLI command
  when it sends isp_async() notifications of target changes.  Look at
  the Establish Image Pair bit, and reset the CRN if that bit is set.
  
  With this change, I am able to switch a tape drive back and forth
  between a direct connection and a switch connection, and the isp(4)
  driver resets the CRN when it should.
  
  sys/dev/isp_stds.h:
Add bit definitions for PRLI Word 0.
  
  sys/dev/ispmbox.h:
Add PRLI Word 0 to the port database type, isp_pdb_t.
  
  sys/dev/ispvar.h
Add PRLI Word 0 to fcportdb_t.
  
  sys/dev/isp.c:
Populate the new prli_word0 parameter in the port database.
  
In isp_pdb_add_update(), add a check to see if the
Establish Image Pair bit is set in PRLI Word 0.  If it is,
then that is an additional reason to create a change
notification.
  
  sys/dev/isp_freebsd.c:
In isp_async(), if the device changed or stayed, look at
PRLI Word 0 to see if the Establish Image Pair bit is set.
If it is, reset the CRN if we haven't already.
  
  MFC after:1 week
  Sponsored by: Spectra Logic
  Differential Revision:https://reviews.freebsd.org/D19472

Modified:
  head/sys/dev/isp/isp.c
  head/sys/dev/isp/isp_freebsd.c
  head/sys/dev/isp/isp_stds.h
  head/sys/dev/isp/ispmbox.h
  head/sys/dev/isp/ispvar.h

Modified: head/sys/dev/isp/isp.c
==
--- head/sys/dev/isp/isp.c  Mon Mar 11 13:56:51 2019(r345007)
+++ head/sys/dev/isp/isp.c  Mon Mar 11 14:21:14 2019(r345008)
@@ -2791,6 +2791,7 @@ isp_getpdb(ispsoftc_t *isp, int chan, uint16_t id, isp
if (IS_24XX(isp)) {
isp_get_pdb_24xx(isp, isp->isp_iocb, );
pdb->handle = un.bill.pdb_handle;
+   pdb->prli_word0 = un.bill.pdb_prli_svc0;
pdb->prli_word3 = un.bill.pdb_prli_svc3;
pdb->portid = BITS2WORD_24XX(un.bill.pdb_portid_bits);
ISP_MEMCPY(pdb->portname, un.bill.pdb_portname, 8);
@@ -2807,6 +2808,7 @@ isp_getpdb(ispsoftc_t *isp, int chan, uint16_t id, isp
} else {
isp_get_pdb_21xx(isp, isp->isp_iocb, );
pdb->handle = un.fred.pdb_loopid;
+   pdb->prli_word0 = un.fred.pdb_prli_svc0;
pdb->prli_word3 = un.fred.pdb_prli_svc3;
pdb->portid = BITS2WORD(un.fred.pdb_portid_bits);
ISP_MEMCPY(pdb->portname, un.fred.pdb_portname, 8);
@@ -3196,6 +3198,7 @@ isp_pdb_sync(ispsoftc_t *isp, int chan)
lp->state = FC_PORTDB_STATE_VALID;
isp_async(isp, ISPASYNC_DEV_CHANGED, chan, lp);
lp->portid = lp->new_portid;
+   lp->prli_word0 = lp->new_prli_word0;
lp->prli_word3 = lp->new_prli_word3;
break;
case FC_PORTDB_STATE_VALID:
@@ -3247,7 +3250,8 @@ isp_pdb_add_update(ispsoftc_t *isp, int chan, isp_pdb_
/* Old device, nothing new. */
if (lp->portid == pdb->portid &&
lp->handle == pdb->handle &&
-   lp->prli_word3 == pdb->prli_word3) {
+   lp->prli_word3 == pdb->prli_word3 &&
+   ((pdb->prli_word0 & PRLI_WD0_EST_IMAGE_PAIR) == 0)) {
if (lp->state != FC_PORTDB_STATE_NEW)
lp->state = FC_PORTDB_STATE_VALID;
isp_prt(isp, ISP_LOG_SANCFG,
@@ 

svn commit: r344761 - in head: lib/libmt usr.bin/mt

2019-03-04 Thread Kenneth D. Merry
Author: ken
Date: Mon Mar  4 14:30:37 2019
New Revision: 344761
URL: https://svnweb.freebsd.org/changeset/base/344761

Log:
  Add IBM TS1160 density codes to libmt and the mt(1) man page.
  
  These are taken directly from the density report from a TS1160
  tape drive.  (Using mt getdensity)
  
  A TS1160 drive stores 20TB raw (60TB with compression) on a JE tape.
  
  lib/libmt/mtlib.c:
Add 3592A6 encrypted/unencrypted density codes, and bpmm/bpi
values.
  
  usr.bin/mt/mt.1:
Add 3592B5 encrypted/unencrypted density codes, bpmm/bpi
values and number of tracks.  Bump the man page date.
  
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/lib/libmt/mtlib.c
  head/usr.bin/mt/mt.1

Modified: head/lib/libmt/mtlib.c
==
--- head/lib/libmt/mtlib.c  Mon Mar  4 13:18:04 2019(r344760)
+++ head/lib/libmt/mtlib.c  Mon Mar  4 14:30:37 2019(r344761)
@@ -642,6 +642,7 @@ static struct densities {
{ 0x54, 19686,  500024, "3592A4 (unencrypted)" },
{ 0x55, 20670,  525018, "3592A5 (unencrypted)" },
{ 0x56, 20670,  525018, "3592B5 (unencrypted)" },
+   { 0x57, 21850,  554990, "3592A6 (unencrypted)" },
{ 0x58, 15142,  384607, "LTO-5" },
{ 0x5A, 15142,  384607, "LTO-6" },
{ 0x5C, 19107,  485318, "LTO-7" },
@@ -653,6 +654,7 @@ static struct densities {
{ 0x74, 19686,  500024, "3592A4 (encrypted)" },
{ 0x75, 20670,  525018, "3592A5 (encrypted)" },
{ 0x76, 20670,  525018, "3592B5 (encrypted)" },
+   { 0x77, 21850,  554990, "3592A6 (encrypted)" },
{ 0x8c,  1789,   45434, "EXB-8500c" },
{ 0x90,  1703,   43245, "EXB-8200c" },
{ 0, 0, 0, NULL }

Modified: head/usr.bin/mt/mt.1
==
--- head/usr.bin/mt/mt.1Mon Mar  4 13:18:04 2019(r344760)
+++ head/usr.bin/mt/mt.1Mon Mar  4 14:30:37 2019(r344761)
@@ -29,7 +29,7 @@
 .\"@(#)mt.18.1 (Berkeley) 6/6/93
 .\" $FreeBSD$
 .\"
-.Dd November 3, 2017
+.Dd March 4, 2019
 .Dt MT 1
 .Os
 .Sh NAME
@@ -519,6 +519,7 @@ Value  WidthTracksDensity Code Typ
 0x54   12.7  (0.5) 2560  19,686 (500,024)   C   3592A4 (unencrypted)
 0x55   12.7  (0.5) 5120  20,670 (525,018)   C   3592A5 (unencrypted)
 0x56   12.7  (0.5) 7680  20,670 (525,018)   C   3592B5 (unencrypted)
+0x57   12.7  (0.5) 8704  21,850 (554,990)   C   3592A6 (unencrypted)
 0x58   12.7  (0.5) 1280  15,142 (384,607)   C   LTO-5
 0x5A   12.7  (0.5) 2176  15,142 (384,607)   C   LTO-6
 0x5C   12.7  (0.5) 3584  19,107 (485,318)   C   LTO-7
@@ -530,6 +531,7 @@ Value  WidthTracksDensity Code Typ
 0x74   12.7  (0.5) 2560  19,686 (500,024)   C   3592A4 (encrypted)
 0x75   12.7  (0.5) 5120  20,670 (525,018)   C   3592A5 (encrypted)
 0x76   12.7  (0.5) 7680  20,670 (525,018)   C   3592B5 (encrypted)
+0x77   12.7  (0.5) 8704  21,850 (554,990)   C   3592A6 (encrypted)
 0x8c8.0  (0.315)  1  1,789  (45,434)  RLL   CS  EXB-8500c5,9
 0x908.0  (0.315)  1  1,703  (43,245)  RLL   CS  EXB-8200c5,9
 .Ed
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r339076 - head/sys/cam/scsi

2018-10-01 Thread Kenneth D. Merry
Author: ken
Date: Mon Oct  1 19:00:46 2018
New Revision: 339076
URL: https://svnweb.freebsd.org/changeset/base/339076

Log:
  Fix a da(4) driver memory leak for SCSI SMR devices.
  
  In the probe case for SCSI SMR Host Aware or Most Managed drives, be sure
  to free allocated memory.
  
  sys/cam/scsi/scsi_da.c:
In dadone_probezone(), free the data pointer before returning.
  
  MFC after:3 days
  Sponsored by: Spectra Logic
  Approved by:  re (kib)

Modified:
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/scsi/scsi_da.c
==
--- head/sys/cam/scsi/scsi_da.c Mon Oct  1 18:51:39 2018(r339075)
+++ head/sys/cam/scsi/scsi_da.c Mon Oct  1 19:00:46 2018(r339076)
@@ -5674,6 +5674,9 @@ dadone_probezone(struct cam_periph *periph, union ccb 
}
}
}
+
+   free(csio->data_ptr, M_SCSIDA);
+
daprobedone(periph, done_ccb);
return;
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r335154 - head/sys/cam/scsi

2018-06-14 Thread Kenneth D. Merry
Author: ken
Date: Thu Jun 14 17:08:44 2018
New Revision: 335154
URL: https://svnweb.freebsd.org/changeset/base/335154

Log:
  Fix da(4) locking when probing SMR drives.
  
  Probing host aware and host managed SMR drives got broken in revision
  330796.
  
  The added cam_periph_lock() calls were in areas in dadone() where
  the peripheral lock was already held.
  
  Since then, dadone() has been split into separate functions that are
  dedicated to each probe state.
  
  The result is that when probing a host aware drive, I ran into a recursive
  lock acquisition in dadone_probeatalogdir(). I would have run into the
  same problem in dadone_probeataiddir(), and in dadone_probeatasup() and
  dadone_probeatazone() in the error paths had the probe continued.
  
  The solution is to take out all of the extra cam_periph_lock() calls. I
  also added cam_periph_assert(periph, MA_OWNED) near the top of each of
  the dadone_* calls. These make it clear to anyone coming along in the
  the future that the lock is held in the probe done functions.
  
  Also add a locking assert in daprobedone(), to make it clear that it must
  be called with the periph lock held.
  
  Sponsored by: Spectra Logic
  Differential Revision:https://reviews.freebsd.org/D15764

Modified:
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/scsi/scsi_da.c
==
--- head/sys/cam/scsi/scsi_da.c Thu Jun 14 17:06:19 2018(r335153)
+++ head/sys/cam/scsi/scsi_da.c Thu Jun 14 17:08:44 2018(r335154)
@@ -2428,6 +2428,8 @@ daprobedone(struct cam_periph *periph, union ccb *ccb)
 
softc = (struct da_softc *)periph->softc;
 
+   cam_periph_assert(periph, MA_OWNED);
+
dadeletemethodchoose(softc, DA_DELETE_NONE);
 
if (bootverbose && (softc->flags & DA_FLAG_ANNOUNCED) == 0) {
@@ -4505,6 +4507,8 @@ dadone_probewp(struct cam_periph *periph, union ccb *d
priority = done_ccb->ccb_h.pinfo.priority;
csio = _ccb->csio;
 
+   cam_periph_assert(periph, MA_OWNED);
+
if (softc->minimum_cmd_size > 6) {
mode_hdr10 = (struct scsi_mode_header_10 *)csio->data_ptr;
dev_spec = mode_hdr10->dev_spec;
@@ -4578,6 +4582,8 @@ dadone_proberc(struct cam_periph *periph, union ccb *d
rcaplong = (struct scsi_read_capacity_data_long *)
csio->data_ptr;
 
+   cam_periph_assert(periph, MA_OWNED);
+
if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
struct disk_params *dp;
uint32_t block_size;
@@ -4835,6 +4841,8 @@ dadone_probelbp(struct cam_periph *periph, union ccb *
csio = _ccb->csio;
lbp = (struct scsi_vpd_logical_block_prov *)csio->data_ptr;
 
+   cam_periph_assert(periph, MA_OWNED);
+
if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
/*
 * T10/1799-D Revision 31 states at least one of these
@@ -4891,6 +4899,8 @@ dadone_probeblklimits(struct cam_periph *periph, union
csio = _ccb->csio;
block_limits = (struct scsi_vpd_block_limits *)csio->data_ptr;
 
+   cam_periph_assert(periph, MA_OWNED);
+
if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
uint32_t max_txfer_len = scsi_4btoul(
block_limits->max_txfer_len);
@@ -4983,6 +4993,8 @@ dadone_probebdc(struct cam_periph *periph, union ccb *
csio = _ccb->csio;
bdc = (struct scsi_vpd_block_device_characteristics *)csio->data_ptr;
 
+   cam_periph_assert(periph, MA_OWNED);
+
if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
uint32_t valid_len;
 
@@ -5088,6 +5100,8 @@ dadone_probeata(struct cam_periph *periph, union ccb *
continue_probe = 0;
error = 0;
 
+   cam_periph_assert(periph, MA_OWNED);
+
if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
uint16_t old_rate;
 
@@ -5223,7 +5237,7 @@ dadone_probeatalogdir(struct cam_periph *periph, union
priority = done_ccb->ccb_h.pinfo.priority;
csio = _ccb->csio;
 
-   cam_periph_lock(periph);
+   cam_periph_assert(periph, MA_OWNED);
if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
error = 0;
softc->valid_logdir_len = 0;
@@ -5276,7 +5290,6 @@ dadone_probeatalogdir(struct cam_periph *periph, union
}
}
}
-   cam_periph_unlock(periph);
 
free(csio->data_ptr, M_SCSIDA);
 
@@ -5305,7 +5318,8 @@ dadone_probeataiddir(struct cam_periph *periph, union 
priority = done_ccb->ccb_h.pinfo.priority;
csio = _ccb->csio;
 
-   cam_periph_lock(periph);
+   cam_periph_assert(periph, MA_OWNED);
+
if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
off_t entries_offset, max_entries;
error = 0;

svn commit: r333492 - head/sys/dev/ocs_fc

2018-05-11 Thread Kenneth D. Merry
Author: ken
Date: Fri May 11 14:50:26 2018
New Revision: 333492
URL: https://svnweb.freebsd.org/changeset/base/333492

Log:
  Clear out the entire structure, not just the size of a pointer to it.
  
  sys/dev/ocs/ocs_os.c:
In ocs_thread_create(), use sizeof(*thread) (instead of
sizeof(thread)) as the size argument to memset so that we clear
out the entire thread structure instead of just a few bytes of it.
  
  Submitted by: jtl
  MFC after:3 days

Modified:
  head/sys/dev/ocs_fc/ocs_os.c

Modified: head/sys/dev/ocs_fc/ocs_os.c
==
--- head/sys/dev/ocs_fc/ocs_os.cFri May 11 14:43:21 2018
(r333491)
+++ head/sys/dev/ocs_fc/ocs_os.cFri May 11 14:50:26 2018
(r333492)
@@ -630,7 +630,7 @@ ocs_thread_create(ocs_os_handle_t os, ocs_thread_t *th
 {
int32_t rc = 0;
 
-   ocs_memset(thread, 0, sizeof(thread));
+   ocs_memset(thread, 0, sizeof(*thread));
 
thread->fctn = fctn;
thread->name = ocs_strdup(name);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332458 - head/sys/cam/scsi

2018-04-12 Thread Kenneth D. Merry
Author: ken
Date: Thu Apr 12 21:21:18 2018
New Revision: 332458
URL: https://svnweb.freebsd.org/changeset/base/332458

Log:
  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 
  Tested by:Dr. Andreas Haakh 
  Sponsored by: Spectra Logic
  MFC after:3 days

Modified:
  head/sys/cam/scsi/scsi_sa.c

Modified: head/sys/cam/scsi/scsi_sa.c
==
--- head/sys/cam/scsi/scsi_sa.c Thu Apr 12 21:13:30 2018(r332457)
+++ head/sys/cam/scsi/scsi_sa.c Thu Apr 12 21:21:18 2018(r332458)
@@ -3453,12 +3453,13 @@ saerror(union ccb *ccb, u_int32_t cflgs, u_int32_t sfl
break;
}
/*
-* If this was just EOM/EOP, Filemark, Setmark or ILI detected
-* on a non read/write command, we assume it's not an error
-* and propagate the residule and return.
+* If this was just EOM/EOP, Filemark, Setmark, ILI or
+* PEW detected on a non read/write command, we assume
+* it's not an error and propagate the residual and return.
 */
-   if ((aqvalid && asc == 0 && ascq > 0 && ascq <= 5) ||
-   (aqvalid == 0 && sense_key == SSD_KEY_NO_SENSE)) {
+   if ((aqvalid && asc == 0 && ((ascq > 0 && ascq <= 5)
+ || (ascq == 0x07)))
+|| (aqvalid == 0 && sense_key == SSD_KEY_NO_SENSE)) {
csio->resid = resid;
QFRLS(ccb);
return (0);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r332386 - head/share/misc

2018-04-11 Thread Kenneth D. Merry
On Tue, Apr 10, 2018 at 14:27:26 -0500, Kyle Evans wrote:
> On Tue, Apr 10, 2018 at 2:22 PM, Rodney W. Grimes
>  wrote:
> > [ Charset UTF-8 unsupported, converting... ]
> >> Author: ram
> >> Date: Tue Apr 10 18:39:20 2018
> >> New Revision: 332386
> >> URL: https://svnweb.freebsd.org/changeset/base/332386
> >>
> >> Log:
> >>   Updated mentors information.
> >>
> >>   Approved by: ken, mav
> >>
> >> Modified:
> >>   head/share/misc/committers-src.dot
> >>
> >> Modified: head/share/misc/committers-src.dot
> >> ==
> >> --- head/share/misc/committers-src.dotTue Apr 10 18:05:02 2018 
> >>(r332385)
> >> +++ head/share/misc/committers-src.dotTue Apr 10 18:39:20 2018 
> >>(r332386)
> >> @@ -76,6 +76,7 @@ nate [label="Nate Willams\nn...@freebsd.org\n1993/06/1
> >>  njl [label="Nate Lawson\n...@freebsd.org\n2002/08/07\n2008/02/16"]
> >>  non [label="Noriaki Mitsnaga\n...@freebsd.org\n2000/06/19\n2007/03/06"]
> >>  onoe [label="Atsushi Onoe\no...@freebsd.org\n2000/07/21\n2008/11/10"]
> >> +ram [label="Ram Kishore Vegesna\n...@freebsd.org\n2018/04/04\n???/??/??"]
> >  ^
> > That should be removed, you only have a start date.
> > Oh and Welcome ram to the project!
> >
> 
> The entry is also smack dab in the middle of the alumni section,
> rather than the later 'active' section. =)

Oops.  My fault for not paying attention. :(

Pointy hat to:  ken

Ram, could you fix this and send me the diffs for approval before you
commit it?

Thanks,

Ken
-- 
Kenneth Merry
k...@freebsd.org
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331766 - in head: share/man/man4 sys/amd64/conf sys/conf sys/dev/ocs_fc sys/modules sys/modules/ocs_fc

2018-03-30 Thread Kenneth D. Merry
Author: ken
Date: Fri Mar 30 15:28:25 2018
New Revision: 331766
URL: https://svnweb.freebsd.org/changeset/base/331766

Log:
  Bring in the Broadcom/Emulex Fibre Channel driver, ocs_fc(4).
  
  The ocs_fc(4) driver supports the following hardware:
  
  Emulex 16/8G FC GEN 5 HBAS
LPe15004 FC Host Bus Adapters
LPe160XX FC Host Bus Adapters
  
  Emulex 32/16G FC GEN 6 HBAS
LPe3100X FC Host Bus Adapters
LPe3200X FC Host Bus Adapters
  
  The driver supports target and initiator mode, and also supports FC-Tape.
  
  Note that the driver only currently works on little endian platforms.  It
  is only included in the module build for amd64 and i386, and in GENERIC
  on amd64 only.
  
  Submitted by: Ram Kishore Vegesna 
  Reviewed by:  mav
  MFC after:5 days
  Relnotes: yes
  Sponsored by: Broadcom
  Differential Revision:https://reviews.freebsd.org/D11423

Added:
  head/share/man/man4/ocs_fc.4   (contents, props changed)
  head/sys/dev/ocs_fc/
  head/sys/dev/ocs_fc/ocs.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_cam.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_cam.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_common.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_ddump.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_ddump.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_device.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_device.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_domain.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_domain.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_drv_fc.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_els.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_els.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_fabric.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_fabric.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_fcp.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_hw.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_hw.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_hw_queues.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_hw_queues.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_io.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_io.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_ioctl.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_ioctl.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_list.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_mgmt.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_mgmt.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_node.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_node.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_os.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_os.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_pci.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_scsi.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_scsi.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_sm.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_sm.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_sport.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_sport.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_stats.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_unsol.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_unsol.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_utils.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_utils.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_vpd.h   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_xport.c   (contents, props changed)
  head/sys/dev/ocs_fc/ocs_xport.h   (contents, props changed)
  head/sys/dev/ocs_fc/sli4.c   (contents, props changed)
  head/sys/dev/ocs_fc/sli4.h   (contents, props changed)
  head/sys/dev/ocs_fc/version.h   (contents, props changed)
  head/sys/modules/ocs_fc/
  head/sys/modules/ocs_fc/Makefile   (contents, props changed)
Modified:
  head/share/man/man4/Makefile
  head/sys/amd64/conf/GENERIC
  head/sys/conf/files
  head/sys/modules/Makefile

Modified: head/share/man/man4/Makefile
==
--- head/share/man/man4/MakefileFri Mar 30 14:41:16 2018
(r331765)
+++ head/share/man/man4/MakefileFri Mar 30 15:28:25 2018
(r331766)
@@ -402,6 +402,7 @@ MAN=aac.4 \
${_nvram2env.4} \
${_nxge.4} \
oce.4 \
+   ocs_fc.4\
ohci.4 \
orm.4 \
ow.4 \

Added: head/share/man/man4/ocs_fc.4
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/man/man4/ocs_fc.4Fri Mar 30 15:28:25 2018
(r331766)
@@ -0,0 +1,194 @@
+.\" Copyright (c) 2017 

svn commit: r331422 - in head/sys/dev: mpr mps

2018-03-23 Thread Kenneth D. Merry
Author: ken
Date: Fri Mar 23 13:52:26 2018
New Revision: 331422
URL: https://svnweb.freebsd.org/changeset/base/331422

Log:
  Disable T10 Protection Information / EEDP handling for type 2 protection.
  
  The mps(4) and mpr(4) drivers and hardware handle T10 Protection
  Information, which is a system of checksums and guard blocks to protect
  data while it is being transferred and while it is on disk.  It is also
  known as T10 DIF.  For more details, see section 4.22 of the SBC-4 spec.
  
  Supporting Type 2 protection requires using 32 byte CDBs, and filling in
  the fields in those CDBs.  We don't yet support that in the da(4) driver.
  
  Type 1 and Type 3 protection don't require that, and can be handled by
  the mps(4)/mpr(4) driver's code and firmware without any additional
  input from the da(4) driver.
  
  If a drive has Type 2 protection enabled (you frequently see this with
  SAS drives shipped from Dell), don't set the various EEDP fields in the
  mps(4)/mpr(4) driver command fields.  Otherwise, you wind up with errors
  like this that would otherwise make no sense:
  
  (da9:mpr0:0:18:0): READ(10). CDB: 28 00 00 00 00 00 00 02 00 00
  (da9:mpr0:0:18:0): CAM status: SCSI Status Error
  (da9:mpr0:0:18:0): SCSI status: Check Condition
  (da9:mpr0:0:18:0): SCSI sense: ILLEGAL REQUEST asc:20,0 (Invalid command 
operation code)
  (da9:mpr0:0:18:0):
  (da9:mpr0:0:18:0): Field Replaceable Unit: 0
  (da9:mpr0:0:18:0): Command Specific Info: 0
  (da9:mpr0:0:18:0):
  (da9:mpr0:0:18:0): Descriptor 0x80: f8 21
  (da9:mpr0:0:18:0): Descriptor 0x81: 00 00 00 00 00 00
  (da9:mpr0:0:18:0): Error 22, Unretryable error
  
  In other words, what kind of strange SAS hard drive doesn't support a
  standard 10 byte SCSI READ command?  In this case, one that has Type 2
  protection enabled.
  
  We can revisit this when we put Type 2 protection support in the da(4)
  driver, but for now this will help people who put Type 2 formatted drives
  in a system and wonder what in the world is going on.
  
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/sys/dev/mpr/mpr_sas.c
  head/sys/dev/mps/mps_sas.c

Modified: head/sys/dev/mpr/mpr_sas.c
==
--- head/sys/dev/mpr/mpr_sas.c  Fri Mar 23 11:08:59 2018(r331421)
+++ head/sys/dev/mpr/mpr_sas.c  Fri Mar 23 13:52:26 2018(r331422)
@@ -2130,8 +2130,8 @@ mprsas_action_scsiio(struct mprsas_softc *sassc, union
CDB.EEDP32.PrimaryReferenceTag);
req->CDB.EEDP32.PrimaryApplicationTagMask =
0x;
-   req->CDB.CDB32[1] = (req->CDB.CDB32[1] & 0x1F) |
-   0x20;
+   req->CDB.CDB32[1] =
+   (req->CDB.CDB32[1] & 0x1F) | 0x20;
} else {
eedp_flags |=
MPI2_SCSIIO_EEDPFLAGS_INC_PRI_APPTAG;
@@ -3502,8 +3502,19 @@ mprsas_async(void *callback_arg, uint32_t code, struct
 
if ((mprsas_get_ccbstatus((union ccb *)) == CAM_REQ_CMP)
&& (rcap_buf.prot & SRC16_PROT_EN)) {
-   lun->eedp_formatted = TRUE;
-   lun->eedp_block_size = scsi_4btoul(rcap_buf.length);
+   switch (rcap_buf.prot & SRC16_P_TYPE) {
+   case SRC16_PTYPE_1:
+   case SRC16_PTYPE_3:
+   lun->eedp_formatted = TRUE;
+   lun->eedp_block_size =
+   scsi_4btoul(rcap_buf.length);
+   break;
+   case SRC16_PTYPE_2:
+   default:
+   lun->eedp_formatted = FALSE;
+   lun->eedp_block_size = 0;
+   break;
+   }
} else {
lun->eedp_formatted = FALSE;
lun->eedp_block_size = 0;

Modified: head/sys/dev/mps/mps_sas.c
==
--- head/sys/dev/mps/mps_sas.c  Fri Mar 23 11:08:59 2018(r331421)
+++ head/sys/dev/mps/mps_sas.c  Fri Mar 23 13:52:26 2018(r331422)
@@ -3231,8 +3231,19 @@ mpssas_async(void *callback_arg, uint32_t code, struct
 
if ((mpssas_get_ccbstatus((union ccb *)) == CAM_REQ_CMP)
 && (rcap_buf.prot & SRC16_PROT_EN)) {
-   lun->eedp_formatted = TRUE;
-   lun->eedp_block_size = scsi_4btoul(rcap_buf.length);
+   switch (rcap_buf.prot & SRC16_P_TYPE) {
+   case SRC16_PTYPE_1:
+   case SRC16_PTYPE_3:
+   lun->eedp_formatted = TRUE;
+   

svn commit: r331223 - head/sys/cam/scsi

2018-03-19 Thread Kenneth D. Merry
Author: ken
Date: Mon Mar 19 20:19:00 2018
New Revision: 331223
URL: https://svnweb.freebsd.org/changeset/base/331223

Log:
  cam_periph_acquire() now returns an errno.
  
  The ch(4) driver was missed in change 328918, which changed
  cam_periph_acquire() to return an errno instead of cam_status.
  
  As a result, ch(4) failed to attach.
  
  Sponsored by: Spectra Logic

Modified:
  head/sys/cam/scsi/scsi_ch.c

Modified: head/sys/cam/scsi/scsi_ch.c
==
--- head/sys/cam/scsi/scsi_ch.c Mon Mar 19 19:32:05 2018(r331222)
+++ head/sys/cam/scsi/scsi_ch.c Mon Mar 19 20:19:00 2018(r331223)
@@ -419,7 +419,7 @@ chregister(struct cam_periph *periph, void *arg)
 * instance for it.  We'll release this reference once the devfs
 * instance has been freed.
 */
-   if (cam_periph_acquire(periph) != CAM_REQ_CMP) {
+   if (cam_periph_acquire(periph) != 0) {
xpt_print(periph->path, "%s: lost periph during "
  "registration!\n", __func__);
cam_periph_lock(periph);
@@ -467,7 +467,7 @@ chopen(struct cdev *dev, int flags, int fmt, struct th
int error;
 
periph = (struct cam_periph *)dev->si_drv1;
-   if (cam_periph_acquire(periph) != CAM_REQ_CMP)
+   if (cam_periph_acquire(periph) != 0)
return (ENXIO);
 
softc = (struct ch_softc *)periph->softc;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328936 - in head/sys/dev: mpr mps

2018-02-06 Thread Kenneth D. Merry
Author: ken
Date: Tue Feb  6 15:58:22 2018
New Revision: 328936
URL: https://svnweb.freebsd.org/changeset/base/328936

Log:
  Diagnostic buffer fixes for the mps(4) and mpr(4) drivers.
  
  In mp{r,s}_diag_register(), which is used to register diagnostic
  buffers with the mp{r,s}(4) firmware, we allocate DMAable memory.
  
  There were several issues here:
   o No checking of the bus_dmamap_load() return value.  If the load
 failed or got deferred, mp{r,s}_diag_register() continued on as if
 nothing had happened.  We now check the return value and bail
 out if it fails.
  
   o No waiting for a deferred load callback.  bus_dmamap_load()
 calls a supplied callback when the mapping is done.  This is
 generally done immediately, but it can be deferred.
 mp{r,s}_diag_register() did not check to see whether the callback
 was already done before proceeding on.  We now sleep until the
 callback is done if it is deferred.
  
   o No call to bus_dmamap_sync(... BUS_DMASYNC_PREREAD) after the
 memory is allocated and loaded.  This is necessary on some
 platforms to synchronize host memory that is going to be updated
 by a device.
  
  Both drivers would also panic if the firmware was reinitialized while
  a diagnostic buffer operation was in progress.  This fixes that problem
  as well.  (The driver will reinitialize the firmware in various
  circumstances, but the problem I ran into was that the firmware would
  generate an IOC Fault due to a PCIe error.)
  
  mp{r,s}var.h:
Add a new structure, struct mpr_busdma_context, that is
used for deferred busdma load callbacks.
  
Add a prototype for mp{r,s}_memaddr_wait_cb().
  mp{r,s}.c:
Add a new busdma callback function, mp{r,s}_memaddr_wait_cb().
This provides synchronization for callers that want to
wait on a deferred bus_dmamap_load() callback.
  
  mp{r,s}_user.c:
In bus_dmamap_register(), add a call to bus_dmamap_sync()
with the BUS_DMASYNC_PREREAD flag set after an allocation
is loaded.
  
Also, check the return value of bus_dmamap_load().  If it
fails, bail out.  If it is EINPROGRESS, wait for the
callback to happen.  We use an interruptible sleep (msleep
with PCATCH) and let the callback clean things up if we get
interrupted.
  
In mpr_diag_read_buffer() and mps_diag_read_buffer(), call
bus_dmamap_sync(..., BUS_DMASYNC_POSTREAD) before copying
the data out to make sure the data is in stable storage.
  
In mp{r,s}_post_fw_diag_buffer() and
mp{r,s}_release_fw_diag_buffer(), check the reply to see
whether it is NULL.  It can be NULL (and the command non-NULL)
if the controller gets reinitialized while we're waiting for
the command to complete but the driver structures aren't
reallocated.  The driver structures generally won't be
reallocated unless there is a firmware upgrade that changes
one of the IOCFacts.
  
When freeing diagnostic buffers in mp{r,s}_diag_register()
and mp{r,s}_diag_unregister(), zero/NULL out the buffer after
freeing it.  This will prevent a duplicate free in some
situations.
  
  Sponsored by: Spectra Logic
  Reviewed by:  mav, scottl
  MFC after:1 week
  Differential Revision:D13453

Modified:
  head/sys/dev/mpr/mpr.c
  head/sys/dev/mpr/mpr_user.c
  head/sys/dev/mpr/mprvar.h
  head/sys/dev/mps/mps.c
  head/sys/dev/mps/mps_user.c
  head/sys/dev/mps/mpsvar.h

Modified: head/sys/dev/mpr/mpr.c
==
--- head/sys/dev/mpr/mpr.c  Tue Feb  6 15:41:45 2018(r328935)
+++ head/sys/dev/mpr/mpr.c  Tue Feb  6 15:58:22 2018(r328936)
@@ -1183,6 +1183,42 @@ mpr_memaddr_cb(void *arg, bus_dma_segment_t *segs, int
*addr = segs[0].ds_addr;
 }
 
+void
+mpr_memaddr_wait_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
+{
+   struct mpr_busdma_context *ctx;
+   int need_unload, need_free;
+
+   ctx = (struct mpr_busdma_context *)arg;
+   need_unload = 0;
+   need_free = 0;
+
+   mpr_lock(ctx->softc);
+   ctx->error = error;
+   ctx->completed = 1;
+   if ((error == 0) && (ctx->abandoned == 0)) {
+   *ctx->addr = segs[0].ds_addr;
+   } else {
+   if (nsegs != 0)
+   need_unload = 1;
+   if (ctx->abandoned != 0)
+   need_free = 1;
+   }
+   if (need_free == 0)
+   wakeup(ctx);
+
+   mpr_unlock(ctx->softc);
+
+   if (need_unload != 0) {
+   bus_dmamap_unload(ctx->buffer_dmat,
+ ctx->buffer_dmamap);
+   *ctx->addr = 0;
+   }
+
+   if (need_free != 0)
+   free(ctx, M_MPR);
+}
+
 static int
 mpr_alloc_queues(struct mpr_softc *sc)
 {

Modified: 

svn commit: r325371 - in head: lib/libmt usr.bin/mt

2017-11-03 Thread Kenneth D. Merry
Author: ken
Date: Fri Nov  3 21:04:22 2017
New Revision: 325371
URL: https://svnweb.freebsd.org/changeset/base/325371

Log:
  Add the LTO-8 Type M density code (0x5d, LTO-8M) to libmt and the
  mt(1) man page.
  
  LTO-8 Type M (also known as M8) is a pristine LTO-7 cartridge
  formatted in a LTO-8 drive in a new, higher density format.  It
  has a separate density code, and is only readable in an LTO-8
  drive.
  
  lib/libmt/mtlib.c:
Add the LTO-8 Type M density code to the density table
in libmt.
  
  usr.bin/mt/mt.1:
Add the LTO-8 Type M density code to the density
table in the mt(1) man page.
  
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/lib/libmt/mtlib.c
  head/usr.bin/mt/mt.1

Modified: head/lib/libmt/mtlib.c
==
--- head/lib/libmt/mtlib.c  Fri Nov  3 20:46:12 2017(r325370)
+++ head/lib/libmt/mtlib.c  Fri Nov  3 21:04:22 2017(r325371)
@@ -645,6 +645,7 @@ static struct densities {
{ 0x58, 15142,  384607, "LTO-5" },
{ 0x5A, 15142,  384607, "LTO-6" },
{ 0x5C, 19107,  485318, "LTO-7" },
+   { 0x5D, 19107,  485318, "LTO-M8" },
{ 0x5E, 20669,  524993, "LTO-8" },
{ 0x71, 11800,  299720, "3592A1 (encrypted)" },
{ 0x72, 11800,  299720, "3592A2 (encrypted)" },

Modified: head/usr.bin/mt/mt.1
==
--- head/usr.bin/mt/mt.1Fri Nov  3 20:46:12 2017(r325370)
+++ head/usr.bin/mt/mt.1Fri Nov  3 21:04:22 2017(r325371)
@@ -29,7 +29,7 @@
 .\"@(#)mt.18.1 (Berkeley) 6/6/93
 .\" $FreeBSD$
 .\"
-.Dd August 11, 2017
+.Dd November 3, 2017
 .Dt MT 1
 .Os
 .Sh NAME
@@ -522,6 +522,7 @@ Value  WidthTracksDensity Code Typ
 0x58   12.7  (0.5) 1280  15,142 (384,607)   C   LTO-5
 0x5A   12.7  (0.5) 2176  15,142 (384,607)   C   LTO-6
 0x5C   12.7  (0.5) 3584  19,107 (485,318)   C   LTO-7
+0x5D   12.7  (0.5) 5376  19,107 (485,318)   C   LTO-M8   14
 0x5E   12.7  (0.5) 6656  20,669 (524,993)   C   LTO-8
 0x71   12.7  (0.5)  512  11,800 (299,720)   C   3592A1 (encrypted)
 0x72   12.7  (0.5)  896  11,800 (299,720)   C   3592A2 (encrypted)
@@ -565,6 +566,10 @@ NOTES
 12. This is Exabyte 8500 uncompressed format.  The compressed format
 density code is 0x8c.
 13. This density code (0x48) was also used for DAT-160.
+14. Officially known as LTO-8 Type M, abbreviated M8.  This is a pristine
+LTO-7 cartridge initialized with a higher density format by an LTO-8
+drive.  It cannot be read by an LTO-7 drive.  Uncompressed capacity
+is 9TB, compared to 6TB for LTO-7 and 12TB for LTO-8.
 .Ed
 .Bd -literal -offset 2n
 NOTE ON QIC STREAMERS
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322819 - head/usr.sbin/camdd

2017-08-23 Thread Kenneth D. Merry
Author: ken
Date: Wed Aug 23 17:52:49 2017
New Revision: 322819
URL: https://svnweb.freebsd.org/changeset/base/322819

Log:
  Fix a resource leak in an error case in camdd_buf_sg_create().
  
  Submitted by: Coverity
  CID:  1341622
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/usr.sbin/camdd/camdd.c

Modified: head/usr.sbin/camdd/camdd.c
==
--- head/usr.sbin/camdd/camdd.c Wed Aug 23 17:47:57 2017(r322818)
+++ head/usr.sbin/camdd/camdd.c Wed Aug 23 17:52:49 2017(r322819)
@@ -824,6 +824,7 @@ camdd_buf_sg_create(struct camdd_buf *buf, int iovec, 
struct camdd_buf_data *data;
uint8_t *extra_buf = NULL;
size_t extra_buf_len = 0;
+   int extra_buf_attached = 0;
int i, retval = 0;
 
data = >buf_type_spec.data;
@@ -913,6 +914,7 @@ camdd_buf_sg_create(struct camdd_buf *buf, int iovec, 
data->iovec[i].iov_base = extra_buf;
data->iovec[i].iov_len = extra_buf_len;
}
+   extra_buf_attached = 1;
i++;
}
if ((tmp_buf != NULL) || (i != data->sg_count)) {
@@ -926,6 +928,14 @@ bailout:
if (retval == 0) {
*num_sectors_used = (data->fill_len + extra_buf_len) /
sector_size;
+   } else if (extra_buf_attached == 0) {
+   /*
+* If extra_buf isn't attached yet, we need to free it
+* to avoid leaking.
+*/
+   free(extra_buf);
+   data->extra_buf = 0;
+   data->sg_count--;
}
return (retval);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322785 - head/usr.sbin/camdd

2017-08-22 Thread Kenneth D. Merry
Author: ken
Date: Tue Aug 22 13:08:22 2017
New Revision: 322785
URL: https://svnweb.freebsd.org/changeset/base/322785

Log:
  Restructure camdd(8) slightly to make it easier to add support for
  additional protocols.
  
  Submitted by: Chuck Tuffli 
  MFC after:1 week
  Differential Revision:D11230

Modified:
  head/usr.sbin/camdd/camdd.c

Modified: head/usr.sbin/camdd/camdd.c
==
--- head/usr.sbin/camdd/camdd.c Tue Aug 22 11:11:49 2017(r322784)
+++ head/usr.sbin/camdd/camdd.c Tue Aug 22 13:08:22 2017(r322785)
@@ -260,6 +260,7 @@ struct camdd_buf {
 
 struct camdd_dev_pass {
int  scsi_dev_type;
+   int  protocol;
struct cam_device   *dev;
uint64_t max_sector;
uint32_t block_len;
@@ -477,6 +478,9 @@ uint32_t camdd_buf_get_len(struct camdd_buf *buf);
 void camdd_buf_add_child(struct camdd_buf *buf, struct camdd_buf *child_buf);
 int camdd_probe_tape(int fd, char *filename, uint64_t *max_iosize,
 uint64_t *max_blk, uint64_t *min_blk, uint64_t *blk_gran);
+int camdd_probe_pass_scsi(struct cam_device *cam_dev, union ccb *ccb,
+ camdd_argmask arglist, int probe_retry_count,
+ int probe_timeout, uint64_t *maxsector, uint32_t *block_len);
 struct camdd_dev *camdd_probe_file(int fd, struct camdd_io_opts *io_opts,
   int retry_count, int timeout);
 struct camdd_dev *camdd_probe_pass(struct cam_device *cam_dev,
@@ -485,7 +489,8 @@ struct camdd_dev *camdd_probe_pass(struct cam_device *
   int probe_timeout, int io_retry_count,
   int io_timeout);
 void *camdd_file_worker(void *arg);
-camdd_buf_status camdd_ccb_status(union ccb *ccb);
+camdd_buf_status camdd_ccb_status(union ccb *ccb, int protocol);
+int camdd_get_cgd(struct cam_device *device, struct ccb_getdev *cgd);
 int camdd_queue_peer_buf(struct camdd_dev *dev, struct camdd_buf *buf);
 int camdd_complete_peer_buf(struct camdd_dev *dev, struct camdd_buf *peer_buf);
 void camdd_peer_done(struct camdd_buf *buf);
@@ -1248,56 +1253,59 @@ bailout_error:
 }
 
 /*
- * Need to implement this.  Do a basic probe:
- * - Check the inquiry data, make sure we're talking to a device that we
- *   can reasonably expect to talk to -- direct, RBC, CD, WORM.
- * - Send a test unit ready, make sure the device is available.
- * - Get the capacity and block size.
+ * Get a get device CCB for the specified device.
  */
-struct camdd_dev *
-camdd_probe_pass(struct cam_device *cam_dev, struct camdd_io_opts *io_opts,
-camdd_argmask arglist, int probe_retry_count,
-int probe_timeout, int io_retry_count, int io_timeout)
+int
+camdd_get_cgd(struct cam_device *device, struct ccb_getdev *cgd)
 {
-   union ccb *ccb;
-   uint64_t maxsector;
-   uint32_t cpi_maxio, max_iosize, pass_numblocks;
-   uint32_t block_len;
-   struct scsi_read_capacity_data rcap;
-   struct scsi_read_capacity_data_long rcaplong;
-   struct camdd_dev *dev;
-   struct camdd_dev_pass *pass_dev;
-   struct kevent ke;
-   int scsi_dev_type;
+union ccb *ccb;
+   int retval = 0;
 
-   dev = NULL;
+   ccb = cam_getccb(device);
+ 
+   if (ccb == NULL) {
+   warnx("%s: couldn't allocate CCB", __func__);
+   return -1;
+   }
 
-   scsi_dev_type = SID_TYPE(_dev->inq_data);
-   maxsector = 0;
-   block_len = 0;
+   CCB_CLEAR_ALL_EXCEPT_HDR(>cgd);
 
-   /*
-* For devices that support READ CAPACITY, we'll attempt to get the
-* capacity.  Otherwise, we really don't support tape or other
-* devices via SCSI passthrough, so just return an error in that case.
-*/
-   switch (scsi_dev_type) {
-   case T_DIRECT:
-   case T_WORM:
-   case T_CDROM:
-   case T_OPTICAL:
-   case T_RBC:
-   case T_ZBC_HM:
-   break;
-   default:
-   errx(1, "Unsupported SCSI device type %d", scsi_dev_type);
-   break; /*NOTREACHED*/
+   ccb->ccb_h.func_code = XPT_GDEV_TYPE;
+ 
+   if (cam_send_ccb(device, ccb) < 0) {
+   warn("%s: error sending Get Device Information CCB", __func__);
+   cam_error_print(device, ccb, CAM_ESF_ALL,
+   CAM_EPF_ALL, stderr);
+   retval = -1;
+   goto bailout;
}
 
-   ccb = cam_getccb(cam_dev);
+   if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
+   cam_error_print(device, ccb, CAM_ESF_ALL,
+   CAM_EPF_ALL, stderr);
+   retval = -1;
+   goto bailout;
+   }
 
+   bcopy(>cgd, cgd, sizeof(struct ccb_getdev));
+
+bailout:
+  

svn commit: r322410 - head/usr.bin/mt

2017-08-11 Thread Kenneth D. Merry
Author: ken
Date: Fri Aug 11 18:43:52 2017
New Revision: 322410
URL: https://svnweb.freebsd.org/changeset/base/322410

Log:
  Add historical notes on QIC tape drives and fix a couple of issues in mt(1).
  
   o Density code 0x5 is also known as QIC-11, and should have a footnote
 reference.
   o Add notes on QIC tape drives from the bug report.  These may help anyone
 trying to use a QIC drive.
   o Take out a "more more" instance found by igor.
   o Bump the man page date.
  
  The PR is 14 years old, so it's past time to retire it.
  
  PR:   doc/53596
  Submitted by: t...@toybox.placo.com
  Reviewed by:  bcr
  Sponsored by: Spectra Logic

Modified:
  head/usr.bin/mt/mt.1

Modified: head/usr.bin/mt/mt.1
==
--- head/usr.bin/mt/mt.1Fri Aug 11 18:09:26 2017(r322409)
+++ head/usr.bin/mt/mt.1Fri Aug 11 18:43:52 2017(r322410)
@@ -29,7 +29,7 @@
 .\"@(#)mt.18.1 (Berkeley) 6/6/93
 .\" $FreeBSD$
 .\"
-.Dd August 3, 2017
+.Dd August 11, 2017
 .Dt MT 1
 .Os
 .Sh NAME
@@ -333,7 +333,7 @@ The default protection method used is Reed-Solomon CRC
 1), as specified in ECMA-319.
 The default protection information length used with Reed-Solomon CRC is
 4 bytes.
-To enable all settings except one more more settings, specify the
+To enable all settings except one more setting, specify the
 .Fl e
 argument and then explicitly disable settings that you do not wish to
 enable.
@@ -463,7 +463,7 @@ Value  WidthTracksDensity Code Typ
 0x01   12.7  (0.5)9 32 (800)  NRZI  R   X3.22-1983   2
 0x02   12.7  (0.5)9 63   (1,600)  PER   X3.39-1986   2
 0x03   12.7  (0.5)9246   (6,250)  GCR   R   X3.54-1986   2
-0x056.3  (0.25)  4/9   315   (8,000)  GCR   C   X3.136-1986  1
+0x056.3  (0.25)  4/9   315   (8,000)  GCR   C   X3.136-1986  1,3
 0x06   12.7  (0.5)9126   (3,200)  PER   X3.157-1987  2
 0x076.3  (0.25)   4252   (6,400)  IMFM  C   X3.116-1986  1
 0x083.81 (0.15)   4315   (8,000)  GCR   CS  X3.158-1987  1
@@ -566,6 +566,60 @@ NOTES
 density code is 0x8c.
 13. This density code (0x48) was also used for DAT-160.
 .Ed
+.Bd -literal -offset 2n
+NOTE ON QIC STREAMERS
+
+The following is a table of Data Cartridge types as used in the 1/4 inch
+tape drives such as the Archive Viper 150, Wangtek 5525ES, and Tandberg
+TDC4220 tape drives:
+
+Value Reference FormatCartridge Type  Capacity   Tracks  Length
+- - ----     --  --
+
+0x05QIC-11DC300   15MB   4300ft
+0x05QIC-11DC300XL/P   20MB   4450ft
+0x05QIC-11DC600   27MB   4600ft
+0x05  X3.136-1986   QIC-24DC615A  15MB   9150ft
+0x05  X3.136-1986   QIC-24DC300XL/P   45MB   9450ft
+0x05  X3.136-1986   QIC-24DC600A  60MB   9600ft
+0x0F  QIC-120   QIC-120   DC600A/DC6150   120MB  15   620ft
+0x10  QIC-150   QIC-150   DC600XTD/DC6150 150MB  18   620ft
+0x10  QIC-150   QIC-150   DC6250  250MB  18 1,020ft
+0x11  QIC-320   QIC-525   DC6320  320MB  26   620ft
+0x11  QIC-320   QIC-525   DC6525  525MB  26 1,020ft
+0x1E  QIC-1000C QIC-1000  DC9100/DL9135   1.0GB  30   760ft
+0x1E  QIC-1000C QIC-1000  DC9150  1.2GB  30   950ft
+0x22  QIC-2GB(C)QIC-2GB   DC9200  2.0GB  42   950ft
+0x22  QIC-2GB(C)QIC-2GB   DC9250  2.5GB  42 1,200ft
+.Ed
+.Pp
+Notes:
+.Pp
+QIC-24, QIC-120, QIC-150 use fixed blocksize of 512 bytes, QIC-525, QIC-1000
+and QIC-2GB can use blocksize of 1,024 bytes.
+DDS (DAT) drives generally use variable blocks.
+.Pp
+QIC-02 and QIC-36 are interface standards for tape drives.
+The QIC-02 and QIC-36 streamers such as the Wangtek 5250EQ are otherwise
+identical to their SCSI versions (i.e.: Wangtek 5250ES).
+.Pp
+It seems that the 150MB and larger streamers cannot write QIC-24 9 track
+formats, only read them.
+.Pp
+DC600A cartridges marked "10,000ftpi" can only be used as QIC-11, QIC-24,
+and QIC-120 format.
+DC600A cartridges marked 12,500ftpi can be used as both QIC-120 and QIC-150
+format.
+.Pp
+Some manufacturers do not use "DC" on their cartridges.
+Verbatim uses DL, Maxell uses MC, Sony uses QD, Quill uses DQ.
+.Pp
+3M/Imation & Fuji use DC.
+Thus a DL6250, MC-6250, QD6250, DQ6250 are all identical media to a DC6250.
+.Pp
+QIC tape media is not "connected" to the take up reels and will de-spool
+if the tape drive has dust covering the light sensor that looks for the end
+of tape holes in the media.
 .Sh ENVIRONMENT
 .Bl -tag -width ".Ev TAPE"
 .It Ev TAPE
___
svn-src-head@freebsd.org mailing list

svn commit: r322364 - in head/sys/dev: mpr mps

2017-08-10 Thread Kenneth D. Merry
Author: ken
Date: Thu Aug 10 14:59:17 2017
New Revision: 322364
URL: https://svnweb.freebsd.org/changeset/base/322364

Log:
  Changes to make mps(4) and mpr(4) handle reinit with reallocation.
  
  When the mps(4) and mpr(4) drivers need to reinitialize the
  firmware, they sometimes need to reallocate all of the memory
  allocated by the driver.  The reallocation happens whenever the IOC
  Facts change.  That should only happen after a firmware upgrade.
  
  If the reinitialization happens as a result of a timed out command
  sent to the card, the command that timed out and triggered the
  reinit may have been freed if iocfacts_allocate() reallocated all
  memory.  If the caller attempts to access the command after that,
  the kernel will panic because the caller will be dereferencing
  freed memory.
  
  The solution is to set a flag in the softc when we reallocate,
  and avoid dereferencing the command strucure if we've reallocated.
  
  The changes are largely the same in both drivers, since mpr(4) is a
  derivative of mps(4).
  
   o In iocfacts_allocate(), if the IOC Facts have changed and we
 need to reallocate, set the REALLOCATED flag in the softc.
  
   o Change wait_command() to take a struct mps_command ** instead of
 a struct mps_command *.  This allows us to NULL out the caller's
 command pointer if we have to reinit the controller and the data
 structures get reallocated.  (The REALLOCATED flag will be set
 in the softc if that has happened.)
  
   o In every place that calls wait_command(), make sure we handle
 the case where the command is NULL after the call.
  
   o The mpr(4) driver has mpr_request_polled() which can also
 reinitialize the card.  Also check for reallocation there.
  
  Reviewed by:  scottl, slm
  MFC after:1 week
  Sponsored by: Spectra Logic

Modified:
  head/sys/dev/mpr/mpr.c
  head/sys/dev/mpr/mpr_config.c
  head/sys/dev/mpr/mpr_sas.c
  head/sys/dev/mpr/mpr_sas_lsi.c
  head/sys/dev/mpr/mpr_user.c
  head/sys/dev/mpr/mprvar.h
  head/sys/dev/mps/mps.c
  head/sys/dev/mps/mps_config.c
  head/sys/dev/mps/mps_sas.c
  head/sys/dev/mps/mps_sas_lsi.c
  head/sys/dev/mps/mps_user.c
  head/sys/dev/mps/mpsvar.h

Modified: head/sys/dev/mpr/mpr.c
==
--- head/sys/dev/mpr/mpr.c  Thu Aug 10 14:54:36 2017(r322363)
+++ head/sys/dev/mpr/mpr.c  Thu Aug 10 14:59:17 2017(r322364)
@@ -436,6 +436,8 @@ mpr_iocfacts_allocate(struct mpr_softc *sc, uint8_t at
 
/* Only deallocate and reallocate if relevant IOC Facts have changed */
reallocating = FALSE;
+   sc->mpr_flags &= ~MPR_FLAGS_REALLOCATED;
+
if ((!attaching) &&
((saved_facts.MsgVersion != sc->facts->MsgVersion) ||
(saved_facts.HeaderVersion != sc->facts->HeaderVersion) ||
@@ -458,6 +460,9 @@ mpr_iocfacts_allocate(struct mpr_softc *sc, uint8_t at
(saved_facts.MaxPersistentEntries !=
sc->facts->MaxPersistentEntries))) {
reallocating = TRUE;
+
+   /* Record that we reallocated everything */
+   sc->mpr_flags |= MPR_FLAGS_REALLOCATED;
}
 
/*
@@ -2229,8 +2234,8 @@ mpr_update_events(struct mpr_softc *sc, struct mpr_eve
 uint8_t *mask)
 {
MPI2_EVENT_NOTIFICATION_REQUEST *evtreq;
-   MPI2_EVENT_NOTIFICATION_REPLY *reply;
-   struct mpr_command *cm;
+   MPI2_EVENT_NOTIFICATION_REPLY *reply = NULL;
+   struct mpr_command *cm = NULL;
struct mpr_event_handle *eh;
int error, i;
 
@@ -2263,8 +2268,9 @@ mpr_update_events(struct mpr_softc *sc, struct mpr_eve
cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
cm->cm_data = NULL;
 
-   error = mpr_request_polled(sc, cm);
-   reply = (MPI2_EVENT_NOTIFICATION_REPLY *)cm->cm_reply;
+   error = mpr_request_polled(sc, );
+   if (cm != NULL)
+   reply = (MPI2_EVENT_NOTIFICATION_REPLY *)cm->cm_reply;
if ((reply == NULL) ||
(reply->IOCStatus & MPI2_IOCSTATUS_MASK) != MPI2_IOCSTATUS_SUCCESS)
error = ENXIO;
@@ -2274,7 +2280,8 @@ mpr_update_events(struct mpr_softc *sc, struct mpr_eve
 
mpr_dprint(sc, MPR_TRACE, "%s finished error %d\n", __func__, error);
 
-   mpr_free_command(sc, cm);
+   if (cm != NULL)
+   mpr_free_command(sc, cm);
return (error);
 }
 
@@ -3260,11 +3267,12 @@ mpr_map_command(struct mpr_softc *sc, struct mpr_comma
  * be executed and enqueued automatically.  Other errors come from msleep().
  */
 int
-mpr_wait_command(struct mpr_softc *sc, struct mpr_command *cm, int timeout,
+mpr_wait_command(struct mpr_softc *sc, struct mpr_command **cmp, int timeout,
 int sleep_flag)
 {
int error, rc;
struct timeval cur_time, start_time;
+   struct mpr_command *cm = *cmp;
 
if (sc->mpr_flags & MPR_FLAGS_DIAGRESET) 
return  

svn commit: r322016 - head/usr.bin/mt

2017-08-03 Thread Kenneth D. Merry
Author: ken
Date: Thu Aug  3 15:04:54 2017
New Revision: 322016
URL: https://svnweb.freebsd.org/changeset/base/322016

Log:
  Oracle T1 tape drives use PRML encoding.
  
  Source:   Oracle T1 SCSI reference guide.
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/usr.bin/mt/mt.1

Modified: head/usr.bin/mt/mt.1
==
--- head/usr.bin/mt/mt.1Thu Aug  3 14:43:41 2017(r322015)
+++ head/usr.bin/mt/mt.1Thu Aug  3 15:04:54 2017(r322016)
@@ -29,7 +29,7 @@
 .\"@(#)mt.18.1 (Berkeley) 6/6/93
 .\" $FreeBSD$
 .\"
-.Dd July 14, 2017
+.Dd August 3, 2017
 .Dt MT 1
 .Os
 .Sh NAME
@@ -509,10 +509,10 @@ Value  WidthTracksDensity Code Typ
 0x473.81 (0.25)   ?  6,417  (163,000)   CS  DAT-72
 0x48   12.7  (0.5)  448  5,236  (133,000) PRML  C   SDLTapeI(110) 6,8,13
 0x49   12.7  (0.5)  448  7,598  (193,000) PRML  C   SDLTapeI(160) 6,8
-0x4A   12.7  (0.5)  768  ?  C   T1A  10
-0x4B   12.7  (0.5) 1152  ?  C   T1B  10
-0x4C   12.7  (0.5) 3584  ?  C   T1C  10
-0x4D   12.7  (0.5) 4608  ?  C   T1D  10
+0x4A   12.7  (0.5)  768  ?PRML  C   T1A  10
+0x4B   12.7  (0.5) 1152  ?PRML  C   T1B  10
+0x4C   12.7  (0.5) 3584  ?PRML  C   T1C  10
+0x4D   12.7  (0.5) 4608  ?PRML  C   T1D  10
 0x51   12.7  (0.5)  512  11,800 (299,720)   C   3592A1 (unencrypted)
 0x52   12.7  (0.5)  896  11,800 (299,720)   C   3592A2 (unencrypted)
 0x53   12.7  (0.5) 1152  13,452 (341,681)   C   3592A3 (unencrypted)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r321623 - head/sys/dev/isp

2017-07-27 Thread Kenneth D. Merry
Author: ken
Date: Thu Jul 27 15:51:56 2017
New Revision: 321623
URL: https://svnweb.freebsd.org/changeset/base/321623

Log:
  Remove duplicate assignments from r321622.
  
  Submitted by: mav
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/sys/dev/isp/isp.c

Modified: head/sys/dev/isp/isp.c
==
--- head/sys/dev/isp/isp.c  Thu Jul 27 15:33:57 2017(r321622)
+++ head/sys/dev/isp/isp.c  Thu Jul 27 15:51:56 2017(r321623)
@@ -2043,7 +2043,6 @@ isp_fibre_init_2400(ispsoftc_t *isp)
if (ownloopid)
icbp->icb_fwoptions1 |= ICB2400_OPT1_HARD_ADDRESS;
 
-   icbp->icb_fwoptions2 = fcp->isp_xfwoptions;
if (isp->isp_confopts & ISP_CFG_NOFCTAPE) {
icbp->icb_fwoptions2 &= ~ICB2400_OPT2_FCTAPE;
}
@@ -2106,7 +2105,6 @@ isp_fibre_init_2400(ispsoftc_t *isp)
icbp->icb_fwoptions2 |= ICB2400_OPT2_ENA_IHA;
}
 
-   icbp->icb_fwoptions3 = fcp->isp_zfwoptions;
if ((icbp->icb_fwoptions3 & ICB2400_OPT3_RSPSZ_MASK) == 0) {
icbp->icb_fwoptions3 |= ICB2400_OPT3_RSPSZ_24;
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r321622 - head/sys/dev/isp

2017-07-27 Thread Kenneth D. Merry
Author: ken
Date: Thu Jul 27 15:33:57 2017
New Revision: 321622
URL: https://svnweb.freebsd.org/changeset/base/321622

Log:
  Fix probing FC targets with hard addressing turned on.
  
  This largely reverts FreeBSD SVN change 289937 from October 25th, 2015.
  
  The intent of that change was to keep loop IDs persistent across
  chip reinits.
  
  The problem is that the change turned on the PREVLOOP /
  PREV_ADDRESS bit (bit 7 in Firmware Options 2), which tells the
  Qlogic chip to not participate in the loop if it can't get the
  requested loop address.  It also turned off soft addressing on 2400
  (4Gb) and newer controllers.
  
  The isp(4) driver defaults to loop address 0, and the tape drives
  I have tested default to loop address 0 if hard addressing is turned
  on.  So when hard loop addressing is turned on on the drive, the isp(4)
  driver just refuses to participate in the loop.
  
  The solution is to largely revert that change.  I left some elements
  in place that are related to virtual ports, since they were new.
  
  This does work with IBM tape drives with hard and soft addressing
  turned on.  I have tested it with 4Gb, 8Gb, and 16Gb controllers.
  
  sys/dev/isp.c:
Largely revert FreeBSD SVN change 289937.  I left the
ispmbox.h changes in place.
  
Don't use the PREV_ADDRESS bit on initialization.  It tells
the chip to not participate if it can't get the requested
loop ID.
  
Do use soft addressing on 2400 and newer chips.
  
Use hard addressing when the user has requested a specific
initiator ID.  (hint.isp.X.iid=N in /boot/loader.conf)
  
Leave some of the virtual port options from that change in
place, but don't turn on the PREV_ADDRESS bit.
  
  Reviewed by:  mav
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/sys/dev/isp/isp.c

Modified: head/sys/dev/isp/isp.c
==
--- head/sys/dev/isp/isp.c  Thu Jul 27 15:06:34 2017(r321621)
+++ head/sys/dev/isp/isp.c  Thu Jul 27 15:33:57 2017(r321622)
@@ -1631,6 +1631,7 @@ isp_fibre_init(ispsoftc_t *isp)
fcparam *fcp;
isp_icb_t local, *icbp = 
mbreg_t mbs;
+   int ownloopid;
 
/*
 * We only support one channel on non-24XX cards
@@ -1709,15 +1710,22 @@ isp_fibre_init(ispsoftc_t *isp)
}
icbp->icb_retry_delay = fcp->isp_retry_delay;
icbp->icb_retry_count = fcp->isp_retry_count;
-   if (fcp->isp_loopid < LOCAL_LOOP_LIM) {
-   icbp->icb_hardaddr = fcp->isp_loopid;
-   if (isp->isp_confopts & ISP_CFG_OWNLOOPID)
-   icbp->icb_fwoptions |= ICBOPT_HARD_ADDRESS;
-   else
-   icbp->icb_fwoptions |= ICBOPT_PREV_ADDRESS;
+   icbp->icb_hardaddr = fcp->isp_loopid;
+   ownloopid = (isp->isp_confopts & ISP_CFG_OWNLOOPID) != 0;
+   if (icbp->icb_hardaddr >= LOCAL_LOOP_LIM) {
+   icbp->icb_hardaddr = 0;
+   ownloopid = 0;
}
 
/*
+* Our life seems so much better with 2200s and later with
+* the latest f/w if we set Hard Address.
+*/
+   if (ownloopid || ISP_FW_NEWER_THAN(isp, 2, 2, 5)) {
+   icbp->icb_fwoptions |= ICBOPT_HARD_ADDRESS;
+   }
+
+   /*
 * Right now we just set extended options to prefer point-to-point
 * over loop based upon some soft config options.
 *
@@ -1951,6 +1959,7 @@ isp_fibre_init_2400(ispsoftc_t *isp)
isp_icb_2400_t local, *icbp = 
mbreg_t mbs;
int chan;
+   int ownloopid = 0;
 
/*
 * Check to see whether all channels have *some* kind of role
@@ -2023,14 +2032,18 @@ isp_fibre_init_2400(ispsoftc_t *isp)
icbp->icb_xchgcnt >>= 1;
}
 
-   if (fcp->isp_loopid < LOCAL_LOOP_LIM) {
-   icbp->icb_hardaddr = fcp->isp_loopid;
-   if (isp->isp_confopts & ISP_CFG_OWNLOOPID)
-   icbp->icb_fwoptions1 |= ICB2400_OPT1_HARD_ADDRESS;
-   else
-   icbp->icb_fwoptions1 |= ICB2400_OPT1_PREV_ADDRESS;
+
+   ownloopid = (isp->isp_confopts & ISP_CFG_OWNLOOPID) != 0;
+   icbp->icb_hardaddr = fcp->isp_loopid;
+   if (icbp->icb_hardaddr >= LOCAL_LOOP_LIM) {
+   icbp->icb_hardaddr = 0;
+   ownloopid = 0;
}
 
+   if (ownloopid)
+   icbp->icb_fwoptions1 |= ICB2400_OPT1_HARD_ADDRESS;
+
+   icbp->icb_fwoptions2 = fcp->isp_xfwoptions;
if (isp->isp_confopts & ISP_CFG_NOFCTAPE) {
icbp->icb_fwoptions2 &= ~ICB2400_OPT2_FCTAPE;
}
@@ -2093,6 +2106,7 @@ isp_fibre_init_2400(ispsoftc_t *isp)
icbp->icb_fwoptions2 |= ICB2400_OPT2_ENA_IHA;
}
 
+   icbp->icb_fwoptions3 = fcp->isp_zfwoptions;
if ((icbp->icb_fwoptions3 & ICB2400_OPT3_RSPSZ_MASK) 

svn commit: r321207 - in head/sys/dev: mpr mps

2017-07-19 Thread Kenneth D. Merry
Author: ken
Date: Wed Jul 19 15:39:01 2017
New Revision: 321207
URL: https://svnweb.freebsd.org/changeset/base/321207

Log:
  Fix spurious timeouts on commands sent to mps(4) and mpr(4) controllers.
  
  mps_wait_command() and mpr_wait_command() were using getmicrotime() to
  determine elapsed time when checking for a timeout in polled mode.
  getmicrotime() isn't guaranteed to monotonically increase, and that
  caused spurious timeouts occasionally.
  
  Switch to using getmicrouptime(), which does increase monotonically.
  This fixes the spurious timeouts in my test case.
  
  Reviewed by:  slm, scottl
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/sys/dev/mpr/mpr.c
  head/sys/dev/mps/mps.c

Modified: head/sys/dev/mpr/mpr.c
==
--- head/sys/dev/mpr/mpr.c  Wed Jul 19 15:22:10 2017(r321206)
+++ head/sys/dev/mpr/mpr.c  Wed Jul 19 15:39:01 2017(r321207)
@@ -3286,9 +3286,17 @@ mpr_wait_command(struct mpr_softc *sc, struct mpr_comm
if (curthread->td_pflags & TDP_NOSLEEPING)
 #endif //__FreeBSD_version >= 129
sleep_flag = NO_SLEEP;
-   getmicrotime(_time);
+   getmicrouptime(_time);
if (mtx_owned(>mpr_mtx) && sleep_flag == CAN_SLEEP) {
error = msleep(cm, >mpr_mtx, 0, "mprwait", timeout*hz);
+   if (error == EWOULDBLOCK) {
+   /*
+* Record the actual elapsed time in the case of a
+* timeout for the message below.
+*/
+   getmicrouptime(_time);
+   timevalsub(_time, _time);
+   }
} else {
while ((cm->cm_flags & MPR_CM_FLAGS_COMPLETE) == 0) {
mpr_intr_locked(sc);
@@ -3297,8 +3305,9 @@ mpr_wait_command(struct mpr_softc *sc, struct mpr_comm
else
DELAY(5);

-   getmicrotime(_time);
-   if ((cur_time.tv_sec - start_time.tv_sec) > timeout) {
+   getmicrouptime(_time);
+   timevalsub(_time, _time);
+   if (cur_time.tv_sec > timeout) {
error = EWOULDBLOCK;
break;
}
@@ -3306,7 +3315,9 @@ mpr_wait_command(struct mpr_softc *sc, struct mpr_comm
}
 
if (error == EWOULDBLOCK) {
-   mpr_dprint(sc, MPR_FAULT, "Calling Reinit from %s\n", __func__);
+   mpr_dprint(sc, MPR_FAULT, "Calling Reinit from %s, timeout=%d,"
+   " elapsed=%jd\n", __func__, timeout,
+   (intmax_t)cur_time.tv_sec);
rc = mpr_reinit(sc);
mpr_dprint(sc, MPR_FAULT, "Reinit %s\n", (rc == 0) ? "success" :
"failed");

Modified: head/sys/dev/mps/mps.c
==
--- head/sys/dev/mps/mps.c  Wed Jul 19 15:22:10 2017(r321206)
+++ head/sys/dev/mps/mps.c  Wed Jul 19 15:39:01 2017(r321207)
@@ -2551,10 +2551,18 @@ mps_wait_command(struct mps_softc *sc, struct mps_comm
 */
if (curthread->td_no_sleeping != 0)
sleep_flag = NO_SLEEP;
-   getmicrotime(_time);
+   getmicrouptime(_time);
if (mtx_owned(>mps_mtx) && sleep_flag == CAN_SLEEP) {
cm->cm_flags |= MPS_CM_FLAGS_WAKEUP;
error = msleep(cm, >mps_mtx, 0, "mpswait", timeout*hz);
+   if (error == EWOULDBLOCK) {
+   /*
+* Record the actual elapsed time in the case of a
+* timeout for the message below.
+*/
+   getmicrouptime(_time);
+   timevalsub(_time, _time);
+   }
} else {
while ((cm->cm_flags & MPS_CM_FLAGS_COMPLETE) == 0) {
mps_intr_locked(sc);
@@ -2563,8 +2571,9 @@ mps_wait_command(struct mps_softc *sc, struct mps_comm
else
DELAY(5);

-   getmicrotime(_time);
-   if ((cur_time.tv_sec - start_time.tv_sec) > timeout) {
+   getmicrouptime(_time);
+   timevalsub(_time, _time);
+   if (cur_time.tv_sec > timeout) {
error = EWOULDBLOCK;
break;
}
@@ -2572,7 +2581,9 @@ mps_wait_command(struct mps_softc *sc, struct mps_comm
}
 
if (error == EWOULDBLOCK) {
-   mps_dprint(sc, MPS_FAULT, "Calling Reinit from %s\n", __func__);
+   mps_dprint(sc, MPS_FAULT, "Calling Reinit from %s, timeout=%d,"
+  

svn commit: r320991 - in head: lib/libmt usr.bin/mt

2017-07-14 Thread Kenneth D. Merry
Author: ken
Date: Fri Jul 14 16:45:46 2017
New Revision: 320991
URL: https://svnweb.freebsd.org/changeset/base/320991

Log:
  Add IBM TS1155 density codes to libmt and the mt(1) man page.
  
  These are taken directly from the density report from a TS1155
  tape drive.  (Using mt getdensity)
  
  lib/libmt/mtlib.c:
Add 3592B5 encrypted/unencrypted density codes, and bpmm/bpi
values.  The bpmm/bpi values are the same as TS1150, but
there are 50% more tracks.
  
  usr.bin/mt/mt.1:
Add 3592B5 encrypted/unencrypted density codes, bpmm/bpi
values and number of tracks.  Bump the man page date.
  
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/lib/libmt/mtlib.c
  head/usr.bin/mt/mt.1

Modified: head/lib/libmt/mtlib.c
==
--- head/lib/libmt/mtlib.c  Fri Jul 14 16:05:54 2017(r320990)
+++ head/lib/libmt/mtlib.c  Fri Jul 14 16:45:46 2017(r320991)
@@ -641,6 +641,7 @@ static struct densities {
{ 0x53, 13452,  341681, "3592A3 (unencrypted)" },
{ 0x54, 19686,  500024, "3592A4 (unencrypted)" },
{ 0x55, 20670,  525018, "3592A5 (unencrypted)" },
+   { 0x56, 20670,  525018, "3592B5 (unencrypted)" },
{ 0x58, 15142,  384607, "LTO-5" },
{ 0x5A, 15142,  384607, "LTO-6" },
{ 0x5C, 19107,  485318, "LTO-7" },
@@ -650,6 +651,7 @@ static struct densities {
{ 0x73, 13452,  341681, "3592A3 (encrypted)" },
{ 0x74, 19686,  500024, "3592A4 (encrypted)" },
{ 0x75, 20670,  525018, "3592A5 (encrypted)" },
+   { 0x76, 20670,  525018, "3592B5 (encrypted)" },
{ 0x8c,  1789,   45434, "EXB-8500c" },
{ 0x90,  1703,   43245, "EXB-8200c" },
{ 0, 0, 0, NULL }

Modified: head/usr.bin/mt/mt.1
==
--- head/usr.bin/mt/mt.1Fri Jul 14 16:05:54 2017(r320990)
+++ head/usr.bin/mt/mt.1Fri Jul 14 16:45:46 2017(r320991)
@@ -29,7 +29,7 @@
 .\"@(#)mt.18.1 (Berkeley) 6/6/93
 .\" $FreeBSD$
 .\"
-.Dd May 11, 2017
+.Dd July 14, 2017
 .Dt MT 1
 .Os
 .Sh NAME
@@ -518,6 +518,7 @@ Value  WidthTracksDensity Code Typ
 0x53   12.7  (0.5) 1152  13,452 (341,681)   C   3592A3 (unencrypted)
 0x54   12.7  (0.5) 2560  19,686 (500,024)   C   3592A4 (unencrypted)
 0x55   12.7  (0.5) 5120  20,670 (525,018)   C   3592A5 (unencrypted)
+0x56   12.7  (0.5) 7680  20,670 (525,018)   C   3592B5 (unencrypted)
 0x58   12.7  (0.5) 1280  15,142 (384,607)   C   LTO-5
 0x5A   12.7  (0.5) 2176  15,142 (384,607)   C   LTO-6
 0x5C   12.7  (0.5) 3584  19,107 (485,318)   C   LTO-7
@@ -527,6 +528,7 @@ Value  WidthTracksDensity Code Typ
 0x73   12.7  (0.5) 1152  13,452 (341,681)   C   3592A3 (encrypted)
 0x74   12.7  (0.5) 2560  19,686 (500,024)   C   3592A4 (encrypted)
 0x75   12.7  (0.5) 5120  20,670 (525,018)   C   3592A5 (encrypted)
+0x76   12.7  (0.5) 7680  20,670 (525,018)   C   3592B5 (encrypted)
 0x8c8.0  (0.315)  1  1,789  (45,434)  RLL   CS  EXB-8500c5,9
 0x908.0  (0.315)  1  1,703  (43,245)  RLL   CS  EXB-8200c5,9
 .Ed
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r320421 - head/sys/cam

2017-06-27 Thread Kenneth D. Merry
Author: ken
Date: Tue Jun 27 19:26:02 2017
New Revision: 320421
URL: https://svnweb.freebsd.org/changeset/base/320421

Log:
  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
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/sys/cam/cam_periph.c

Modified: head/sys/cam/cam_periph.c
==
--- head/sys/cam/cam_periph.c   Tue Jun 27 17:55:25 2017(r320420)
+++ head/sys/cam/cam_periph.c   Tue Jun 27 19:26:02 2017(r320421)
@@ -661,6 +661,7 @@ static void
 camperiphfree(struct cam_periph *periph)
 {
struct periph_driver **p_drv;
+   struct periph_driver *drv;
 
cam_periph_assert(periph, MA_OWNED);
KASSERT(periph->periph_allocating == 0, ("%s%d: freed while allocating",
@@ -673,6 +674,15 @@ camperiphfree(struct cam_periph *periph)
printf("camperiphfree: attempt to free non-existant periph\n");
return;
}
+   /*
+* Cache a pointer to the periph_driver structure.  If a
+* periph_driver is added or removed from the array (see
+* periphdriver_register()) while we drop the toplogy lock
+* below, p_drv may change.  This doesn't protect against this
+* particular periph_driver going away.  That will require full
+* reference counting in the periph_driver infrastructure.
+*/
+   drv = *p_drv;
 
/*
 * We need to set this flag before dropping the topology lock, to
@@ -708,8 +718,8 @@ camperiphfree(struct cam_periph *periph)
 */
xpt_lock_buses();
 
-   TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links);
-   (*p_drv)->generation++;
+   TAILQ_REMOVE(>units, periph, unit_links);
+   drv->generation++;
 
xpt_remove_periph(periph);
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r320420 - head/sys/cam/scsi

2017-06-27 Thread Kenneth D. Merry
Author: ken
Date: Tue Jun 27 17:55:25 2017
New Revision: 320420
URL: https://svnweb.freebsd.org/changeset/base/320420

Log:
  In scsi_zbc_in(), fill in the length in the ZBC IN CDB.
  
  Without the allocation length set, the target will either reject
  the command or complete it without transferring any data.
  
  This fixes the REPORT ZONES command for SCSI ZBC protocol devices,
  as well as ATA ZAC protocol devices that are behind a SCSI to ATA
  translation layer.  (LSI/Broadcom's 12Gb SAS adapters translate ZBC
  commands to ZAC commands.)  Those are Host Aware and Host Managed SMR
  drives.
  
  This will fix REPORT ZONE commands sent to the da(4) driver via the
  GEOM bio interface and zonectl, and REPORT ZONE commands sent from
  camcontrol(8).
  
  Note that in the case of camcontrol(8), we currently only send
  SCSI ZBC commands to native SCSI protocol devices, not ATA devices
  behind a SAT layer.
  
  sys/cam/scsi/scsi_da.c:
Fill in the length field in scsi_zbc_in().
  
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/scsi/scsi_da.c
==
--- head/sys/cam/scsi/scsi_da.c Tue Jun 27 17:48:11 2017(r320419)
+++ head/sys/cam/scsi/scsi_da.c Tue Jun 27 17:55:25 2017(r320420)
@@ -5804,6 +5804,7 @@ scsi_zbc_in(struct ccb_scsiio *csio, uint32_t retries,
scsi_cmd = (struct scsi_zbc_in *)>cdb_io.cdb_bytes;
scsi_cmd->opcode = ZBC_IN;
scsi_cmd->service_action = service_action;
+   scsi_ulto4b(dxfer_len, scsi_cmd->length);
scsi_u64to8b(zone_start_lba, scsi_cmd->zone_start_lba);
scsi_cmd->zone_options = zone_options;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r320156 - in head: cddl/contrib/opensolaris/cmd/zdb cddl/contrib/opensolaris/cmd/ztest cddl/contrib/opensolaris/lib/libzfs/common sys/cddl/contrib/opensolaris/common/zfs sys/cddl/contr

2017-06-21 Thread Kenneth D. Merry
On Wed, Jun 21, 2017 at 11:16:23 +0300, Andriy Gapon wrote:
> On 21/06/2017 00:25, Kenneth D. Merry wrote:
> > FWIW, avg sent me a patch for this particular problem (by checking for NULL
> > before dereferencing the pointer), and although it got me past the above
> > problem, I hit another related panic:
> 
> Could you please re-enable ZFS TRIM support and test r320186 or later?
> Thank you for all your help with the testing and debugging.

That fixed it, thank you!

Ken
-- 
Kenneth Merry
k...@freebsd.org
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r320156 - in head: cddl/contrib/opensolaris/cmd/zdb cddl/contrib/opensolaris/cmd/ztest cddl/contrib/opensolaris/lib/libzfs/common sys/cddl/contrib/opensolaris/common/zfs sys/cddl/contr

2017-06-20 Thread Kenneth D. Merry
On Tue, Jun 20, 2017 at 23:37:10 +0300, Andriy Gapon wrote:
> On 20/06/2017 23:29, Ken Merry wrote:
> > I don???t know for sure that this commit is the cause, but it (and r320153) 
> > are the only ZFS commits between a version of head from June 14th that 
> > boots off a ZFS mirror, and one that panics.
> > 
> > Here???s the stack trace:
> > 
> > Fatal trap 12: page fault while in kernel mode
> > cpuid = 22; 
> > 
> > Fatal trap 12: page fault while in kernel mode
> > cpuid = 9; apic id = 09
> > fault virtual address   = 0x0
> > fault code  = supervisor read data, page not present
> > instruction pointer = 0x20:0x81e47f21
> > stack pointer   = 0x28:0xfe08b37f8810
> > frame pointer   = 0x28:0xfe08b37f8860
> > code segment= base 0x0, limit 0xf, type 0x1b
> > = DPL 0, pres 1, long 1, def32 0, gran 1
> > processor eflags= interrupt enabled, resume, IOPL = 0
> > current process = 0 (zio_free_issue_0_3)
> > [ thread pid 0 tid 100478 ]
> > Stopped at  0x81e47f21 = zio_vdev_io_start+0x1f1:   testb   
> > $0x1,(%rax)
> > db> bt
> > Tracing pid 0 tid 100478 td 0xf80193156000
> > zio_vdev_io_start() at 0x81e47f21 = zio_vdev_io_start+0x1f1/frame 
> > 0xfe08b37f8860
> > zio_execute() at 0x81e4312c = zio_execute+0x36c/frame 
> > 0xfe08b37f88b0
> > zio_nowait() at 0x81e422b8 = zio_nowait+0xb8/frame 
> > 0xfe08b37f88e0
> > vdev_mirror_io_start() at 0x81e224fc = 
> > vdev_mirror_io_start+0x38c/frame 0xfe08b37f8930
> > zio_vdev_io_start() at 0x81e48030 = zio_vdev_io_start+0x300/frame 
> > 0xfe08b37f8990
> > zio_execute() at 0x81e4312c = zio_execute+0x36c/frame 
> > 0xfe08b37f89e0
> > taskqueue_run_locked() at 0x809a9d6d = 
> > taskqueue_run_locked+0x13d/frame 0xfe08b37f8a40
> > taskqueue_thread_loop() at 0x809aab28 = 
> > taskqueue_thread_loop+0x88/frame 0xfe08b37f8a70
> > fork_exit() at 0x8091e3e4 = fork_exit+0x84/frame 0xfe08b37f8ab0
> > fork_trampoline() at 0x80d930fe = fork_trampoline+0xe/frame 
> > 0xfe08b37f8ab0
> > --- trap 0, rip = 0, rsp = 0, rbp = 0 ---
> > db> 
> > 
> > (kgdb) list *(zio_vdev_io_start+0x1f1)
> > 0xd9f21 is in zio_vdev_io_start 
> > (/usr/home/kenm/perforce4/kenm/FreeBSD-test/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c:350).
> > 345
> > 346 /*
> > 347  * Ensure that anyone expecting this zio to contain a 
> > linear ABD isn't
> > 348  * going to get a nasty surprise when they try to access 
> > the data.
> > 349  */
> > 350 IMPLY(abd_is_linear(zio->io_abd), abd_is_linear(data));
> > 351
> > 352 zt->zt_orig_abd = zio->io_abd;
> > 353 zt->zt_orig_size = zio->io_size;
> > 354 zt->zt_bufsize = bufsize;
> > 
> > I???ll try rebooting and see if the problem goes away.  If not, I???ll roll 
> > back the ABD change and see if the problem goes away.
> 
> Judging from the thread that panic-ed the problem may have to do with our TRIM
> support.  Unfortunately,  I didn't have a chance to test the change on a 
> system
> with working TRIM and, so, I missed it.
> I will look into this further, but it's almost obvious that the problem is
> caused by zio->io_abd being NULL for a zio of type ZIO_TYPE_FREE.

FWIW, avg sent me a patch for this particular problem (by checking for NULL
before dereferencing the pointer), and although it got me past the above
problem, I hit another related panic:

Fatal trap 12: page fault while in kernel mode
cpuid = 6; 

Fatal trap 12: page fault while in kernel mode
cpuid = 14; apic id = 22
fault virtual address   = 0x4
fault code  = supervisor read data, page not present
instruction pointer = 0x20:0x81d92a2d
stack pointer   = 0x0:0xfe08b36e0710
frame pointer   = 0x0:0xfe08b36e0730
code segment= base 0x0, limit 0xf, type 0x1b


Fatal trap 12: page fault while in kernel mode
cpuid = 11; apic id = 0b
fault virtual address   = 0x4
Fatal trap 12: page fault while in kernel mode
cpuid = 8; apic id = 08
= DPL 0, pres 1, long 1, def32 0, gran 1
processor eflags= interrupt enabled, resume, IOPL = 0
current process = 0 (zio_free_issue_4_1)
[ thread pid 0 tid 100799 ]
Stopped at  0x81d92a2d = abd_verify+0xd:movl0x4(%r14),%eax
db> bt
Tracing pid 0 tid 100799 td 0xf801931b8560
abd_verify() at 0x81d92a2d = abd_verify+0xd/frame 0xfe08b36e0730
abd_put() at 0x81d92eff = abd_put+0xf/frame 0xfe08b36e0750
vdev_raidz_map_free() at 0x81e26312 = vdev_raidz_map_free+0x82/frame 
0xfe08b36e0780
zio_vdev_io_assess() at 0x81e48646 = zio_vdev_io_assess+0x116/frame 
0xfe08b36e07b0
zio_execute() at 0x81e4312c = zio_execute+0x36c/frame 0xfe08b36e0800
zio_vdev_io_start() at 

svn commit: r320123 - head/sys/cam/scsi

2017-06-19 Thread Kenneth D. Merry
Author: ken
Date: Mon Jun 19 20:48:00 2017
New Revision: 320123
URL: https://svnweb.freebsd.org/changeset/base/320123

Log:
  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 
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/sys/cam/scsi/scsi_sa.c

Modified: head/sys/cam/scsi/scsi_sa.c
==
--- head/sys/cam/scsi/scsi_sa.c Mon Jun 19 20:47:24 2017(r320122)
+++ head/sys/cam/scsi/scsi_sa.c Mon Jun 19 20:48:00 2017(r320123)
@@ -4465,7 +4465,18 @@ saextget(struct cdev *dev, struct cam_periph *periph, 
if (cgd.serial_num_len > sizeof(tmpstr)) {
ts2_len = cgd.serial_num_len + 1;
ts2_malloc = 1;
-   tmpstr2 = malloc(ts2_len, M_SCSISA, M_WAITOK | M_ZERO);
+   tmpstr2 = malloc(ts2_len, M_SCSISA, M_NOWAIT | M_ZERO);
+   /*
+* The 80 characters allocated on the stack above
+* will handle the vast majority of serial numbers.
+* If we run into one that is larger than that, and
+* we can't malloc the length without blocking,
+* bail out with an out of memory error.
+*/
+   if (tmpstr2 == NULL) {
+   error = ENOMEM;
+   goto extget_bailout;
+   }
} else {
ts2_len = sizeof(tmpstr);
ts2_malloc = 0;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r318185 - in head: lib/libmt usr.bin/mt

2017-05-11 Thread Kenneth D. Merry
Author: ken
Date: Thu May 11 13:46:30 2017
New Revision: 318185
URL: https://svnweb.freebsd.org/changeset/base/318185

Log:
  Add LTO-8 density codes.
  
  lib/libmt/mtlib.c:
Add the LTO-8 density code to the density table in libmt.
  
  usr.bin/mt/mt.1:
Add the LTO-8 density code, tracks, bpmm, and bpi to the density
table in the mt(1) man page.
  
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/lib/libmt/mtlib.c
  head/usr.bin/mt/mt.1

Modified: head/lib/libmt/mtlib.c
==
--- head/lib/libmt/mtlib.c  Thu May 11 11:13:02 2017(r318184)
+++ head/lib/libmt/mtlib.c  Thu May 11 13:46:30 2017(r318185)
@@ -644,6 +644,7 @@ static struct densities {
{ 0x58, 15142,  384607, "LTO-5" },
{ 0x5A, 15142,  384607, "LTO-6" },
{ 0x5C, 19107,  485318, "LTO-7" },
+   { 0x5E, 20669,  524993, "LTO-8" },
{ 0x71, 11800,  299720, "3592A1 (encrypted)" },
{ 0x72, 11800,  299720, "3592A2 (encrypted)" },
{ 0x73, 13452,  341681, "3592A3 (encrypted)" },

Modified: head/usr.bin/mt/mt.1
==
--- head/usr.bin/mt/mt.1Thu May 11 11:13:02 2017(r318184)
+++ head/usr.bin/mt/mt.1Thu May 11 13:46:30 2017(r318185)
@@ -29,7 +29,7 @@
 .\"@(#)mt.18.1 (Berkeley) 6/6/93
 .\" $FreeBSD$
 .\"
-.Dd May 5, 2017
+.Dd May 11, 2017
 .Dt MT 1
 .Os
 .Sh NAME
@@ -521,6 +521,7 @@ Value  WidthTracksDensity   
 0x58   12.7  (0.5) 1280  15,142 (384,607)   C   LTO-5
 0x5A   12.7  (0.5) 2176  15,142 (384,607)   C   LTO-6
 0x5C   12.7  (0.5) 3584  19,107 (485,318)   C   LTO-7
+0x5E   12.7  (0.5) 6656  20,669 (524,993)   C   LTO-8
 0x71   12.7  (0.5)  512  11,800 (299,720)   C   3592A1 (encrypted)
 0x72   12.7  (0.5)  896  11,800 (299,720)   C   3592A2 (encrypted)
 0x73   12.7  (0.5) 1152  13,452 (341,681)   C   3592A3 (encrypted)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317854 - head/sbin/camcontrol

2017-05-05 Thread Kenneth D. Merry
Author: ken
Date: Fri May  5 21:29:28 2017
New Revision: 317854
URL: https://svnweb.freebsd.org/changeset/base/317854

Log:
  When editing a mode page on a tape drive, do not clear the device
  specific parameter.
  
  Tape drives include write protect (WP), Buffered Mode and Speed
  settings in the device-specific parameter.  Clearing this
  parameter on a mode select can have the effect of turning off
  write protect or buffered mode, or changing the speed setting of
  the tape drive.
  
  Disks report DPO/FUA support via the device specific parameter
  for MODE SENSE, but the bit is reserved for MODE SELECT.  So we
  clear this for disks (and other non-tape devices) to avoid
  potential errors from the target device.
  
  sbin/camcontrol/modeedit.c:
Clear the device-specific parameter in the mode page
header if we're not operating on a tape drive.
  
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/sbin/camcontrol/modeedit.c

Modified: head/sbin/camcontrol/modeedit.c
==
--- head/sbin/camcontrol/modeedit.c Fri May  5 20:45:55 2017
(r317853)
+++ head/sbin/camcontrol/modeedit.c Fri May  5 21:29:28 2017
(r317854)
@@ -629,8 +629,21 @@ editlist_save(struct cam_device *device,
 
/* Recalculate headers & offsets. */
mh->data_length = 0;/* Reserved for MODE SELECT command. */
-   mh->dev_spec = 0;   /* Clear device-specific parameters. */
mh->blk_desc_len = 0;   /* No block descriptors. */
+   /*
+* Tape drives include write protect (WP), Buffered Mode and Speed
+* settings in the device-specific parameter.  Clearing this
+* parameter on a mode select can have the effect of turning off
+* write protect or buffered mode, or changing the speed setting of
+* the tape drive.
+*
+* Disks report DPO/FUA support via the device specific parameter
+* for MODE SENSE, but the bit is reserved for MODE SELECT.  So we
+* clear this for disks (and other non-tape devices) to avoid
+* potential errors from the target device.
+*/
+   if (device->pd_type != T_SEQUENTIAL)
+   mh->dev_spec = 0;
mph = MODE_PAGE_HEADER(mh);
mph->page_code &= ~SMPH_PS; /* Reserved for MODE SELECT command. */
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317848 - in head: share/man/man4 sys/cam/scsi usr.bin/mt

2017-05-05 Thread Kenneth D. Merry
Author: ken
Date: Fri May  5 20:00:53 2017
New Revision: 317848
URL: https://svnweb.freebsd.org/changeset/base/317848

Log:
  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.
  
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/share/man/man4/sa.4
  head/sys/cam/scsi/scsi_sa.c
  head/usr.bin/mt/mt.1

Modified: head/share/man/man4/sa.4
==
--- head/share/man/man4/sa.4Fri May  5 19:34:05 2017(r317847)
+++ head/share/man/man4/sa.4Fri May  5 20:00:53 2017(r317848)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 12, 2015
+.Dd May 5, 2017
 .Dt SA 4
 .Os
 .Sh NAME
@@ -242,6 +242,87 @@ These devices include the QIC family of 
 block devices.
 This has not been determined yet, and they are treated
 as separate behaviors by the driver at this time.)
+.Sh PARAMETERS
+The
+.Nm
+driver supports a number of parameters.
+The user can query parameters using
+.Dq mt param -l
+(which uses the
+.Dv MTIOCPARAMGET
+ioctl) and the user can set parameters using
+.Dq mt param -s 
+(which uses the
+.Dv MTIOCPARAMSET
+ioctl).
+See
+.Xr mt 1
+and
+.Xr mtio 4
+for more details on the interface.
+.Pp
+Supported parameters:
+.Bl -tag -width 5n
+.It sili
+The default is 0.
+When set to 1, it sets the Suppress Incorrect Length Indicator (SILI) bit
+on tape reads.
+Tape drives normally return sense data (which contains the residual) when the
+application reads a block that is not the same length as the amount of data
+requested.
+The SILI bit supresses that notification in most cases.
+See the SSC-5 spec (available at t10.org), specifically the section on the
+READ(6) command, for more information.
+.It eot_warn
+The default is 0.
+By default, the
+.Nm
+driver reports entering Programmable Early Warning, Early Warning and End
+of Media conditions by returning a write with 0 bytes written, and
+.Dv errno
+set to 0.
+If 
+.Va eot_warn
+is set to 1, the
+.Nm
+driver will set
+.Dv errno
+to 
+.Dv ENOSPC
+when it enters any of the out of space conditions.
+.It protection.protection_supported
+This is a read-only parameter, and is set to 1 if the tape drive supports
+protection information.
+.It protection.prot_method
+If protection is supported, set this to the desired protection method
+supported by the tape drive.
+As of SSC-5r03 (available at t10.org), the protection method values are:
+.Bl -tag -width 3n
+.It 0
+No protection.
+.It 1
+Reed-Solomon CRC, 4 bytes in length.
+.It 2
+CRC32C, 4 bytes in length.
+.El
+.It protection.pi_length
+Length of the protection information, see above for lengths.
+.It protection.lbp_w
+If set to 1, enable logical block protection on writes.
+The CRC must be appended to the end of the block written to the tape driver.
+The tape drive will verify the CRC when it receives the block.
+.It protection.lbp_r
+If set to 1, enable logical block protection on reads.
+The CRC will be appended to the end of the block read from the tape driver.
+The application should verify the CRC when it receives the block.
+.It protection.rdbp
+If set to 1, enable logical block protection on the RECOVER BUFFERED DATA
+command.
+The
+.Nm
+driver does not currently use the
+RECOVER BUFFERED DATA command.
+.El
 .Sh IOCTLS
 The
 .Nm
@@ -262,7 +343,26 @@ Control mode device (to examine state wh
 accessing the device, e.g.).
 .El
 .Sh DIAGNOSTICS

svn commit: r317799 - head/sys/cam/scsi

2017-05-04 Thread Kenneth D. Merry
Author: ken
Date: Thu May  4 17:23:39 2017
New Revision: 317799
URL: https://svnweb.freebsd.org/changeset/base/317799

Log:
  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.
  
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/sys/cam/scsi/scsi_all.h

Modified: head/sys/cam/scsi/scsi_all.h
==
--- head/sys/cam/scsi/scsi_all.hThu May  4 15:26:28 2017
(r317798)
+++ head/sys/cam/scsi/scsi_all.hThu May  4 17:23:39 2017
(r317799)
@@ -565,6 +565,7 @@ struct scsi_log_sense
 #defineSLS_ERROR_LASTN_PAGE0x07
 #defineSLS_LOGICAL_BLOCK_PROVISIONING  0x0c
 #defineSLS_SELF_TEST_PAGE  0x10
+#defineSLS_SOLID_STATE_MEDIA   0x11
 #defineSLS_STAT_AND_PERF   0x19
 #defineSLS_IE_PAGE 0x2f
 #defineSLS_PAGE_CTRL_MASK  0xC0
@@ -624,6 +625,13 @@ struct scsi_log_param_header {
u_int8_t param_len;
 };
 
+struct scsi_log_media_pct_used {
+   struct scsi_log_param_header hdr;
+#defineSLP_SS_MEDIA_PCT_USED   0x0001
+   uint8_t reserved[3];
+   uint8_t pct_used;
+};
+
 struct scsi_log_stat_and_perf {
struct scsi_log_param_header hdr;
 #defineSLP_SAP 0x0001
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317776 - head/sbin/camcontrol

2017-05-03 Thread Kenneth D. Merry
Author: ken
Date: Wed May  3 21:04:32 2017
New Revision: 317776
URL: https://svnweb.freebsd.org/changeset/base/317776

Log:
  Bump the camcontrol(8) man page date.
  
  MFC after:3 days
  X-MFC-with:   r317774
  Sponsored by: Spectra Logic

Modified:
  head/sbin/camcontrol/camcontrol.8

Modified: head/sbin/camcontrol/camcontrol.8
==
--- head/sbin/camcontrol/camcontrol.8   Wed May  3 20:59:47 2017
(r317775)
+++ head/sbin/camcontrol/camcontrol.8   Wed May  3 21:04:32 2017
(r317776)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 1, 2017
+.Dd May 3, 2017
 .Dt CAMCONTROL 8
 .Os
 .Sh NAME
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317775 - in head: share/man/man4 sys/cam/scsi

2017-05-03 Thread Kenneth D. Merry
Author: ken
Date: Wed May  3 20:59:47 2017
New Revision: 317775
URL: https://svnweb.freebsd.org/changeset/base/317775

Log:
  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 
  PR:   kern/218572
  MFC after:1 week
  Sponsored by: Spectra Logic

Modified:
  head/share/man/man4/pass.4
  head/sys/cam/scsi/scsi_pass.c

Modified: head/share/man/man4/pass.4
==
--- head/share/man/man4/pass.4  Wed May  3 20:57:52 2017(r317774)
+++ head/share/man/man4/pass.4  Wed May  3 20:59:47 2017(r317775)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 17, 2015
+.Dd May 3, 2017
 .Dt PASS 4
 .Os
 .Sh NAME
@@ -85,6 +85,11 @@ Some examples of xpt-only CCBs are XPT_S
 XPT_DEV_MATCH, XPT_RESET_BUS, XPT_SCAN_LUN, XPT_ENG_INQ, and XPT_ENG_EXEC.
 These CCB types have various attributes that make it illogical or
 impossible to service them through the passthrough interface.
+.Pp
+If the user would like the kernel to do error recovery, the
+.Dv CAM_PASS_ERR_RECOVER
+flag must be set on the CCB, and the retry_count field set to the number
+of retries.
 .It CAMGETPASSTHRU union ccb *
 This ioctl takes an XPT_GDEVLIST CCB, and returns the passthrough device
 corresponding to the device in question.
@@ -160,6 +165,11 @@ available for userland use with the
 and
 .Dv CAMIOGET
 ioctls and will be preserved across calls.
+.Pp
+If the user would like the kernel to do error recovery, the
+.Dv CAM_PASS_ERR_RECOVER
+flag must be set on the CCB, and the retry_count field set to the number
+of retries.
 .It CAMIOGET union ccb *
 Retrieve completed CAM CCBs queued via the
 .Dv CAMIOQUEUE

Modified: head/sys/cam/scsi/scsi_pass.c
==
--- head/sys/cam/scsi/scsi_pass.c   Wed May  3 20:57:52 2017
(r317774)
+++ head/sys/cam/scsi/scsi_pass.c   Wed May  3 20:59:47 2017
(r317775)
@@ -2229,9 +2229,9 @@ passsendccb(struct cam_periph *periph, u
 * that request.  Otherwise, it's up to the user to perform any
 * error recovery.
 */
-   cam_periph_runccb(ccb, passerror, /* cam_flags */ CAM_RETRY_SELTO,
-   /* sense_flags */ ((ccb->ccb_h.flags & CAM_PASS_ERR_RECOVER) ?
-SF_RETRY_UA : SF_NO_RECOVERY) | SF_NO_PRINT,
+   cam_periph_runccb(ccb, (ccb->ccb_h.flags & CAM_PASS_ERR_RECOVER) ? 
+   passerror : NULL, /* cam_flags */ CAM_RETRY_SELTO,
+   /* sense_flags */ SF_RETRY_UA | SF_NO_PRINT,
softc->device_stats);
 
cam_periph_unmapmem(ccb, );
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317774 - head/sbin/camcontrol

2017-05-03 Thread Kenneth D. Merry
Author: ken
Date: Wed May  3 20:57:52 2017
New Revision: 317774
URL: https://svnweb.freebsd.org/changeset/base/317774

Log:
  Add the ability to rescan or reset devices specified by peripheral
  name and unit number in camcontrol(8).
  
  Previously camcontrol(8) only supported rescanning or resetting
  devices specified by bus:target:lun.  This is because for
  rescanning at least, you don't have a peripheral name and unit
  number (e.g. da4) for devices that don't exist yet.
  
  That is still the case after this change, but in other cases, when
  the device does exist in the CAM EDT (Existing Device Table), we
  do a careful lookup of the bus/target/lun if the user supplies a
  peripheral name and unit number to find the bus:target:lun and then
  issue the requested reset or rescan.
  
  The lookup is done without actually opening the device in question,
  since a rescan is often done to make a device go away after it has
  been pulled.  (This is especially true for busses/controllers, like
  parallel SCSI controllers, that don't automatically detect changes
  in topology.)  Opening a device that is no longer there to
  determine the bus/target/lun might result in error recovery actions
  when the user really just wanted to make the device go away.
  
  sbin/camcontrol/camcontrol.c:
In dorescan_or_reset(), if the use hasn't specified a
numeric argument, assume he has specified a device.  Lookup
the pass(4) instance for that device using the transport
layer CAMGETPASSTHRU ioctl.  If that is successful, we can
use the returned bus:target:lun to rescan or reset the
device.
  
Under the hood, resetting a device using XPT_RESET_DEV is
actually sent via the pass(4) device anyway.  But this
provides a way for the user to specify devices in a more
convenient way, and can work on device rescans when the
device is going away, assuming it still exists in the EDT.
  
  sbin/camcontrol/camcontrol.8:
Update the man page for the rescan and reset subcommands
to reflect that you can now use a device name and unit
number with them.
  
  Sponsored by: Spectra Logic
  MFC after:3 days

Modified:
  head/sbin/camcontrol/camcontrol.8
  head/sbin/camcontrol/camcontrol.c

Modified: head/sbin/camcontrol/camcontrol.8
==
--- head/sbin/camcontrol/camcontrol.8   Wed May  3 20:56:54 2017
(r317773)
+++ head/sbin/camcontrol/camcontrol.8   Wed May  3 20:57:52 2017
(r317774)
@@ -102,10 +102,10 @@
 .Op device id
 .Nm
 .Ic rescan
-.Aq all | bus Ns Op :target:lun
+.Aq all | device id | bus Ns Op :target:lun
 .Nm
 .Ic reset
-.Aq all | bus Ns Op :target:lun
+.Aq all | device id | bus Ns Op :target:lun
 .Nm
 .Ic defects
 .Op device id
@@ -578,12 +578,20 @@ start bit cleared and the load/eject bit
 .It Ic rescan
 Tell the kernel to scan all buses in the system (with the
 .Ar all
-argument), the given bus (XPT_SCAN_BUS), or bus:target:lun
+argument), the given bus (XPT_SCAN_BUS), bus:target:lun or device
 (XPT_SCAN_LUN) for new devices or devices that have gone away.
 The user
 may specify a scan of all buses, a single bus, or a lun.
 Scanning all luns
 on a target is not supported.
+.Pp
+If a device is specified by peripheral name and unit number, for instance
+da4, it may only be rescanned if that device currently exists in the CAM EDT
+(Existing Device Table).
+If the device is no longer there (see
+.Nm
+devlist ),
+you must use the bus:target:lun form to rescan it.
 .It Ic reprobe
 Tell the kernel to refresh the information about the device and
 notify the upper layer,
@@ -593,8 +601,8 @@ the disk size visible to the rest of the
 .It Ic reset
 Tell the kernel to reset all buses in the system (with the
 .Ar all
-argument) or the given bus (XPT_RESET_BUS) by issuing a SCSI bus
-reset for that bus, or to reset the given bus:target:lun
+argument), the given bus (XPT_RESET_BUS) by issuing a SCSI bus
+reset for that bus, or to reset the given bus:target:lun or device
 (XPT_RESET_DEV), typically by issuing a BUS DEVICE RESET message after
 connecting to that device.
 Note that this can have a destructive impact

Modified: head/sbin/camcontrol/camcontrol.c
==
--- head/sbin/camcontrol/camcontrol.c   Wed May  3 20:56:54 2017
(r317773)
+++ head/sbin/camcontrol/camcontrol.c   Wed May  3 20:57:52 2017
(r317774)
@@ -3131,12 +3131,107 @@ dorescan_or_reset(int argc, char **argv,
tstr++;
if (strncasecmp(tstr, "all", strlen("all")) == 0)
arglist |= CAM_ARG_BUS;
-   else {
+   else if (isdigit(*tstr)) {
rv = parse_btl(argv[optind], , , , );
if (rv != 1 && rv != 3) {
warnx(must, rescan? "rescan" : "reset");
return(1);
}
+

svn commit: r317745 - head/sys/cam/scsi

2017-05-03 Thread Kenneth D. Merry
Author: ken
Date: Wed May  3 14:53:27 2017
New Revision: 317745
URL: https://svnweb.freebsd.org/changeset/base/317745

Log:
  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.
  
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/sys/cam/scsi/scsi_all.c

Modified: head/sys/cam/scsi/scsi_all.c
==
--- head/sys/cam/scsi/scsi_all.cWed May  3 14:21:18 2017
(r317744)
+++ head/sys/cam/scsi/scsi_all.cWed May  3 14:53:27 2017
(r317745)
@@ -1614,7 +1614,7 @@ static struct asc_table_entry asc_table[
{ SST(0x20, 0x01, SS_RDEF,  /* XXX TBD */
"Access denied - initiator pending-enrolled") },
/* DT PWROMAEBK   */
-   { SST(0x20, 0x02, SS_RDEF,  /* XXX TBD */
+   { SST(0x20, 0x02, SS_FATAL | EPERM,
"Access denied - no access rights") },
/* DT PWROMAEBK   */
{ SST(0x20, 0x03, SS_RDEF,  /* XXX TBD */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317740 - head/sys/dev/isp

2017-05-03 Thread Kenneth D. Merry
Author: ken
Date: Wed May  3 13:17:01 2017
New Revision: 317740
URL: https://svnweb.freebsd.org/changeset/base/317740

Log:
  Correct loop mode CRN resets to adhere to FCP-4 section 4.10
  
  Prior to this change, the CRN (Command Reference Number) is reset on any
  firmware LIP, LOOP DOWN, or LOOP RESET event in violation of FCP-4 which
  specifies that the CRN should only be reset in response to a LIP Reset
  (LIPyx) primitive. FCP-4 also indicates PLOGI/LOGO and PRLI/PRLO ELS
  actions as conditions for resetting the CRN for the associated initiator
  port.
  
  These violations manifest themselves when the HBA is removed from the
  loop, or a target device is removed (especially during an outstanding
  command) without power cycling. If the HBA and and the target device
  determine upon re-establishing the loop that no PLOGI or PRLI is
  required, and the target does not issue a LIPxy to the initiator, the
  CRN for the target will have been improperly reset by the isp driver. As
  a result, the target port will silently ignore all FCP commands issued
  during the device probe (which will time out) preventing the device from
  attaching.
  
  This change corrects thie CRN reset behavior in response to loop state
  changes, also introduces CRN resets for the above mentioned ELS actions
  as encountered through async PDB change events.
  
  This change also adds cleanup of outstanding commands in isp_loop_dead()
  that was previously missing.
  
  sys/dev/isp/isp.c
Add the last login state to debug output when syncing the pdb
  
  sys/dev/isp/isp_freebsd.c
Replace binary statement setting aborted ccb status in
isp_watchdog() with the XS_SETERR macro used elsewhere
  
In isp_loop_dead(), abort or complete pending commands as done
in isp_watchdog()
  
In isp_async(), segregate the ISPASYNC_LOOP_RESET action from
ISPASYNC_LIP, ISPASYNC_LOOP_DOWN, and ISPASYNC_LOOP_UP
fallthroughs, and only reset the CRN in the RESET case. Also add
checks to handle false LOOP RESET actions that do not have a
proper associated LIP primitive, and log the primitive in the
debug messages
  
In isp_async(), remove the goto from ISP_ASYNC_DEV_STAYED, and
only reset the CRN in the DEV_CHANGED action
  
In isp_async(), when processing an ISPASYNC_CHANGE_PDB status,
reset CRN(s) for the associated nphdl (or all ports) if the
change reason is some form of ELS login/logout. Also remove
assignment to fc since it is not used in the scope
  
  sys/dev/isp/ispmbox.h
Add macro definition for the global N-Port handle, and correct a
macro typo 'PDB24XX_AE_PRLI_DONJE'
  
  sys/dev/isp/ispvar.h
Add macros FCP_AL_DA_ALL, FCP_AL_PA, and FCP_IS_DEST_ALPD for
more legible code when determining if an AL_PD port matches the
portid for a given struct fcparam* by value or by virtue of the
AL_PD port being 0xFF
  
  Submitted by: Reid Linnemann
  Sponsored by: Spectra Logic
  MFC after:1 week

Modified:
  head/sys/dev/isp/isp.c
  head/sys/dev/isp/isp_freebsd.c
  head/sys/dev/isp/ispmbox.h
  head/sys/dev/isp/ispvar.h

Modified: head/sys/dev/isp/isp.c
==
--- head/sys/dev/isp/isp.c  Wed May  3 12:26:16 2017(r317739)
+++ head/sys/dev/isp/isp.c  Wed May  3 13:17:01 2017(r317740)
@@ -2771,10 +2771,11 @@ isp_getpdb(ispsoftc_t *isp, int chan, ui
pdb->portid = BITS2WORD_24XX(un.bill.pdb_portid_bits);
ISP_MEMCPY(pdb->portname, un.bill.pdb_portname, 8);
ISP_MEMCPY(pdb->nodename, un.bill.pdb_nodename, 8);
-   isp_prt(isp, ISP_LOGDEBUG1,
-   "Chan %d handle 0x%x Port 0x%06x flags 0x%x curstate %x",
+   isp_prt(isp, ISP_LOGDEBUG0,
+   "Chan %d handle 0x%x Port 0x%06x flags 0x%x curstate %x 
laststate %x",
chan, id, pdb->portid, un.bill.pdb_flags,
-   un.bill.pdb_curstate);
+   un.bill.pdb_curstate, un.bill.pdb_laststate);
+
if (un.bill.pdb_curstate < PDB2400_STATE_PLOGI_DONE || 
un.bill.pdb_curstate > PDB2400_STATE_LOGGED_IN) {
mbs.param[0] = MBOX_NOT_LOGGED_IN;
return (mbs.param[0]);

Modified: head/sys/dev/isp/isp_freebsd.c
==
--- head/sys/dev/isp/isp_freebsd.c  Wed May  3 12:26:16 2017
(r317739)
+++ head/sys/dev/isp/isp_freebsd.c  Wed May  3 13:17:01 2017
(r317740)
@@ -2567,8 +2567,7 @@ isp_watchdog(void *arg)
} 
isp_destroy_handle(isp, handle);
isp_prt(isp, ISP_LOGERR, "%s: timeout for handle 0x%x", 
__func__, handle);
-   xs->ccb_h.status &= ~CAM_STATUS_MASK;
-   xs->ccb_h.status |= 

svn commit: r317680 - head/sys/cam/scsi

2017-05-02 Thread Kenneth D. Merry
Author: ken
Date: Tue May  2 14:52:28 2017
New Revision: 317680
URL: https://svnweb.freebsd.org/changeset/base/317680

Log:
  Add the SCSI SSC Manufacturer assigned serial number VPD page.
  
  This is current as of SSC-5r03.
  
  Submitted by: Sam Klopsch
  MFC after:3 days

Modified:
  head/sys/cam/scsi/scsi_sa.h

Modified: head/sys/cam/scsi/scsi_sa.h
==
--- head/sys/cam/scsi/scsi_sa.h Tue May  2 13:47:15 2017(r317679)
+++ head/sys/cam/scsi/scsi_sa.h Tue May  2 14:52:28 2017(r317680)
@@ -487,6 +487,19 @@ struct scsi_medium_type_data {
 };
 
 /*
+ * Manufacturer-assigned Serial Number VPD page.
+ * Current as of SSC-5r03, 28 September 2016.
+ */
+struct scsi_vpd_mfg_serial_number
+{
+   u_int8_t device;
+   u_int8_t page_code;
+#defineSVPD_MFG_SERIAL_NUMBER_PAGE_CODE 0xB1
+   u_int8_t page_length[2];
+   u_int8_t mfg_serial_num[];
+};
+
+/*
  * Security Protocol Specific values for the Tape Data Encryption protocol
  * (0x20) used with SECURITY PROTOCOL IN.  See below for values used with
  * SECURITY PROTOCOL OUT.  Current as of SSC4r03.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317657 - head/sbin/camcontrol

2017-05-01 Thread Kenneth D. Merry
Author: ken
Date: Mon May  1 18:53:47 2017
New Revision: 317657
URL: https://svnweb.freebsd.org/changeset/base/317657

Log:
  Fix camcontrol timestamp setting and update the man page.
  
  camcontrol timestamp -s would somtimes fail due to stack garbage.  Zero out
  the timestamp parameters to fix it.
  
  Fix another nearby bug, and update the man page.
  
  sbin/camcontrol/timestamp.c:
In set_timestamp(), bzero ts_p prior to creating the timestamp.
Previously stack garbage could cause some tape drives to reject the
timestamp.
  
In set_timestamp(), check for failures from strptime().
  
  sbin/camcontrol/camcontrol.8:
Add the time argument to the -T option to camcontrol timestamp -s
in the long description.
  
Change the time/date format used in the camcontrol timestamp
example to RFC 2822 format.  This fixes a time zone issue with the
original example by specifying the time zone as -0600.  Otherwise,
the time zone seems to default to standard time in the current
locale, which makes the time, when reported back from the drive,
1 hour off from the intended setting.  This also fixes a duplicate
day of the week ("Wednesday Wed") in the previous example.
  
  Submitted by: Sam Klopsch
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/sbin/camcontrol/camcontrol.8
  head/sbin/camcontrol/timestamp.c

Modified: head/sbin/camcontrol/camcontrol.8
==
--- head/sbin/camcontrol/camcontrol.8   Mon May  1 17:10:43 2017
(r317656)
+++ head/sbin/camcontrol/camcontrol.8   Mon May  1 18:53:47 2017
(r317657)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 17, 2017
+.Dd May 1, 2017
 .Dt CAMCONTROL 8
 .Os
 .Sh NAME
@@ -2488,7 +2488,7 @@ Specify the strptime format string, as d
 The time must also be specified with the
 .Fl T 
 option.
-.It Fl T
+.It Fl T Ar time
 Provide the time in the format specified with the
 .Fl f
 option.
@@ -2814,8 +2814,8 @@ drive
 .Pa ada0 .
 .Pp
 .Bd -literal -offset indent
-camcontrol timestamp sa0 -s -f "%A %c" \e
-   -T "Wednesday Wed Oct 26 21:43:57 2016"
+camcontrol timestamp sa0 -s -f "%a, %d %b %Y %T %z" \e
+   -T "Wed, 26 Oct 2016 21:43:57 -0600"
 .Ed
 .Pp
 Set the timestamp of drive

Modified: head/sbin/camcontrol/timestamp.c
==
--- head/sbin/camcontrol/timestamp.cMon May  1 17:10:43 2017
(r317656)
+++ head/sbin/camcontrol/timestamp.cMon May  1 18:53:47 2017
(r317657)
@@ -282,12 +282,18 @@ set_timestamp(struct cam_device *device,
ts = (uint64_t) time_value;
} else {
bzero(_struct, sizeof(struct tm));
-   strptime(timestamp_string, format_string, _struct);
+   if (strptime(timestamp_string, format_string,
+   _struct) == NULL) {
+   warnx("%s: strptime(3) failed", __func__);
+   error = 1;
+   goto bailout;
+   }
time_value = mktime(_struct);
ts = (uint64_t) time_value;
}
/* Convert time from seconds to milliseconds */
ts *= 1000;
+   bzero(_p, sizeof(ts_p));
scsi_create_timestamp(ts_p.timestamp, ts);
 
scsi_set_timestamp(>csio,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r299182 - head/sys/dev/e1000

2017-02-20 Thread Kenneth D. Merry
On Fri, May 06, 2016 at 15:41:38 +, Sean Bruno wrote:
> Author: sbruno
> Date: Fri May  6 15:41:38 2016
> New Revision: 299182
> URL: https://svnweb.freebsd.org/changeset/base/299182
> 
> Log:
>   If ALTQ is defined in the kern conf, switch to Legacy Mode.
>   
>   PR: 208409
>   Submitted by:   free...@mcwest.org
>   MFC after:  2 weeks
> 
> Modified:
>   head/sys/dev/e1000/if_igb.h

Just for the mail archives (and hopefully for someone who is interested in
fixing it), IGB_LEGACY_TX is broken.  (It leads to panics.)

See:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=213257
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=212413

And some comments about it in this particular bug as well:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=208409

This bit me last night on 10-stable.  I have ALTQ in my kernel
configuration, but I'm only using it on em(4) interfaces, not igb(4)
interfaces.  (I bought an em(4) NIC in mid-2015 because of this particular
problem.)

Some folks have been able to get around the problem by rate-limiting
traffic on the igb(4) interfaces, but that is fairly kludgy.

IMO, we shouldn't enable IGB_LEGACY_TX automatically when ALTQ is enabled
when it can lead to crashes.

There are several possible ways to fix things:

1. Actually fix IGB_LEGACY_TX so that it doesn't cause crashes.
2. If ALTQ is actually in use with igb(4), switch igb(4) into single queue
   mode.  (Not sure how feasible that is.)
3. Come up with a way for ALTQ to generically and easily work on top of
   multiqueue interfaces.

I'm sure other folks more well versed in the network stack will have
additional ideas.

Ken
-- 
Kenneth Merry
k...@freebsd.org
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r313895 - head/sys/cam/ctl

2017-02-17 Thread Kenneth D. Merry
Author: ken
Date: Fri Feb 17 20:15:27 2017
New Revision: 313895
URL: https://svnweb.freebsd.org/changeset/base/313895

Log:
  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.
  
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/sys/cam/ctl/ctl.c

Modified: head/sys/cam/ctl/ctl.c
==
--- head/sys/cam/ctl/ctl.c  Fri Feb 17 20:07:35 2017(r313894)
+++ head/sys/cam/ctl/ctl.c  Fri Feb 17 20:15:27 2017(r313895)
@@ -12405,6 +12405,9 @@ ctl_datamove(union ctl_io *io)
if (io->io_hdr.flags & CTL_FLAG_DELAY_DONE) {
io->io_hdr.flags &= ~CTL_FLAG_DELAY_DONE;
} else {
+   struct ctl_lun *lun;
+
+   lun = CTL_LUN(io);
if ((lun != NULL)
 && (lun->delay_info.datamove_delay > 0)) {
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r313893 - head/sbin/camcontrol

2017-02-17 Thread Kenneth D. Merry
Author: ken
Date: Fri Feb 17 20:04:22 2017
New Revision: 313893
URL: https://svnweb.freebsd.org/changeset/base/313893

Log:
  Add task attribute support to camcontrol(8).
  
  Users can use the new generic argument, -Q task_attr, to specify a task
  attribute (simple, ordered, head of queue, aca) for the commands issued.
  The the default is simple, which works with all SCSI devices that support
  tagged queueing.
  
  This will mostly be useful for debugging target behavior in certain
  situations.
  
  You can try it out by compiling CTL with CTL_IO_DELAY turned on (in
  sys/cam/ctl/ctl_io.h) and then do something like this with one of the CTL
  LUNs:
  
  ctladm delay 0:0 -l done -t 10
  camcontrol tur da34 -v
  
  And at then before the 10 second timer is up, in another terminal:
  
  camcontrol inquiry da34 -Q ordered -v
  
  The Inquiry should complete just after the TUR completes.  Ordinarily
  it would complete first because of the delay injection, but because the
  task attribute is set to ordered in this case, CTL holds it up until the
  previous command has completed.
  
  sbin/camcontrol/camcontrol.c:
Add the new generic argument, -Q, which allows the user to specify
a SCSI task attribute.  The user can specify task attributes by
name or numerically.
  
Add a new task_attr arguments to SCSI sub-functions.
  
  sbin/camcontrol/attrib.c,
  sbin/camcontrol/camcontrol.h,
  sbin/camcontrol/fwdownload.c,
  sbin/camcontrol/modeedit.c,
  sbin/camcontrol/persist.c,
  sbin/camcontrol/timestamp.c,
  sbin/camcontrol/zone.c:
Add the new task_attr argument to SCSI sub-functions.
  
  sbin/camcontrol/camcontrol.8:
Document the new -Q option, and add an example.
  
  Sponsored by: Spectra Logic
  MFC after:1 week

Modified:
  head/sbin/camcontrol/attrib.c
  head/sbin/camcontrol/camcontrol.8
  head/sbin/camcontrol/camcontrol.c
  head/sbin/camcontrol/camcontrol.h
  head/sbin/camcontrol/fwdownload.c
  head/sbin/camcontrol/modeedit.c
  head/sbin/camcontrol/persist.c
  head/sbin/camcontrol/timestamp.c
  head/sbin/camcontrol/zone.c

Modified: head/sbin/camcontrol/attrib.c
==
--- head/sbin/camcontrol/attrib.c   Fri Feb 17 20:02:40 2017
(r313892)
+++ head/sbin/camcontrol/attrib.c   Fri Feb 17 20:04:22 2017
(r313893)
@@ -106,7 +106,8 @@ static struct scsi_nv output_format_map[
 
 int
 scsiattrib(struct cam_device *device, int argc, char **argv, char *combinedopt,
-  int retry_count, int timeout, int verbosemode, int err_recover)
+  int task_attr, int retry_count, int timeout, int verbosemode,
+  int err_recover)
 {
union ccb *ccb = NULL;
int attr_num = -1;
@@ -317,7 +318,7 @@ scsiattrib(struct cam_device *device, in
scsi_read_attribute(>csio,
/*retries*/ retry_count,
/*cbfcnp*/ NULL,
-   /*tag_action*/ MSG_SIMPLE_Q_TAG,
+   /*tag_action*/ task_attr,
/*service_action*/ read_service_action,
/*element*/ element_address,
/*elem_type*/ element_type,

Modified: head/sbin/camcontrol/camcontrol.8
==
--- head/sbin/camcontrol/camcontrol.8   Fri Feb 17 20:02:40 2017
(r313892)
+++ head/sbin/camcontrol/camcontrol.8   Fri Feb 17 20:04:22 2017
(r313893)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 20, 2017
+.Dd February 17, 2017
 .Dt CAMCONTROL 8
 .Os
 .Sh NAME
@@ -422,6 +422,17 @@ It may take some other actions, dependin
 the command.
 .It Fl n Ar dev_name
 Specify the device type to operate on, e.g.\& "da", "cd".
+.It Fl Q Ar task_attr
+.Tn SCSI
+task attribute for the command, if it is a
+.Tn SCSI
+command.
+This may be ordered, simple, head, or aca.
+In most cases this is not needed.
+The default is simple, which works with all
+.Tn SCSI
+devices.
+The task attribute may also be specified numerically.
 .It Fl t Ar timeout
 SCSI command timeout in seconds.
 This overrides the default timeout for
@@ -2523,7 +2534,7 @@ information if the command fails since t
 .Fl v
 switch was not specified.
 .Bd -literal -offset indent
-camcontrol tur da1 -E -C 4 -t 50 -v
+camcontrol tur da1 -E -C 4 -t 50 -Q head -v
 .Ed
 .Pp
 Send a test unit ready command to da1.
@@ -2536,6 +2547,9 @@ flag) if the command fails.
 Since error recovery is turned on, the
 disk will be spun up if it is not currently spinning.
 The
+.Tn SCSI
+task attribute for the command will be set to Head of Queue.
+The
 .Nm
 utility will report whether the disk is ready.
 .Bd -literal -offset indent

Modified: head/sbin/camcontrol/camcontrol.c
==
--- 

svn commit: r313568 - head/sys/dev/isp

2017-02-10 Thread Kenneth D. Merry
Author: ken
Date: Fri Feb 10 22:02:45 2017
New Revision: 313568
URL: https://svnweb.freebsd.org/changeset/base/313568

Log:
  Change the isp(4) driver to not adjust the tag type for REQUEST SENSE.
  
  The isp(4) driver was changing the tag type for REQUEST SENSE
  commands to Head of Queue, when the CAM CCB flag
  CAM_TAG_ACTION_VALID was NOT set.  CAM_TAG_ACTION_VALID is set
  when the tag action in the XPT_SCSI_IO is not CAM_TAG_ACTION_NONE
  and when the target has tagged queueing turned on.
  
  In most cases when CAM_TAG_ACTION_VALID is not set, it is because
  the target is not doing tagged queueing.  In those cases, trying to
  send a Head of Queue tag may cause problems.  Instead, default to
  sending a simple tag.
  
  IBM tape drives claim to support tagged queueing in their standard
  Inquiry data, but have the DQue bit set in the control mode page
  (mode page 10).  CAM correctly detects that these drives do not
  support tagged queueing, and clears the CAM_TAG_ACTION_VALID flag
  on CCBs sent down to the drives.
  
  This caused the isp(4) driver to go down the path of setting the
  tag action to a default value, and for Request Sense commands only,
  set the tag action to Head of Queue.
  
  If an IBM tape drive does get a Head of Queue tag, it rejects it with
  Invalid Message Error (0x49,0x00).  (The Qlogic firmware translates that
  to a Transport Error, which the driver translates to an Unrecoverable
  HBA Error, or CAM_UNREC_HBA_ERROR.) So, by default, it wasn't possible
  to get a good response from a REQUEST SENSE to an FC-attached IBM
  tape drive with the isp(4) driver.
  
  IBM tape drives (tested on an LTO-5 with G9N1 firmware and a TS1150
  with 4470 firmware) also have a bug in that sending a command with a
  non-simple tag attribute breaks the tape drive's Command Reference
  Number (CRN) accounting and causes it to ignore all subsequent
  commands because it and the initiator disagree about the next
  expected CRN.  The drives do reject the initial command with a head
  of queue tag with an Invalid Message Error (0x49,0x00), but after that
  they ignore any subsequent commands.  IBM confirmed that it is a bug,
  and sent me test firmware that fixes the bug.  However tape drives in
  the field will still exhibit the bug until they are upgraded.
  
  Request Sense is not often sent to targets because most errors are
  reported automatically through autosense in Fibre Channel and other
  modern transports.  ("Modern" meaning post SCSI-2.)  So this is not
  an error that would crop up frequently.  But Request Sense is useful on
  tape devices to report status information, aside from error reporting.
  
  This problem is less serious without FC-Tape features turned on,
  specifically precise delivery of commands (which enables Command
  Reference Numbers), enabled on the target and initiator.  Without
  FC-Tape features turned on, the target would return an error and
  things would continue on.
  
  And it also does not cause problems for targets that do tagged
  queueing, because in those cases the isp(4) driver just uses the
  tag type that is specified in the CCB, assuming the
  CAM_TAG_ACTION_VALID flag is set, and defaults to sending a Simple
  tag action if it isn't an ordered or head of queue tag.
  
  sys/dev/isp/isp.c:
In isp_start(), don't try to send Request Sense commands
with the Head of Queue tag attribute if the CCB doesn't
have a valid tag action.  The tag action likely isn't valid
because the target doesn't support tagged queueing.
  
  Sponsored by: Spectra Logic
  MFC after:3 days

Modified:
  head/sys/dev/isp/isp.c

Modified: head/sys/dev/isp/isp.c
==
--- head/sys/dev/isp/isp.c  Fri Feb 10 19:49:42 2017(r313567)
+++ head/sys/dev/isp/isp.c  Fri Feb 10 22:02:45 2017(r313568)
@@ -4451,11 +4451,7 @@ isp_start(XS_T *xs)
if (XS_TAG_P(xs)) {
ttype = XS_TAG_TYPE(xs);
} else {
-   if (XS_CDBP(xs)[0] == 0x3) {
-   ttype = REQFLAG_HTAG;
-   } else {
-   ttype = REQFLAG_STAG;
-   }
+   ttype = REQFLAG_STAG;
}
if (ttype == REQFLAG_OTAG) {
ttype = FCP_CMND_TASK_ATTR_ORDERED;
@@ -4479,14 +4475,7 @@ isp_start(XS_T *xs)
if (XS_TAG_P(xs)) {
((ispreqt2_t *)reqp)->req_flags = XS_TAG_TYPE(xs);
} else {
-   /*
-* If we don't know what tag to use, use HEAD OF QUEUE
-* for Request Sense or Simple.
-*/
-   if (XS_CDBP(xs)[0] == 0x3)  /* REQUEST SENSE */
-   ((ispreqt2_t *)reqp)->req_flags = REQFLAG_HTAG;
-

svn commit: r310338 - in head: share/man/man4 sys/conf sys/dev/isp

2016-12-20 Thread Kenneth D. Merry
Author: ken
Date: Tue Dec 20 21:17:07 2016
New Revision: 310338
URL: https://svnweb.freebsd.org/changeset/base/310338

Log:
  Turn on FC-Tape by default in the isp(4) driver.
  
  FC-Tape provides additional link level error recovery, and is
  highly recommended for tape devices.  It will only be turned on for
  a given target if the target supports it.
  
  Without this setting, we default to whatever FC-Tape setting is in
  NVRAM on the card.
  
  This can be overridden by setting the following loader tunable, for
  example for isp0:
  
  hint.isp.0.nofctape=1
  
  sys/conf/options:
Add a new kernel config option, ISP_FCTAPE_OFF, that
defaults the FC-Tape configuration to off.
  
  sys/dev/isp/isp_pci.c:
If ISP_FCTAPE_OFF is defined, turn off FC-Tape.  Otherwise,
turn it on if the card supports it.
  
  share/man/man4/isp.4:
Add a description of FC-Tape to the isp(4) man page.
  
Add descriptions of the fctape and nofctape options, as well as the
ISP_FCTAPE_OFF kernel configuration option.
  
Add the ispfw module and kernel drivers to the suggested
configurations at the top of the man page so that users are less
likely to leave it out.  The driver works well with the included
firmware, but may not work at all with whatever firmware the user
has flashed on their card.
  
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/share/man/man4/isp.4
  head/sys/conf/options
  head/sys/dev/isp/isp_pci.c

Modified: head/share/man/man4/isp.4
==
--- head/share/man/man4/isp.4   Tue Dec 20 20:11:16 2016(r310337)
+++ head/share/man/man4/isp.4   Tue Dec 20 21:17:07 2016(r310338)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 9, 2015
+.Dd December 20, 2016
 .Dt ISP 4
 .Os
 .Sh NAME
@@ -39,13 +39,15 @@ kernel configuration file:
 .Bd -ragged -offset indent
 .Cd "device scbus"
 .Cd "device isp"
+.Cd "device ispfw"
 .Ed
 .Pp
 Alternatively, to load the driver as a
-module at boot time, place the following line in
+module at boot time, place the following lines in
 .Xr loader.conf 5 :
 .Bd -literal -offset indent
 isp_load="YES"
+ispfw_load="YES"
 .Ed
 .Sh DESCRIPTION
 This driver provides access to
@@ -62,6 +64,30 @@ Fibre Channel supports initiator and tar
 utilizing Class 3 and Class 2 (2200 and later) connections.
 Support is available for Public and Private loops, Point-to-Point
 and Fabric connections.
+.Pp
+FC-Tape is supported on 4Gb (2400) and newer controllers.
+FC-Tape is highly recommended for connections to tape drives that support
+it.
+It encompasses four elements from the the T-10 FCP-4 specification:
+.Bl -bullet -offset indent
+.It
+Precise Delivery of Commands
+.It
+Confirmed Completion of FCP I/O Operations
+.It
+Retransmission of Unsuccessfully Transmitted IUs
+.It
+Task Retry Identification
+.El
+.Pp
+Together these features allow for link level error recovery with tape
+devices.
+Without it, an initiator cannot, for instance, tell whether a tape write
+command that has timed out resulted in all, part or none of the data going to
+the tape drive.
+FC-Tape is automatically enabled when connecting controller that supports
+it to a target that supports it.
+It may be disabled using configuration and hint options described below.
 .Sh FIRMWARE
 Firmware loading is supported if the
 .Xr ispfw 4
@@ -120,6 +146,13 @@ Target mode support for Fibre Channel ad
 .Cd options ISP_TARGET_MODE
 .Pp
 option.
+.Pp
+To disable FC-Tape, use the following configuration option:
+.Pp
+.Cd options ISP_FCTAPE_OFF
+.Pp
+Note that even if the ISP_FCTAPE_OFF option is used, it may be overridden
+by the fctape hint described below.
 .Sh BOOT OPTIONS
 The following options are switchable by setting values in
 .Pa /boot/device.hints .
@@ -169,6 +202,11 @@ A hint value for a driver debug level (s
 for the values.
 .It Va hint.isp.0.vports
 A hint to create specified number of additional virtual ports.
+.It Va hint.isp.0.nofctape
+Set this to 1 to disable FC-Tape operation on the given isp instance.
+.It Va hint.isp.0.fctape
+Set this to 1 to enable FC-Tape operation on the given isp instance for
+targets that support it.
 .El
 .Sh SYSCTL OPTIONS
 .Bl -tag -width indent

Modified: head/sys/conf/options
==
--- head/sys/conf/options   Tue Dec 20 20:11:16 2016(r310337)
+++ head/sys/conf/options   Tue Dec 20 21:17:07 2016(r310338)
@@ -384,6 +384,7 @@ ISP_TARGET_MODE opt_isp.h
 ISP_FW_CRASH_DUMP  opt_isp.h
 ISP_DEFAULT_ROLES  opt_isp.h
 ISP_INTERNAL_TARGETopt_isp.h
+ISP_FCTAPE_OFF opt_isp.h
 
 # Options used only in dev/iscsi
 ISCSI_INITIATOR_DEBUG  opt_iscsi_initiator.h

Modified: head/sys/dev/isp/isp_pci.c
==
--- 

Re: svn commit: r307684 - head/sbin/camcontrol

2016-12-19 Thread Kenneth D. Merry
On Sat, Dec 17, 2016 at 20:50:15 +0100, Oliver Pinter wrote:
> On 12/12/16, Kenneth D. Merry <k...@freebsd.org> wrote:
> > On Sun, Dec 11, 2016 at 00:49:12 +0100, Oliver Pinter wrote:
> >> On 10/20/16, Kenneth D. Merry <k...@freebsd.org> wrote:
> >> > Author: ken
> >> > Date: Thu Oct 20 19:42:26 2016
> >> > New Revision: 307684
> >> > URL: https://svnweb.freebsd.org/changeset/base/307684
> >> >
> >> > Log:
> >> >   For CCBs allocated on the stack, we need to clear the entire CCB, not
> >> > just
> >> >   the header.  Otherwise stack garbage can lead to random flags getting
> >> > set.
> >> >
> >> >   This showed up as 'camcontrol rescan all' failing with EINVAL because
> >> > the
> >> >   address type wasn't CAM_DATA_VADDR.
> >> >
> >> >   sbin/camcontrol/camcontrol.c:
> >> >  In rescan_or_reset_bus(), bzero the stack-allocated CCBs before
> >> >  use instead of clearing the body.
> >> >
> >> >   MFC after: 3 days
> >> >   Sponsored by:  Spectra Logic
> >>
> >> The MFC of this commit is missed both for 10-STABLE and 11-STABLE. Is
> >> this still in plan to do?
> >
> > Done, thanks for the reminder!
> 
> Thanks!
> 
> Slightly related problem what I found on one of my INVARIANTS enabled
> kernel is the following:
> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=215356 . A similar
> change what this is required in smartmontools too.

Ahh, yes, sounds like the same basic issue.  Thanks for submitting it
upstream!

Ken
-- 
Kenneth Merry
k...@freebsd.org
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r307684 - head/sbin/camcontrol

2016-12-12 Thread Kenneth D. Merry
On Sun, Dec 11, 2016 at 00:49:12 +0100, Oliver Pinter wrote:
> On 10/20/16, Kenneth D. Merry <k...@freebsd.org> wrote:
> > Author: ken
> > Date: Thu Oct 20 19:42:26 2016
> > New Revision: 307684
> > URL: https://svnweb.freebsd.org/changeset/base/307684
> >
> > Log:
> >   For CCBs allocated on the stack, we need to clear the entire CCB, not
> > just
> >   the header.  Otherwise stack garbage can lead to random flags getting
> > set.
> >
> >   This showed up as 'camcontrol rescan all' failing with EINVAL because the
> >   address type wasn't CAM_DATA_VADDR.
> >
> >   sbin/camcontrol/camcontrol.c:
> > In rescan_or_reset_bus(), bzero the stack-allocated CCBs before
> > use instead of clearing the body.
> >
> >   MFC after:3 days
> >   Sponsored by: Spectra Logic
> 
> The MFC of this commit is missed both for 10-STABLE and 11-STABLE. Is
> this still in plan to do?

Done, thanks for the reminder!

Ken
-- 
Kenneth Merry
k...@freebsd.org
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r309374 - in head: sbin/camcontrol sys/cam/scsi

2016-12-01 Thread Kenneth D. Merry
Author: ken
Date: Thu Dec  1 22:20:27 2016
New Revision: 309374
URL: https://svnweb.freebsd.org/changeset/base/309374

Log:
  Add SCSI REPORT TIMESTAMP and SET TIMESTAMP support.
  
  This adds support to camcontrol(8) and libcam(3) for getting and setting
  the time on SCSI protocol drives.  This is more commonly found on tape
  drives, but is a SPC (SCSI Primary Commands) command, and may be found
  on any device that speaks SCSI.
  
  The new camcontrol timestamp subcommand allows getting the current device
  time or setting the time to the current system time or any arbitrary time.
  
  sbin/camcontrol/Makefile:
Add timestamp.c.
  
  sbin/camcontrol/camcontrol.8:
Document the new timestamp subcommand.
  
  sbin/camcontrol/camcontrol.c:
Add the timestamp subcommand to camcontrol.
  
  sbin/camcontrol/camcontrol.h:
Add the timestamp() function prototype.
  
  sbin/camcontrol/timestamp.c:
Timestamp setting and reporting functionality.
  
  sys/cam/scsi/scsi_all.c:
Add two new CCB building functions, scsi_set_timestamp() and
scsi_report_timestamp().  Also, add a new helper function,
scsi_create_timestamp().
  
  sys/cam/scsi/scsi_all.h:
Add CDB and parameter data for the the set and report timestamp
commands.
  
Add function declarations for the new CCB building and helper
functions.
  
  Submitted by: Sam Klopsch
  Sponsored by: Spectra Logic
  MFC After:2 weeks

Added:
  head/sbin/camcontrol/timestamp.c   (contents, props changed)
Modified:
  head/sbin/camcontrol/Makefile
  head/sbin/camcontrol/camcontrol.8
  head/sbin/camcontrol/camcontrol.c
  head/sbin/camcontrol/camcontrol.h
  head/sys/cam/scsi/scsi_all.c
  head/sys/cam/scsi/scsi_all.h

Modified: head/sbin/camcontrol/Makefile
==
--- head/sbin/camcontrol/Makefile   Thu Dec  1 22:12:58 2016
(r309373)
+++ head/sbin/camcontrol/Makefile   Thu Dec  1 22:20:27 2016
(r309374)
@@ -4,7 +4,7 @@ PACKAGE=runtime
 PROG=  camcontrol
 SRCS=  camcontrol.c util.c
 .if !defined(RELEASE_CRUNCH)
-SRCS+= attrib.c epc.c fwdownload.c modeedit.c persist.c progress.c zone.c
+SRCS+= attrib.c epc.c fwdownload.c modeedit.c persist.c progress.c timestamp.c 
zone.c
 .else
 CFLAGS+= -DMINIMALISTIC
 .endif

Modified: head/sbin/camcontrol/camcontrol.8
==
--- head/sbin/camcontrol/camcontrol.8   Thu Dec  1 22:12:58 2016
(r309373)
+++ head/sbin/camcontrol/camcontrol.8   Thu Dec  1 22:20:27 2016
(r309374)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 16, 2016
+.Dd November 30, 2016
 .Dt CAMCONTROL 8
 .Os
 .Sh NAME
@@ -343,6 +343,11 @@
 .Op Fl S Ar power_src
 .Op Fl T Ar timer
 .Nm
+.Ic timestamp
+.Op device id
+.Op generic args
+.Ao Fl r Oo Ns Fl f Ar format | Fl m | Fl U Oc | Fl s Ao Fl f Ar format Fl T 
Ar time | Fl U Ac Ac
+.Nm
 .Ic help
 .Sh DESCRIPTION
 The
@@ -2417,6 +2422,54 @@ supports, and a number of parameters abo
 whether it is enabled and what the timer value is.
 .El
 .El
+.It Ic timestamp
+Issue REPORT TIMESTAMP or SET TIMESTAMP
+.Tn SCSI
+commands. Either the
+.Fl r
+option or the
+.Fl s
+option must be specified.
+.Bl -tag -width 6n
+.It Fl r
+Report the device's timestamp.
+If no more arguments are specified, the timestamp will be reported using
+the national representation of the date and time, followed by the time
+zone.
+.Bl -tag -width 9n
+.It Fl f Ar format
+Specify the strftime format string, as documented in strftime(3), to be used
+to format the reported timestamp.
+.It Fl m
+Report the timestamp as milliseconds since the epoch.
+.It Fl U
+Report the timestamp using the national representation of the date and
+time, but override the system time zone and use UTC instead.
+.El
+.El
+.Bl -tag -width 6n
+.It Fl s
+Set the device's timestamp. Either the
+.Fl f
+and 
+.Fl T
+options or the
+.Fl U
+option must be specified.
+.Bl -tag -width 9n
+.It Fl f Ar format
+Specify the strptime format string, as documented in strptime(3).
+The time must also be specified with the
+.Fl T 
+option.
+.It Fl T
+Provide the time in the format specified with the
+.Fl f
+option.
+.It Fl U
+Set the timestamp to the host system's time in UTC.
+.El
+.El
 .It Ic help
 Print out verbose usage information.
 .El
@@ -2730,6 +2783,18 @@ camcontrol epc ada0 -c list
 Display the ATA Power Conditions log (Log Address 0x08) for
 drive
 .Pa ada0 .
+.Pp
+.Bd -literal -offset indent
+camcontrol timestamp sa0 -s -f "%A %c" \e
+   -T "Wednesday Wed Oct 26 21:43:57 2016"
+.Ed
+.Pp
+Set the timestamp of drive
+.Pa sa0
+using a
+.Xr strptime 3 
+format string followed by a time string
+that was created using this format string.
 .Sh SEE ALSO
 .Xr cam 3 ,
 .Xr cam_cdbparse 3 ,

Modified: head/sbin/camcontrol/camcontrol.c
==
--- 

svn commit: r307747 - head/sbin/camcontrol

2016-10-21 Thread Kenneth D. Merry
Author: ken
Date: Fri Oct 21 18:54:56 2016
New Revision: 307747
URL: https://svnweb.freebsd.org/changeset/base/307747

Log:
  Fix a problem in camcontrol(8) that cropped up with r307684.
  
  In r307684, I changed rescan_or_reset_bus() to bzero stack-allocated CCBs
  before sending them to the kernel because there was stack garbage in there
  that wound up meaning that bogus CCB flags were set.
  
  While this fixed the 'camcontrol rescan all' case (XPT_DEV_MATCH CCBs were
  failing previously), it broke the 'camcontrol rescan 0' (or any other
  number) case when INVARIANTS are turned on.  Rescanning a single bus
  reliably produced an assert in cam_periph_runccb():
  
  panic: cam_periph_runccb: ccb=0xf80044ffe000, func_code=0x708, 
flags=0xdde0
  
  The flags values don't make sense from the code.  Changing the CCBs in
  rescan_or_reset_bus() from stack to heap allocated avoids the problem.
  
  It would be better to understand why userland stack allocated CCBs don't
  work properly, since there may be other code that breaks if stack allocated
  CCBs don't work.
  
  sbin/camcontrol/camcontrol.c:
In rescan_or_reset_bus(), allocate the CCBs using malloc(3) instead
of on the stack to avoid an assertion in cam_periph_runccb().
  
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/sbin/camcontrol/camcontrol.c

Modified: head/sbin/camcontrol/camcontrol.c
==
--- head/sbin/camcontrol/camcontrol.c   Fri Oct 21 18:45:09 2016
(r307746)
+++ head/sbin/camcontrol/camcontrol.c   Fri Oct 21 18:54:56 2016
(r307747)
@@ -3127,8 +3127,8 @@ dorescan_or_reset(int argc, char **argv,
 static int
 rescan_or_reset_bus(path_id_t bus, int rescan)
 {
-   union ccb ccb, matchccb;
-   int fd, retval;
+   union ccb *ccb = NULL, *matchccb = NULL;
+   int fd = -1, retval;
int bufsize;
 
retval = 0;
@@ -3139,37 +3139,41 @@ rescan_or_reset_bus(path_id_t bus, int r
return(1);
}
 
-   bzero(, sizeof(ccb));
+   ccb = malloc(sizeof(*ccb));
+   if (ccb == NULL) {
+   warn("failed to allocate CCB");
+   retval = 1;
+   goto bailout;
+   }
+   bzero(ccb, sizeof(*ccb));
 
if (bus != CAM_BUS_WILDCARD) {
-   ccb.ccb_h.func_code = rescan ? XPT_SCAN_BUS : XPT_RESET_BUS;
-   ccb.ccb_h.path_id = bus;
-   ccb.ccb_h.target_id = CAM_TARGET_WILDCARD;
-   ccb.ccb_h.target_lun = CAM_LUN_WILDCARD;
-   ccb.crcn.flags = CAM_FLAG_NONE;
+   ccb->ccb_h.func_code = rescan ? XPT_SCAN_BUS : XPT_RESET_BUS;
+   ccb->ccb_h.path_id = bus;
+   ccb->ccb_h.target_id = CAM_TARGET_WILDCARD;
+   ccb->ccb_h.target_lun = CAM_LUN_WILDCARD;
+   ccb->crcn.flags = CAM_FLAG_NONE;
 
/* run this at a low priority */
-   ccb.ccb_h.pinfo.priority = 5;
+   ccb->ccb_h.pinfo.priority = 5;
 
-   if (ioctl(fd, CAMIOCOMMAND, ) == -1) {
+   if (ioctl(fd, CAMIOCOMMAND, ccb) == -1) {
warn("CAMIOCOMMAND ioctl failed");
-   close(fd);
-   return(1);
+   retval = 1;
+   goto bailout;
}
 
-   if ((ccb.ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
+   if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
fprintf(stdout, "%s of bus %d was successful\n",
rescan ? "Re-scan" : "Reset", bus);
} else {
fprintf(stdout, "%s of bus %d returned error %#x\n",
rescan ? "Re-scan" : "Reset", bus,
-   ccb.ccb_h.status & CAM_STATUS_MASK);
+   ccb->ccb_h.status & CAM_STATUS_MASK);
retval = 1;
}
 
-   close(fd);
-   return(retval);
-
+   goto bailout;
}
 
 
@@ -3183,58 +3187,64 @@ rescan_or_reset_bus(path_id_t bus, int r
 * no-op, sending a rescan to the xpt bus would result in a status of
 * CAM_REQ_INVALID.
 */
-   bzero(, sizeof(matchccb));
-   matchccb.ccb_h.func_code = XPT_DEV_MATCH;
-   matchccb.ccb_h.path_id = CAM_BUS_WILDCARD;
+   matchccb = malloc(sizeof(*matchccb));
+   if (matchccb == NULL) {
+   warn("failed to allocate CCB");
+   retval = 1;
+   goto bailout;
+   }
+   bzero(matchccb, sizeof(*matchccb));
+   matchccb->ccb_h.func_code = XPT_DEV_MATCH;
+   matchccb->ccb_h.path_id = CAM_BUS_WILDCARD;
bufsize = sizeof(struct dev_match_result) * 20;
-   matchccb.cdm.match_buf_len = bufsize;
-   matchccb.cdm.matches=(struct dev_match_result *)malloc(bufsize);

svn commit: r307684 - head/sbin/camcontrol

2016-10-20 Thread Kenneth D. Merry
Author: ken
Date: Thu Oct 20 19:42:26 2016
New Revision: 307684
URL: https://svnweb.freebsd.org/changeset/base/307684

Log:
  For CCBs allocated on the stack, we need to clear the entire CCB, not just
  the header.  Otherwise stack garbage can lead to random flags getting set.
  
  This showed up as 'camcontrol rescan all' failing with EINVAL because the
  address type wasn't CAM_DATA_VADDR.
  
  sbin/camcontrol/camcontrol.c:
In rescan_or_reset_bus(), bzero the stack-allocated CCBs before
use instead of clearing the body.
  
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/sbin/camcontrol/camcontrol.c

Modified: head/sbin/camcontrol/camcontrol.c
==
--- head/sbin/camcontrol/camcontrol.c   Thu Oct 20 18:43:12 2016
(r307683)
+++ head/sbin/camcontrol/camcontrol.c   Thu Oct 20 19:42:26 2016
(r307684)
@@ -3139,6 +3139,8 @@ rescan_or_reset_bus(path_id_t bus, int r
return(1);
}
 
+   bzero(, sizeof(ccb));
+
if (bus != CAM_BUS_WILDCARD) {
ccb.ccb_h.func_code = rescan ? XPT_SCAN_BUS : XPT_RESET_BUS;
ccb.ccb_h.path_id = bus;
@@ -3181,7 +3183,7 @@ rescan_or_reset_bus(path_id_t bus, int r
 * no-op, sending a rescan to the xpt bus would result in a status of
 * CAM_REQ_INVALID.
 */
-   CCB_CLEAR_ALL_EXCEPT_HDR();
+   bzero(, sizeof(matchccb));
matchccb.ccb_h.func_code = XPT_DEV_MATCH;
matchccb.ccb_h.path_id = CAM_BUS_WILDCARD;
bufsize = sizeof(struct dev_match_result) * 20;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r303019 - head/sys/geom

2016-08-12 Thread Kenneth D. Merry
On Fri, Aug 12, 2016 at 09:13:58 -0600, Warner Losh wrote:
> On Fri, Aug 12, 2016 at 9:11 AM, Kenneth D. Merry <k...@freebsd.org> wrote:
> > On Fri, Aug 12, 2016 at 13:38:21 +0300, Andrey V. Elsukov wrote:
> >> On 12.08.16 03:26, Bryan Drewery wrote:
> >> > On r303467 I ran into this:
> >> >
> >> > panic @ time 1470916206.652, thread 0xf8000412f000:
> >> > g_resize_provider_event but withered
> >> > cpuid = 0
> >> > Panic occurred in module kernel loaded at 0x8020:
> >> >
> >> > Stack: --
> >> > kernel:kassert_panic+0x166
> >> > kernel:g_resize_provider_event+0x181
> >> > kernel:g_run_events+0x186^M^M
> >> > kernel:fork_exit+0x83^M^M
> >> > --
> >> >
> >> > No further information available unfortunately.
> >>
> >> This one is related to r302087 :)
> >
> > It looks like there is a race.  I think we need to replace the KASSERT
> > in g_resize_provider_event() with a return in case the provider is
> > withered.
> >
> > I won't be able to work on or test this until sometime next week.  So if
> > you guys want to go ahead and make the change, please do.
> 
> But why are we calling g_resize_provider on a withered object? That's
> the part I don't understand in this thread.

It isn't withered when the event is queued, but it is withered by the time
the event is executed.

There is a check in g_resize_provider() to make sure it isn't withered.  If
not, the event is queued.  But once g_resize_provider_event() runs, it is
withered and we run into the KASSERT.

There isn't adequate locking and ordering in there to prevent the race
from happening, so the assert should be replaced with an "if (withered)
return" statement.

Ken
-- 
Kenneth Merry
k...@freebsd.org
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r303019 - head/sys/geom

2016-08-12 Thread Kenneth D. Merry
On Fri, Aug 12, 2016 at 13:38:21 +0300, Andrey V. Elsukov wrote:
> On 12.08.16 03:26, Bryan Drewery wrote:
> > On r303467 I ran into this:
> > 
> > panic @ time 1470916206.652, thread 0xf8000412f000:
> > g_resize_provider_event but withered
> > cpuid = 0
> > Panic occurred in module kernel loaded at 0x8020:
> > 
> > Stack: --
> > kernel:kassert_panic+0x166
> > kernel:g_resize_provider_event+0x181
> > kernel:g_run_events+0x186^M^M
> > kernel:fork_exit+0x83^M^M
> > --
> > 
> > No further information available unfortunately.
> 
> This one is related to r302087 :)

It looks like there is a race.  I think we need to replace the KASSERT
in g_resize_provider_event() with a return in case the provider is
withered.

I won't be able to work on or test this until sometime next week.  So if
you guys want to go ahead and make the change, please do.

Ken
-- 
Kenneth Merry
k...@freebsd.org
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302253 - head/sys/cam/scsi

2016-06-28 Thread Kenneth D. Merry
On Tue, Jun 28, 2016 at 11:27:25 -0700, Sean Bruno wrote:
> 
> 
> On 06/28/16 11:17, Ken Merry wrote:
> > This is incorrect.  It should be scsi_ulto4b() instead.
> > 
> > The dxfer_len argument to scsi_persistent_reserve_out() is a uint32_t, and 
> > the length field in the CDB structure is 4 bytes long.
> > 
> > Sorry I didn???t get around to commenting on the PR, otherwise I would have 
> > caught this previously.
> > 
> > Ken
> > ??? 
> > Ken Merry
> > k...@freebsd.org
> 
> Ok, I shall revert this then generate a new diff for your review and
> submission to re for commit.

Thanks!

Ken
-- 
Kenneth Merry
k...@freebsd.org
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r302150 - in head/sys: geom sys

2016-06-23 Thread Kenneth D. Merry
Author: ken
Date: Thu Jun 23 20:05:59 2016
New Revision: 302150
URL: https://svnweb.freebsd.org/changeset/base/302150

Log:
  Switch geom_disk over to using a pool mutex.
  
  The GEOM disk d_mtx is only acquired on disk creation and destruction.
  It is a good candidate for replacement with a pool mutex.  This eliminates
  the mutex initialization and teardown and the mutex and name variables
  themselves from struct disk.
  
  sys/geom/geom_disk.h:
Take d_mtx and d_mtx_name out of struct disk.
  
  sys/geom/geom_disk.c:
Use mtx_pool_lock() and mtx_pool_unlock() to guard the disk
initialization state instead of a dedicated mutex.
  
This allows removing the initialization and destruction of
d_mtx.
  
  sys/sys/param.h:
Bump __FreeBSD_version to 1100119 for the change to struct disk.
  
  Suggested by: jhb
  Sponsored by: Spectra Logic
  Approved by:  re (gjb)

Modified:
  head/sys/geom/geom_disk.c
  head/sys/geom/geom_disk.h
  head/sys/sys/param.h

Modified: head/sys/geom/geom_disk.c
==
--- head/sys/geom/geom_disk.c   Thu Jun 23 19:37:00 2016(r302149)
+++ head/sys/geom/geom_disk.c   Thu Jun 23 20:05:59 2016(r302150)
@@ -670,7 +670,7 @@ g_disk_create(void *arg, int flag)
g_topology_assert();
dp = arg;
 
-   mtx_lock(>d_mtx);
+   mtx_pool_lock(mtxpool_sleep, dp);
dp->d_init_level = DISK_INIT_START;
 
/*
@@ -678,12 +678,12 @@ g_disk_create(void *arg, int flag)
 * call the user's callback to tell him we've cleaned things up.
 */
if (dp->d_goneflag != 0) {
-   mtx_unlock(>d_mtx);
+   mtx_pool_unlock(mtxpool_sleep, dp);
if (dp->d_gone != NULL)
dp->d_gone(dp);
return;
}
-   mtx_unlock(>d_mtx);
+   mtx_pool_unlock(mtxpool_sleep, dp);
 
sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO);
mtx_init(>start_mtx, "g_disk_start", NULL, MTX_DEF);
@@ -721,7 +721,7 @@ g_disk_create(void *arg, int flag)
dp->d_geom = gp;
g_error_provider(pp, 0);
 
-   mtx_lock(>d_mtx);
+   mtx_pool_lock(mtxpool_sleep, dp);
dp->d_init_level = DISK_INIT_DONE;
 
/*
@@ -729,11 +729,11 @@ g_disk_create(void *arg, int flag)
 * process for it.
 */
if (dp->d_goneflag != 0) {
-   mtx_unlock(>d_mtx);
+   mtx_pool_unlock(mtxpool_sleep, dp);
g_wither_provider(pp, ENXIO);
return;
}
-   mtx_unlock(>d_mtx);
+   mtx_pool_unlock(mtxpool_sleep, dp);
 
 }
 
@@ -786,8 +786,6 @@ g_disk_destroy(void *ptr, int flag)
g_wither_geom(gp, ENXIO);
}
 
-   mtx_destroy(>d_mtx);
-
g_free(dp);
 }
 
@@ -852,9 +850,6 @@ disk_create(struct disk *dp, int version
DEVSTAT_TYPE_DIRECT, DEVSTAT_PRIORITY_MAX);
dp->d_geom = NULL;
 
-   snprintf(dp->d_mtx_name, sizeof(dp->d_mtx_name), "%s%ddlk",
-dp->d_name, dp->d_unit);
-   mtx_init(>d_mtx, dp->d_mtx_name, NULL, MTX_DEF);
dp->d_init_level = DISK_INIT_NONE;
 
g_disk_ident_adjust(dp->d_ident, sizeof(dp->d_ident));
@@ -878,7 +873,7 @@ disk_gone(struct disk *dp)
struct g_geom *gp;
struct g_provider *pp;
 
-   mtx_lock(>d_mtx);
+   mtx_pool_lock(mtxpool_sleep, dp);
dp->d_goneflag = 1;
 
/*
@@ -897,10 +892,10 @@ disk_gone(struct disk *dp)
 * has not been fully setup in any case.
 */
if (dp->d_init_level < DISK_INIT_DONE) {
-   mtx_unlock(>d_mtx);
+   mtx_pool_unlock(mtxpool_sleep, dp);
return;
}
-   mtx_unlock(>d_mtx);
+   mtx_pool_unlock(mtxpool_sleep, dp);
 
gp = dp->d_geom;
if (gp != NULL) {

Modified: head/sys/geom/geom_disk.h
==
--- head/sys/geom/geom_disk.h   Thu Jun 23 19:37:00 2016(r302149)
+++ head/sys/geom/geom_disk.h   Thu Jun 23 20:05:59 2016(r302150)
@@ -72,8 +72,6 @@ struct disk {
struct devstat  *d_devstat;
int d_goneflag;
int d_destroyed;
-   struct mtx  d_mtx;
-   chard_mtx_name[24];
disk_init_level d_init_level;
 
/* Shared fields */

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hThu Jun 23 19:37:00 2016(r302149)
+++ head/sys/sys/param.hThu Jun 23 20:05:59 2016(r302150)
@@ -58,7 +58,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1100118  /* Master, propagated to newvers */
+#define __FreeBSD_version 1100119  /* Master, propagated to newvers */
 
 

svn commit: r302087 - head/sys/geom

2016-06-22 Thread Kenneth D. Merry
Author: ken
Date: Wed Jun 22 14:39:13 2016
New Revision: 302087
URL: https://svnweb.freebsd.org/changeset/base/302087

Log:
  Fix a bug that caused da(4) peripheral drivers to not fully go away
  after the underlying device went away.
  
  The problem was that callers who queue the GEOM resize provider
  event didn't check to make sure that the provider had not been
  withered.  For the other equivalent case, g_new_provider_event(),
  the code checks to see whether the provider has been withered
  before queueing a g_new_provider_event() to the event thread.
  
  In some cases, a resize provider event would come through after
  the provider had been withered and all of the existing consumers
  had been orphaned.  When the resize event triggered a taste of
  the provider, that would attach a new consumer to the now
  withered provider.  The wither washer (g_wither_washer() would
  never be able to completely tear down the GEOM because of the
  consumers that were hanging around.
  
  The solution was to check the G_PF_WITHER provider flag before
  queueing the g_resize_provider_event(), and add an assert to
  g_resize_provider_event() to insure that it isn't called on a
  withered provider.
  
  sys/geom/geom_subr.c:
In g_resize_provider(), don't try to continue if the
G_PF_WITHER flag is set.
  
In g_resize_provider_event(), add an assert that the
G_PF_WITHER flag is not set.
  
In g_access(), if a provider has an error, print out the
name of the provider with the error.
  
  Sponsored by: Spectra Logic
  Approved by:  re (marius)
  MFC after:3 days

Modified:
  head/sys/geom/geom_subr.c

Modified: head/sys/geom/geom_subr.c
==
--- head/sys/geom/geom_subr.c   Wed Jun 22 12:53:10 2016(r302086)
+++ head/sys/geom/geom_subr.c   Wed Jun 22 14:39:13 2016(r302087)
@@ -620,6 +620,8 @@ g_resize_provider_event(void *arg, int f
g_free(hh);
 
G_VALID_PROVIDER(pp);
+   KASSERT(!(pp->flags & G_PF_WITHER),
+   ("g_resize_provider_event but withered"));
g_trace(G_T_TOPOLOGY, "g_resize_provider_event(%p)", pp);
 
LIST_FOREACH_SAFE(cp, >consumers, consumers, cp2) {
@@ -662,6 +664,8 @@ g_resize_provider(struct g_provider *pp,
struct g_hh00 *hh;
 
G_VALID_PROVIDER(pp);
+   if (pp->flags & G_PF_WITHER)
+   return;
 
if (size == pp->mediasize)
return;
@@ -909,8 +913,11 @@ g_access(struct g_consumer *cp, int dcr,
else if (dcw > 0 && pe > 0)
return (EPERM);
/* If we try to open more but provider is error'ed: fail */
-   else if ((dcr > 0 || dcw > 0 || dce > 0) && pp->error != 0)
+   else if ((dcr > 0 || dcw > 0 || dce > 0) && pp->error != 0) {
+   printf("%s(%d): provider %s has error\n",
+  __func__, __LINE__, pp->name);
return (pp->error);
+   }
 
/* Ok then... */
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r302071 - head/sys/sys

2016-06-21 Thread Kenneth D. Merry
Author: ken
Date: Tue Jun 21 20:28:30 2016
New Revision: 302071
URL: https://svnweb.freebsd.org/changeset/base/302071

Log:
  Bump __FreeBSD_version to 1100118 for r302069, which breaks binary
  compatibility for loadable modules that depend on struct disk.
  
  Approved by:  re (delphij)
  Sponsored by: Spectra Logic

Modified:
  head/sys/sys/param.h

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hTue Jun 21 20:20:30 2016(r302070)
+++ head/sys/sys/param.hTue Jun 21 20:28:30 2016(r302071)
@@ -58,7 +58,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1100117  /* Master, propagated to newvers */
+#define __FreeBSD_version 1100118  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r302069 - head/sys/geom

2016-06-21 Thread Kenneth D. Merry
Author: ken
Date: Tue Jun 21 20:18:19 2016
New Revision: 302069
URL: https://svnweb.freebsd.org/changeset/base/302069

Log:
  Fix a bug that caused da(4) instances to hang around after the underlying
  device is gone.
  
  The problem was that when disk_gone() is called, if the GEOM disk
  creation process has not yet happened, the withering process
  couldn't start.
  
  We didn't record any state in the GEOM disk code, and so the d_gone()
  callback to the da(4) driver never happened.
  
  The solution is to track the state of the creation process, and
  initiate the withering process from g_disk_create() if the disk is
  being created.
  
  This change does add fields to struct disk, and so I have bumped
  DISK_VERSION.
  
  geom_disk.c:  Track where we are in the disk creation process,
and check to see whether our underlying disk has
gone away or not.
  
In disk_gone(), set a new d_goneflag variable that
g_disk_create() can check to see if it needs to
clean up the disk instance.
  
  geom_disk.h:Add a mutex to struct disk (for internal use) disk
init level, and a gone flag.
  
Bump DISK_VERSION because the size of struct disk has
changed and fields have been added at the beginning.
  
  Sponsored by: Spectra Logic
  Approved by:  re (marius)

Modified:
  head/sys/geom/geom_disk.c
  head/sys/geom/geom_disk.h

Modified: head/sys/geom/geom_disk.c
==
--- head/sys/geom/geom_disk.c   Tue Jun 21 20:15:30 2016(r302068)
+++ head/sys/geom/geom_disk.c   Tue Jun 21 20:18:19 2016(r302069)
@@ -669,6 +669,22 @@ g_disk_create(void *arg, int flag)
return;
g_topology_assert();
dp = arg;
+
+   mtx_lock(>d_mtx);
+   dp->d_init_level = DISK_INIT_START;
+
+   /*
+* If the disk has already gone away, we can just stop here and
+* call the user's callback to tell him we've cleaned things up.
+*/
+   if (dp->d_goneflag != 0) {
+   mtx_unlock(>d_mtx);
+   if (dp->d_gone != NULL)
+   dp->d_gone(dp);
+   return;
+   }
+   mtx_unlock(>d_mtx);
+
sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO);
mtx_init(>start_mtx, "g_disk_start", NULL, MTX_DEF);
mtx_init(>done_mtx, "g_disk_done", NULL, MTX_DEF);
@@ -704,6 +720,21 @@ g_disk_create(void *arg, int flag)
pp->private = sc;
dp->d_geom = gp;
g_error_provider(pp, 0);
+
+   mtx_lock(>d_mtx);
+   dp->d_init_level = DISK_INIT_DONE;
+
+   /*
+* If the disk has gone away at this stage, start the withering
+* process for it.
+*/
+   if (dp->d_goneflag != 0) {
+   mtx_unlock(>d_mtx);
+   g_wither_provider(pp, ENXIO);
+   return;
+   }
+   mtx_unlock(>d_mtx);
+
 }
 
 /*
@@ -754,6 +785,9 @@ g_disk_destroy(void *ptr, int flag)
dp->d_geom = NULL;
g_wither_geom(gp, ENXIO);
}
+
+   mtx_destroy(>d_mtx);
+
g_free(dp);
 }
 
@@ -817,6 +851,12 @@ disk_create(struct disk *dp, int version
dp->d_sectorsize, DEVSTAT_ALL_SUPPORTED,
DEVSTAT_TYPE_DIRECT, DEVSTAT_PRIORITY_MAX);
dp->d_geom = NULL;
+
+   snprintf(dp->d_mtx_name, sizeof(dp->d_mtx_name), "%s%ddlk",
+dp->d_name, dp->d_unit);
+   mtx_init(>d_mtx, dp->d_mtx_name, NULL, MTX_DEF);
+   dp->d_init_level = DISK_INIT_NONE;
+
g_disk_ident_adjust(dp->d_ident, sizeof(dp->d_ident));
g_post_event(g_disk_create, dp, M_WAITOK, dp, NULL);
 }
@@ -838,6 +878,30 @@ disk_gone(struct disk *dp)
struct g_geom *gp;
struct g_provider *pp;
 
+   mtx_lock(>d_mtx);
+   dp->d_goneflag = 1;
+
+   /*
+* If we're still in the process of creating this disk (the
+* g_disk_create() function is still queued, or is in
+* progress), the init level will not yet be DISK_INIT_DONE.
+*
+* If that is the case, g_disk_create() will see d_goneflag
+* and take care of cleaning things up.
+*
+* If the disk has already been created, we default to
+* withering the provider as usual below.
+*
+* If the caller has not set a d_gone() callback, he will
+* not be any worse off by returning here, because the geom
+* has not been fully setup in any case.
+*/
+   if (dp->d_init_level < DISK_INIT_DONE) {
+   mtx_unlock(>d_mtx);
+   return;
+   }
+   mtx_unlock(>d_mtx);
+
gp = dp->d_geom;
if (gp != NULL) {
pp = LIST_FIRST(>provider);

Modified: head/sys/geom/geom_disk.h
==
--- head/sys/geom/geom_disk.h   Tue 

svn commit: r300640 - head/sys/cam/ata

2016-05-24 Thread Kenneth D. Merry
Author: ken
Date: Wed May 25 01:37:39 2016
New Revision: 300640
URL: https://svnweb.freebsd.org/changeset/base/300640

Log:
  Fix a few ada(4) driver issues:
  
   o Some Samsung drives do not support the ATA READ LOG EXT or READ
 LOG DMA EXT commands, despite indicating that they do in their
 IDENTIFY data.  So, fix this in two ways:
1. Only start the log directory probe (ADA_STATE_LOGDIR) if
   the drive claims to be an SMR drive in the first place.
   We don't need to do the extra probing for other devices.
   This will also serve to prevent problems with other
   drives that have the same issue.
2. Add quirks for the two Samsung drives that have been
   reported so far (thanks to Oleg Nauman and Alex Petrov).
   If there is a reason to do a Read Log later on, we will
   know that it doesn't work on these drives.
  
   o Add a quirk entry to mark Seagate Lamarr Drive Managed drives as
 drive managed.  They don't report this in their Identify data.
  
  sys/cam/ata/ata_da.c:
Add two new quirks:
1. ADA_Q_LOG_BROKEN, for drives that claim to support Read
   Log but don't really.
2. ADA_Q_SMR_DM, for drives that are Drive Managed SMR, but
   don't report it.  This can matter for software that
   wants to know when it should make an extra effort to
   write sequentially.
  
Record two Samsung drives that don't support Read Log, and
one Seagate drive that doesn't report that it is a SMR drive.
The Seagate drive is already recorded in the da(4) driver.
  
We may have to come up with a similar solution in the da(4)
driver for SATA drives that don't properly support Read Log.
  
In adasetflags(), Dont' set the ADA_FLAG_CAN_LOG bit if the
device has the LOG_BROKEN quirk set.  Also, look at the
SMR_DM quirk and set the device type accordingly if it is
actually a drive managed drive.
  
When deciding whether to go into the LOGDIR probe state,
look to see whether the device claims to be an SMR device.
If not, don't bother with the LOGDIR probe state.
  
  Sponsored by: Spectra Logic

Modified:
  head/sys/cam/ata/ata_da.c

Modified: head/sys/cam/ata/ata_da.c
==
--- head/sys/cam/ata/ata_da.c   Wed May 25 01:37:25 2016(r300639)
+++ head/sys/cam/ata/ata_da.c   Wed May 25 01:37:39 2016(r300640)
@@ -115,12 +115,16 @@ typedef enum {
ADA_Q_NONE  = 0x00,
ADA_Q_4K= 0x01,
ADA_Q_NCQ_TRIM_BROKEN   = 0x02,
+   ADA_Q_LOG_BROKEN= 0x04,
+   ADA_Q_SMR_DM= 0x08
 } ada_quirks;
 
 #define ADA_Q_BIT_STRING   \
"\020"  \
"\0014K"\
-   "\002NCQ_TRIM_BROKEN"
+   "\002NCQ_TRIM_BROKEN"   \
+   "\003LOG_BROKEN"\
+   "\004SMR_DM"
 
 typedef enum {
ADA_CCB_RAHEAD  = 0x01,
@@ -680,6 +684,35 @@ static struct ada_quirk_entry ada_quirk_
/*quirks*/ADA_Q_4K
},
{
+   /*
+* Samsung drive that doesn't support READ LOG EXT or
+* READ LOG DMA EXT, despite reporting that it does in
+* ATA identify data:
+* SAMSUNG HD200HJ KF100-06
+*/
+   { T_DIRECT, SIP_MEDIA_FIXED, "*", "SAMSUNG HD200*", "*" },
+   /*quirks*/ADA_Q_LOG_BROKEN
+   },
+   {
+   /*
+* Samsung drive that doesn't support READ LOG EXT or
+* READ LOG DMA EXT, despite reporting that it does in
+* ATA identify data:
+* SAMSUNG HD501LJ CR100-10
+*/
+   { T_DIRECT, SIP_MEDIA_FIXED, "*", "SAMSUNG HD501*", "*" },
+   /*quirks*/ADA_Q_LOG_BROKEN
+   },
+   {
+   /*
+* Seagate Lamarr 8TB Shingled Magnetic Recording (SMR)
+* Drive Managed SATA hard drive.  This drive doesn't report
+* in firmware that it is a drive managed SMR drive.
+*/
+   { T_DIRECT, SIP_MEDIA_FIXED, "*", "ST8000AS0002*", "*" },
+   /*quirks*/ADA_Q_SMR_DM
+   },
+   {
/* Default */
{
  T_ANY, SIP_MEDIA_REMOVABLE|SIP_MEDIA_FIXED,
@@ -1258,7 +1291,8 @@ adaasync(void *callback_arg, u_int32_t c
softc->state = ADA_STATE_RAHEAD;
else if (ADA_WC >= 0 && softc->flags & ADA_FLAG_CAN_RAHEAD)
softc->state = ADA_STATE_WCACHE;
-   else if (softc->flags & ADA_FLAG_CAN_LOG)
+   else if ((softc->flags & ADA_FLAG_CAN_LOG)
+ && (softc->zone_mode != ADA_ZONE_NONE))
softc->state = ADA_STATE_LOGDIR;
  

svn commit: r300532 - head/sys/cam/ata

2016-05-23 Thread Kenneth D. Merry
Author: ken
Date: Mon May 23 19:52:08 2016
New Revision: 300532
URL: https://svnweb.freebsd.org/changeset/base/300532

Log:
  Fix ada(4) trim support quirk setting.
  
  I broke broke the quirk in the ada(4) driver disabling NCQ trim support
  in revision 300207.  The support flags were set before the quirks were
  loaded.
  
  sys/cam/ata/ata_da.c:
Call adasetflags() after loading quirks, so that we'll set the
flags accurately.
  
  Sponsored by: Spectra Logic

Modified:
  head/sys/cam/ata/ata_da.c

Modified: head/sys/cam/ata/ata_da.c
==
--- head/sys/cam/ata/ata_da.c   Mon May 23 19:46:58 2016(r300531)
+++ head/sys/cam/ata/ata_da.c   Mon May 23 19:52:08 2016(r300532)
@@ -1639,11 +1639,6 @@ adaregister(struct cam_periph *periph, v
return(CAM_REQ_CMP_ERR);
}
 
-   /*
-* Set support flags based on the Identify data.
-*/
-   adasetflags(softc, cgd);
-
periph->softc = softc;
 
/*
@@ -1683,6 +1678,12 @@ adaregister(struct cam_periph *periph, v
snprintf(announce_buf, sizeof(announce_buf),
"kern.cam.ada.%d.write_cache", periph->unit_number);
TUNABLE_INT_FETCH(announce_buf, >write_cache);
+
+   /*
+* Set support flags based on the Identify data and quirks.
+*/
+   adasetflags(softc, cgd);
+
/* Disable queue sorting for non-rotational media by default. */
if (cgd->ident_data.media_rotation_rate == ATA_RATE_NON_ROTATING) {
softc->rotating = 0;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r300327 - in head: lib/libmt usr.bin/mt

2016-05-20 Thread Kenneth D. Merry
Author: ken
Date: Fri May 20 19:30:52 2016
New Revision: 300327
URL: https://svnweb.freebsd.org/changeset/base/300327

Log:
  Add the density code for LTO-7 to libmt and the mt(1) man page.
  
  The density code and bits per mm values were obtained from an
  actual drive density report.
  
  The number of tracks were obtained from an LTO-7 hardware
  announcement on IBM's web site.
  
  Sponsored by: Spectra Logic
  MFC after:3 days

Modified:
  head/lib/libmt/mtlib.c
  head/usr.bin/mt/mt.1

Modified: head/lib/libmt/mtlib.c
==
--- head/lib/libmt/mtlib.c  Fri May 20 19:25:57 2016(r300326)
+++ head/lib/libmt/mtlib.c  Fri May 20 19:30:52 2016(r300327)
@@ -643,6 +643,7 @@ static struct densities {
{ 0x55, 20670,  525018, "3592A5 (unencrypted)" },
{ 0x58, 15142,  384607, "LTO-5" },
{ 0x5A, 15142,  384607, "LTO-6" },
+   { 0x5C, 19107,  485318, "LTO-7" },
{ 0x71, 11800,  299720, "3592A1 (encrypted)" },
{ 0x72, 11800,  299720, "3592A2 (encrypted)" },
{ 0x73, 13452,  341681, "3592A3 (encrypted)" },

Modified: head/usr.bin/mt/mt.1
==
--- head/usr.bin/mt/mt.1Fri May 20 19:25:57 2016(r300326)
+++ head/usr.bin/mt/mt.1Fri May 20 19:30:52 2016(r300327)
@@ -29,7 +29,7 @@
 .\"@(#)mt.18.1 (Berkeley) 6/6/93
 .\" $FreeBSD$
 .\"
-.Dd March 3, 2014
+.Dd May 20, 2016
 .Dt MT 1
 .Os
 .Sh NAME
@@ -517,6 +517,7 @@ Value  WidthTracksDensity   
 0x55   12.7  (0.5) 5120  20,670 (525,018)   C   3592A5 (unencrypted)
 0x58   12.7  (0.5) 1280  15,142 (384,607)   C   LTO-5
 0x5A   12.7  (0.5) 2176  15,142 (384,607)   C   LTO-6
+0x5C   12.7  (0.5) 3584  19,107 (485,318)   C   LTO-7
 0x71   12.7  (0.5)  512  11,800 (299,720)   C   3592A1 (encrypted)
 0x72   12.7  (0.5)  896  11,800 (299,720)   C   3592A2 (encrypted)
 0x73   12.7  (0.5) 1152  13,452 (341,681)   C   3592A3 (encrypted)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r300224 - head/usr.sbin/camdd

2016-05-19 Thread Kenneth D. Merry
Author: ken
Date: Thu May 19 19:13:43 2016
New Revision: 300224
URL: https://svnweb.freebsd.org/changeset/base/300224

Log:
  Adjust a couple of error cases in camdd(8).
  
  usr.sbin/camdd/camdd.c:
In camdd_probe_file(), fix an error case after fstat where
we were bailing out and leaving two lines of cleanup code
unexecuted.  Instead, just goto bailout_error.
  
In camdd_probe_pass(), fail if the sector size is 0.
  
  Sponsored by: Spectra Logic
  MFC after:3 days

Modified:
  head/usr.sbin/camdd/camdd.c

Modified: head/usr.sbin/camdd/camdd.c
==
--- head/usr.sbin/camdd/camdd.c Thu May 19 17:54:14 2016(r300223)
+++ head/usr.sbin/camdd/camdd.c Thu May 19 19:13:43 2016(r300224)
@@ -1079,9 +1079,7 @@ camdd_probe_file(int fd, struct camdd_io
retval = fstat(fd, _dev->sb);
if (retval != 0) {
warn("Cannot stat %s", dev->device_name);
-   goto bailout;
-   camdd_free_dev(dev);
-   dev = NULL;
+   goto bailout_error;
}
if (S_ISREG(file_dev->sb.st_mode)) {
file_dev->file_type = CAMDD_FILE_REG;
@@ -1383,6 +1381,11 @@ camdd_probe_pass(struct cam_device *cam_
block_len = scsi_4btoul(rcaplong.length);
 
 rcap_done:
+   if (block_len == 0) {
+   warnx("Sector size for %s%u is 0, cannot continue",
+   cam_dev->device_name, cam_dev->dev_unit_num);
+   goto bailout_error;
+   }
 
bzero(&(>ccb_h)[1],
  sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr));
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r300207 - in head: sbin/camcontrol sys/cam/ata sys/cam/scsi sys/dev/ahci sys/geom sys/geom/eli sys/kern sys/sys usr.sbin usr.sbin/diskinfo usr.sbin/zonectl

2016-05-19 Thread Kenneth D. Merry
On Thu, May 19, 2016 at 15:30:37 +0100, Bruce Simpson wrote:
> Right On Commander!
> 
> Now here is hoping the random-write issues with OpenZFS are solved...

Well, this is of course only the underlying infrastructure for SMR drives.

As for the random write issues with ZFS (or rather sequential I/O going out
in random order), we (Spectra) are working on that in general.

The original plan was to do full SMR support for ZFS, but it looks like we
may get good enough write performance with Drive Managed drives by just
making writes from ZFS to drives more sequential rather than going for full
Host Aware and Host Managed support.  If that turns out that performance
isn't good enough after all, then we'll have to put in the effort to put
Host Aware support at least into ZFS.

That's why I said (in the commit message) that I don't know of anyone
working on using the SMR infrastructure for UFS or ZFS.  Now that the
plumbing is in place in CAM and GEOM, it is possible at the filesystem
level if someone wants to do the work.

Ken
-- 
Kenneth Merry
k...@freebsd.org
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r300207 - in head: sbin/camcontrol sys/cam/ata sys/cam/scsi sys/dev/ahci sys/geom sys/geom/eli sys/kern sys/sys usr.sbin usr.sbin/diskinfo usr.sbin/zonectl

2016-05-19 Thread Kenneth D. Merry
Author: ken
Date: Thu May 19 14:08:36 2016
New Revision: 300207
URL: https://svnweb.freebsd.org/changeset/base/300207

Log:
  Add support for managing Shingled Magnetic Recording (SMR) drives.
  
  This change includes support for SCSI SMR drives (which conform to the
  Zoned Block Commands or ZBC spec) and ATA SMR drives (which conform to
  the Zoned ATA Command Set or ZAC spec) behind SAS expanders.
  
  This includes full management support through the GEOM BIO interface, and
  through a new userland utility, zonectl(8), and through camcontrol(8).
  
  This is now ready for filesystems to use to detect and manage zoned drives.
  (There is no work in progress that I know of to use this for ZFS or UFS, if
  anyone is interested, let me know and I may have some suggestions.)
  
  Also, improve ATA command passthrough and dispatch support, both via ATA
  and ATA passthrough over SCSI.
  
  Also, add support to camcontrol(8) for the ATA Extended Power Conditions
  feature set.  You can now manage ATA device power states, and set various
  idle time thresholds for a drive to enter lower power states.
  
  Note that this change cannot be MFCed in full, because it depends on
  changes to the struct bio API that break compatilibity.  In order to
  avoid breaking the stable API, only changes that don't touch or depend on
  the struct bio changes can be merged.  For example, the camcontrol(8)
  changes don't depend on the new bio API, but zonectl(8) and the probe
  changes to the da(4) and ada(4) drivers do depend on it.
  
  Also note that the SMR changes have not yet been tested with an actual
  SCSI ZBC device, or a SCSI to ATA translation layer (SAT) that supports
  ZBC to ZAC translation.  I have not yet gotten a suitable drive or SAT
  layer, so any testing help would be appreciated.  These changes have been
  tested with Seagate Host Aware SATA drives attached to both SAS and SATA
  controllers.  Also, I do not have any SATA Host Managed devices, and I
  suspect that it may take additional (hopefully minor) changes to support
  them.
  
  Thanks to Seagate for supplying the test hardware and answering questions.
  
  sbin/camcontrol/Makefile:
Add epc.c and zone.c.
  
  sbin/camcontrol/camcontrol.8:
Document the zone and epc subcommands.
  
  sbin/camcontrol/camcontrol.c:
Add the zone and epc subcommands.
  
Add auxiliary register support to build_ata_cmd().  Make sure to
set the CAM_ATAIO_NEEDRESULT, CAM_ATAIO_DMA, and CAM_ATAIO_FPDMA
flags as appropriate for ATA commands.
  
Add a new get_ata_status() function to parse ATA result from SCSI
sense descriptors (for ATA passthrough over SCSI) and ATA I/O
requests.
  
  sbin/camcontrol/camcontrol.h:
Update the build_ata_cmd() prototype
  
Add get_ata_status(), zone(), and epc().
  
  sbin/camcontrol/epc.c:
Support for ATA Extended Power Conditions features.  This includes
support for all features documented in the ACS-4 Revision 12
specification from t13.org (dated February 18, 2016).
  
The EPC feature set allows putting a drive into a power power mode
immediately, or setting timeouts so that the drive will
automatically enter progressively lower power states after various
idle times.
  
  sbin/camcontrol/fwdownload.c:
Update the firmware download code for the new build_ata_cmd()
arguments.
  
  sbin/camcontrol/zone.c:
Implement support for Shingled Magnetic Recording (SMR) drives
via SCSI Zoned Block Commands (ZBC) and ATA Zoned Device ATA
Command Set (ZAC).
  
These specs were developed in concert, and are functionally
identical.  The primary differences are due to SCSI and ATA
differences.  (SCSI is big endian, ATA is little endian, for
example.)
  
This includes support for all commands defined in the ZBC and
ZAC specs.
  
  sys/cam/ata/ata_all.c:
Decode a number of additional ATA command names in ata_op_string().
  
Add a new CCB building function, ata_read_log().
  
Add ata_zac_mgmt_in() and ata_zac_mgmt_out() CCB building
functions.  These support both DMA and NCQ encapsulation.
  
  sys/cam/ata/ata_all.h:
Add prototypes for ata_read_log(), ata_zac_mgmt_out(), and
ata_zac_mgmt_in().
  
  sys/cam/ata/ata_da.c:
Revamp the ada(4) driver to support zoned devices.
  
Add four new probe states to gather information needed for zone
support.
  
Add a new adasetflags() function to avoid duplication of large
blocks of flag setting between the async handler and register
functions.
  
Add new sysctl variables that describe zone support and paramters.
  
Add support for the new BIO_ZONE bio, and all of its subcommands:
DISK_ZONE_OPEN, DISK_ZONE_CLOSE, DISK_ZONE_FINISH, DISK_ZONE_RWP,
DISK_ZONE_REPORT_ZONES, and 

svn commit: r295417 - head/sys/cam/scsi

2016-02-08 Thread Kenneth D. Merry
Author: ken
Date: Mon Feb  8 22:13:08 2016
New Revision: 295417
URL: https://svnweb.freebsd.org/changeset/base/295417

Log:
  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
  MFC after:3 days

Modified:
  head/sys/cam/scsi/scsi_xpt.c

Modified: head/sys/cam/scsi/scsi_xpt.c
==
--- head/sys/cam/scsi/scsi_xpt.cMon Feb  8 22:02:56 2016
(r295416)
+++ head/sys/cam/scsi/scsi_xpt.cMon Feb  8 22:13:08 2016
(r295417)
@@ -1518,7 +1518,7 @@ out:
} else if (cam_periph_error(done_ccb, 0,
SF_RETRY_UA,
>saved_ccb) == ERESTART) {
-   return;
+   goto outr;
} else if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) {
/* Don't wedge the queue */
xpt_release_devq(done_ccb->ccb_h.path, /*count*/1,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r291716 - in head: share/man/man4 sys/cam sys/cam/ata sys/cam/scsi sys/dev/md sys/geom sys/kern sys/pc98/include sys/sys usr.sbin usr.sbin/camdd

2016-01-11 Thread Kenneth D. Merry
On Mon, Jan 11, 2016 at 18:29:22 +0100, Roger Pau Monn?? wrote:
> El 03/12/15 a les 21.54, Kenneth D. Merry ha escrit:
> > Author: ken
> > Date: Thu Dec  3 20:54:55 2015
> > New Revision: 291716
> > URL: https://svnweb.freebsd.org/changeset/base/291716
> > 
> > Log:
> >   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 o

svn commit: r291960 - head/sys/cam

2015-12-07 Thread Kenneth D. Merry
Author: ken
Date: Mon Dec  7 21:04:27 2015
New Revision: 291960
URL: https://svnweb.freebsd.org/changeset/base/291960

Log:
  The ccb_xflags enumeration was removed from FreeBSD/head in
  r259397 (it contained the CAM_EXTLUN_VALID bit) and I added the
  same type name with a different set of values back in r291716.
  
  The old ccb_xflags enumeration still exists in FreeBSD stable/10.
  Shift all of the new values by one bit to avoid compatibility
  issues when merged to stable/10.
  
  MFC after:3 days
  Sponsored by: Spectra Logic

Modified:
  head/sys/cam/cam_ccb.h

Modified: head/sys/cam/cam_ccb.h
==
--- head/sys/cam/cam_ccb.h  Mon Dec  7 20:48:28 2015(r291959)
+++ head/sys/cam/cam_ccb.h  Mon Dec  7 21:04:27 2015(r291960)
@@ -110,9 +110,9 @@ typedef enum {
 } ccb_flags;
 
 typedef enum {
-   CAM_USER_DATA_ADDR  = 0x0001,/* Userspace data pointers */
-   CAM_SG_FORMAT_IOVEC = 0x0002,/* iovec instead of busdma S/G*/
-   CAM_UNMAPPED_BUF= 0x0004 /* use unmapped I/O */
+   CAM_USER_DATA_ADDR  = 0x0002,/* Userspace data pointers */
+   CAM_SG_FORMAT_IOVEC = 0x0004,/* iovec instead of busdma S/G*/
+   CAM_UNMAPPED_BUF= 0x0008 /* use unmapped I/O */
 } ccb_xflags;
 
 /* XPT Opcodes for xpt_action */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r291716 - in head: share/man/man4 sys/cam sys/cam/ata sys/cam/scsi sys/dev/md sys/geom sys/kern sys/pc98/include sys/sys usr.sbin usr.sbin/camdd

2015-12-04 Thread Kenneth D. Merry
On Thu, Dec 03, 2015 at 23:55:14 -0800, Ravi Pokala wrote:
> Hi Ken,
> 
> A few questions:
> 
> > 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.
> 
> 
> (a) How does that work? That is, how does the argument get to the ioctl 
> handler in the kernel?
> 

In sys_ioctl(), in sys/kern/sys_generic.c, the pointer argument ("data") to
the ioctl syscall is passed through into kern_ioctl() and then on down
until it gets into the passioctl() call.  It is passed through even when
the declared size of the ioctl is 0, as it is for the two new ioctls:

/*
 * These two ioctls take a union ccb *, but that is not explicitly declared
 * to avoid having the ioctl handling code malloc and free their own copy
 * of the CCB or the CCB pointer.
 */
#define CAMIOQUEUE  _IO(CAM_VERSION, 4)
#define CAMIOGET_IO(CAM_VERSION, 5)

Here's the code in question:

if (size > 0) {
if (com & IOC_VOID) {
/* Integer argument. */
arg = (intptr_t)uap->data;
data = (void *)
size = 0;
} else {
if (size > SYS_IOCTL_SMALL_SIZE)
data = malloc((u_long)size, M_IOCTLOPS, M_WAITOK
);  
else
data = smalldata;
}
} else
data = (void *)>data;

So in the size == 0 case, data is just passed through as is.

Prior to r274017, if the ioctl were declared as _IOWR, there would be a
malloc and copyin of however much data is declared in the ioctl, no matter
what the size.  So, in this case, sizeof(union ccb *) or sizeof(union ccb).

The problem is, upon exit from the ioctl, that data is freed.  With a
queueing interface, we need to keep a copy of the CCB around after the
ioctl exits.  You have the same problem even after r274017, because that
just provides a small buffer on the stack.  (And would only help in the
pointer case.  And we don't need to copyin the pointer.)

So, to avoid that, we don't declare an argument, but we do pass in a
pointer and do the copy the user's CCB into a CCB that is allocated inside
the pass(4) driver.

> (b) The CCB is large, but the CCB pointer is just a pointer; shouldn't that 
> be passed in as the arg?
> 

It is.  Here's what camdd(8) does:

>From camdd_pass_run():

union ccb *ccb;
...
/*
 * Queue the CCB to the pass(4) driver.
 */
if (ioctl(pass_dev->dev->fd, CAMIOQUEUE, ccb) == -1) {

And from camdd_pass_fetch():

union ccb ccb;
...
while ((retval = ioctl(pass_dev->dev->fd, CAMIOGET, )) != -1) {

Ken
-- 
Kenneth Merry
k...@freebsd.org
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r291741 - head/sys/geom

2015-12-03 Thread Kenneth D. Merry
On Thu, Dec 03, 2015 at 19:41:31 -0800, Bryan Drewery wrote:
> On 12/3/2015 7:38 PM, Kenneth D. Merry wrote:
> >  g_disk_limit(struct disk *dp, struct bio *bp)
> >  {
> > bool limited = false;
> > -   off_t d_maxsize;
> > -
> > -   d_maxsize = (bp->bio_cmd == BIO_DELETE) ?
> > -   dp->d_delmaxsize : dp->d_maxsize;
> > +   off_t maxsz = g_disk_maxsize(dp, bp);
> 
> This looks like a style issue.

You are correct.  Fixed.

Thanks!

Ken
-- 
Kenneth Merry
k...@freebsd.org
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r291741 - head/sys/geom

2015-12-03 Thread Kenneth D. Merry
Author: ken
Date: Fri Dec  4 03:38:35 2015
New Revision: 291741
URL: https://svnweb.freebsd.org/changeset/base/291741

Log:
  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
  MFC after:1 week
  Sponsored by: Spectra Logic

Modified:
  head/sys/geom/geom_disk.c

Modified: head/sys/geom/geom_disk.c
==
--- head/sys/geom/geom_disk.c   Fri Dec  4 03:18:02 2015(r291740)
+++ head/sys/geom/geom_disk.c   Fri Dec  4 03:38:35 2015(r291741)
@@ -253,10 +253,18 @@ g_disk_ioctl(struct g_provider *pp, u_lo
return (error);
 }
 
+static off_t
+g_disk_maxsize(struct disk *dp, struct bio *bp)
+{
+   if (bp->bio_cmd == BIO_DELETE)
+   return (dp->d_delmaxsize);
+   return (dp->d_maxsize);
+}
+
 static int
-g_disk_maxsegs(struct disk *dp)
+g_disk_maxsegs(struct disk *dp, struct bio *bp)
 {
-   return ((dp->d_maxsize / PAGE_SIZE) + 1);
+   return ((g_disk_maxsize(dp, bp) / PAGE_SIZE) + 1);
 }
 
 static void
@@ -334,7 +342,7 @@ g_disk_vlist_limit(struct disk *dp, stru
end = (bus_dma_segment_t *)bp->bio_data + bp->bio_ma_n;
residual = bp->bio_length;
offset = bp->bio_ma_offset;
-   pages = g_disk_maxsegs(dp);
+   pages = g_disk_maxsegs(dp, bp);
while (residual != 0 && pages != 0) {
KASSERT((seg != end),
("vlist limit runs off the end"));
@@ -350,10 +358,7 @@ static bool
 g_disk_limit(struct disk *dp, struct bio *bp)
 {
bool limited = false;
-   off_t d_maxsize;
-
-   d_maxsize = (bp->bio_cmd == BIO_DELETE) ?
-   dp->d_delmaxsize : dp->d_maxsize;
+   off_t maxsz = g_disk_maxsize(dp, bp);
 
/*
 * XXX: If we have a stripesize we should really use it here.
@@ -361,8 +366,8 @@ g_disk_limit(struct disk *dp, struct bio
 *  as deletes can be very sensitive to size given how they
 *  are processed.
 */
-   if (bp->bio_length > d_maxsize) {
-   bp->bio_length = d_maxsize;
+   if (bp->bio_length > maxsz) {
+   bp->bio_length = maxsz;
limited = true;
}
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r291742 - head/sys/geom

2015-12-03 Thread Kenneth D. Merry
Author: ken
Date: Fri Dec  4 03:44:12 2015
New Revision: 291742
URL: https://svnweb.freebsd.org/changeset/base/291742

Log:
  Fix a style issue in g_disk_limit().
  
  Noticed by:   bdrewery
  MFC after:1 week

Modified:
  head/sys/geom/geom_disk.c

Modified: head/sys/geom/geom_disk.c
==
--- head/sys/geom/geom_disk.c   Fri Dec  4 03:38:35 2015(r291741)
+++ head/sys/geom/geom_disk.c   Fri Dec  4 03:44:12 2015(r291742)
@@ -358,7 +358,9 @@ static bool
 g_disk_limit(struct disk *dp, struct bio *bp)
 {
bool limited = false;
-   off_t maxsz = g_disk_maxsize(dp, bp);
+   off_t maxsz;
+
+   maxsz = g_disk_maxsize(dp, bp);
 
/*
 * XXX: If we have a stripesize we should really use it here.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r291724 - head/usr.sbin/camdd

2015-12-03 Thread Kenneth D. Merry
Author: ken
Date: Thu Dec  3 22:07:01 2015
New Revision: 291724
URL: https://svnweb.freebsd.org/changeset/base/291724

Log:
  Fix typos in the camdd(8) usage() function output caused by an error in
  my diff filter script.
  
  Sponsored by: Spectra Logic
  MFC after:1 week

Modified:
  head/usr.sbin/camdd/camdd.c

Modified: head/usr.sbin/camdd/camdd.c
==
--- head/usr.sbin/camdd/camdd.c Thu Dec  3 21:25:59 2015(r291723)
+++ head/usr.sbin/camdd/camdd.c Thu Dec  3 22:07:01 2015(r291724)
@@ -3205,7 +3205,7 @@ usage(void)
 "-o 

Re: svn commit: r291716 - in head: share/man/man4 sys/cam sys/cam/ata sys/cam/scsi sys/dev/md sys/geom sys/kern sys/pc98/include sys/sys usr.sbin usr.sbin/camdd

2015-12-03 Thread Kenneth D. Merry
On Thu, Dec 03, 2015 at 13:13:25 -0800, Bryan Drewery wrote:
> On 12/3/15 12:54 PM, Kenneth D. Merry wrote:
> > Author: ken
> > Date: Thu Dec  3 20:54:55 2015
> > New Revision: 291716
> > URL: https://svnweb.freebsd.org/changeset/base/291716
> > 
> > Log:
> >   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 s

svn commit: r291716 - in head: share/man/man4 sys/cam sys/cam/ata sys/cam/scsi sys/dev/md sys/geom sys/kern sys/pc98/include sys/sys usr.sbin usr.sbin/camdd

2015-12-03 Thread Kenneth D. Merry
Author: ken
Date: Thu Dec  3 20:54:55 2015
New Revision: 291716
URL: https://svnweb.freebsd.org/changeset/base/291716

Log:
  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 

Re: svn commit: r287621 - in head/sys: cam/ctl conf modules/ctl

2015-09-11 Thread Kenneth D. Merry
On Thu, Sep 10, 2015 at 12:40:32 +, Alexander Motin wrote:
> Author: mav
> Date: Thu Sep 10 12:40:31 2015
> New Revision: 287621
> URL: https://svnweb.freebsd.org/changeset/base/287621
> 
> Log:
>   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.

Wow, very cool!

Thank you for doing that, and thanks to iX for sponsoring it!

I was hoping that someone would pick up the HA work years ago when I put in
those stubs, and I'm very glad that you have done the work!

This will be great functionality for FreeBSD!

Ken
-- 
Kenneth Merry
k...@freebsd.org
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r286965 - in head: sbin/camcontrol sys/cam/scsi

2015-08-20 Thread Kenneth D. Merry
Author: ken
Date: Thu Aug 20 16:07:51 2015
New Revision: 286965
URL: https://svnweb.freebsd.org/changeset/base/286965

Log:
  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
 

svn commit: r284192 - in head: lib/libsbuf lib/libutil sbin/camcontrol share/man/man9 sys/cam sys/cam/scsi sys/kern sys/sys

2015-06-09 Thread Kenneth D. Merry
Author: ken
Date: Tue Jun  9 21:39:38 2015
New Revision: 284192
URL: https://svnweb.freebsd.org/changeset/base/284192

Log:
  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
  MFC after:1 week

Added:
  head/sbin/camcontrol/attrib.c   (contents, props changed)
Modified:
  head/lib/libsbuf/Makefile
  head/lib/libsbuf/Symbol.map
  head/lib/libsbuf/Version.def
  head/lib/libutil/hexdump.3
  head/sbin/camcontrol/Makefile
  head/sbin/camcontrol/camcontrol.8
  head/sbin/camcontrol/camcontrol.c
  head/sbin/camcontrol/camcontrol.h
  head/share/man/man9/sbuf.9
  head/sys/cam/cam.c
  head/sys/cam/cam.h
  head/sys/cam/scsi/scsi_all.c
  head/sys/cam/scsi/scsi_all.h
  head/sys/kern/subr_prf.c
  head/sys/sys/sbuf.h

Modified: head/lib/libsbuf/Makefile
==
--- head/lib/libsbuf/Makefile   Tue Jun  9 19:41:16 2015(r284191)
+++ head/lib/libsbuf/Makefile   Tue Jun  9 21:39:38 2015(r284192)
@@ -2,7 +2,7 @@
 
 LIB=   sbuf
 SHLIBDIR?= /lib
-SRCS=  subr_sbuf.c 
+SRCS=  subr_prf.c subr_sbuf.c
 
 SHLIB_MAJOR= 6
 

Modified: head/lib/libsbuf/Symbol.map
==
--- head/lib/libsbuf/Symbol.map Tue Jun  9 19:41:16 2015(r284191)
+++ head/lib/libsbuf/Symbol.map Tue Jun  9 21:39:38 2015(r284192)
@@ -27,3 

svn commit: r280463 - head/sys/cam/ctl

2015-03-24 Thread Kenneth D. Merry
Author: ken
Date: Tue Mar 24 21:42:28 2015
New Revision: 280463
URL: https://svnweb.freebsd.org/changeset/base/280463

Log:
  Remove some #if 0'ed code that apparently confuses cscope.
  
  Requested by: Peter Xu xzpe...@gmail.com
  MFC after:3 days

Modified:
  head/sys/cam/ctl/ctl.c

Modified: head/sys/cam/ctl/ctl.c
==
--- head/sys/cam/ctl/ctl.c  Tue Mar 24 21:32:49 2015(r280462)
+++ head/sys/cam/ctl/ctl.c  Tue Mar 24 21:42:28 2015(r280463)
@@ -12152,9 +12152,6 @@ ctl_lun_reset(struct ctl_lun *lun, union
/*
 * Run through the OOA queue and abort each I/O.
 */
-#if 0
-   TAILQ_FOREACH((struct ctl_io_hdr *)xio, lun-ooa_queue, ooa_links) {
-#endif
for (xio = (union ctl_io *)TAILQ_FIRST(lun-ooa_queue); xio != NULL;
 xio = (union ctl_io *)TAILQ_NEXT(xio-io_hdr, ooa_links)) {
xio-io_hdr.flags |= CTL_FLAG_ABORT | CTL_FLAG_ABORT_STATUS;
@@ -12335,9 +12332,6 @@ ctl_abort_task(union ctl_io *io)
 * untagged command to abort, simply abort the first untagged command
 * we come to.  We only allow one untagged command at a time of course.
 */
-#if 0
-   TAILQ_FOREACH((struct ctl_io_hdr *)xio, lun-ooa_queue, ooa_links) {
-#endif
for (xio = (union ctl_io *)TAILQ_FIRST(lun-ooa_queue); xio != NULL;
 xio = (union ctl_io *)TAILQ_NEXT(xio-io_hdr, ooa_links)) {
 #if 0
@@ -12375,7 +12369,7 @@ ctl_abort_task(union ctl_io *io)
 #if 0
if (((xio-scsiio.tag_type == CTL_TAG_UNTAGGED)
   (io-taskio.tag_type == CTL_TAG_UNTAGGED))
-|| (xio-scsiio.tag_num == io-taskio.tag_num)) {
+|| (xio-scsiio.tag_num == io-taskio.tag_num))
 #endif
/*
 * XXX KDM we've got problems with FC, because it
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r280230 - in head: sys/cam/scsi usr.bin/mt

2015-03-18 Thread Kenneth D. Merry
Author: ken
Date: Wed Mar 18 20:52:34 2015
New Revision: 280230
URL: https://svnweb.freebsd.org/changeset/base/280230

Log:
  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

Modified:
  head/sys/cam/scsi/scsi_sa.h
  head/usr.bin/mt/mt.c

Modified: head/sys/cam/scsi/scsi_sa.h
==
--- head/sys/cam/scsi/scsi_sa.h Wed Mar 18 20:40:42 2015(r280229)
+++ head/sys/cam/scsi/scsi_sa.h Wed Mar 18 20:52:34 2015(r280230)
@@ -477,7 +477,7 @@ struct scsi_medium_type_data {
u_int8_t length[2];
 #defineSMTD_DEFAULT_LENGTH 52
u_int8_t num_density_codes;
-   u_int8_t primary_density_codes[8];
+   u_int8_t primary_density_codes[9];
u_int8_t media_width[2];
u_int8_t medium_length[2];
u_int8_t reserved2[2];

Modified: head/usr.bin/mt/mt.c
==
--- head/usr.bin/mt/mt.cWed Mar 18 20:40:42 2015(r280229)
+++ head/usr.bin/mt/mt.cWed Mar 18 20:52:34 2015(r280230)
@@ -1406,9 +1406,9 @@ mt_print_density_entry(struct mt_status_
continue;
}
if ((strcmp(entry-entry_name, primary_density_code) == 0)
-|| (strcmp(entry-entry_name, secondary_density_code) == 0)){
+|| (strcmp(entry-entry_name, secondary_density_code) == 0)
+|| (strcmp(entry-entry_name, density_code) == 0)) {
 
-   /* XXX KDM this should really be unsigned */
printf(%*s%s (%s): %s\n, indent, , entry-desc ?
entry-desc : , entry-entry_name,
denstostring(entry-value_unsigned));
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r280231 - head/usr.bin/mt

2015-03-18 Thread Kenneth D. Merry
Author: ken
Date: Wed Mar 18 20:54:54 2015
New Revision: 280231
URL: https://svnweb.freebsd.org/changeset/base/280231

Log:
  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

Modified:
  head/usr.bin/mt/mt.c

Modified: head/usr.bin/mt/mt.c
==
--- head/usr.bin/mt/mt.cWed Mar 18 20:52:34 2015(r280230)
+++ head/usr.bin/mt/mt.cWed Mar 18 20:54:54 2015(r280231)
@@ -119,6 +119,7 @@ __FBSDID($FreeBSD$);
 #ifndef MAX
 #defineMAX(a, b) (a  b) ? a : b
 #endif
+#define MT_PLURAL(a) (a == 1) ?  : s
 
 typedef enum {
MT_CMD_NONE = MTLOAD + 1,
@@ -384,10 +385,16 @@ main(int argc, char *argv[])
 
if (ioctl(mtfd, MTIOCRBLIM, (caddr_t)rblim)  0)
err(2, %s, tape);
-   (void)printf(%s: min blocksize %u bytes, 
-   max blocksize %u bytes, granularity %u bytes\n,
+   (void)printf(%s:\n
+   min blocksize %u byte%s\n
+   max blocksize %u byte%s\n
+   granularity %u byte%s\n,
tape, rblim.min_block_length,
-   rblim.max_block_length, rblim.granularity);
+   MT_PLURAL(rblim.min_block_length),
+   rblim.max_block_length,
+   MT_PLURAL(rblim.max_block_length),
+   (1  rblim.granularity),
+   MT_PLURAL((1  rblim.granularity)));
exit(0);
/* NOTREACHED */
}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r279570 - in head: lib/libmt usr.bin/mt

2015-03-03 Thread Kenneth D. Merry
Author: ken
Date: Tue Mar  3 22:49:07 2015
New Revision: 279570
URL: https://svnweb.freebsd.org/changeset/base/279570

Log:
  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

Modified:
  head/lib/libmt/mtlib.c
  head/usr.bin/mt/mt.1

Modified: head/lib/libmt/mtlib.c
==
--- head/lib/libmt/mtlib.c  Tue Mar  3 21:21:43 2015(r279569)
+++ head/lib/libmt/mtlib.c  Tue Mar  3 22:49:07 2015(r279570)
@@ -568,6 +568,15 @@ static struct densities {
 *
 * IBM 3592 definitions obtained from second edition of the IBM
 * System Storage Tape Drive 3592 SCSI Reference (May 25, 2012).
+*
+* DAT-72 and DAT-160 bpi values taken from HP StorageWorks DAT160
+* tape drive white paper, dated June 2007.
+*
+* DAT-160 / SDLT220 density code (0x48) conflict information
+* found here:
+*
+* 
http://h20564.www2.hp.com/hpsc/doc/public/display?docId=emr_na-c01065117sp4ts.oid=429311
+* (Document ID c01065117)
 */
/*Num.  bpmmbpi Reference */
{ 0x1,  32, 800,X3.22-1983 },
@@ -613,6 +622,14 @@ static struct densities {
{ 0x42, 7398,   187909, LTO-2 },
{ 0x44, 9638,   244805, LTO-3 }, 
{ 0x46, 12725,  323215, LTO-4 }, 
+   { 0x47, 6417,   163000, DAT-72 },
+   /*
+* XXX KDM note that 0x48 is also the density code for DAT-160.
+* For some reason they used overlapping density codes.
+*/
+#if 0
+   { 0x48, 6870,   174500, DAT-160 },
+#endif
{ 0x48, 5236,   133000, SDLTapeI(110) },
{ 0x49, 7598,   193000, SDLTapeI(160) },
{ 0x4a, 0,   0, T1A },

Modified: head/usr.bin/mt/mt.1
==
--- head/usr.bin/mt/mt.1Tue Mar  3 21:21:43 2015(r279569)
+++ head/usr.bin/mt/mt.1Tue Mar  3 22:49:07 2015(r279570)
@@ -29,7 +29,7 @@
 .\@(#)mt.18.1 (Berkeley) 6/6/93
 .\ $FreeBSD$
 .\
-.Dd February 12, 2014
+.Dd March 3, 2014
 .Dt MT 1
 .Os
 .Sh NAME
@@ -503,7 +503,8 @@ Value  WidthTracksDensity   
 0x42   12.7  (0.5)  512  7,398  (187,909)   C   LTO-2
 0x44   12.7  (0.5)  704  9,638  (244,805)   C   LTO-3
 0x46   12.7  (0.5)  896  12,725 (323,215)   C   LTO-4
-0x48   12.7  (0.5)  448  5,236  (133,000) PRML  C   SDLTapeI(110) 6,8
+0x473.81 (0.25)   ?  6,417  (163,000)   CS  DAT-72
+0x48   12.7  (0.5)  448  5,236  (133,000) PRML  C   SDLTapeI(110) 6,8,13
 0x49   12.7  (0.5)  448  7,598  (193,000) PRML  C   SDLTapeI(160) 6,8
 0x4A   12.7  (0.5)  768  ?  C   T1A  10
 0x4B   12.7  (0.5) 1152  ?  C   T1B  10
@@ -556,6 +557,7 @@ NOTES
 density code is 0x90.
 12. This is Exabyte 8500 uncompressed format.  The compressed format
 density code is 0x8c.
+13. This density code (0x48) was also used for DAT-160.
 .Ed
 .Sh ENVIRONMENT
 .Bl -tag -width .Ev TAPE
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r279534 - head/sys/cam/scsi

2015-03-02 Thread Kenneth D. Merry
Author: ken
Date: Mon Mar  2 18:09:49 2015
New Revision: 279534
URL: https://svnweb.freebsd.org/changeset/base/279534

Log:
  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

Modified:
  head/sys/cam/scsi/scsi_sa.c

Modified: head/sys/cam/scsi/scsi_sa.c
==
--- head/sys/cam/scsi/scsi_sa.c Mon Mar  2 18:08:39 2015(r279533)
+++ head/sys/cam/scsi/scsi_sa.c Mon Mar  2 18:09:49 2015(r279534)
@@ -2396,9 +2396,13 @@ saregister(struct cam_periph *periph, vo
 * Long format data for READ POSITION was introduced in SSC, which
 * was after SCSI-2.  (Roughly equivalent to SCSI-3.)  If the drive
 * reports that it is SCSI-2 or older, it is unlikely to support
-* long position data.
+* long position data, but it might.  Some drives from that era
+* claim to be SCSI-2, but do support long position information.
+* So, instead of immediately disabling long position information
+* for SCSI-2 devices, we'll try one pass through sagetpos(), and 
+* then disable long position information if we get an error.   
 */
-   if (cgd-inq_data.version = SCSI_REV_2)
+   if (cgd-inq_data.version = SCSI_REV_CCS)
softc-quirks |= SA_QUIRK_NO_LONG_POS;
 
if (cgd-inq_data.spc3_flags  SPC3_SID_PROTECT) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r279375 - head/sys/cam

2015-02-27 Thread Kenneth D. Merry
Author: ken
Date: Fri Feb 27 21:35:36 2015
New Revision: 279375
URL: https://svnweb.freebsd.org/changeset/base/279375

Log:
  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

Modified:
  head/sys/cam/cam_periph.c

Modified: head/sys/cam/cam_periph.c
==
--- head/sys/cam/cam_periph.c   Fri Feb 27 21:27:02 2015(r279374)
+++ head/sys/cam/cam_periph.c   Fri Feb 27 21:35:36 2015(r279375)
@@ -1048,8 +1048,11 @@ cam_periph_runccb(union ccb *ccb,
  cam_flags camflags, u_int32_t sense_flags,
  struct devstat *ds)
 {
+   struct bintime *starttime;
+   struct bintime ltime;
int error;
  
+   starttime = NULL;
xpt_path_assert(ccb-ccb_h.path, MA_OWNED);
 
/*
@@ -1057,8 +1060,11 @@ cam_periph_runccb(union ccb *ccb,
 * this particular type of ccb, record the transaction start.
 */
if ((ds != NULL)  (ccb-ccb_h.func_code == XPT_SCSI_IO ||
-   ccb-ccb_h.func_code == XPT_ATA_IO))
-   devstat_start_transaction(ds, NULL);
+   ccb-ccb_h.func_code == XPT_ATA_IO)) {
+   starttime = ltime;
+   binuptime(starttime);
+   devstat_start_transaction(ds, starttime);
+   }
 
ccb-ccb_h.cbfcnp = cam_periph_done;
xpt_action(ccb);
@@ -1086,22 +1092,22 @@ cam_periph_runccb(union ccb *ccb,
if (ds != NULL) {
if (ccb-ccb_h.func_code == XPT_SCSI_IO) {
devstat_end_transaction(ds,
-   ccb-csio.dxfer_len,
+   ccb-csio.dxfer_len - ccb-csio.resid,
ccb-csio.tag_action  0x3,
((ccb-ccb_h.flags  CAM_DIR_MASK) ==
CAM_DIR_NONE) ?  DEVSTAT_NO_DATA : 
(ccb-ccb_h.flags  CAM_DIR_OUT) ?
DEVSTAT_WRITE : 
-   DEVSTAT_READ, NULL, NULL);
+   DEVSTAT_READ, NULL, starttime);
} else if (ccb-ccb_h.func_code == XPT_ATA_IO) {
devstat_end_transaction(ds,
-   ccb-ataio.dxfer_len,
+   ccb-ataio.dxfer_len - ccb-ataio.resid,
ccb-ataio.tag_action  0x3,
((ccb-ccb_h.flags  CAM_DIR_MASK) ==
CAM_DIR_NONE) ?  DEVSTAT_NO_DATA : 
(ccb-ccb_h.flags  CAM_DIR_OUT) ?
DEVSTAT_WRITE : 
-   DEVSTAT_READ, NULL, NULL);
+   DEVSTAT_READ, NULL, starttime);
}
}
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r279336 - in head/sys/dev: mpr mps

2015-02-26 Thread Kenneth D. Merry
Author: ken
Date: Thu Feb 26 22:22:06 2015
New Revision: 279336
URL: https://svnweb.freebsd.org/changeset/base/279336

Log:
  Add FreeBSD stable/10 version checks for the availability of the
  CDAI_FLAG_NONE advanced information CCB flag.
  
  Support for the flag was merged to stable/10 in r279329, and the
  __FreeBSD_version in stable/10 was bumped to 1001510.
  
  Check for that version in the mps(4) and mpr(4) drivers when determining
  whether to use the flag.
  
  Sponsored by: Spectra Logic
  MFC after:3 days

Modified:
  head/sys/dev/mpr/mpr_sas.c
  head/sys/dev/mps/mps_sas.c

Modified: head/sys/dev/mpr/mpr_sas.c
==
--- head/sys/dev/mpr/mpr_sas.c  Thu Feb 26 21:30:40 2015(r279335)
+++ head/sys/dev/mpr/mpr_sas.c  Thu Feb 26 22:22:06 2015(r279336)
@@ -3082,7 +3082,8 @@ mprsas_async(void *callback_arg, uint32_
cdai.ccb_h.func_code = XPT_DEV_ADVINFO;
cdai.ccb_h.flags = CAM_DIR_IN;
cdai.buftype = CDAI_TYPE_RCAPLONG;
-#if __FreeBSD_version = 1100061
+#if (__FreeBSD_version = 1100061) || \
+((__FreeBSD_version = 1001510)  (__FreeBSD_version  110))
cdai.flags = CDAI_FLAG_NONE;
 #else
cdai.flags = 0;

Modified: head/sys/dev/mps/mps_sas.c
==
--- head/sys/dev/mps/mps_sas.c  Thu Feb 26 21:30:40 2015(r279335)
+++ head/sys/dev/mps/mps_sas.c  Thu Feb 26 22:22:06 2015(r279336)
@@ -3277,7 +3277,8 @@ mpssas_async(void *callback_arg, uint32_
cdai.ccb_h.func_code = XPT_DEV_ADVINFO;
cdai.ccb_h.flags = CAM_DIR_IN;
cdai.buftype = CDAI_TYPE_RCAPLONG;
-#if __FreeBSD_version = 1100061
+#if (__FreeBSD_version = 1100061) || \
+((__FreeBSD_version = 1001510)  (__FreeBSD_version  110))
cdai.flags = CDAI_FLAG_NONE;
 #else
cdai.flags = 0;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r279346 - head/lib/libdevstat

2015-02-26 Thread Kenneth D. Merry
Author: ken
Date: Fri Feb 27 02:44:12 2015
New Revision: 279346
URL: https://svnweb.freebsd.org/changeset/base/279346

Log:
  Remove an obsolete comment in devstat(3) about the accuracy of the
  milliseconds per transaction (DSM_MS_PER_TRANSACTION) calculation.
  
  The comment was accurate many years ago when the kernel didn't
  record I/O times on a per-I/O basis, but now that we do collect
  that information in most areas, it isn't correct.
  
  The milliseconds per transaction values are correct, assuming the
  I/O duration has been recorded.
  
  Sponsored by: Spectra Logic
  MFC after:3 days

Modified:
  head/lib/libdevstat/devstat.c

Modified: head/lib/libdevstat/devstat.c
==
--- head/lib/libdevstat/devstat.c   Fri Feb 27 02:21:52 2015
(r279345)
+++ head/lib/libdevstat/devstat.c   Fri Feb 27 02:44:12 2015
(r279346)
@@ -1487,22 +1487,9 @@ devstat_compute_statistics(struct devsta
*destld = 0.0;
break;
/*
-* This calculation is somewhat bogus.  It simply divides
-* the elapsed time by the total number of transactions
-* completed.  While that does give the caller a good
-* picture of the average rate of transaction completion,
-* it doesn't necessarily give the caller a good view of
-* how long transactions took to complete on average.
-* Those two numbers will be different for a device that
-* can handle more than one transaction at a time.  e.g.
-* SCSI disks doing tagged queueing.
-*
-* The only way to accurately determine the real average
-* time per transaction would be to compute and store the
-* time on a per-transaction basis.  That currently isn't
-* done in the kernel, and would only be desireable if it
-* could be implemented in a somewhat non-intrusive and high
-* performance way.
+* Some devstat callers update the duration and some don't.
+* So this will only be accurate if they provide the
+* duration. 
 */
case DSM_MS_PER_TRANSACTION:
if (totaltransfers  0) {
@@ -1512,11 +1499,6 @@ devstat_compute_statistics(struct devsta
} else
*destld = 0.0;
break;
-   /*
-* As above, these next two really only give the average
-* rate of completion for read and write transactions, not
-* the average time the transaction took to complete.
-*/
case DSM_MS_PER_TRANSACTION_READ:
if (totaltransfersread  0) {
*destld = totaldurationread;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r279261 - in head: lib/libmt usr.bin/mt

2015-02-24 Thread Kenneth D. Merry
Author: ken
Date: Wed Feb 25 04:30:23 2015
New Revision: 279261
URL: https://svnweb.freebsd.org/changeset/base/279261

Log:
  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

Modified:
  head/lib/libmt/mtlib.c
  head/usr.bin/mt/mt.c

Modified: head/lib/libmt/mtlib.c
==
--- head/lib/libmt/mtlib.c  Wed Feb 25 00:06:25 2015(r279260)
+++ head/lib/libmt/mtlib.c  Wed Feb 25 04:30:23 2015(r279261)
@@ -68,7 +68,7 @@ mt_start_element(void *user_data, const 
return;
 
mtinfo-level++;
-   if ((u_int)mtinfo-level  (sizeof(mtinfo-cur_sb) /
+   if ((u_int)mtinfo-level = (sizeof(mtinfo-cur_sb) /
 sizeof(mtinfo-cur_sb[0]))) {
mtinfo-error = 1;
 snprintf(mtinfo-error_str, sizeof(mtinfo-error_str), 

Modified: head/usr.bin/mt/mt.c
==
--- head/usr.bin/mt/mt.cWed Feb 25 00:06:25 2015(r279260)
+++ head/usr.bin/mt/mt.cWed Feb 25 04:30:23 2015(r279261)
@@ -212,6 +212,8 @@ main(int argc, char *argv[])
int ch, len, mtfd;
const char *p, *tape;
 
+   bzero(mt_com, sizeof(mt_com));
+   
if ((tape = getenv(TAPE)) == NULL)
tape = DEFTAPE;
 
@@ -1333,12 +1335,24 @@ mt_param(int argc, char **argv, int mtfd
list = 1;
break;
case 'p':
+   if (param_name != NULL) {
+   warnx(Only one paramter name may be 
+   specified);
+   retval = 1;
+   goto bailout;
+   }
param_name = strdup(optarg);
break;
case 'q':
quiet = 1;
break;
case 's':
+   if (param_value != NULL) {
+   warnx(Only one paramter value may be 
+   specified);
+   retval = 1;
+   goto bailout;
+   }
param_value = strdup(optarg);
do_set = 1;
break;
@@ -1350,12 +1364,16 @@ mt_param(int argc, char **argv, int mtfd
}
}
 
-   if ((list + do_set + xml_dump) != 1)
-   errx(1, You must specify only one of -s, -l or -x);
+   if ((list + do_set + xml_dump) != 1) {
+   warnx(You must specify only one of -s, -l or -x);
+   retval = 1;
+   goto bailout;
+   }
 
if (xml_dump != 0) {
printf(%s, xml_str);
-   return (0);
+   retval = 0;
+   goto bailout;
}
 
if (do_set != 0) {
@@ -1367,6 +1385,9 @@ mt_param(int argc, char **argv, int mtfd
} else if (list != 0)
retval = mt_param_list(status_data, param_name, quiet);
 
+bailout:
+   free(param_name);
+   free(param_value);
return (retval);
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r279221 - head/sys/sys

2015-02-23 Thread Kenneth D. Merry
Author: ken
Date: Mon Feb 23 22:50:43 2015
New Revision: 279221
URL: https://svnweb.freebsd.org/changeset/base/279221

Log:
  Bump __FreeBSD_version for the mtio(4) / sa(4) ioctl and API additions
  in revision 279219.
  
  Sponsored by: Spectra Logic
  MFC after:1 month

Modified:
  head/sys/sys/param.h

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hMon Feb 23 22:31:39 2015(r279220)
+++ head/sys/sys/param.hMon Feb 23 22:50:43 2015(r279221)
@@ -58,7 +58,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1100061  /* Master, propagated to newvers */
+#define __FreeBSD_version 1100062  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r279219 - in head: contrib/groff/tmac lib lib/libmt rescue/rescue share/man/man4 share/mk sys/cam/scsi sys/sys usr.bin/mt

2015-02-23 Thread Kenneth D. Merry
Author: ken
Date: Mon Feb 23 21:59:30 2015
New Revision: 279219
URL: https://svnweb.freebsd.org/changeset/base/279219

Log:
  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

svn commit: r279229 - head/sys/cam/scsi

2015-02-23 Thread Kenneth D. Merry
Author: ken
Date: Tue Feb 24 05:43:16 2015
New Revision: 279229
URL: https://svnweb.freebsd.org/changeset/base/279229

Log:
  Fix printf format warnings on sparc64 and mips.
  
  Sponsored by: Spectra Logic
  MFC after:1 month

Modified:
  head/sys/cam/scsi/scsi_sa.c

Modified: head/sys/cam/scsi/scsi_sa.c
==
--- head/sys/cam/scsi/scsi_sa.c Tue Feb 24 05:35:15 2015(r279228)
+++ head/sys/cam/scsi/scsi_sa.c Tue Feb 24 05:43:16 2015(r279229)
@@ -4432,7 +4432,7 @@ saextget(struct cdev *dev, struct cam_pe
ts2_len);
 
SASBADDVARSTRDESC(sb, indent, tmpstr2, %s, serial_num,
-   cgd.serial_num_len + 1, Serial Number);
+   (ssize_t)cgd.serial_num_len + 1, Serial Number);
if (ts2_malloc != 0)
free(tmpstr2, M_SCSISA);
} else {
@@ -4441,8 +4441,8 @@ saextget(struct cdev *dev, struct cam_pe
 * be empty if the device has no serial number.
 */
tmpstr[0] = '\0';
-   SASBADDVARSTRDESC(sb, indent, tmpstr, %s, serial_num, 0,
-   Serial Number);
+   SASBADDVARSTRDESC(sb, indent, tmpstr, %s, serial_num,
+   (ssize_t)0, Serial Number);
}
 
SASBADDUINTDESC(sb, indent, softc-maxio, %u, maxio, 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r278964 - in head: sbin/camcontrol sys/cam sys/cam/scsi sys/dev/mpr sys/dev/mps sys/sys

2015-02-18 Thread Kenneth D. Merry
Author: ken
Date: Wed Feb 18 18:30:19 2015
New Revision: 278964
URL: https://svnweb.freebsd.org/changeset/base/278964

Log:
  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
  MFC after:1 week

Modified:
  head/sbin/camcontrol/camcontrol.c
  head/sys/cam/cam_ccb.h
  head/sys/cam/scsi/scsi_da.c
  head/sys/cam/scsi/scsi_enc_ses.c
  head/sys/dev/mpr/mpr_sas.c
  head/sys/dev/mps/mps_sas.c
  head/sys/sys/param.h

Modified: head/sbin/camcontrol/camcontrol.c
==
--- head/sbin/camcontrol/camcontrol.c   Wed Feb 18 18:12:06 2015
(r278963)
+++ head/sbin/camcontrol/camcontrol.c   Wed Feb 18 18:30:19 2015
(r278964)
@@ -7404,7 +7404,7 @@ getdevid(struct cam_devitem *item)
 retry:
ccb-ccb_h.func_code = XPT_DEV_ADVINFO;
ccb-ccb_h.flags = CAM_DIR_IN;
-   ccb-cdai.flags = 0;
+   ccb-cdai.flags = CDAI_FLAG_NONE;
ccb-cdai.buftype = CDAI_TYPE_SCSI_DEVID;
ccb-cdai.bufsiz = item-device_id_len;
if (item-device_id_len != 0)

Modified: head/sys/cam/cam_ccb.h
==
--- head/sys/cam/cam_ccb.h  Wed Feb 18 18:12:06 2015(r278963)
+++ head/sys/cam/cam_ccb.h  Wed Feb 18 18:30:19 2015(r278964)
@@ -1140,6 +1140,7 @@ struct ccb_eng_exec { /* This structure 
 struct ccb_dev_advinfo {
struct ccb_hdr ccb_h;
uint32_t flags;
+#defineCDAI_FLAG_NONE  0x0 /* No flags set */
 #defineCDAI_FLAG_STORE 0x1 /* If set, action becomes store 
*/
uint32_t buftype;   /* IN: Type of data being requested */
/* NB: buftype is interpreted on a per-transport basis */

Modified: head/sys/cam/scsi/scsi_da.c
==
--- head/sys/cam/scsi/scsi_da.c Wed Feb 18 18:12:06 2015(r278963)
+++ head/sys/cam/scsi/scsi_da.c Wed Feb 18 18:30:19 2015(r278964)
@@ -3787,7 +3787,7 @@ dasetgeom(struct cam_periph *periph, uin
xpt_setup_ccb(cdai.ccb_h, periph-path, CAM_PRIORITY_NORMAL);
cdai.ccb_h.func_code = XPT_DEV_ADVINFO;
cdai.buftype = CDAI_TYPE_RCAPLONG;
-   cdai.flags |= CDAI_FLAG_STORE;
+   cdai.flags = CDAI_FLAG_STORE;
cdai.bufsiz = rcap_len;
cdai.buf = (uint8_t *)rcaplong;
xpt_action((union ccb *)cdai);

Modified: head/sys/cam/scsi/scsi_enc_ses.c
==
--- head/sys/cam/scsi/scsi_enc_ses.cWed Feb 18 18:12:06 2015
(r278963)
+++ head/sys/cam/scsi/scsi_enc_ses.cWed Feb 18 18:30:19 2015
(r278964)
@@ -1007,7 +1007,7 @@ ses_setphyspath_callback(enc_softc_t *en
xpt_setup_ccb(cdai.ccb_h, path, CAM_PRIORITY_NORMAL);
cdai.ccb_h.func_code = XPT_DEV_ADVINFO;
cdai.buftype = CDAI_TYPE_PHYS_PATH;
-   cdai.flags = 0;
+   cdai.flags = CDAI_FLAG_NONE;
cdai.bufsiz = MAXPATHLEN;
cdai.buf = old_physpath;
xpt_action((union ccb *)cdai);
@@ -1019,7 +1019,7 @@ ses_setphyspath_callback(enc_softc_t *en
xpt_setup_ccb(cdai.ccb_h, path, CAM_PRIORITY_NORMAL);
cdai.ccb_h.func_code = XPT_DEV_ADVINFO;

svn commit: r278228 - in head/sys: cam cam/scsi sys

2015-02-04 Thread Kenneth D. Merry
Author: ken
Date: Thu Feb  5 00:12:21 2015
New Revision: 278228
URL: https://svnweb.freebsd.org/changeset/base/278228

Log:
  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

Modified:
  head/sys/cam/cam_ccb.h
  head/sys/cam/cam_xpt.c
  head/sys/cam/cam_xpt_internal.h
  head/sys/cam/scsi/scsi_xpt.c
  head/sys/sys/param.h

Modified: head/sys/cam/cam_ccb.h
==
--- head/sys/cam/cam_ccb.h  Thu Feb  5 00:11:05 2015(r278227)
+++ head/sys/cam/cam_ccb.h  Thu Feb  5 00:12:21 2015(r278228)
@@ -1147,6 +1147,7 @@ struct ccb_dev_advinfo {
 #defineCDAI_TYPE_SERIAL_NUM2
 #defineCDAI_TYPE_PHYS_PATH 3
 #defineCDAI_TYPE_RCAPLONG  4
+#defineCDAI_TYPE_EXT_INQ   5
off_t bufsiz;   /* IN: Size of external buffer */
 #defineCAM_SCSI_DEVID_MAXLEN   65536   /* length in buffer is an 
uint16_t */
off_t provsiz;  /* OUT: Size required/used */

Modified: head/sys/cam/cam_xpt.c
==
--- head/sys/cam/cam_xpt.c  Thu Feb  5 00:11:05 2015(r278227)
+++ head/sys/cam/cam_xpt.c  Thu Feb  5 00:12:21 2015(r278228)
@@ -4795,6 +4795,7 @@ xpt_release_device(struct cam_ed *device
 */
free(device-supported_vpds, M_CAMXPT);
free(device-device_id, M_CAMXPT);
+   free(device-ext_inq, M_CAMXPT);
free(device-physpath, M_CAMXPT);
free(device-rcap_buf, M_CAMXPT);
free(device-serial_num, M_CAMXPT);

Modified: head/sys/cam/cam_xpt_internal.h
==
--- head/sys/cam/cam_xpt_internal.h Thu Feb  5 00:11:05 2015
(r278227)
+++ head/sys/cam/cam_xpt_internal.h Thu Feb  5 00:12:21 2015
(r278228)
@@ -83,6 +83,8 @@ struct cam_ed {
uint8_t  supported_vpds_len;
uint32_t device_id_len;
uint8_t  *device_id;
+   uint32_t ext_inq_len;
+   uint8_t  *ext_inq;
uint8_t  physpath_len;
uint8_t  *physpath; /* physical path string form */
uint32_t rcap_len;

Modified: head/sys/cam/scsi/scsi_xpt.c
==
--- head/sys/cam/scsi/scsi_xpt.cThu Feb  5 00:11:05 2015
(r278227)
+++ head/sys/cam/scsi/scsi_xpt.cThu Feb  5 00:12:21 2015
(r278228)
@@ -139,6 +139,7 @@ typedef enum {
PROBE_MODE_SENSE,
PROBE_SUPPORTED_VPD_LIST,
PROBE_DEVICE_ID,
+   PROBE_EXTENDED_INQUIRY,
PROBE_SERIAL_NUM,
PROBE_TUR_FOR_NEGOTIATION,
PROBE_INQUIRY_BASIC_DV1,
@@ -156,6 +157,7 @@ static char *probe_action_text[] = {
PROBE_MODE_SENSE,
PROBE_SUPPORTED_VPD_LIST,
PROBE_DEVICE_ID,
+   PROBE_EXTENDED_INQUIRY,
PROBE_SERIAL_NUM,
PROBE_TUR_FOR_NEGOTIATION,
PROBE_INQUIRY_BASIC_DV1,
@@ -923,6 +925,34 @@ done:
}
goto done;
}
+   case PROBE_EXTENDED_INQUIRY:
+   {
+   struct scsi_vpd_extended_inquiry_data *ext_inq;
+
+   ext_inq = NULL;
+   if (scsi_vpd_supported_page(periph, SVPD_EXTENDED_INQUIRY_DATA))
+   ext_inq = malloc(sizeof(*ext_inq), M_CAMXPT,
+   M_NOWAIT | M_ZERO);
+
+   if (ext_inq != NULL) {
+   scsi_inquiry(csio,
+/*retries*/4,
+probedone,
+MSG_SIMPLE_Q_TAG,
+(uint8_t *)ext_inq,
+sizeof(*ext_inq),
+

svn commit: r277917 - in head/sys/cam: ctl scsi

2015-01-29 Thread Kenneth D. Merry
Author: ken
Date: Fri Jan 30 05:23:39 2015
New Revision: 277917
URL: https://svnweb.freebsd.org/changeset/base/277917

Log:
  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.
  
  Sponsored by: Spectra Logic
  MFC after:1 week

Modified:
  head/sys/cam/ctl/ctl.c
  head/sys/cam/scsi/scsi_all.h

Modified: head/sys/cam/ctl/ctl.c
==
--- head/sys/cam/ctl/ctl.c  Fri Jan 30 05:14:01 2015(r277916)
+++ head/sys/cam/ctl/ctl.c  Fri Jan 30 05:23:39 2015(r277917)
@@ -31,7 +31,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl.c#8 $
+ * $Id$
  */
 /*
  * CAM Target Layer, a SCSI device emulation subsystem.
@@ -446,6 +446,8 @@ static int ctl_scsiio_lun_check(struct c
struct ctl_scsiio *ctsio);
 //static int ctl_check_rtr(union ctl_io *pending_io, struct ctl_softc *softc);
 static void ctl_failover(void);
+static void ctl_clear_ua(struct ctl_softc *ctl_softc, uint32_t initidx,
+ctl_ua_type ua_type);
 static int ctl_scsiio_precheck(struct ctl_softc *ctl_softc,
   struct ctl_scsiio *ctsio);
 static int ctl_scsiio(struct ctl_scsiio *ctsio);
@@ -9433,6 +9435,7 @@ ctl_request_sense(struct ctl_scsiio *cts
 {
struct scsi_request_sense *cdb;
struct scsi_sense_data *sense_ptr;
+   struct ctl_softc *ctl_softc;
struct ctl_lun *lun;
uint32_t initidx;
int have_error;
@@ -9441,6 +9444,7 @@ ctl_request_sense(struct ctl_scsiio *cts
 
cdb = (struct scsi_request_sense *)ctsio-cdb;
 
+   ctl_softc = control_softc;
lun = (struct ctl_lun *)ctsio-io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
 
CTL_DEBUG_PRINT((ctl_request_sense\n));
@@ -9526,6 +9530,14 @@ ctl_request_sense(struct ctl_scsiio *cts
ua_type = ctl_build_ua(lun, initidx, sense_ptr, sense_format);
if (ua_type != CTL_UA_NONE)
have_error = 1;
+   if (ua_type == CTL_UA_LUN_CHANGE) {
+   mtx_unlock(lun-lun_lock);
+   mtx_lock(ctl_softc-ctl_lock);
+   ctl_clear_ua(ctl_softc, initidx, ua_type);
+   mtx_unlock(ctl_softc-ctl_lock);
+   mtx_lock(lun-lun_lock);
+   }
+
}
mtx_unlock(lun-lun_lock);
 
@@ -9593,6 +9605,9 @@ ctl_cmddt_inquiry(struct ctl_scsiio *cts
 }
 #endif
 
+/*
+ * SCSI VPD page 0x00, the Supported VPD Pages page.
+ */
 static int
 ctl_inquiry_evpd_supported(struct ctl_scsiio *ctsio, int alloc_len)
 {
@@ -9665,6 +9680,9 @@ ctl_inquiry_evpd_supported(struct ctl_sc
return (CTL_RETVAL_COMPLETE);
 }
 
+/*
+ * SCSI VPD page 0x80, the Unit Serial Number page.
+ */
 static int
 ctl_inquiry_evpd_serial(struct ctl_scsiio *ctsio, int alloc_len)
 {
@@ -9721,6 +9739,9 @@ ctl_inquiry_evpd_serial(struct ctl_scsii
 }
 
 
+/*
+ * SCSI VPD page 0x86, the Extended INQUIRY Data page.
+ */
 static int
 ctl_inquiry_evpd_eid(struct ctl_scsiio *ctsio, int alloc_len)

svn commit: r276839 - head/sys/dev/isp

2015-01-08 Thread Kenneth D. Merry
Author: ken
Date: Thu Jan  8 17:41:28 2015
New Revision: 276839
URL: https://svnweb.freebsd.org/changeset/base/276839

Log:
  Fix Fibre Channel Command Reference Number handling in the isp(4) driver.
  
  The Command Reference Number is used for precise delivery of
  commands, and is part of the FC-Tape functionality set.  (This is
  only enabled for devices that support precise delivery of commands.)
  It is an 8-bit unsigned number that increments from 1 to 255.  The
  commands sent by the initiator must be processed by the target in
  CRN order if the CRN is non-zero.
  
  There are certain scenarios where the Command Reference Number
  sequence needs to be reset.  When the target is power cycled, for
  instance, the initiator needs to reset the CRN to 1.  The initiator
  will know this because it will see a LIP (when directly connected)
  or get a logout/login event (when connected to a switch).
  
  The isp(4) driver was not resetting the CRN when a target
  went away and came back.  When it saw the target again after a
  power cycle, it would continue the CRN sequence where it left off.
  The target would ignore the command because the CRN sequence is
  supposed to be reset to 1 after a power cycle or other similar
  event.
  
  The symptom that the user would see is that there would be lots of
  aborted INQUIRY commands after a tape library was power cycled, and
  the library would fail to probe.  The INQUIRY commands were being
  ignored by the tape drive due to the CRN issue mentioned above.
  
  isp_freebsd.c:
Add a new function, isp_fcp_reset_crn().  This will reset
all of the CRNs for a given port, or the CRNs for all LUNs
on a target.
  
Reset the CRNs for all targets on a port when we get a LIP,
loop reset, or loop down event.
  
Reset the CRN for a particular target when it arrives, is changed
or departs.  This is less precise behavior than the
clearing behavior specified in the FCP-4 spec (which says
that it should be reset for PRLI, PRLO, PLOGI and LOGO),
but this is the level of information we have here.  If this
is insufficient, then we will need to add more precise
notification from the lower level isp(4) code.
  
  isp_freebsd.h:
Add a prototype for isp_fcp_reset_crn().
  
  Sponsored by: Spectra Logic
  MFC after:1 week

Modified:
  head/sys/dev/isp/isp_freebsd.c
  head/sys/dev/isp/isp_freebsd.h

Modified: head/sys/dev/isp/isp_freebsd.c
==
--- head/sys/dev/isp/isp_freebsd.c  Thu Jan  8 17:38:03 2015
(r276838)
+++ head/sys/dev/isp/isp_freebsd.c  Thu Jan  8 17:41:28 2015
(r276839)
@@ -5696,6 +5696,8 @@ isp_async(ispsoftc_t *isp, ispasync_t cm
}
}
}
+   isp_fcp_reset_crn(fc, /*tgt*/0, /*tgt_set*/ 0);
+
isp_prt(isp, ISP_LOGINFO, Chan %d: %s, bus, msg);
break;
}
@@ -5747,6 +5749,7 @@ isp_async(ispsoftc_t *isp, ispasync_t cm
if (lp-dev_map_idx) {
tgt = lp-dev_map_idx - 1;
isp_prt(isp, ISP_LOGCONFIG, prom2, bus, lp-portid, 
lp-handle, buf, arrived at, tgt, (uint32_t) (lp-port_wwn  32), (uint32_t) 
lp-port_wwn);
+   isp_fcp_reset_crn(fc, tgt, /*tgt_set*/ 1);
isp_make_here(isp, bus, tgt);
} else {
isp_prt(isp, ISP_LOGCONFIG, prom0, bus, lp-portid, 
lp-handle, buf, arrived, (uint32_t) (lp-port_wwn  32), (uint32_t) 
lp-port_wwn);
@@ -5783,6 +5786,7 @@ isp_async(ispsoftc_t *isp, ispasync_t cm
tgt = lp-dev_map_idx - 1;
isp_prt(isp, ISP_LOGCONFIG, prom2, bus, 
lp-portid, lp-handle, buf, changed at, tgt,
(uint32_t) (lp-port_wwn  32), (uint32_t) 
lp-port_wwn);
+   isp_fcp_reset_crn(fc, tgt, /*tgt_set*/ 1);
} else {
isp_prt(isp, ISP_LOGCONFIG, prom0, bus, 
lp-portid, lp-handle, buf, changed, (uint32_t) (lp-port_wwn  32), 
(uint32_t) lp-port_wwn);
}
@@ -5795,6 +5799,7 @@ isp_async(ispsoftc_t *isp, ispasync_t cm
va_end(ap);
isp_gen_role_str(buf, sizeof (buf), lp-prli_word3);
if (lp-dev_map_idx) {
+   fc = ISP_FC_PC(isp, bus);
tgt = lp-dev_map_idx - 1;
isp_prt(isp, ISP_LOGCONFIG, prom2, bus, lp-portid, 
lp-handle, buf, stayed at, tgt,
(uint32_t) (lp-port_wwn  32), (uint32_t) 
lp-port_wwn);
@@ -5829,6 +5834,7 @@ isp_async(ispsoftc_t *isp, ispasync_t cm
}
tgt = lp-dev_map_idx - 1;
isp_prt(isp, ISP_LOGCONFIG, prom2, 

svn commit: r276842 - head/sys/dev/isp

2015-01-08 Thread Kenneth D. Merry
Author: ken
Date: Thu Jan  8 17:51:12 2015
New Revision: 276842
URL: https://svnweb.freebsd.org/changeset/base/276842

Log:
  Close a race in the isp(4) driver that caused devices to disappear
  and not automatically come back if they were gone for a short
  period of time.
  
  The isp(4) driver has a 30 second gone device timer that gets
  activated whenever a device goes away.  If the device comes back
  before the timer expires, we don't send a notification to CAM that
  it has gone away.  If, however, there is a command sent to the
  device while it is gone and before it comes back, the isp(4) driver
  sends the command back with CAM_SEL_TIMEOUT status.
  
  CAM responds to the CAM_SEL_TIMEOUT status by removing the device.
  In the case where a device comes back within the 30 second gone
  device timer window, though, we weren't telling CAM the device
  came back.
  
  So, fix this by tracking whether we have told CAM the device is
  gone, and if we have, send a rescan if it comes back within the 30
  second window.
  
  ispvar.h:
In the fcportdb_t structure, add a new bitfield,
reported_gone.  This gets set whenever we return a command
with CAM_SEL_TIMEOUT status on a Fibre Channel device.
  
  isp_freebsd.c:
In isp_done(), if we're sending CAM_SEL_TIMEOUT for for a
command sent to a FC device, set the reported_gone bit.
  
In isp_async(), in the ISPASYNC_DEV_STAYED case, rescan the
device in question if it is mapped to a target ID and has
been reported gone.
  
In isp_make_here(), take a port database entry argument,
and clear the reported_gone bit when we send a rescan to
CAM.
  
In isp_make_gone(), take a port database entry as an
argument, and set the reported_gone bit when we send an
async event telling CAM consumers that the device is gone.
  
  Sponsored by: Spectra Logic
  MFC after:1 week

Modified:
  head/sys/dev/isp/isp_freebsd.c
  head/sys/dev/isp/ispvar.h

Modified: head/sys/dev/isp/isp_freebsd.c
==
--- head/sys/dev/isp/isp_freebsd.c  Thu Jan  8 17:49:07 2015
(r276841)
+++ head/sys/dev/isp/isp_freebsd.c  Thu Jan  8 17:51:12 2015
(r276842)
@@ -4565,7 +4565,7 @@ isp_watchdog(void *arg)
 }
 
 static void
-isp_make_here(ispsoftc_t *isp, int chan, int tgt)
+isp_make_here(ispsoftc_t *isp, fcportdb_t *fcp, int chan, int tgt)
 {
union ccb *ccb;
struct isp_fc *fc = ISP_FC_PC(isp, chan);
@@ -4588,11 +4588,18 @@ isp_make_here(ispsoftc_t *isp, int chan,
xpt_free_ccb(ccb);
return;
}
+
+   /*
+* Since we're about to issue a rescan, mark this device as not
+* reported gone.
+*/
+   fcp-reported_gone = 0;
+
xpt_rescan(ccb);
 }
 
 static void
-isp_make_gone(ispsoftc_t *isp, int chan, int tgt)
+isp_make_gone(ispsoftc_t *isp, fcportdb_t *fcp, int chan, int tgt)
 {
struct cam_path *tp;
struct isp_fc *fc = ISP_FC_PC(isp, chan);
@@ -4601,6 +4608,11 @@ isp_make_gone(ispsoftc_t *isp, int chan,
return;
}
if (xpt_create_path(tp, NULL, cam_sim_path(fc-sim), tgt, 
CAM_LUN_WILDCARD) == CAM_REQ_CMP) {
+   /*
+* We're about to send out the lost device async
+* notification, so indicate that we have reported it gone.
+*/
+   fcp-reported_gone = 1;
xpt_async(AC_LOST_DEVICE, tp, NULL);
xpt_free_path(tp);
}
@@ -4654,7 +4666,7 @@ isp_gdt_task(void *arg, int pending)
lp-dev_map_idx = 0;
lp-state = FC_PORTDB_STATE_NIL;
isp_prt(isp, ISP_LOGCONFIG, prom3, chan, lp-portid, tgt, Gone 
Device Timeout);
-   isp_make_gone(isp, chan, tgt);
+   isp_make_gone(isp, lp, chan, tgt);
}
if (fc-ready) {
if (more_to_do) {
@@ -4747,7 +4759,7 @@ isp_ldt_task(void *arg, int pending)
lp-dev_map_idx = 0;
lp-state = FC_PORTDB_STATE_NIL;
isp_prt(isp, ISP_LOGCONFIG, prom3, chan, lp-portid, tgt, Loop 
Down Timeout);
-   isp_make_gone(isp, chan, tgt);
+   isp_make_gone(isp, lp, chan, tgt);
}
 
if (FCPARAM(isp, chan)-role  ISP_ROLE_INITIATOR) {
@@ -5561,6 +5573,21 @@ isp_done(XS_T *sccb)
if (status != CAM_REQ_CMP) {
if (status != CAM_SEL_TIMEOUT)
isp_prt(isp, ISP_LOGDEBUG0, target %d lun %d CAM 
status 0x%x SCSI status 0x%x, XS_TGT(sccb), XS_LUN(sccb), sccb-ccb_h.status, 
sccb-scsi_status);
+   else if ((IS_FC(isp))
+  (XS_TGT(sccb)  MAX_FC_TARG)) {
+   fcparam *fcp;
+   int hdlidx;
+
+   fcp = FCPARAM(isp, XS_CHANNEL(sccb));
+   hdlidx = 

svn commit: r276835 - in head: sbin/camcontrol sys/cam/scsi

2015-01-08 Thread Kenneth D. Merry
Author: ken
Date: Thu Jan  8 16:58:40 2015
New Revision: 276835
URL: https://svnweb.freebsd.org/changeset/base/276835

Log:
  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
  MFC after:1 week

Modified:
  head/sbin/camcontrol/camcontrol.8
  head/sbin/camcontrol/camcontrol.c
  head/sys/cam/scsi/scsi_da.c
  head/sys/cam/scsi/scsi_da.h

Modified: head/sbin/camcontrol/camcontrol.8
==
--- head/sbin/camcontrol/camcontrol.8   Thu Jan  8 16:50:35 2015
(r276834)
+++ head/sbin/camcontrol/camcontrol.8   Thu Jan  8 16:58:40 2015
(r276835)
@@ -110,6 +110,10 @@
 .Aq Fl f Ar format
 .Op Fl P
 .Op Fl G
+.Op Fl q
+.Op Fl s
+.Op Fl S Ar offset
+.Op Fl X
 .Nm
 .Ic modepage
 .Op device id
@@ -513,18 +517,16 @@ connecting to that device.
 Note that this can have a destructive impact
 on the system.
 .It Ic defects
-Send the SCSI READ DEFECT DATA (10) command (0x37) to the given device, and
+Send the
+.Tn SCSI
+READ DEFECT DATA (10) command (0x37) or the 
+.Tn SCSI
+READ DEFECT DATA (12) command (0xB7) to the given device, and
 print 

svn commit: r276831 - head/sys/cam/scsi

2015-01-08 Thread Kenneth D. Merry
Author: ken
Date: Thu Jan  8 16:27:56 2015
New Revision: 276831
URL: https://svnweb.freebsd.org/changeset/base/276831

Log:
  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.
  
  MFC after:1 week
  Sponsored by: Spectra Logic

Modified:
  head/sys/cam/scsi/scsi_xpt.c

Modified: head/sys/cam/scsi/scsi_xpt.c
==
--- head/sys/cam/scsi/scsi_xpt.cThu Jan  8 16:13:21 2015
(r276830)
+++ head/sys/cam/scsi/scsi_xpt.cThu Jan  8 16:27:56 2015
(r276831)
@@ -755,7 +755,8 @@ again:
 * serial number check finish, we attempt to figure out
 * whether we still have the same device.
 */
-   if ((periph-path-device-flags  CAM_DEV_UNCONFIGURED) == 0) {
+   if (((periph-path-device-flags  CAM_DEV_UNCONFIGURED) == 0)
+ ((softc-flags  PROBE_INQUIRY_CKSUM) == 0)) {
 
MD5Init(softc-context);
MD5Update(softc-context, (unsigned char *)inq_buf,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r268240 - in head: sbin/camcontrol sys/cam/scsi

2014-07-03 Thread Kenneth D. Merry
Author: ken
Date: Thu Jul  3 23:09:44 2014
New Revision: 268240
URL: http://svnweb.freebsd.org/changeset/base/268240

Log:
  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.
  
  sbin/camcontrol/Makefile:
Add persist.c.
  
  sbin/camcontrol/persist.c:
New persistent reservation support for camcontrol(8).
  
We have support for all known operation modes for PERSISTENT RESERVE
IN and PERSISTENT RESERVE OUT.
exceptions noted above.
  
  sbin/camcontrol/camcontrol.8:
Document the new 'persist' subcommand.
  
In the section on the Transport ID (-I) option, explain what
Transport IDs for each protocol should look like.  At some point
some of this information could probably get moved off in a
separate man page, either on Transport IDs alone or a man page
documenting the Transport ID parsing code.
  
Add a number of examples of persistent reservation commands.
Persistent Reservations are complex enough that the average user
probably won't be able to get the commands exactly right by just
reading the man page.  These examples show a few basic and
advanced examples of how to use persistent reservations.
  
  sbin/camcontrol/camcontrol.h:
Move the definition for camcontrol_optret here, so we can use it
for the persistent reservation code.
  
Add a definition for the new scsipersist() function.
  
  sbin/camcontrol/camcontrol.c:
Add 'persist' to the list of subcommands.
  
Document 'persist' in the help text.
  
  sys/cam/scsi/scsi_all.c:
Add the scsi_persistent_reserve_in() and
scsi_persistent_reserve_out() CCB building functions.
  
Add a new function, scsi_transportid_sbuf().  This takes a
SCSI Transport ID (documented in SPC-4), and prints it to
an sbuf(9).  There are some transports (like ATA, USB, and
SSA) for which there is no transport defined.  We need to
come up with a reasonable thing to do if we're presented
with a Transport ID that claims to be for one of those
protocols.
  
Add new routines scsi_get_nv() and scsi_nv_to_str().
  
These functions do a table lookup to go between a string and an
integer.  There are lots of table lookups needed in the
persistent reservation code in camcontrol(8).
  
Add a new function, scsi_parse_transportid(), along with leaf node
functions to parse:
FC, 1394 and SAS (scsi_parse_transportid_64bit())
iSCSI (scsi_parse_transportid_iscsi())
SPI (scsi_parse_transportid_spi())
RDMA (scsi_parse_transportid_rdma())
PCIe (scsi_parse_transportid_sop())
  
Transport IDs.  Given a string with the general form proto,id these
functions create a SCSI Transport ID structure.
  
  sys/cam/scsi/scsi_all.h:
Update the various persistent reservation data structures to
SPC4r36l, but also rename some fields that were previously
obsolete with the proper names from older SCSI specs.  This
allows using older, obsolete persistent reservation types when
desired.
  
Add function prototypes for the new persistent reservation CCB
building functions.
  
Add a data strucure for the READ FULL STATUS service action
of the PERSISTENT RESERVE IN command.
  
Add Transport ID structures for all protocols described in SPC-4.
  
Add a new series of SCSI_PROTO_XXX definitions, and
redefine other defines in terms of these new definitions.
  
Add a prototype for scsi_transportid_sbuf().
  
Change a couple of obsolete persistent reservation data
structure fields into something more meaningful, based on
what the field was called when it was defined in the spec.
(e.g. SPC, SPC-2, etc.)
  
Create a new define, SPRI_MAX_LEN, for the maximum allocation
length allowed for the PERSISTENT RESERVE IN command.
  
Add data structures and enumerations for the new name/value
translation functions.
  
Add data structures for SCSI over PCIe Routing IDs.
  
Bring the PERSISTENT RESERVE OUT Register and Move parameter list
structure (struct scsi_per_res_out_parms) up to date with SPC-4.
  
Add a data structure for the transport IDs that can optionally be
appended to the basic PERSISTENT RESERVE OUT parameter list.
  
Move SCSI protocol macro definitions out of the VPD page 0x83
definition and combine them with the more up to date protocol
definitions higher in the file.
  
Add function prototypes for scsi_nv_to_str(), scsi_get_nv(),
scsi_parse_transportid_64bit(), scsi_parse_transportid_spi(),

Re: svn commit: r254627 - in head: bin/chflags bin/ls lib/libc/gen lib/libc/sys sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/fs/msdosfs sys/fs/smbfs sys/sys sys/ufs/ufs

2014-06-27 Thread Kenneth D. Merry
On Fri, Jun 27, 2014 at 12:48:29 -0700, Xin LI wrote:
 Hi,
 
 Craig have hit an interesting issue today, where he tried to 'mv' a file
 from ZFS dataset to a NFS mount, 'mv' bails out because chflags failed.
 
 I think it's probably sensible to have mv ignoring UF_ARCHIVE, and set the
 flag on the target unconditionally?  i.e.:
 
 Index: mv.c
 ===
 --- mv.c (revision 267940)
 +++ mv.c (working copy)
 @@ -337,8 +337,8 @@
   * on a file that we copied, i.e., that we didn't create.)
   */
   errno = 0;
 - if (fchflags(to_fd, sbp-st_flags))
 - if (errno != EOPNOTSUPP || sbp-st_flags != 0)
 + if (fchflags(to_fd, sbp-st_flags | UF_ARCHIVE))
 + if (errno != EOPNOTSUPP || (sbp-st_flags  ~UF_ARCHIVE) != 0)
   warn(%s: set flags (was: 0%07o), to, sbp-st_flags);
 
   tval[0].tv_sec = sbp-st_atime;

Yes, that sounds like a good way to do it.

Ken
-- 
Kenneth Merry
k...@freebsd.org
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r267986 - head/sys/cam/ctl

2014-06-27 Thread Kenneth D. Merry
On Fri, Jun 27, 2014 at 22:28:14 +, Alexander Motin wrote:
 Author: mav
 Date: Fri Jun 27 22:28:14 2014
 New Revision: 267986
 URL: http://svnweb.freebsd.org/changeset/base/267986
 
 Log:
   Remove odd practice of inverting error codes.
   
   -EPERM is equal to ERESTART, returning which from ioctl() handler causes
   infinite syscall restart.
   
   MFC after:  2 weeks

Oops.  Not sure how I left that in there.

I suppose you can tell it was originally written for Linux. :)

Ken
-- 
Kenneth Merry
k...@freebsd.org
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r265709 - in head/sys/dev: mpr mps

2014-05-08 Thread Kenneth D. Merry
Author: ken
Date: Thu May  8 20:28:22 2014
New Revision: 265709
URL: http://svnweb.freebsd.org/changeset/base/265709

Log:
  Fix TLR (Transport Layer Retry) support in the mps(4) and mpr(4) drivers.
  
  TLR is necessary for reliable communication with SAS tape drives.
  
  This was broken by change 246713 in the mps(4) driver.  It changed the
  cm_data field for SCSI I/O requests to point to the CCB instead of the data
  buffer.  So, instead, look at the CCB's data pointer to determine whether
  or not we're talking to a tape drive.
  
  Also, take the residual into account to make sure that we don't go off the
  end of the request.
  
  MFC after:3 days
  Sponsored by: Spectra Logic Corporation

Modified:
  head/sys/dev/mpr/mpr_sas.c
  head/sys/dev/mps/mps_sas.c

Modified: head/sys/dev/mpr/mpr_sas.c
==
--- head/sys/dev/mpr/mpr_sas.c  Thu May  8 20:27:06 2014(r265708)
+++ head/sys/dev/mpr/mpr_sas.c  Thu May  8 20:28:22 2014(r265709)
@@ -2355,8 +2355,9 @@ mprsas_scsiio_complete(struct mpr_softc 
(csio-cdb_io.cdb_bytes[1]  SI_EVPD) 
(csio-cdb_io.cdb_bytes[2] == SVPD_SUPPORTED_PAGE_LIST) 
((csio-ccb_h.flags  CAM_DATA_MASK) == CAM_DATA_VADDR) 
-   (csio-data_ptr != NULL)  (((uint8_t *)cm-cm_data)[0] ==
-   T_SEQUENTIAL)  (sc-control_TLR) 
+   (csio-data_ptr != NULL) 
+   ((csio-data_ptr[0]  0x1f) == T_SEQUENTIAL) 
+   (sc-control_TLR) 
(sc-mapping_table[csio-ccb_h.target_id].device_info 
MPI2_SAS_DEVICE_INFO_SSP_TARGET)) {
vpd_list = (struct scsi_vpd_supported_page_list *)
@@ -2367,6 +2368,7 @@ mprsas_scsiio_complete(struct mpr_softc 
TLR_on = (u8)MPI2_SCSIIO_CONTROL_TLR_ON;
alloc_len = ((u16)csio-cdb_io.cdb_bytes[3]  8) +
csio-cdb_io.cdb_bytes[4];
+   alloc_len -= csio-resid;
for (i = 0; i  MIN(vpd_list-length, alloc_len); i++) {
if (vpd_list-list[i] == 0x90) {
*TLR_bits = TLR_on;

Modified: head/sys/dev/mps/mps_sas.c
==
--- head/sys/dev/mps/mps_sas.c  Thu May  8 20:27:06 2014(r265708)
+++ head/sys/dev/mps/mps_sas.c  Thu May  8 20:28:22 2014(r265709)
@@ -2316,8 +2316,9 @@ mpssas_scsiio_complete(struct mps_softc 
(csio-cdb_io.cdb_bytes[1]  SI_EVPD) 
(csio-cdb_io.cdb_bytes[2] == SVPD_SUPPORTED_PAGE_LIST) 
((csio-ccb_h.flags  CAM_DATA_MASK) == CAM_DATA_VADDR) 
-   (csio-data_ptr != NULL)  (((uint8_t *)cm-cm_data)[0] ==
-   T_SEQUENTIAL)  (sc-control_TLR) 
+   (csio-data_ptr != NULL) 
+   ((csio-data_ptr[0]  0x1f) == T_SEQUENTIAL) 
+   (sc-control_TLR) 
(sc-mapping_table[csio-ccb_h.target_id].device_info 
MPI2_SAS_DEVICE_INFO_SSP_TARGET)) {
vpd_list = (struct scsi_vpd_supported_page_list *)
@@ -2328,6 +2329,7 @@ mpssas_scsiio_complete(struct mps_softc 
TLR_on = (u8)MPI2_SCSIIO_CONTROL_TLR_ON;
alloc_len = ((u16)csio-cdb_io.cdb_bytes[3]  8) +
csio-cdb_io.cdb_bytes[4];
+   alloc_len -= csio-resid;
for (i = 0; i  MIN(vpd_list-length, alloc_len); i++) {
if (vpd_list-list[i] == 0x90) {
*TLR_bits = TLR_on;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


  1   2   3   >