On Wed, 16 Jun 2010 22:42:08 -0700 "Nicholas A. Bellinger" <nab at linux-iscsi.org> wrote: > From: Nicholas Bellinger <nab at linux-iscsi.org> > > This patch adds support for the block layer implementation of the sg v4 interface > (BSG) -> STGT with a new struct backingstore_template bsg_bst sharing code with the > original sg_bst. It adds for new function bs_bsg_cmd_submit() for incoming write I/O > and bs_bsg_cmd_complete() for polling read I/O using include/linux/bsg.h:struct sg_io_v4. > > This patch adds BSG specific major checks in bs_sg_open() and for getting max_queue using > SG_GET_COMMAND_Q and calling SG_SET_RESERVED_SIZE following init_sg_device(). > > So far this has been tested with STGT/iSCSI <-> BSG <-> TCM_Loop SPC-4 iSCSI Target > Port emulation and is able to mkfs, fsck and mount a filesystem from a TCM/IBLOCK > Linux LVM kernel level backstore. This code has also been tested with SG_IO and the > legacy codepath. > > Signed-off-by: Nicholas A. Bellinger <nab at linux-iscsi.org> > --- > usr/bs_sg.c | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++--- > usr/scsi_cmnd.h | 3 + > 2 files changed, 155 insertions(+), 9 deletions(-) > > diff --git a/usr/bs_sg.c b/usr/bs_sg.c > index bb03d46..e8e3551 100644 > --- a/usr/bs_sg.c > +++ b/usr/bs_sg.c > @@ -3,6 +3,9 @@ > * > * Copyright (C) 2008 Alexander Nezhinsky <nezhinsky at gmail.com> > * > + * Added linux/block/bsg.c support using struct sg_io_v4. > + * Copyright (C) 2010 Nicholas A. Bellinger <nab at linux-iscsi.org> > + * > * This program is free software; you can redistribute it and/or > * modify it under the terms of the GNU General Public License as > * published by the Free Software Foundation, version 2 of the > @@ -33,6 +36,7 @@ > #include <sys/stat.h> > #include <sys/epoll.h> > #include <scsi/sg.h> > +#include <linux/bsg.h> This breaks distributions that don't have linux/bsg.h. At least, I care about RHEL5 so please copy linux/bsg.h into tgt's tree instead of using linux/bsg.h. > #include "list.h" > #include "util.h" > @@ -45,6 +49,14 @@ > #define BS_SG_TIMEOUT 2000 > #define BS_SG_SHIFT 9 > > +//#define BSG_DEBUG_IO > + > +#ifdef BSG_DEBUG_IO > +#define BSG_IO(x...) eprintf(x) > +#else > +#define BSG_IO(x...) > +#endif > + Hmm, can we avoid it? We can enable/disable the debugging option on the fly. > static int graceful_read(int fd, void *p_read, int to_read) > { > int err; > @@ -107,7 +119,7 @@ static int bs_sg_rw(int host_no, struct scsi_cmd *cmd) > return SAM_STAT_CHECK_CONDITION; > } > > -static void set_cmd_failed(struct scsi_cmd *cmd) > +static int set_cmd_failed(struct scsi_cmd *cmd) > { > int result = SAM_STAT_CHECK_CONDITION; > uint16_t asc = ASC_READ_ERROR; > @@ -115,6 +127,52 @@ static void set_cmd_failed(struct scsi_cmd *cmd) > > scsi_set_result(cmd, result); > sense_data_build(cmd, key, asc); > + > + return result; > +} > + > +static int bs_bsg_cmd_submit(struct scsi_cmd *cmd) > +{ > + struct scsi_lu *dev = cmd->dev; > + int fd = dev->fd; > + struct sg_io_v4 *io_hdr = &cmd->cmd_bsg_hdr; Hmm, why do we need to add struct sg_io_v4 to scsi_cmd? Can't we do like bs_sg_cmd_submit? I really like to avoid to fatten struct scsi_cmd. -- To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html |