Skip to content

Commit

Permalink
md/bitmap: remove bitmap_mask_state
Browse files Browse the repository at this point in the history
This function isn't really needed.  It sets or clears a flag in both
bitmap->flags and sb->state.
However both times it is called, bitmap_update_sb is called soon
afterwards which copies bitmap->flags to sb->state.
So just make changes to bitmap->flags, and open-code those rather than
hiding in a function.

Signed-off-by: NeilBrown <neilb@suse.de>
  • Loading branch information
NeilBrown committed May 22, 2012
1 parent bc9891a commit edbb79d
Showing 1 changed file with 3 additions and 34 deletions.
37 changes: 3 additions & 34 deletions drivers/md/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,38 +640,6 @@ static int bitmap_read_sb(struct bitmap *bitmap)
return err;
}

enum bitmap_mask_op {
MASK_SET,
MASK_UNSET
};

/* record the state of the bitmap in the superblock. Return the old value */
static int bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits,
enum bitmap_mask_op op)
{
bitmap_super_t *sb;
int old;

if (!bitmap->storage.sb_page) /* can't set the state */
return 0;
sb = kmap_atomic(bitmap->storage.sb_page);
old = le32_to_cpu(sb->state) & bits;
switch (op) {
case MASK_SET:
sb->state |= cpu_to_le32(bits);
bitmap->flags |= bits;
break;
case MASK_UNSET:
sb->state &= cpu_to_le32(~bits);
bitmap->flags &= ~bits;
break;
default:
BUG();
}
kunmap_atomic(sb);
return old;
}

/*
* general bitmap file operations
*/
Expand Down Expand Up @@ -828,7 +796,8 @@ static void bitmap_file_kick(struct bitmap *bitmap)
{
char *path, *ptr = NULL;

if (bitmap_mask_state(bitmap, BITMAP_STALE, MASK_SET) == 0) {
if (!(bitmap->flags & BITMAP_STALE)) {
bitmap->flags |= BITMAP_STALE;
bitmap_update_sb(bitmap);

if (bitmap->storage.file) {
Expand Down Expand Up @@ -1830,7 +1799,7 @@ int bitmap_load(struct mddev *mddev)

if (err)
goto out;
bitmap_mask_state(bitmap, BITMAP_STALE, MASK_UNSET);
bitmap->flags &= ~BITMAP_STALE;

/* Kick recovery in case any bits were set */
set_bit(MD_RECOVERY_NEEDED, &bitmap->mddev->recovery);
Expand Down

0 comments on commit edbb79d

Please sign in to comment.