From: NeilBrown <neilb@suse.de>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
Paul Clements <paul.clements@steeleye.com>
Subject: [PATCH 005 of 8] md/bitmap: Remove unnecessary page reference manipulations from md/bitmap code.
Date: Fri, 12 May 2006 16:07:53 +1000 [thread overview]
Message-ID: <1060512060753.8049@suse.de> (raw)
In-Reply-To: 20060512160121.7872.patches@notabene
md/bitmap gets a collection of pages representing the bitmap when it
initialises the bitmap, and puts all the references when discarding
the bitmap.
It also occasionally takes extra references without any good reason,
and sometimes drops them ... though it doesn't always drop them, which
can result in a memory leak.
This patch removes the unnecessary 'get_page' calls, and the
corresponding 'put_page' calls.
Signed-off-by: Neil Brown <neilb@suse.de>
### Diffstat output
./drivers/md/bitmap.c | 20 ++------------------
1 file changed, 2 insertions(+), 18 deletions(-)
diff ./drivers/md/bitmap.c~current~ ./drivers/md/bitmap.c
--- ./drivers/md/bitmap.c~current~ 2006-05-12 15:58:22.000000000 +1000
+++ ./drivers/md/bitmap.c 2006-05-12 15:58:57.000000000 +1000
@@ -332,7 +332,6 @@ static int write_page(struct bitmap *bit
/* add to list to be waited for */
struct page_list *item = mempool_alloc(bitmap->write_pool, GFP_NOIO);
item->page = page;
- get_page(page);
spin_lock(&bitmap->write_lock);
list_add(&item->list, &bitmap->complete_pages);
spin_unlock(&bitmap->write_lock);
@@ -548,7 +547,6 @@ static void bitmap_mask_state(struct bit
spin_unlock_irqrestore(&bitmap->lock, flags);
return;
}
- get_page(bitmap->sb_page);
spin_unlock_irqrestore(&bitmap->lock, flags);
sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
switch (op) {
@@ -559,7 +557,6 @@ static void bitmap_mask_state(struct bit
default: BUG();
}
kunmap_atomic(sb, KM_USER0);
- put_page(bitmap->sb_page);
}
/*
@@ -641,7 +638,6 @@ static void drain_write_queues(struct bi
while ((item = dequeue_page(bitmap))) {
/* don't bother to wait */
- put_page(item->page);
mempool_free(item, bitmap->write_pool);
}
}
@@ -744,11 +740,6 @@ static void bitmap_file_set_bit(struct b
page = filemap_get_page(bitmap, chunk);
bit = file_page_offset(chunk);
-
- /* make sure the page stays cached until it gets written out */
- if (! test_page_attr(bitmap, page, BITMAP_PAGE_DIRTY))
- get_page(page);
-
/* set the bit */
kaddr = kmap_atomic(page, KM_USER0);
if (bitmap->flags & BITMAP_HOSTENDIAN)
@@ -1028,10 +1019,9 @@ int bitmap_daemon_work(struct bitmap *bi
if (!test_page_attr(bitmap, page, BITMAP_PAGE_CLEAN)) {
int need_write = test_page_attr(bitmap, page,
BITMAP_PAGE_NEEDWRITE);
- if (need_write) {
- get_page(page);
+ if (need_write)
clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE);
- }
+
spin_unlock_irqrestore(&bitmap->lock, flags);
if (need_write) {
switch (write_page(bitmap, page, 0)) {
@@ -1043,13 +1033,11 @@ int bitmap_daemon_work(struct bitmap *bi
default:
bitmap_file_kick(bitmap);
}
- put_page(page);
}
continue;
}
/* grab the new page, sync and release the old */
- get_page(page);
if (lastpage != NULL) {
if (test_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE)) {
clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
@@ -1063,7 +1051,6 @@ int bitmap_daemon_work(struct bitmap *bi
set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
spin_unlock_irqrestore(&bitmap->lock, flags);
}
- put_page(lastpage);
if (err)
bitmap_file_kick(bitmap);
} else
@@ -1117,8 +1104,6 @@ int bitmap_daemon_work(struct bitmap *bi
set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
spin_unlock_irqrestore(&bitmap->lock, flags);
}
-
- put_page(lastpage);
}
return err;
@@ -1140,7 +1125,6 @@ static void bitmap_writeback(struct bitm
PRINTK("finished page writeback: %p\n", page);
err = PageError(page);
- put_page(page);
if (err) {
printk(KERN_WARNING "%s: bitmap file writeback "
"failed (page %lu): %d\n",
next prev parent reply other threads:[~2006-05-12 6:07 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-12 6:07 [PATCH 000 of 8] md/bitmap: Introduction - rework management of bitmap files NeilBrown
2006-05-12 6:07 ` [PATCH 001 of 8] md/bitmap: Fix online removal of file-backed bitmaps NeilBrown
2006-05-12 6:07 ` [PATCH 002 of 8] md/bitmap: Remove bitmap writeback daemon NeilBrown
2006-05-12 17:40 ` Andrew Morton
2006-05-13 3:14 ` Neil Brown
2006-05-13 6:59 ` Andrew Morton
2006-05-12 6:07 ` [PATCH 003 of 8] md/bitmap: Cleaner separation of page attribute handlers in md/bitmap NeilBrown
2006-05-12 6:07 ` [PATCH 004 of 8] md/bitmap: Use set_bit etc for bitmap page attributes NeilBrown
2006-05-12 6:07 ` NeilBrown [this message]
2006-05-12 6:07 ` [PATCH 006 of 8] md/bitmap: Remove dead code from md/bitmap NeilBrown
2006-05-12 6:08 ` [PATCH 007 of 8] md/bitmap: Tidy up i_writecount handling in md/bitmap NeilBrown
2006-05-12 6:08 ` [PATCH 008 of 8] md/bitmap: Change md/bitmap file handling to use bmap to file blocks NeilBrown
2006-05-12 17:47 ` Andrew Morton
2006-05-13 3:46 ` Neil Brown
2006-05-13 6:59 ` Andrew Morton
2006-05-13 15:29 ` Paul Clements
2006-05-13 15:42 ` Andrew Morton
2006-05-14 11:15 ` Neil Brown
2006-05-14 11:22 ` Andrew Morton
2006-05-15 0:26 ` Neil Brown
2006-05-15 21:04 ` Andrew Morton
2006-05-15 23:03 ` Neil Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1060512060753.8049@suse.de \
--to=neilb@suse.de \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=paul.clements@steeleye.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).