Message ID | 20170116211201.46601-4-farman@linux.vnet.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, 01/16 22:12, Eric Farman wrote: > Commit 6f607174 introduced a routine to get the maximum number > of bytes for a single I/O transfer for block devices, however > scsi generic devices are character devices, not block. Add > a condition for this, with slightly different logic because > the value is already in bytes, and need not be converted from > blocks as happens for block devices. > > Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com> > --- > block/file-posix.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/block/file-posix.c b/block/file-posix.c > index 2115155..c0843c2 100644 > --- a/block/file-posix.c > +++ b/block/file-posix.c > @@ -679,6 +679,13 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp) > if (ret > 0 && ret <= BDRV_REQUEST_MAX_SECTORS) { > bs->bl.max_transfer = pow2floor(ret << BDRV_SECTOR_BITS); > } > + } else if (S_ISCHR(st.st_mode)) { > + /* sg returns transfer length in bytes already */ > + int ret = hdev_get_max_transfer_length(bs, s->fd); > + if (ret > 0 && > + (ret >> BDRV_SECTOR_BITS) <= BDRV_REQUEST_MAX_SECTORS) { > + bs->bl.max_transfer = pow2floor(ret); > + } Please keep the sectors/bytes quirk in hdev_get_max_transfer_length and always return bytes from there. Fam > } > } > > -- > 2.8.4 > >
On 01/17/2017 02:04 AM, Fam Zheng wrote: > On Mon, 01/16 22:12, Eric Farman wrote: >> Commit 6f607174 introduced a routine to get the maximum number >> of bytes for a single I/O transfer for block devices, however >> scsi generic devices are character devices, not block. Add >> a condition for this, with slightly different logic because >> the value is already in bytes, and need not be converted from >> blocks as happens for block devices. >> >> Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com> >> --- >> block/file-posix.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/block/file-posix.c b/block/file-posix.c >> index 2115155..c0843c2 100644 >> --- a/block/file-posix.c >> +++ b/block/file-posix.c >> @@ -679,6 +679,13 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp) >> if (ret > 0 && ret <= BDRV_REQUEST_MAX_SECTORS) { >> bs->bl.max_transfer = pow2floor(ret << BDRV_SECTOR_BITS); >> } >> + } else if (S_ISCHR(st.st_mode)) { >> + /* sg returns transfer length in bytes already */ >> + int ret = hdev_get_max_transfer_length(bs, s->fd); >> + if (ret > 0 && >> + (ret >> BDRV_SECTOR_BITS) <= BDRV_REQUEST_MAX_SECTORS) { >> + bs->bl.max_transfer = pow2floor(ret); >> + } > > Please keep the sectors/bytes quirk in hdev_get_max_transfer_length and always > return bytes from there. That's easy enough. I'll allow a day or two before sending a v2, in case there's other considerations for the rats nest I've wandered into. Thanks! - Eric
diff --git a/block/file-posix.c b/block/file-posix.c index 2115155..c0843c2 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -679,6 +679,13 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp) if (ret > 0 && ret <= BDRV_REQUEST_MAX_SECTORS) { bs->bl.max_transfer = pow2floor(ret << BDRV_SECTOR_BITS); } + } else if (S_ISCHR(st.st_mode)) { + /* sg returns transfer length in bytes already */ + int ret = hdev_get_max_transfer_length(bs, s->fd); + if (ret > 0 && + (ret >> BDRV_SECTOR_BITS) <= BDRV_REQUEST_MAX_SECTORS) { + bs->bl.max_transfer = pow2floor(ret); + } } }
Commit 6f607174 introduced a routine to get the maximum number of bytes for a single I/O transfer for block devices, however scsi generic devices are character devices, not block. Add a condition for this, with slightly different logic because the value is already in bytes, and need not be converted from blocks as happens for block devices. Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com> --- block/file-posix.c | 7 +++++++ 1 file changed, 7 insertions(+)