Commit c32b0d4b authored by Hai Shan's avatar Hai Shan Committed by Linus Torvalds

fs/mpage.c: consolidate code

Merge mpage_end_io_read() and mpage_end_io_write() into mpage_end_io() to
eliminate code duplication.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: default avatarHai Shan <shan.hai@windriver.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 9cbb4cb2
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
* status of that page is hard. See end_buffer_async_read() for the details. * status of that page is hard. See end_buffer_async_read() for the details.
* There is no point in duplicating all that complexity. * There is no point in duplicating all that complexity.
*/ */
static void mpage_end_io_read(struct bio *bio, int err) static void mpage_end_io(struct bio *bio, int err)
{ {
const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
...@@ -50,44 +50,29 @@ static void mpage_end_io_read(struct bio *bio, int err) ...@@ -50,44 +50,29 @@ static void mpage_end_io_read(struct bio *bio, int err)
if (--bvec >= bio->bi_io_vec) if (--bvec >= bio->bi_io_vec)
prefetchw(&bvec->bv_page->flags); prefetchw(&bvec->bv_page->flags);
if (bio_data_dir(bio) == READ) {
if (uptodate) { if (uptodate) {
SetPageUptodate(page); SetPageUptodate(page);
} else { } else {
ClearPageUptodate(page); ClearPageUptodate(page);
SetPageError(page); SetPageError(page);
} }
unlock_page(page); unlock_page(page);
} while (bvec >= bio->bi_io_vec); } else { /* bio_data_dir(bio) == WRITE */
bio_put(bio); if (!uptodate) {
} SetPageError(page);
if (page->mapping)
static void mpage_end_io_write(struct bio *bio, int err) set_bit(AS_EIO, &page->mapping->flags);
{ }
const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); end_page_writeback(page);
struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
do {
struct page *page = bvec->bv_page;
if (--bvec >= bio->bi_io_vec)
prefetchw(&bvec->bv_page->flags);
if (!uptodate){
SetPageError(page);
if (page->mapping)
set_bit(AS_EIO, &page->mapping->flags);
} }
end_page_writeback(page);
} while (bvec >= bio->bi_io_vec); } while (bvec >= bio->bi_io_vec);
bio_put(bio); bio_put(bio);
} }
static struct bio *mpage_bio_submit(int rw, struct bio *bio) static struct bio *mpage_bio_submit(int rw, struct bio *bio)
{ {
bio->bi_end_io = mpage_end_io_read; bio->bi_end_io = mpage_end_io;
if (rw == WRITE)
bio->bi_end_io = mpage_end_io_write;
submit_bio(rw, bio); submit_bio(rw, bio);
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment