summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2003-09-21 01:42:13 -0700
committerLinus Torvalds <torvalds@home.osdl.org>2003-09-21 01:42:13 -0700
commit69d858195d876e745eddfbd7fa4c8d1adbc68be1 (patch)
tree9c0becbd11d3823fdac36466a5d2150cff486ea1
parent1669e6e99503a394ecd360f2cbed7e9a372939e0 (diff)
[PATCH] bio_dirty_fn() page leak fix
bio_dirty_fn() needs to drop its ref against each remaining page in the BIO before releasing the BIO.
-rw-r--r--fs/bio.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/fs/bio.c b/fs/bio.c
index b02019be4668..d0165231eedb 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -558,6 +558,19 @@ void bio_set_pages_dirty(struct bio *bio)
}
}
+void bio_release_pages(struct bio *bio)
+{
+ struct bio_vec *bvec = bio->bi_io_vec;
+ int i;
+
+ for (i = 0; i < bio->bi_vcnt; i++) {
+ struct page *page = bvec[i].bv_page;
+
+ if (page)
+ put_page(page);
+ }
+}
+
/*
* bio_check_pages_dirty() will check that all the BIO's pages are still dirty.
* If they are, then fine. If, however, some pages are clean then they must
@@ -592,6 +605,7 @@ static void bio_dirty_fn(void *data)
struct bio *next = bio->bi_private;
bio_set_pages_dirty(bio);
+ bio_release_pages(bio);
bio_put(bio);
bio = next;
}