summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoaz Harrosh <bharrosh@panasas.com>2011-01-23 17:53:24 +0200
committerJames Bottomley <James.Bottomley@suse.de>2011-01-24 12:06:31 -0600
commit4977c82504f58d7579acabd21688183eaa8768fb (patch)
treefc455d2fe5f925b6cb1c143231c56b76befae373
parent1e34c8387380269b9d7707d625aeb9e9e92233f0 (diff)
[SCSI] libosd: osd_req_read_sg, optimize the single entry case
Since sg-read is a bidi operation, it is a gain to convert a single sg entry into a regular read. Better do this in the generic layer then force each caller to do so. Signed-off-by: Boaz Harrosh <bharrosh@panasas.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
-rw-r--r--drivers/scsi/osd/osd_initiator.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c
index b37c8a3c1bb0..86afb13f1e79 100644
--- a/drivers/scsi/osd/osd_initiator.c
+++ b/drivers/scsi/osd/osd_initiator.c
@@ -1005,11 +1005,23 @@ int osd_req_read_sg(struct osd_request *or,
const struct osd_sg_entry *sglist, unsigned numentries)
{
u64 len;
- int ret = _add_sg_continuation_descriptor(or, sglist, numentries, &len);
+ u64 off;
+ int ret;
- if (ret)
- return ret;
- osd_req_read(or, obj, 0, bio, len);
+ if (numentries > 1) {
+ off = 0;
+ ret = _add_sg_continuation_descriptor(or, sglist, numentries,
+ &len);
+ if (ret)
+ return ret;
+ } else {
+ /* Optimize the case of single segment, read_sg is a
+ * bidi operation.
+ */
+ len = sglist->len;
+ off = sglist->offset;
+ }
+ osd_req_read(or, obj, off, bio, len);
return 0;
}