提交 62f82faa 编写于 作者: N NeilBrown

md/bitmap: remove async freeing of bitmap file.

There is no real value in freeing things the moment there is an error.
It is just as good to free the bitmap file and pages when the bitmap
is explicitly removed (and replaced?) or at shutdown.

With this gone, the bitmap will only disappear when the array is
quiescent, so we can remove some locking.

As the 'filemap' doesn't disappear now, include extra checks before
trying to write any of it out.
Also remove the check for "has it disappeared" in
bitmap_daemon_write().
Signed-off-by: NNeilBrown <neilb@suse.de>
上级 74667123
...@@ -739,7 +739,6 @@ static void bitmap_file_unmap(struct bitmap *bitmap) ...@@ -739,7 +739,6 @@ static void bitmap_file_unmap(struct bitmap *bitmap)
int pages; int pages;
struct bitmap_storage *store = &bitmap->storage; struct bitmap_storage *store = &bitmap->storage;
spin_lock_irq(&bitmap->lock);
map = store->filemap; map = store->filemap;
store->filemap = NULL; store->filemap = NULL;
attr = store->filemap_attr; attr = store->filemap_attr;
...@@ -748,7 +747,6 @@ static void bitmap_file_unmap(struct bitmap *bitmap) ...@@ -748,7 +747,6 @@ static void bitmap_file_unmap(struct bitmap *bitmap)
store->file_pages = 0; store->file_pages = 0;
sb_page = store->sb_page; sb_page = store->sb_page;
store->sb_page = NULL; store->sb_page = NULL;
spin_unlock_irq(&bitmap->lock);
while (pages--) while (pages--)
if (map[pages] != sb_page) /* 0 is sb_page, release it below */ if (map[pages] != sb_page) /* 0 is sb_page, release it below */
...@@ -764,10 +762,8 @@ static void bitmap_file_put(struct bitmap *bitmap) ...@@ -764,10 +762,8 @@ static void bitmap_file_put(struct bitmap *bitmap)
{ {
struct file *file; struct file *file;
spin_lock_irq(&bitmap->lock);
file = bitmap->storage.file; file = bitmap->storage.file;
bitmap->storage.file = NULL; bitmap->storage.file = NULL;
spin_unlock_irq(&bitmap->lock);
if (file) if (file)
wait_event(bitmap->write_wait, wait_event(bitmap->write_wait,
...@@ -809,10 +805,6 @@ static void bitmap_file_kick(struct bitmap *bitmap) ...@@ -809,10 +805,6 @@ static void bitmap_file_kick(struct bitmap *bitmap)
"%s: disabling internal bitmap due to errors\n", "%s: disabling internal bitmap due to errors\n",
bmname(bitmap)); bmname(bitmap));
} }
bitmap_file_put(bitmap);
return;
} }
enum bitmap_page_attr { enum bitmap_page_attr {
...@@ -903,7 +895,8 @@ void bitmap_unplug(struct bitmap *bitmap) ...@@ -903,7 +895,8 @@ void bitmap_unplug(struct bitmap *bitmap)
int dirty, need_write; int dirty, need_write;
int wait = 0; int wait = 0;
if (!bitmap || !bitmap->storage.filemap) if (!bitmap || !bitmap->storage.filemap ||
test_bit(BITMAP_STALE, &bitmap->flags))
return; return;
/* look at each page to see if there are any set bits that need to be /* look at each page to see if there are any set bits that need to be
...@@ -1222,7 +1215,10 @@ void bitmap_daemon_work(struct mddev *mddev) ...@@ -1222,7 +1215,10 @@ void bitmap_daemon_work(struct mddev *mddev)
* the first blocking holds the superblock and it has been updated. * the first blocking holds the superblock and it has been updated.
* We mustn't write any other blocks before the superblock. * We mustn't write any other blocks before the superblock.
*/ */
for (j = 0; j < bitmap->storage.file_pages; j++) { for (j = 0;
j < bitmap->storage.file_pages
&& !test_bit(BITMAP_STALE, &bitmap->flags);
j++) {
if (test_page_attr(bitmap, j, if (test_page_attr(bitmap, j,
BITMAP_PAGE_DIRTY)) BITMAP_PAGE_DIRTY))
...@@ -1235,8 +1231,6 @@ void bitmap_daemon_work(struct mddev *mddev) ...@@ -1235,8 +1231,6 @@ void bitmap_daemon_work(struct mddev *mddev)
spin_unlock_irq(&bitmap->lock); spin_unlock_irq(&bitmap->lock);
write_page(bitmap, bitmap->storage.filemap[j], 0); write_page(bitmap, bitmap->storage.filemap[j], 0);
spin_lock_irq(&bitmap->lock); spin_lock_irq(&bitmap->lock);
if (!bitmap->storage.filemap)
break;
} }
} }
spin_unlock_irq(&bitmap->lock); spin_unlock_irq(&bitmap->lock);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册