Bug 433481

Summary: sg: cap reserved_size values to max_sectors
Product: Red Hat Enterprise Linux 5 Reporter: Bryn M. Reeves <bmr>
Component: kernelAssignee: David Milburn <dmilburn>
Status: CLOSED ERRATA QA Contact: Martin Jenner <mjenner>
Severity: high Docs Contact:
Priority: urgent    
Version: 5.1CC: dmair, tao
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: RHBA-2008-0314 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-05-21 15:09:44 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Bryn M. Reeves 2008-02-19 15:54:46 UTC
Description of problem:
The sg driver does not cap the reserved_size values at max_sectors for the
SG_GET_RESERVED_SIZE and SG_SET_RESERVED_SIZE sg ioctls. This prevents tools
like cdrecord and sg_dd from obtaining a legal value for the maximum transfer
length and causing problems such as failed burns and I/O errors.

See kernel bugzill #7026: http://bugzilla.kernel.org/show_bug.cgi?id=7026

Version-Release number of selected component (if applicable):
2.6.18-53.el5, 2.6.18-81.el5

How reproducible:
100%

Steps to Reproduce:
With sg_dd:
1. sg_dd if=/dev/sg1 of=/dev/null bpt=128 bs=2048 count=128

Using cdrecord you can hit the same underlying problem (see steps in kbz#7026).
  
Actual results:
# sg_dd if=/dev/sg1 of=/dev/null bpt=128 bs=2048 count=128
reading: SCSI status: Check Condition
Descriptor format, current;  Sense key: Aborted Command
Additional sense: No additional sense information
 Descriptor type: Information
   0x0000000000000000
plus...: Driver_status=0x08 [DRIVER_SENSE, SUGGEST_OK]
sg_read failed, at or after lba=0 [0x0]
Some error occurred,  remaining block count=128
0+0 records in
0+0 records out
1 unrecovered read error(s)

Expected results:
sg_dd exits with success.

Additional info:
Fixed upstream:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=44ec95425c1d9dce6e4638c29e4362cfb44814e7

Comment 1 Bryn M. Reeves 2008-02-19 15:55:57 UTC
commit 44ec95425c1d9dce6e4638c29e4362cfb44814e7
Author: Alan Stern <stern.edu>
Date:   Tue Feb 20 11:01:57 2007 -0500

[SCSI] sg: cap reserved_size values at max_sectors
Alan Stern [Tue, 20 Feb 2007 16:01:57 +0000 (11:01 -0500)]
This patch (as857) modifies the SG_GET_RESERVED_SIZE and
SG_SET_RESERVED_SIZE ioctls in the sg driver, capping the values at
the device's request_queue's max_sectors value.  This will permit
cdrecord to obtain a legal value for the maximum transfer length,
fixing Bugzilla #7026.

The patch also caps the initial reserved_size value.  There's no
reason to have a reserved buffer larger than max_sectors, since it
would be impossible to use the extra space.

The corresponding ioctls in the block layer are modified similarly,
and the initial value for the reserved_size is set as large as
possible.  This will effectively make it default to max_sectors.
Note that the actual value is meaningless anyway, since block devices
don't have a reserved buffer.

Finally, the BLKSECTGET ioctl is added to sg, so that there will be a
uniform way for users to determine the actual max_sectors value for
any raw SCSI transport.

Signed-off-by: Alan Stern <stern.edu>
Acked-by: Jens Axboe <jens.axboe>
Acked-by: Douglas Gilbert <dougg>
Signed-off-by: James Bottomley <James.Bottomley>

Comment 4 RHEL Program Management 2008-02-29 15:48:51 UTC
This bugzilla has Keywords: Regression.  

Since no regressions are allowed between releases, 
it is also being proposed as a blocker for this release.  

Please resolve ASAP.

Comment 7 RHEL Program Management 2008-03-19 14:26:02 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.

Comment 10 RHEL Program Management 2008-03-20 11:55:46 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.

Comment 12 Don Zickus 2008-03-26 20:31:45 UTC
in kernel-2.6.18-87.el5
You can download this test kernel from http://people.redhat.com/dzickus/el5

Comment 16 errata-xmlrpc 2008-05-21 15:09:44 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2008-0314.html