xfs
[Top] [All Lists]

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

To: xfs-masters@xxxxxxxxxxx
Subject: [PATCH 5/6] Handle possible bio_alloc failure in xfs
From: Nikanth Karthikesan <knikanth@xxxxxxx>
Date: Tue, 14 Apr 2009 16:36:45 +0530
Cc: xfs@xxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, Jens Axboe <jens.axboe@xxxxxxxxxx>
Organization: suse.de
User-agent: KMail/1.11.1 (Linux/2.6.27.21-0.1-default; KDE/4.2.1; x86_64; ; )
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



<Prev in Thread] Current Thread [Next in Thread>