diff options
author | NeilBrown <neilb@suse.de> | 2012-05-21 23:55:21 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-05-21 23:55:21 -0400 |
commit | fae7d326cd0905624c173337fdfcfe9b86b9e6e2 (patch) | |
tree | 2f98bd9e055dce2250c0ba813aeaa95873665018 /drivers/md/bitmap.c | |
parent | 62f82faaceb483284ea938b3a092b9f0a4d2d029 (diff) |
md/bitmap: merge bitmap_file_unmap and bitmap_file_put.
There functions really do one thing together: release the
'bitmap_storage'. So make them just one function.
Since we removed the locking (previous patch), we don't need to zero
any fields before freeing them, so it all becomes a bit simpler.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r-- | drivers/md/bitmap.c | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 7e015c9ea73e..d2ab7d3df3ea 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -732,43 +732,25 @@ static int bitmap_storage_alloc(struct bitmap_storage *store, | |||
732 | return 0; | 732 | return 0; |
733 | } | 733 | } |
734 | 734 | ||
735 | static void bitmap_file_unmap(struct bitmap *bitmap) | 735 | static void bitmap_file_unmap(struct bitmap_storage *store) |
736 | { | 736 | { |
737 | struct page **map, *sb_page; | 737 | struct page **map, *sb_page; |
738 | unsigned long *attr; | ||
739 | int pages; | 738 | int pages; |
740 | struct bitmap_storage *store = &bitmap->storage; | 739 | struct file *file; |
741 | 740 | ||
741 | file = store->file; | ||
742 | map = store->filemap; | 742 | map = store->filemap; |
743 | store->filemap = NULL; | ||
744 | attr = store->filemap_attr; | ||
745 | store->filemap_attr = NULL; | ||
746 | pages = store->file_pages; | 743 | pages = store->file_pages; |
747 | store->file_pages = 0; | ||
748 | sb_page = store->sb_page; | 744 | sb_page = store->sb_page; |
749 | store->sb_page = NULL; | ||
750 | 745 | ||
751 | while (pages--) | 746 | while (pages--) |
752 | if (map[pages] != sb_page) /* 0 is sb_page, release it below */ | 747 | if (map[pages] != sb_page) /* 0 is sb_page, release it below */ |
753 | free_buffers(map[pages]); | 748 | free_buffers(map[pages]); |
754 | kfree(map); | 749 | kfree(map); |
755 | kfree(attr); | 750 | kfree(store->filemap_attr); |
756 | 751 | ||
757 | if (sb_page) | 752 | if (sb_page) |
758 | free_buffers(sb_page); | 753 | free_buffers(sb_page); |
759 | } | ||
760 | |||
761 | static void bitmap_file_put(struct bitmap *bitmap) | ||
762 | { | ||
763 | struct file *file; | ||
764 | |||
765 | file = bitmap->storage.file; | ||
766 | bitmap->storage.file = NULL; | ||
767 | |||
768 | if (file) | ||
769 | wait_event(bitmap->write_wait, | ||
770 | atomic_read(&bitmap->pending_writes)==0); | ||
771 | bitmap_file_unmap(bitmap); | ||
772 | 754 | ||
773 | if (file) { | 755 | if (file) { |
774 | struct inode *inode = file->f_path.dentry->d_inode; | 756 | struct inode *inode = file->f_path.dentry->d_inode; |
@@ -1610,8 +1592,12 @@ static void bitmap_free(struct bitmap *bitmap) | |||
1610 | if (!bitmap) /* there was no bitmap */ | 1592 | if (!bitmap) /* there was no bitmap */ |
1611 | return; | 1593 | return; |
1612 | 1594 | ||
1613 | /* release the bitmap file and kill the daemon */ | 1595 | /* Shouldn't be needed - but just in case.... */ |
1614 | bitmap_file_put(bitmap); | 1596 | wait_event(bitmap->write_wait, |
1597 | atomic_read(&bitmap->pending_writes) == 0); | ||
1598 | |||
1599 | /* release the bitmap file */ | ||
1600 | bitmap_file_unmap(&bitmap->storage); | ||
1615 | 1601 | ||
1616 | bp = bitmap->bp; | 1602 | bp = bitmap->bp; |
1617 | pages = bitmap->pages; | 1603 | pages = bitmap->pages; |