[PATCH 5/6] Handle possible bio_alloc failure in xfs

From: Nikanth Karthikesan
Date: Tue Apr 14 2009 - 07:11:49 EST


Handle bio_alloc failure in xfs.

Signed-off-by: Nikanth Karthikesan <knikanth@xxxxxxx>

---

Index: linux-2.6/fs/xfs/linux-2.6/xfs_buf.c
===================================================================
--- linux-2.6.orig/fs/xfs/linux-2.6/xfs_buf.c
+++ linux-2.6/fs/xfs/linux-2.6/xfs_buf.c
@@ -1196,6 +1196,8 @@ _xfs_buf_ioapply(
(XBF_READ|_XBF_PAGE_LOCKED)) &&
(blocksize >= PAGE_CACHE_SIZE)) {
bio = bio_alloc(GFP_NOIO, 1);
+ if (unlikely(!bio))
+ goto out_enomem;

bio->bi_bdev = bp->b_target->bt_bdev;
bio->bi_sector = sector - (offset >> BBSHIFT);
@@ -1217,6 +1219,9 @@ next_chunk:
nr_pages = total_nr_pages;

bio = bio_alloc(GFP_NOIO, nr_pages);
+ if (unlikely(!bio))
+ goto out_enomem;
+
bio->bi_bdev = bp->b_target->bt_bdev;
bio->bi_sector = sector;
bio->bi_end_io = xfs_buf_bio_end_io;
@@ -1247,6 +1252,11 @@ submit_io:
bio_put(bio);
xfs_buf_ioerror(bp, EIO);
}
+ return;
+
+out_enomem:
+ xfs_buf_ioerror(bp, ENOMEM);
+
}

int



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/