Re: [PATCH] sd: disentangle barriers in SCSI

2007-08-04 Thread Tejun Heo
James Bottomley wrote:
> Our current implementation has a generic set of barrier functions that
> go through the SCSI driver model.  Realistically, this is unnecessary,
> because the only device that can use barriers (sd) can set the flush
> functions up at probe or revalidate time.  This patch pulls the barrier
> functions out of the mid layer and scsi driver model and relocates them
> directly in sd.

Looks good to me.

Thanks.

-- 
tejun
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH update] firewire: fw-sbp2: add support for multiple logical units per target

2007-08-04 Thread Stefan Richter
Fixes "New firewire stack only recognizing half of a chain of drives",
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=242254

Signed-off-by: Stefan Richter <[EMAIL PROTECTED]>
---

This replaces the patches
 "firewire: remove unused macros"
 "firewire: fw-sbp2: use one Scsi_Host for all targets"
 "firewire: fw-sbp2: split logical unit data from target data"
 "firewire: fw-sbp2: add support for multiple logical units per target"
 "firewire: fw-sbp2: remove some log messages"

 drivers/firewire/fw-device.h |5 
 drivers/firewire/fw-sbp2.c   |  577 +++
 2 files changed, 325 insertions(+), 257 deletions(-)

Index: linux/drivers/firewire/fw-device.h
===
--- linux.orig/drivers/firewire/fw-device.h
+++ linux/drivers/firewire/fw-device.h
@@ -102,11 +102,6 @@ fw_unit(struct device *dev)
 #define CSR_INSTANCE   0x18
 #define CSR_DIRECTORY_ID   0x20
 
-#define SBP2_COMMAND_SET_SPECIFIER 0x38
-#define SBP2_COMMAND_SET   0x39
-#define SBP2_COMMAND_SET_REVISION  0x3b
-#define SBP2_FIRMWARE_REVISION 0x3c
-
 struct fw_csr_iterator {
u32 *p;
u32 *end;
Index: linux/drivers/firewire/fw-sbp2.c
===
--- linux.orig/drivers/firewire/fw-sbp2.c
+++ linux/drivers/firewire/fw-sbp2.c
@@ -41,7 +41,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -66,31 +65,49 @@ typedef void (*scsi_done_fn_t)(struct sc
 
 static const char sbp2_driver_name[] = "sbp2";
 
-struct sbp2_device {
-   struct kref kref;
-   struct fw_unit *unit;
+/*
+ * We create one struct sbp2_logical_unit per SBP-2 Logical Unit Number Entry
+ * and one struct scsi_device per sbp2_logical_unit.
+ */
+struct sbp2_logical_unit {
+   struct sbp2_target *tgt;
+   struct list_head link;
+   struct scsi_device *sdev;
struct fw_address_handler address_handler;
struct list_head orb_list;
-   u64 management_agent_address;
+
u64 command_block_agent_address;
-   u32 workarounds;
+   u16 lun;
int login_id;
 
/*
-* We cache these addresses and only update them once we've
-* logged in or reconnected to the sbp2 device.  That way, any
-* IO to the device will automatically fail and get retried if
-* it happens in a window where the device is not ready to
-* handle it (e.g. after a bus reset but before we reconnect).
+* The generation is updated once we've logged in or reconnected
+* to the logical unit.  Thus, I/O to the device will automatically
+* fail and get retried if it happens in a window where the device
+* is not ready, e.g. after a bus reset but before we reconnect.
 */
-   int node_id;
-   int address_high;
int generation;
-
int retries;
struct delayed_work work;
 };
 
+/*
+ * We create one struct sbp2_target per IEEE 1212 Unit Directory
+ * and one struct Scsi_Host per sbp2_target.
+ */
+struct sbp2_target {
+   struct kref kref;
+   struct fw_unit *unit;
+
+   u64 management_agent_address;
+   int directory_id;
+   int node_id;
+   int address_high;
+
+   unsigned workarounds;
+   struct list_head lu_list;
+};
+
 #define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000
 #define SBP2_MAX_SECTORS   255 /* Max sectors supported */
 #define SBP2_ORB_TIMEOUT   2000/* Timeout in ms */
@@ -101,10 +118,9 @@ struct sbp2_device {
 #define SBP2_DIRECTION_FROM_MEDIA  0x1
 
 /* Unit directory keys */
-#define SBP2_COMMAND_SET_SPECIFIER 0x38
-#define SBP2_COMMAND_SET   0x39
-#define SBP2_COMMAND_SET_REVISION  0x3b
-#define SBP2_FIRMWARE_REVISION 0x3c
+#define SBP2_CSR_FIRMWARE_REVISION 0x3c
+#define SBP2_CSR_LOGICAL_UNIT_NUMBER   0x14
+#define SBP2_CSR_LOGICAL_UNIT_DIRECTORY0xd4
 
 /* Flags for detected oddities and brokeness */
 #define SBP2_WORKAROUND_128K_MAX_TRANS 0x1
@@ -218,7 +234,7 @@ struct sbp2_command_orb {
} request;
struct scsi_cmnd *cmd;
scsi_done_fn_t done;
-   struct fw_unit *unit;
+   struct sbp2_logical_unit *lu;
 
struct sbp2_pointer page_table[SG_ALL] __attribute__((aligned(8)));
dma_addr_t page_table_bus;
@@ -286,7 +302,7 @@ sbp2_status_write(struct fw_card *card, 
  unsigned long long offset,
  void *payload, size_t length, void *callback_data)
 {
-   struct sbp2_device *sd = callback_data;
+   struct sbp2_logical_unit *lu = callback_data;
struct sbp2_orb *orb;
struct sbp2_status status;
size_t header_size;
@@ -310,7 +326,7 @@ sbp2_status_write(struct fw_card *card, 
 
/* Lookup the orb corresponding to this status write. */
spin_lock_irqsave(&card->lock, flags);
-   list_for_each_entry(orb, &sd->orb_list, link) {
+   lis

[PATCH] move ULD attachment into the prep function

2007-08-04 Thread James Bottomley
One of the intents of the block prep function was to allow ULDs to use
it for preprocessing.  The original SCSI model was to have a single prep
function and add a pointer indirect filter to build the necessary
commands.  This patch reverses that, does away with the init_command
field of the scsi_driver structure and makes ULDs attach directly to the
prep function instead.  The value is really that it allows us to begin
to separate the ULDs from the SCSI mid layer (as long as they don't use
any core functions---which is hard at the moment---a ULD doesn't even
need SCSI to bind).

James

Index: BUILD-2.6/drivers/scsi/scsi_lib.c
===
--- BUILD-2.6.orig/drivers/scsi/scsi_lib.c  2007-08-04 09:53:44.0 
-0500
+++ BUILD-2.6/drivers/scsi/scsi_lib.c   2007-08-04 09:53:49.0 -0500
@@ -1032,9 +1032,6 @@ static int scsi_init_io(struct scsi_cmnd
printk(KERN_ERR "req nr_sec %lu, cur_nr_sec %u\n", req->nr_sectors,
req->current_nr_sectors);
 
-   /* release the command and kill it */
-   scsi_release_buffers(cmd);
-   scsi_put_command(cmd);
return BLKPREP_KILL;
 }
 
@@ -1071,9 +1068,13 @@ static void scsi_blk_pc_done(struct scsi
scsi_io_completion(cmd, cmd->request_bufflen);
 }
 
-static int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request 
*req)
+int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req)
 {
struct scsi_cmnd *cmd;
+   int ret = scsi_prep_state_check(sdev, req);
+
+   if (ret != BLKPREP_OK)
+   return ret;
 
cmd = scsi_get_cmd_from_req(sdev, req);
if (unlikely(!cmd))
@@ -1119,18 +1120,20 @@ static int scsi_setup_blk_pc_cmnd(struct
cmd->done = scsi_blk_pc_done;
return BLKPREP_OK;
 }
+EXPORT_SYMBOL(scsi_setup_blk_pc_cmnd);
 
 /*
  * Setup a REQ_TYPE_FS command.  These are simple read/write request
  * from filesystems that still need to be translated to SCSI CDBs from
  * the ULD.
  */
-static int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req)
+int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req)
 {
struct scsi_cmnd *cmd;
-   struct scsi_driver *drv;
-   int ret;
+   int ret = scsi_prep_state_check(sdev, req);
 
+   if (ret != BLKPREP_OK)
+   return ret;
/*
 * Filesystem requests must transfer data.
 */
@@ -1140,26 +1143,12 @@ static int scsi_setup_fs_cmnd(struct scs
if (unlikely(!cmd))
return BLKPREP_DEFER;
 
-   ret = scsi_init_io(cmd);
-   if (unlikely(ret))
-   return ret;
-
-   /*
-* Initialize the actual SCSI command for this request.
-*/
-   drv = *(struct scsi_driver **)req->rq_disk->private_data;
-   if (unlikely(!drv->init_command(cmd))) {
-   scsi_release_buffers(cmd);
-   scsi_put_command(cmd);
-   return BLKPREP_KILL;
-   }
-
-   return BLKPREP_OK;
+   return scsi_init_io(cmd);
 }
+EXPORT_SYMBOL(scsi_setup_fs_cmnd);
 
-static int scsi_prep_fn(struct request_queue *q, struct request *req)
+int scsi_prep_state_check(struct scsi_device *sdev, struct request *req)
 {
-   struct scsi_device *sdev = q->queuedata;
int ret = BLKPREP_OK;
 
/*
@@ -1205,35 +1194,25 @@ static int scsi_prep_fn(struct request_q
ret = BLKPREP_KILL;
break;
}
-
-   if (ret != BLKPREP_OK)
-   goto out;
}
+   return ret;
+}
+EXPORT_SYMBOL(scsi_prep_state_check);
 
-   switch (req->cmd_type) {
-   case REQ_TYPE_BLOCK_PC:
-   ret = scsi_setup_blk_pc_cmnd(sdev, req);
-   break;
-   case REQ_TYPE_FS:
-   ret = scsi_setup_fs_cmnd(sdev, req);
-   break;
-   default:
-   /*
-* All other command types are not supported.
-*
-* Note that these days the SCSI subsystem does not use
-* REQ_TYPE_SPECIAL requests anymore.  These are only used
-* (directly or via blk_insert_request) by non-SCSI drivers.
-*/
-   blk_dump_rq_flags(req, "SCSI bad req");
-   ret = BLKPREP_KILL;
-   break;
-   }
+int scsi_prep_return(struct request_queue *q, struct request *req, int ret)
+{
+   struct scsi_device *sdev = q->queuedata;
 
- out:
switch (ret) {
case BLKPREP_KILL:
req->errors = DID_NO_CONNECT << 16;
+   /* release the command and kill it */
+   if (req->special) {
+   struct scsi_cmnd *cmd = req->special;
+   scsi_release_buffers(cmd);
+   scsi_put_command(cmd);
+   req->special = NULL;
+   }
break;
cas

[GIT PATCH] scsi bug fixes for 2.6.23-rc2

2007-08-04 Thread James Bottomley
This is mainly bug fixes ... there's one or two features completions
that have been delayed pending ack and review to do with bsg (headers
and passthrough) but these are really required to complete already
upstream code.

The patch is available here:

master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-rc-fixes-2.6.git

The short changelog is:

Boaz Harrosh (6):
  aha152x: use data accessors and !use_sg cleanup
  aha152x: Fix check_condition code-path
  aha152x: Clean Reset path
  aha152x: preliminary fixes and some comments
  aha152x: use bounce buffer
  aha152x: fix debug mode symbol conflict

David Miller (1):
  ESP: Revert ESP_BUS_TIMEOUT back down to 250

FUJITA Tomonori (6):
  initialize shost_data to zero
  mptsas: add SMP passthrough support via bsg
  bsg: update sg_io_v4 structure
  ibmvscsi: use shost_priv
  ibmvscsi: remove unnecessary map_sg check
  zfcp: convert to use the data buffer accessors

James Bottomley (4):
  sd: disentangle barriers in SCSI
  aic7xxx: cap maxsync according to correct card limits
  mpt fusion: make logging a global sysfs parameter
  libsas: fix build dependencies on libata

James Smart (9):
  lpfc : scsi command accessor fix for 8.2.2
  lpfc 8.2.2 : Change version number to 8.2.2
  lpfc 8.2.2 : Style cleanups
  lpfc 8.2.2 : Miscellaneous Bug Fixes
  lpfc 8.2.2 : Miscellaneous management and logging mods
  lpfc 8.2.2 : Rework the lpfc_printf_log() macro
  lpfc 8.2.2 : Attribute and Parameter splits for vport and physical port
  lpfc 8.2.2 : Fix locking around HBA's port_list
  lpfc 8.2.2 : Error messages and debugfs updates

Jeff Garzik (1):
  gdth: remove redundant PCI stuff

Mark Fortescue (1):
  qlogicpti: Some cosmetic changes

Matthew Wilcox (1):
  dpt_i2o: convert to SCSI hotplug model

Matthias Kaehlcke (1):
  st: Use mutex instead of semaphore

Salyzyn, Mark (1):
  aacraid: prevent panic on adapter resource failure

Seokmann Ju (1):
  qla2xxx: fix panic caused by previous patch


and the diffstat:

 block/bsg.c |   10 
 drivers/message/fusion/mptbase.c|   17 
 drivers/message/fusion/mptsas.c |  126 ++
 drivers/s390/scsi/zfcp_fsf.c|5 
 drivers/s390/scsi/zfcp_qdio.c   |   41 --
 drivers/scsi/aacraid/linit.c|4 
 drivers/scsi/aha152x.c  |  169 
 drivers/scsi/aha152x.h  |2 
 drivers/scsi/aic7xxx/aic7xxx_core.c |   22 +
 drivers/scsi/dpt_i2o.c  |  132 +++---
 drivers/scsi/dpti.h |9 
 drivers/scsi/esp_scsi.h |2 
 drivers/scsi/gdth.c |   48 +-
 drivers/scsi/gdth.h |6 
 drivers/scsi/hosts.c|2 
 drivers/scsi/ibmvscsi/ibmvscsi.c|   39 --
 drivers/scsi/libsas/Kconfig |3 
 drivers/scsi/lpfc/lpfc.h|   72 ++-
 drivers/scsi/lpfc/lpfc_attr.c   |  423 +++---
 drivers/scsi/lpfc/lpfc_crtn.h   |   28 -
 drivers/scsi/lpfc/lpfc_ct.c |  243 ++--
 drivers/scsi/lpfc/lpfc_debugfs.c|  595 ---
 drivers/scsi/lpfc/lpfc_debugfs.h|2 
 drivers/scsi/lpfc/lpfc_els.c|  679 
 drivers/scsi/lpfc/lpfc_hbadisc.c|  539 
 drivers/scsi/lpfc/lpfc_hw.h |   14 
 drivers/scsi/lpfc/lpfc_init.c   |  284 +++
 drivers/scsi/lpfc/lpfc_logmsg.h |   10 
 drivers/scsi/lpfc/lpfc_mbox.c   |   20 -
 drivers/scsi/lpfc/lpfc_mem.c|   32 +
 drivers/scsi/lpfc/lpfc_nportdisc.c  |  162 +++-
 drivers/scsi/lpfc/lpfc_scsi.c   |  413 ++---
 drivers/scsi/lpfc/lpfc_sli.c|  423 +++---
 drivers/scsi/lpfc/lpfc_sli.h|   10 
 drivers/scsi/lpfc/lpfc_version.h|4 
 drivers/scsi/lpfc/lpfc_vport.c  |  164 +---
 drivers/scsi/lpfc/lpfc_vport.h  |2 
 drivers/scsi/qla2xxx/qla_os.c   |   14 
 drivers/scsi/qlogicpti.c|   50 +-
 drivers/scsi/scsi_lib.c |   17 
 drivers/scsi/sd.c   |   14 
 drivers/scsi/st.c   |   16 
 drivers/scsi/st.h   |3 
 include/linux/bsg.h |   13 
 include/scsi/scsi_driver.h  |2 
 include/scsi/sd.h   |2 
 46 files changed, 2837 insertions(+), 2050 deletions(-)

James


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH][RESEND] Fix a potential NULL pointer deref in the aic7xxx, ahc_print_register() function

2007-08-04 Thread James Bottomley
On Sat, 2007-08-04 at 20:30 +0200, Jesper Juhl wrote:
> (resend of patch previously submitted on 28-Jul-2007 23:06)
> 
> 
> Ehlo,
> 
> The Coverity checker noticed that we have a potential NULL pointer 
> deref in drivers/scsi/aic7xxx/aic7xxx_core.c::ahc_print_register().
> This patch handles it by adding the same test against NULL that is 
> used elsewhere in the same function.

It's on my list of things to look at ... but not very high.  I suspect
it actually isn't triggerable, but if you can tell me how, it will save
me from looking.

James


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html