Commit d189122d authored by NeilBrown's avatar NeilBrown

md/bitmap: change *_page_attr() to take a page number, not a page.

Most often we have the page number, not the page.  And that is what
the  *_page_attr() functions really want.  So change the arguments to
take that number.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent 27581e5a
...@@ -800,22 +800,22 @@ enum bitmap_page_attr { ...@@ -800,22 +800,22 @@ enum bitmap_page_attr {
BITMAP_PAGE_NEEDWRITE = 2, /* there are cleared bits that need to be synced */ BITMAP_PAGE_NEEDWRITE = 2, /* there are cleared bits that need to be synced */
}; };
static inline void set_page_attr(struct bitmap *bitmap, struct page *page, static inline void set_page_attr(struct bitmap *bitmap, int pnum,
enum bitmap_page_attr attr) enum bitmap_page_attr attr)
{ {
__set_bit((page->index<<2) + attr, bitmap->filemap_attr); __set_bit((pnum<<2) + attr, bitmap->filemap_attr);
} }
static inline void clear_page_attr(struct bitmap *bitmap, struct page *page, static inline void clear_page_attr(struct bitmap *bitmap, int pnum,
enum bitmap_page_attr attr) enum bitmap_page_attr attr)
{ {
__clear_bit((page->index<<2) + attr, bitmap->filemap_attr); __clear_bit((pnum<<2) + attr, bitmap->filemap_attr);
} }
static inline unsigned long test_page_attr(struct bitmap *bitmap, struct page *page, static inline unsigned long test_page_attr(struct bitmap *bitmap, int pnum,
enum bitmap_page_attr attr) enum bitmap_page_attr attr)
{ {
return test_bit((page->index<<2) + attr, bitmap->filemap_attr); return test_bit((pnum<<2) + attr, bitmap->filemap_attr);
} }
/* /*
...@@ -846,7 +846,7 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block) ...@@ -846,7 +846,7 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block)
kunmap_atomic(kaddr); kunmap_atomic(kaddr);
pr_debug("set file bit %lu page %lu\n", bit, page->index); pr_debug("set file bit %lu page %lu\n", bit, page->index);
/* record page number so it gets flushed to disk when unplug occurs */ /* record page number so it gets flushed to disk when unplug occurs */
set_page_attr(bitmap, page, BITMAP_PAGE_DIRTY); set_page_attr(bitmap, page->index, BITMAP_PAGE_DIRTY);
} }
static void bitmap_file_clear_bit(struct bitmap *bitmap, sector_t block) static void bitmap_file_clear_bit(struct bitmap *bitmap, sector_t block)
...@@ -866,8 +866,8 @@ static void bitmap_file_clear_bit(struct bitmap *bitmap, sector_t block) ...@@ -866,8 +866,8 @@ static void bitmap_file_clear_bit(struct bitmap *bitmap, sector_t block)
else else
__clear_bit_le(bit, paddr); __clear_bit_le(bit, paddr);
kunmap_atomic(paddr); kunmap_atomic(paddr);
if (!test_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE)) { if (!test_page_attr(bitmap, page->index, BITMAP_PAGE_NEEDWRITE)) {
set_page_attr(bitmap, page, BITMAP_PAGE_PENDING); set_page_attr(bitmap, page->index, BITMAP_PAGE_PENDING);
bitmap->allclean = 0; bitmap->allclean = 0;
} }
} }
...@@ -879,7 +879,6 @@ void bitmap_unplug(struct bitmap *bitmap) ...@@ -879,7 +879,6 @@ void bitmap_unplug(struct bitmap *bitmap)
{ {
unsigned long i, flags; unsigned long i, flags;
int dirty, need_write; int dirty, need_write;
struct page *page;
int wait = 0; int wait = 0;
if (!bitmap || !bitmap->filemap) if (!bitmap || !bitmap->filemap)
...@@ -893,19 +892,18 @@ void bitmap_unplug(struct bitmap *bitmap) ...@@ -893,19 +892,18 @@ void bitmap_unplug(struct bitmap *bitmap)
spin_unlock_irqrestore(&bitmap->lock, flags); spin_unlock_irqrestore(&bitmap->lock, flags);
return; return;
} }
page = bitmap->filemap[i]; dirty = test_page_attr(bitmap, i, BITMAP_PAGE_DIRTY);
dirty = test_page_attr(bitmap, page, BITMAP_PAGE_DIRTY); need_write = test_page_attr(bitmap, i, BITMAP_PAGE_NEEDWRITE);
need_write = test_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE); clear_page_attr(bitmap, i, BITMAP_PAGE_DIRTY);
clear_page_attr(bitmap, page, BITMAP_PAGE_DIRTY); clear_page_attr(bitmap, i, BITMAP_PAGE_NEEDWRITE);
clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE);
if (dirty || need_write) if (dirty || need_write)
clear_page_attr(bitmap, page, BITMAP_PAGE_PENDING); clear_page_attr(bitmap, i, BITMAP_PAGE_PENDING);
if (dirty) if (dirty)
wait = 1; wait = 1;
spin_unlock_irqrestore(&bitmap->lock, flags); spin_unlock_irqrestore(&bitmap->lock, flags);
if (dirty || need_write) if (dirty || need_write)
write_page(bitmap, page, 0); write_page(bitmap, bitmap->filemap[i], 0);
} }
if (wait) { /* if any writes were performed, we need to wait on them */ if (wait) { /* if any writes were performed, we need to wait on them */
if (bitmap->file) if (bitmap->file)
...@@ -1101,7 +1099,7 @@ void bitmap_write_all(struct bitmap *bitmap) ...@@ -1101,7 +1099,7 @@ void bitmap_write_all(struct bitmap *bitmap)
spin_lock_irq(&bitmap->lock); spin_lock_irq(&bitmap->lock);
for (i = 0; i < bitmap->file_pages; i++) for (i = 0; i < bitmap->file_pages; i++)
set_page_attr(bitmap, bitmap->filemap[i], set_page_attr(bitmap, i,
BITMAP_PAGE_NEEDWRITE); BITMAP_PAGE_NEEDWRITE);
bitmap->allclean = 0; bitmap->allclean = 0;
spin_unlock_irq(&bitmap->lock); spin_unlock_irq(&bitmap->lock);
...@@ -1168,11 +1166,11 @@ void bitmap_daemon_work(struct mddev *mddev) ...@@ -1168,11 +1166,11 @@ void bitmap_daemon_work(struct mddev *mddev)
*/ */
spin_lock_irqsave(&bitmap->lock, flags); spin_lock_irqsave(&bitmap->lock, flags);
for (j = 0; j < bitmap->file_pages; j++) for (j = 0; j < bitmap->file_pages; j++)
if (test_page_attr(bitmap, bitmap->filemap[j], if (test_page_attr(bitmap, j,
BITMAP_PAGE_PENDING)) { BITMAP_PAGE_PENDING)) {
set_page_attr(bitmap, bitmap->filemap[j], set_page_attr(bitmap, j,
BITMAP_PAGE_NEEDWRITE); BITMAP_PAGE_NEEDWRITE);
clear_page_attr(bitmap, bitmap->filemap[j], clear_page_attr(bitmap, j,
BITMAP_PAGE_PENDING); BITMAP_PAGE_PENDING);
} }
...@@ -1187,7 +1185,7 @@ void bitmap_daemon_work(struct mddev *mddev) ...@@ -1187,7 +1185,7 @@ void bitmap_daemon_work(struct mddev *mddev)
sb->events_cleared = sb->events_cleared =
cpu_to_le64(bitmap->events_cleared); cpu_to_le64(bitmap->events_cleared);
kunmap_atomic(sb); kunmap_atomic(sb);
set_page_attr(bitmap, bitmap->sb_page, set_page_attr(bitmap, 0,
BITMAP_PAGE_NEEDWRITE); BITMAP_PAGE_NEEDWRITE);
} }
} }
...@@ -1236,18 +1234,17 @@ void bitmap_daemon_work(struct mddev *mddev) ...@@ -1236,18 +1234,17 @@ void bitmap_daemon_work(struct mddev *mddev)
* 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->file_pages; j++) { for (j = 0; j < bitmap->file_pages; j++) {
struct page *page = bitmap->filemap[j];
if (test_page_attr(bitmap, page, if (test_page_attr(bitmap, j,
BITMAP_PAGE_DIRTY)) BITMAP_PAGE_DIRTY))
/* bitmap_unplug will handle the rest */ /* bitmap_unplug will handle the rest */
break; break;
if (test_page_attr(bitmap, page, if (test_page_attr(bitmap, j,
BITMAP_PAGE_NEEDWRITE)) { BITMAP_PAGE_NEEDWRITE)) {
clear_page_attr(bitmap, page, clear_page_attr(bitmap, j,
BITMAP_PAGE_NEEDWRITE); BITMAP_PAGE_NEEDWRITE);
spin_unlock_irqrestore(&bitmap->lock, flags); spin_unlock_irqrestore(&bitmap->lock, flags);
write_page(bitmap, page, 0); write_page(bitmap, bitmap->filemap[j], 0);
spin_lock_irqsave(&bitmap->lock, flags); spin_lock_irqsave(&bitmap->lock, flags);
if (!bitmap->filemap) if (!bitmap->filemap)
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment