Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 305940
b: refs/heads/master
c: d189122
h: refs/heads/master
v: v3
  • Loading branch information
NeilBrown committed May 22, 2012
1 parent 5d6b132 commit 1a7a8a8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 30 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 27581e5ae01f77b5472dc5c2368b41063fed7f37
refs/heads/master: d189122d4bca2647441fdc170dc6d4cc5c8bb2fa
55 changes: 26 additions & 29 deletions trunk/drivers/md/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,22 +800,22 @@ enum bitmap_page_attr {
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,
enum bitmap_page_attr attr)
static inline void set_page_attr(struct bitmap *bitmap, int pnum,
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,
enum bitmap_page_attr attr)
static inline void clear_page_attr(struct bitmap *bitmap, int pnum,
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)
{
return test_bit((page->index<<2) + attr, bitmap->filemap_attr);
return test_bit((pnum<<2) + attr, bitmap->filemap_attr);
}

/*
Expand Down Expand Up @@ -846,7 +846,7 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block)
kunmap_atomic(kaddr);
pr_debug("set file bit %lu page %lu\n", bit, page->index);
/* 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)
Expand All @@ -866,8 +866,8 @@ static void bitmap_file_clear_bit(struct bitmap *bitmap, sector_t block)
else
__clear_bit_le(bit, paddr);
kunmap_atomic(paddr);
if (!test_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE)) {
set_page_attr(bitmap, page, BITMAP_PAGE_PENDING);
if (!test_page_attr(bitmap, page->index, BITMAP_PAGE_NEEDWRITE)) {
set_page_attr(bitmap, page->index, BITMAP_PAGE_PENDING);
bitmap->allclean = 0;
}
}
Expand All @@ -879,7 +879,6 @@ void bitmap_unplug(struct bitmap *bitmap)
{
unsigned long i, flags;
int dirty, need_write;
struct page *page;
int wait = 0;

if (!bitmap || !bitmap->filemap)
Expand All @@ -893,19 +892,18 @@ void bitmap_unplug(struct bitmap *bitmap)
spin_unlock_irqrestore(&bitmap->lock, flags);
return;
}
page = bitmap->filemap[i];
dirty = test_page_attr(bitmap, page, BITMAP_PAGE_DIRTY);
need_write = test_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE);
clear_page_attr(bitmap, page, BITMAP_PAGE_DIRTY);
clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE);
dirty = test_page_attr(bitmap, i, BITMAP_PAGE_DIRTY);
need_write = test_page_attr(bitmap, i, BITMAP_PAGE_NEEDWRITE);
clear_page_attr(bitmap, i, BITMAP_PAGE_DIRTY);
clear_page_attr(bitmap, i, BITMAP_PAGE_NEEDWRITE);
if (dirty || need_write)
clear_page_attr(bitmap, page, BITMAP_PAGE_PENDING);
clear_page_attr(bitmap, i, BITMAP_PAGE_PENDING);
if (dirty)
wait = 1;
spin_unlock_irqrestore(&bitmap->lock, flags);

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 (bitmap->file)
Expand Down Expand Up @@ -1101,7 +1099,7 @@ void bitmap_write_all(struct bitmap *bitmap)

spin_lock_irq(&bitmap->lock);
for (i = 0; i < bitmap->file_pages; i++)
set_page_attr(bitmap, bitmap->filemap[i],
set_page_attr(bitmap, i,
BITMAP_PAGE_NEEDWRITE);
bitmap->allclean = 0;
spin_unlock_irq(&bitmap->lock);
Expand Down Expand Up @@ -1168,11 +1166,11 @@ void bitmap_daemon_work(struct mddev *mddev)
*/
spin_lock_irqsave(&bitmap->lock, flags);
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)) {
set_page_attr(bitmap, bitmap->filemap[j],
set_page_attr(bitmap, j,
BITMAP_PAGE_NEEDWRITE);
clear_page_attr(bitmap, bitmap->filemap[j],
clear_page_attr(bitmap, j,
BITMAP_PAGE_PENDING);
}

Expand All @@ -1187,7 +1185,7 @@ void bitmap_daemon_work(struct mddev *mddev)
sb->events_cleared =
cpu_to_le64(bitmap->events_cleared);
kunmap_atomic(sb);
set_page_attr(bitmap, bitmap->sb_page,
set_page_attr(bitmap, 0,
BITMAP_PAGE_NEEDWRITE);
}
}
Expand Down Expand Up @@ -1236,18 +1234,17 @@ void bitmap_daemon_work(struct mddev *mddev)
* We mustn't write any other blocks before the superblock.
*/
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_unplug will handle the rest */
break;
if (test_page_attr(bitmap, page,
if (test_page_attr(bitmap, j,
BITMAP_PAGE_NEEDWRITE)) {
clear_page_attr(bitmap, page,
clear_page_attr(bitmap, j,
BITMAP_PAGE_NEEDWRITE);
spin_unlock_irqrestore(&bitmap->lock, flags);
write_page(bitmap, page, 0);
write_page(bitmap, bitmap->filemap[j], 0);
spin_lock_irqsave(&bitmap->lock, flags);
if (!bitmap->filemap)
break;
Expand Down

0 comments on commit 1a7a8a8

Please sign in to comment.