aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bitmap.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-06-26 03:27:46 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-26 12:58:38 -0400
commita647e4bc5ce697e25ff50d2e22de68a581b1ed38 (patch)
tree465559f3786e7b5b10bf1ff58a63e198c95c8879 /drivers/md/bitmap.c
parente16b68b6e456a61b895a198baf5aa473cf2a32bf (diff)
[PATCH] md/bitmap: remove unnecessary page reference manipulations from md/bitmap code
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> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r--drivers/md/bitmap.c20
1 files changed, 2 insertions, 18 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 2e257d5998bc..609e68d3e1bc 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -332,7 +332,6 @@ static int write_page(struct bitmap *bitmap, struct page *page, int wait)
332 /* add to list to be waited for */ 332 /* add to list to be waited for */
333 struct page_list *item = mempool_alloc(bitmap->write_pool, GFP_NOIO); 333 struct page_list *item = mempool_alloc(bitmap->write_pool, GFP_NOIO);
334 item->page = page; 334 item->page = page;
335 get_page(page);
336 spin_lock(&bitmap->write_lock); 335 spin_lock(&bitmap->write_lock);
337 list_add(&item->list, &bitmap->complete_pages); 336 list_add(&item->list, &bitmap->complete_pages);
338 spin_unlock(&bitmap->write_lock); 337 spin_unlock(&bitmap->write_lock);
@@ -548,7 +547,6 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits,
548 spin_unlock_irqrestore(&bitmap->lock, flags); 547 spin_unlock_irqrestore(&bitmap->lock, flags);
549 return; 548 return;
550 } 549 }
551 get_page(bitmap->sb_page);
552 spin_unlock_irqrestore(&bitmap->lock, flags); 550 spin_unlock_irqrestore(&bitmap->lock, flags);
553 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0); 551 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
554 switch (op) { 552 switch (op) {
@@ -559,7 +557,6 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits,
559 default: BUG(); 557 default: BUG();
560 } 558 }
561 kunmap_atomic(sb, KM_USER0); 559 kunmap_atomic(sb, KM_USER0);
562 put_page(bitmap->sb_page);
563} 560}
564 561
565/* 562/*
@@ -641,7 +638,6 @@ static void drain_write_queues(struct bitmap *bitmap)
641 638
642 while ((item = dequeue_page(bitmap))) { 639 while ((item = dequeue_page(bitmap))) {
643 /* don't bother to wait */ 640 /* don't bother to wait */
644 put_page(item->page);
645 mempool_free(item, bitmap->write_pool); 641 mempool_free(item, bitmap->write_pool);
646 } 642 }
647} 643}
@@ -744,11 +740,6 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block)
744 page = filemap_get_page(bitmap, chunk); 740 page = filemap_get_page(bitmap, chunk);
745 bit = file_page_offset(chunk); 741 bit = file_page_offset(chunk);
746 742
747
748 /* make sure the page stays cached until it gets written out */
749 if (! test_page_attr(bitmap, page, BITMAP_PAGE_DIRTY))
750 get_page(page);
751
752 /* set the bit */ 743 /* set the bit */
753 kaddr = kmap_atomic(page, KM_USER0); 744 kaddr = kmap_atomic(page, KM_USER0);
754 if (bitmap->flags & BITMAP_HOSTENDIAN) 745 if (bitmap->flags & BITMAP_HOSTENDIAN)
@@ -1028,10 +1019,9 @@ int bitmap_daemon_work(struct bitmap *bitmap)
1028 if (!test_page_attr(bitmap, page, BITMAP_PAGE_CLEAN)) { 1019 if (!test_page_attr(bitmap, page, BITMAP_PAGE_CLEAN)) {
1029 int need_write = test_page_attr(bitmap, page, 1020 int need_write = test_page_attr(bitmap, page,
1030 BITMAP_PAGE_NEEDWRITE); 1021 BITMAP_PAGE_NEEDWRITE);
1031 if (need_write) { 1022 if (need_write)
1032 get_page(page);
1033 clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE); 1023 clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE);
1034 } 1024
1035 spin_unlock_irqrestore(&bitmap->lock, flags); 1025 spin_unlock_irqrestore(&bitmap->lock, flags);
1036 if (need_write) { 1026 if (need_write) {
1037 switch (write_page(bitmap, page, 0)) { 1027 switch (write_page(bitmap, page, 0)) {
@@ -1043,13 +1033,11 @@ int bitmap_daemon_work(struct bitmap *bitmap)
1043 default: 1033 default:
1044 bitmap_file_kick(bitmap); 1034 bitmap_file_kick(bitmap);
1045 } 1035 }
1046 put_page(page);
1047 } 1036 }
1048 continue; 1037 continue;
1049 } 1038 }
1050 1039
1051 /* grab the new page, sync and release the old */ 1040 /* grab the new page, sync and release the old */
1052 get_page(page);
1053 if (lastpage != NULL) { 1041 if (lastpage != NULL) {
1054 if (test_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE)) { 1042 if (test_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE)) {
1055 clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); 1043 clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
@@ -1063,7 +1051,6 @@ int bitmap_daemon_work(struct bitmap *bitmap)
1063 set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); 1051 set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
1064 spin_unlock_irqrestore(&bitmap->lock, flags); 1052 spin_unlock_irqrestore(&bitmap->lock, flags);
1065 } 1053 }
1066 put_page(lastpage);
1067 if (err) 1054 if (err)
1068 bitmap_file_kick(bitmap); 1055 bitmap_file_kick(bitmap);
1069 } else 1056 } else
@@ -1117,8 +1104,6 @@ int bitmap_daemon_work(struct bitmap *bitmap)
1117 set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); 1104 set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
1118 spin_unlock_irqrestore(&bitmap->lock, flags); 1105 spin_unlock_irqrestore(&bitmap->lock, flags);
1119 } 1106 }
1120
1121 put_page(lastpage);
1122 } 1107 }
1123 1108
1124 return err; 1109 return err;
@@ -1140,7 +1125,6 @@ static void bitmap_writeback(struct bitmap *bitmap)
1140 PRINTK("finished page writeback: %p\n", page); 1125 PRINTK("finished page writeback: %p\n", page);
1141 1126
1142 err = PageError(page); 1127 err = PageError(page);
1143 put_page(page);
1144 if (err) { 1128 if (err) {
1145 printk(KERN_WARNING "%s: bitmap file writeback " 1129 printk(KERN_WARNING "%s: bitmap file writeback "
1146 "failed (page %lu): %d\n", 1130 "failed (page %lu): %d\n",