xfs
[Top] [All Lists]

[PATCH] xfs: fix xfs_alloc_ioend_bio code to try and get atleast a small

To: Dave Chinner <david@xxxxxxxxxxxxx>
Subject: [PATCH] xfs: fix xfs_alloc_ioend_bio code to try and get atleast a smaller bio
From: Nikanth Karthikesan <knikanth@xxxxxxx>
Date: Wed, 22 Apr 2009 12:15:17 +0530
Cc: xfs-masters@xxxxxxxxxxx, Christoph Hellwig <hch@xxxxxxxxxxxxx>, Jens Axboe <jens.axboe@xxxxxxxxxx>, xfs@xxxxxxxxxxx
In-reply-to: <20090420010237.GF16929@xxxxxxxxxxxxxxxx>
Organization: suse.de
References: <200904151609.30677.knikanth@xxxxxxx> <20090420010237.GF16929@xxxxxxxxxxxxxxxx>
User-agent: KMail/1.11.1 (Linux/2.6.27.21-0.1-default; KDE/4.2.1; x86_64; ; )
The intent of the code in xfs_alloc_ioend_bio() is that if we can't get a
large bio immediately, try a smaller one which is more likely to succeed when
we are under memory pressure. i.e. we will get IO moving faster than if we
waited for a maximally sized biovec to be allocated. But GFP_NOIO implies
__GFP_WAIT which would return only if it can allocate the bio. So the first
attempt to get a larger bio itself would return only after it succeeds, which
makes the logic useless.

Change it to try with GFP_NOWAIT for a bio. If not possible wait for it.

See http://oss.sgi.com/archives/xfs-masters/2009-04/msg00027.html for the
discussion.

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

---

diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index 7ec89fc..002ce7f 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -419,12 +419,15 @@ xfs_alloc_ioend_bio(
        struct buffer_head      *bh)
 {
        struct bio              *bio;
-       int                     nvecs = bio_get_nr_vecs(bh->b_bdev);
+       int                     nr_iovecs = bio_get_nr_vecs(bh->b_bdev);
+       int                     nvecs = nr_iovecs;
 
        do {
-               bio = bio_alloc(GFP_NOIO, nvecs);
-               nvecs >>= 1;
-       } while (!bio);
+               bio = bio_alloc(GFP_NOWAIT, nvecs);
+       } while (!bio && (nvecs >>= 1));
+
+       if (unlikely(!bio))
+               bio = bio_alloc(GFP_NOIO, nr_iovecs);
 
        ASSERT(bio->bi_private == NULL);
        bio->bi_sector = bh->b_blocknr * (bh->b_size >> 9);

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