[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [linux-2.6.18-xen] blkfront: properly fail packet requests
# HG changeset patch # User Jan Beulich <jbeulich@xxxxxxxx> # Date 1329304142 -3600 # Node ID dc034d0ccdd857503de483012bea9c8e549daa76 # Parent b9627a5740d223827053317cd9c8f40c721db972 blkfront: properly fail packet requests c/s 1036:f5635e334aa5 ("blkfront: forward unknown IOCTLs to scsi_cmd_ioctl() for /dev/sdX") uncovered a problem in blkfront's request handling: blk_pc_request()-s, among other sources resulting from the handling of the SG_IO ioctl in scsi_cmd_ioctl(), must not be passed to end_request() without prior adjustment: Neither is their ->hard_cur_sectors necessarily correct (potentially resulting in an infinite loop), nor is ->errors ever getting set properly to reflect the failure (sg_io() intentionally ignores the return value from blk_execute_rq()). As blktap2's internally created devices have the same deficiency, fix this there too. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> --- diff -r b9627a5740d2 -r dc034d0ccdd8 drivers/xen/blkfront/blkfront.c --- a/drivers/xen/blkfront/blkfront.c Fri Feb 10 17:46:45 2012 +0100 +++ b/drivers/xen/blkfront/blkfront.c Wed Feb 15 12:09:02 2012 +0100 @@ -709,6 +709,12 @@ while ((req = elv_next_request(rq)) != NULL) { info = req->rq_disk->private_data; if (!blk_fs_request(req)) { + if (blk_pc_request(req)) { + req->errors = (DID_ERROR << 16) + | (DRIVER_INVALID << 24); + req->hard_cur_sectors = (req->data_len + + 511) >> 9; + } end_request(req, 0); continue; } diff -r b9627a5740d2 -r dc034d0ccdd8 drivers/xen/blktap2/device.c --- a/drivers/xen/blktap2/device.c Fri Feb 10 17:46:45 2012 +0100 +++ b/drivers/xen/blktap2/device.c Wed Feb 15 12:09:02 2012 +0100 @@ -3,6 +3,7 @@ #include <linux/cdrom.h> #include <linux/hdreg.h> #include <linux/module.h> +#include <scsi/scsi.h> #include <asm/tlbflush.h> #include <scsi/scsi.h> @@ -825,6 +826,12 @@ while ((req = elv_next_request(rq)) != NULL) { if (!blk_fs_request(req)) { + if (blk_pc_request(req)) { + req->errors = (DID_ERROR << 16) + | (DRIVER_INVALID << 24); + req->hard_cur_sectors = (req->data_len + + 511) >> 9; + } end_request(req, 0); continue; } @@ -912,9 +919,16 @@ fail: while ((req = elv_next_request(rq))) { - BTERR("device closed: failing secs %llu - %llu\n", - (unsigned long long)req->sector, - (unsigned long long)req->sector + req->nr_sectors); + if (blk_fs_request(req)) { + unsigned long long sec = req->sector; + + BTERR("device closed: failing secs %#Lx-%#Lx\n", + sec, sec + req->nr_sectors - 1); + } else if (blk_pc_request(req)) { + req->errors = (DID_ERROR << 16) + | (DRIVER_INVALID << 24); + req->hard_cur_sectors = (req->data_len + 511) >> 9; + } end_request(req, 0); } } _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |