Skip to content

Commit 4977c82

Browse files
Boaz HarroshJames Bottomley
authored andcommitted
[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>
1 parent 1e34c83 commit 4977c82

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

‎drivers/scsi/osd/osd_initiator.c‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,11 +1005,23 @@ int osd_req_read_sg(struct osd_request *or,
10051005
const struct osd_sg_entry *sglist, unsigned numentries)
10061006
{
10071007
u64 len;
1008-
int ret = _add_sg_continuation_descriptor(or, sglist, numentries, &len);
1008+
u64 off;
1009+
int ret;
10091010

1010-
if (ret)
1011-
return ret;
1012-
osd_req_read(or, obj, 0, bio, len);
1011+
if (numentries > 1) {
1012+
off = 0;
1013+
ret = _add_sg_continuation_descriptor(or, sglist, numentries,
1014+
&len);
1015+
if (ret)
1016+
return ret;
1017+
} else {
1018+
/* Optimize the case of single segment, read_sg is a
1019+
* bidi operation.
1020+
*/
1021+
len = sglist->len;
1022+
off = sglist->offset;
1023+
}
1024+
osd_req_read(or, obj, off, bio, len);
10131025

10141026
return 0;
10151027
}

0 commit comments

Comments
 (0)