summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2010-07-13 17:50:50 +1000
committerJens Axboe <jaxboe@fusionio.com>2010-07-13 14:57:25 +0200
commitcbc588d74f238166ec3544374b31f2e23040654f (patch)
tree89d43b9b6dec7821df7825d16ccee63797f91deb /block
parent0d31b84fdd1be7195c1497b1d32f5c1a52c8bf8f (diff)
blkdev: check for valid request queue before issuing flush
Issuing a blkdev_issue_flush() on an unconfigured loop device causes a panic as q->make_request_fn is not configured. This can occur when trying to mount the unconfigured loop device as an XFS filesystem. There are no guards that catch the bio before the request function is called because we don't add a payload to the bio. Instead, manually check this case as soon as we have a pointer to the queue to flush. Signed-off-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'block')
-rw-r--r--block/blk-barrier.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/block/blk-barrier.c b/block/blk-barrier.c
index eefbde835308..557f69360b6a 100644
--- a/block/blk-barrier.c
+++ b/block/blk-barrier.c
@@ -310,6 +310,15 @@ int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask,
if (!q)
return -ENXIO;
+ /*
+ * some block devices may not have their queue correctly set up here
+ * (e.g. loop device without a backing file) and so issuing a flush
+ * here will panic. Ensure there is a request function before issuing
+ * the barrier.
+ */
+ if (!q->make_request_fn)
+ return -ENXIO;
+
bio = bio_alloc(gfp_mask, 0);
bio->bi_end_io = bio_end_empty_barrier;
bio->bi_bdev = bdev;