All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] osst: remove scsi_execute_async usage
@ 2008-12-13 15:55 FUJITA Tomonori
  2008-12-13 15:55 ` [PATCH 1/2] osst: make all the buffer the same size FUJITA Tomonori
  2009-01-11  4:44 ` [PATCH 0/2] osst: remove scsi_execute_async usage FUJITA Tomonori
  0 siblings, 2 replies; 4+ messages in thread
From: FUJITA Tomonori @ 2008-12-13 15:55 UTC (permalink / raw)
  To: osst; +Cc: James.Bottomley, fujita.tomonori, linux-scsi

This patchset removes scsi_execute_async usage in osst driver. IOW,
this converts osst driver to use the block layer functions. We are in
the process of removing scsi_execute_async and
scsi_req_map_sg. scsi_execute_async in sg driver were removed in
2.6.27. The patchset to remove scsi_execute_async in st is available
(the first half patchset was already merged into scsi-misc). osst is
the last user.

This is against scsi-misc and depends on 'removing scsi_execute_async
in st' the second half patchset:

http://marc.info/?l=linux-scsi&m=122900494917385&w=2




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] osst: make all the buffer the same size
  2008-12-13 15:55 [PATCH 0/2] osst: remove scsi_execute_async usage FUJITA Tomonori
@ 2008-12-13 15:55 ` FUJITA Tomonori
  2008-12-13 15:55   ` [PATCH 2/2] osst: replace scsi_execute_async with the block layer API FUJITA Tomonori
  2009-01-11  4:44 ` [PATCH 0/2] osst: remove scsi_execute_async usage FUJITA Tomonori
  1 sibling, 1 reply; 4+ messages in thread
From: FUJITA Tomonori @ 2008-12-13 15:55 UTC (permalink / raw)
  To: osst; +Cc: James.Bottomley, fujita.tomonori, linux-scsi

This simiplifies the buffer management; all the buffers in osst_buffer
become the same size. This is necessary to use the block layer API (sg
driver was modified in the same way) since the block layer API takes
the same size page frames instead of scatter gatter.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
 drivers/scsi/osst.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 0ea78d9..f733b93 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -5286,11 +5286,6 @@ static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma)
 		struct page *page = alloc_pages(priority, (OS_FRAME_SIZE - got <= PAGE_SIZE) ? 0 : order);
 		STbuffer->sg[segs].offset = 0;
 		if (page == NULL) {
-			if (OS_FRAME_SIZE - got <= (max_segs - segs) * b_size / 2 && order) {
-				b_size /= 2;  /* Large enough for the rest of the buffers */
-				order--;
-				continue;
-			}
 			printk(KERN_WARNING "osst :W: Failed to enlarge buffer to %d bytes.\n",
 						OS_FRAME_SIZE);
 #if DEBUG
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] osst: replace scsi_execute_async with the block layer API
  2008-12-13 15:55 ` [PATCH 1/2] osst: make all the buffer the same size FUJITA Tomonori
@ 2008-12-13 15:55   ` FUJITA Tomonori
  0 siblings, 0 replies; 4+ messages in thread
From: FUJITA Tomonori @ 2008-12-13 15:55 UTC (permalink / raw)
  To: osst; +Cc: James.Bottomley, fujita.tomonori, linux-scsi

This replaces scsi_execute_async with the block layer API. st does the
same thing so it might make sense to have something like libst (there
are other things that os and osst can share).

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
 drivers/scsi/osst.c |   87 +++++++++++++++++++++++++++++++++++++++++++++++---
 drivers/scsi/osst.h |    2 +
 2 files changed, 83 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index f733b93..676f9e2 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -317,18 +317,25 @@ static int osst_chk_result(struct osst_tape * STp, struct osst_request * SRpnt)
 
 
 /* Wakeup from interrupt */
-static void osst_sleep_done(void *data, char *sense, int result, int resid)
+static void osst_end_async(struct request *req, int update)
 {
-	struct osst_request *SRpnt = data;
+	struct osst_request *SRpnt = req->end_io_data;
 	struct osst_tape *STp = SRpnt->stp;
+	struct rq_map_data *mdata = &SRpnt->stp->buffer->map_data;
 
-	memcpy(SRpnt->sense, sense, SCSI_SENSE_BUFFERSIZE);
-	STp->buffer->cmdstat.midlevel_result = SRpnt->result = result;
+	STp->buffer->cmdstat.midlevel_result = SRpnt->result = req->errors;
 #if DEBUG
 	STp->write_pending = 0;
 #endif
 	if (SRpnt->waiting)
 		complete(SRpnt->waiting);
+
+	if (SRpnt->bio) {
+		kfree(mdata->pages);
+		blk_rq_unmap_user(SRpnt->bio);
+	}
+
+	__blk_put_request(req->q, req);
 }
 
 /* osst_request memory management */
@@ -342,6 +349,74 @@ static void osst_release_request(struct osst_request *streq)
 	kfree(streq);
 }
 
+static int osst_execute(struct osst_request *SRpnt, const unsigned char *cmd,
+			int cmd_len, int data_direction, void *buffer, unsigned bufflen,
+			int use_sg, int timeout, int retries)
+{
+	struct request *req;
+	struct page **pages = NULL;
+	struct rq_map_data *mdata = &SRpnt->stp->buffer->map_data;
+
+	int err = 0;
+	int write = (data_direction == DMA_TO_DEVICE);
+
+	req = blk_get_request(SRpnt->stp->device->request_queue, write, GFP_KERNEL);
+	if (!req)
+		return DRIVER_ERROR << 24;
+
+	req->cmd_type = REQ_TYPE_BLOCK_PC;
+	req->cmd_flags |= REQ_QUIET;
+
+	SRpnt->bio = NULL;
+
+	if (use_sg) {
+		struct scatterlist *sg, *sgl = (struct scatterlist *)buffer;
+		int i;
+
+		pages = kzalloc(use_sg * sizeof(struct page *), GFP_KERNEL);
+		if (!pages)
+			goto free_req;
+
+		for_each_sg(sgl, sg, use_sg, i)
+			pages[i] = sg_page(sg);
+
+		mdata->null_mapped = 1;
+
+		mdata->page_order = get_order(sgl[0].length);
+		mdata->nr_entries =
+			DIV_ROUND_UP(bufflen, PAGE_SIZE << mdata->page_order);
+		mdata->offset = 0;
+
+		err = blk_rq_map_user(req->q, req, mdata, NULL, bufflen, GFP_KERNEL);
+		if (err) {
+			kfree(pages);
+			goto free_req;
+		}
+		SRpnt->bio = req->bio;
+		mdata->pages = pages;
+
+	} else if (bufflen) {
+		err = blk_rq_map_kern(req->q, req, buffer, bufflen, GFP_KERNEL);
+		if (err)
+			goto free_req;
+	}
+
+	req->cmd_len = cmd_len;
+	memset(req->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */
+	memcpy(req->cmd, cmd, req->cmd_len);
+	req->sense = SRpnt->sense;
+	req->sense_len = 0;
+	req->timeout = timeout;
+	req->retries = retries;
+	req->end_io_data = SRpnt;
+
+	blk_execute_rq_nowait(req->q, NULL, req, 1, osst_end_async);
+	return 0;
+free_req:
+	blk_put_request(req);
+	return DRIVER_ERROR << 24;
+}
+
 /* Do the scsi command. Waits until command performed if do_wait is true.
    Otherwise osst_write_behind_check() is used to check that the command
    has finished. */
@@ -403,8 +478,8 @@ static	struct osst_request * osst_do_scsi(struct osst_request *SRpnt, struct oss
 	STp->buffer->cmdstat.have_sense = 0;
 	STp->buffer->syscall_result = 0;
 
-	if (scsi_execute_async(STp->device, cmd, COMMAND_SIZE(cmd[0]), direction, bp, bytes,
-			use_sg, timeout, retries, SRpnt, osst_sleep_done, GFP_KERNEL))
+	if (osst_execute(SRpnt, cmd, COMMAND_SIZE(cmd[0]), direction, bp, bytes,
+			 use_sg, timeout, retries))
 		/* could not allocate the buffer or request was too large */
 		(STp->buffer)->syscall_result = (-EBUSY);
 	else if (do_wait) {
diff --git a/drivers/scsi/osst.h b/drivers/scsi/osst.h
index 5aa2274..11d26c5 100644
--- a/drivers/scsi/osst.h
+++ b/drivers/scsi/osst.h
@@ -520,6 +520,7 @@ struct osst_buffer {
   int syscall_result;
   struct osst_request *last_SRpnt;
   struct st_cmdstatus cmdstat;
+  struct rq_map_data map_data;
   unsigned char *b_data;
   os_aux_t *aux;               /* onstream AUX structure at end of each block     */
   unsigned short use_sg;       /* zero or number of s/g segments for this adapter */
@@ -634,6 +635,7 @@ struct osst_request {
 	int result;
 	struct osst_tape *stp;
 	struct completion *waiting;
+	struct bio *bio;
 };
 
 /* Values of write_type */
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] osst: remove scsi_execute_async usage
  2008-12-13 15:55 [PATCH 0/2] osst: remove scsi_execute_async usage FUJITA Tomonori
  2008-12-13 15:55 ` [PATCH 1/2] osst: make all the buffer the same size FUJITA Tomonori
@ 2009-01-11  4:44 ` FUJITA Tomonori
  1 sibling, 0 replies; 4+ messages in thread
From: FUJITA Tomonori @ 2009-01-11  4:44 UTC (permalink / raw)
  To: osst; +Cc: James.Bottomley, linux-scsi, fujita.tomonori

On Sun, 14 Dec 2008 00:55:16 +0900
FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> wrote:

> This patchset removes scsi_execute_async usage in osst driver. IOW,
> this converts osst driver to use the block layer functions. We are in
> the process of removing scsi_execute_async and
> scsi_req_map_sg. scsi_execute_async in sg driver were removed in
> 2.6.27. The patchset to remove scsi_execute_async in st is available
> (the first half patchset was already merged into scsi-misc). osst is
> the last user.
> 
> This is against scsi-misc and depends on 'removing scsi_execute_async
> in st' the second half patchset:
> 
> http://marc.info/?l=linux-scsi&m=122900494917385&w=2

Willem, any change to test the patches? They can be cleanly applied to
2.6.29-rc1.


Thanks,

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-01-11  4:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-13 15:55 [PATCH 0/2] osst: remove scsi_execute_async usage FUJITA Tomonori
2008-12-13 15:55 ` [PATCH 1/2] osst: make all the buffer the same size FUJITA Tomonori
2008-12-13 15:55   ` [PATCH 2/2] osst: replace scsi_execute_async with the block layer API FUJITA Tomonori
2009-01-11  4:44 ` [PATCH 0/2] osst: remove scsi_execute_async usage FUJITA Tomonori

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.