Skip to content

Commit

Permalink
md: Don't test all of mddev->flags at once.
Browse files Browse the repository at this point in the history
mddev->flags is mostly used to record if an update of the
metadata is needed.  Sometimes the whole field is tested
instead of just the important bits.  This makes it difficult
to introduce more state bits.

So replace all bare tests of mddev->flags with tests for the bits
that actually need testing.

Signed-off-by: NeilBrown <neilb@suse.de>
  • Loading branch information
NeilBrown committed Aug 27, 2013
1 parent c9ad020 commit 7a0a535
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -5144,7 +5144,7 @@ int md_run(struct mddev *mddev)

set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);

if (mddev->flags)
if (mddev->flags & MD_UPDATE_SB_FLAGS)
md_update_sb(mddev, 0);

md_new_event(mddev);
Expand Down Expand Up @@ -5289,7 +5289,7 @@ static void __md_stop_writes(struct mddev *mddev)
md_super_wait(mddev);

if (mddev->ro == 0 &&
(!mddev->in_sync || mddev->flags)) {
(!mddev->in_sync || (mddev->flags & MD_UPDATE_SB_FLAGS))) {
/* mark array as shutdown cleanly */
mddev->in_sync = 1;
md_update_sb(mddev, 1);
Expand Down Expand Up @@ -7814,7 +7814,7 @@ void md_check_recovery(struct mddev *mddev)
sysfs_notify_dirent_safe(mddev->sysfs_state);
}

if (mddev->flags)
if (mddev->flags & MD_UPDATE_SB_FLAGS)
md_update_sb(mddev, 0);

if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) &&
Expand Down
5 changes: 3 additions & 2 deletions drivers/md/md.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,12 @@ struct mddev {
struct md_personality *pers;
dev_t unit;
int md_minor;
struct list_head disks;
struct list_head disks;
unsigned long flags;
#define MD_CHANGE_DEVS 0 /* Some device status has changed */
#define MD_CHANGE_CLEAN 1 /* transition to or from 'clean' */
#define MD_CHANGE_PENDING 2 /* switch from 'clean' to 'active' in progress */
#define MD_UPDATE_SB_FLAGS (1 | 2 | 4) /* If these are set, md_update_sb needed */
#define MD_ARRAY_FIRST_USE 3 /* First use of array, needs initialization */

int suspended;
Expand All @@ -218,7 +219,7 @@ struct mddev {
* are happening, so run/
* takeover/stop are not safe
*/
int ready; /* See when safe to pass
int ready; /* See when safe to pass
* IO requests down */
struct gendisk *gendisk;

Expand Down

0 comments on commit 7a0a535

Please sign in to comment.