diff options
author | Jens Axboe <axboe@suse.de> | 2006-01-06 09:43:28 +0100 |
---|---|---|
committer | Jens Axboe <axboe@suse.de> | 2006-01-06 09:43:28 +0100 |
commit | 80cfd548eed68cf90c5ae9cfcd6b02230cece756 (patch) | |
tree | a178608e394b5ee079838353004eb318ff22c513 /fs/bio.c | |
parent | 88ee5ef157202624de2b43b3512fdcb54fda1ab5 (diff) | |
download | kernel_samsung_smdk4412-80cfd548eed68cf90c5ae9cfcd6b02230cece756.tar.gz kernel_samsung_smdk4412-80cfd548eed68cf90c5ae9cfcd6b02230cece756.tar.bz2 kernel_samsung_smdk4412-80cfd548eed68cf90c5ae9cfcd6b02230cece756.zip |
[BLOCK] bio: check for same page merge possibilities in __bio_add_page()
For filesystems with a blocksize < page size, we can merge same page
calls into the bio_vec at the end of the bio. This saves segments
on systems with a page size > the "normal" 4kb fs block size.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@suse.de>
Diffstat (limited to 'fs/bio.c')
-rw-r--r-- | fs/bio.c | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -325,10 +325,31 @@ static int __bio_add_page(request_queue_t *q, struct bio *bio, struct page if (unlikely(bio_flagged(bio, BIO_CLONED))) return 0; - if (bio->bi_vcnt >= bio->bi_max_vecs) + if (((bio->bi_size + len) >> 9) > max_sectors) return 0; - if (((bio->bi_size + len) >> 9) > max_sectors) + /* + * For filesystems with a blocksize smaller than the pagesize + * we will often be called with the same page as last time and + * a consecutive offset. Optimize this special case. + */ + if (bio->bi_vcnt > 0) { + struct bio_vec *prev = &bio->bi_io_vec[bio->bi_vcnt - 1]; + + if (page == prev->bv_page && + offset == prev->bv_offset + prev->bv_len) { + prev->bv_len += len; + if (q->merge_bvec_fn && + q->merge_bvec_fn(q, bio, prev) < len) { + prev->bv_len -= len; + return 0; + } + + goto done; + } + } + + if (bio->bi_vcnt >= bio->bi_max_vecs) return 0; /* @@ -382,6 +403,7 @@ static int __bio_add_page(request_queue_t *q, struct bio *bio, struct page bio->bi_vcnt++; bio->bi_phys_segments++; bio->bi_hw_segments++; + done: bio->bi_size += len; return len; } |