Skip to contentSkip to conversation

DM RAID: Explicitly turn off bad block support

PATCH In review Jonathan Brassow 2 participants 6 messages Apr 19, 2013 – Apr 24, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 DM RAID: Explicitly turn off bad block support

DM RAID: Explicitly turn off bad block support

DM RAID does not currently use the bad block tracking available in MD. 'badblocks.shift' must be set to '-1' in order to explicitly tell MD not to perform bad block related functions, like narrow_write_error().

drivers/md/dm-raid.c +3 -1
Index: linux-upstream/drivers/md/dm-raid.c
===================================================================
@@ -170,8 +170,10 @@ static struct raid_set *context_alloc(st
 	rs->md.delta_disks = 0;
 	rs->md.recovery_cp = 0;
 
-	for (i = 0; i < raid_devs; i++)
+	for (i = 0; i < raid_devs; i++) {
 		md_rdev_init(&rs->dev[i].rdev);
+		rs->dev[i].rdev.badblocks.shift = -1; /* No bad block support */
+	}
 
 	/*
 	 * Remaining items to be initialized by further RAID params:
#1 lore raw
Quoted 16 lines · On Fri, 19 Apr 2013 08:30:24 -0500 Jonathan Brassow <[email protected]> wrote:

DM RAID: Explicitly turn off bad block support

DM RAID does not currently use the bad block tracking available in MD. 'badblocks.shift' must be set to '-1' in order to explicitly tell MD not to perform bad block related functions, like narrow_write_error().

Index: linux-upstream/drivers/md/dm-raid.c
===================================================================

drivers/md/dm-raid.c +0 -0
@@ -170,8 +170,10 @@ static struct raid_set *context_alloc(st
 	rs->md.delta_disks = 0;

drivers/md/dm-raid.c static struct raid_set *context_alloc(st · line 179

Quoted 10 lines
drivers/md/dm-raid.c +3 -1
 	rs->md.recovery_cp = 0;
 
-	for (i = 0; i < raid_devs; i++)
+	for (i = 0; i < raid_devs; i++) {
 		md_rdev_init(&rs->dev[i].rdev);
+		rs->dev[i].rdev.badblocks.shift = -1; /* No bad block support */
+	}
 
 	/*
 	 * Remaining items to be initialized by further RAID params:

Thanks, but I don't think this is the right fix. md_rdev_init really should set shift to -1, because we can only support badblocks if the metadata explicitly supports it.

What do you think of this instead?

Thanks,
NeilBrown

drivers/md/md.c +3 -6
index 41502cf..2166486 100644
@@ -1567,8 +1567,8 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
 					     sector, count, 1) == 0)
 				return -EINVAL;
 		}
-	} else if (sb->bblog_offset == 0)
-		rdev->badblocks.shift = -1;
+	} else if (sb->bblog_offset != 0)
+		rdev->badblocks.shift = 0;
 
 	if (!refdev) {
 		ret = 1;
@@ -3227,7 +3227,7 @@ int md_rdev_init(struct md_rdev *rdev)
 	 * be used - I wonder if that matters
 	 */
 	rdev->badblocks.count = 0;
-	rdev->badblocks.shift = 0;
+	rdev->badblocks.shift = -1; /* disabled until explicitly enabled */
 	rdev->badblocks.page = kmalloc(PAGE_SIZE, GFP_KERNEL);
 	seqlock_init(&rdev->badblocks.lock);
 	if (rdev->badblocks.page == NULL)
@@ -3299,9 +3299,6 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe
 			goto abort_free;
 		}
 	}
-	if (super_format == -1)
-		/* hot-add for 0.90, or non-persistent: so no badblocks */
-		rdev->badblocks.shift = -1;
 
 	return rdev;
 
#2 lore raw
Quoted 34 lines · NeilBrown
Quoted 16 lines · On Fri, 19 Apr 2013 08:30:24 -0500 Jonathan Brassow <[email protected]> wrote:

DM RAID: Explicitly turn off bad block support

DM RAID does not currently use the bad block tracking available in MD. 'badblocks.shift' must be set to '-1' in order to explicitly tell MD not to perform bad block related functions, like narrow_write_error().

Index: linux-upstream/drivers/md/dm-raid.c
===================================================================

drivers/md/dm-raid.c +0 -0
@@ -170,8 +170,10 @@ static struct raid_set *context_alloc(st
 	rs->md.delta_disks = 0;

drivers/md/dm-raid.c static struct raid_set *context_alloc(st · line 179

Quoted 10 lines
drivers/md/dm-raid.c +3 -1
 	rs->md.recovery_cp = 0;
 
-	for (i = 0; i < raid_devs; i++)
+	for (i = 0; i < raid_devs; i++) {
 		md_rdev_init(&rs->dev[i].rdev);
+		rs->dev[i].rdev.badblocks.shift = -1; /* No bad block support */
+	}
 
 	/*
 	 * Remaining items to be initialized by further RAID params:

Thanks, but I don't think this is the right fix. md_rdev_init really should set shift to -1, because we can only support badblocks if the metadata explicitly supports it.

Quoted 1 line

What do you think of this instead?

I like it much better. It means that the proper initialization is done centrally, rather than expecting every super block type to know enough to turn off things they may not know about. I considered this, but went along with the idea that it was the responsibility of the individual superblock handlers.

thanks!
brassow

#3 lore raw
Quoted 37 lines · On Mon, 22 Apr 2013 11:29:48 -0500 Brassow Jonathan <[email protected]> wrote:
Quoted 34 lines · NeilBrown
Quoted 16 lines · On Fri, 19 Apr 2013 08:30:24 -0500 Jonathan Brassow <[email protected]> wrote:

DM RAID: Explicitly turn off bad block support

DM RAID does not currently use the bad block tracking available in MD. 'badblocks.shift' must be set to '-1' in order to explicitly tell MD not to perform bad block related functions, like narrow_write_error().

Index: linux-upstream/drivers/md/dm-raid.c
===================================================================

drivers/md/dm-raid.c +0 -0
@@ -170,8 +170,10 @@ static struct raid_set *context_alloc(st
 	rs->md.delta_disks = 0;

drivers/md/dm-raid.c static struct raid_set *context_alloc(st · line 179

Quoted 10 lines
drivers/md/dm-raid.c +3 -1
 	rs->md.recovery_cp = 0;
 
-	for (i = 0; i < raid_devs; i++)
+	for (i = 0; i < raid_devs; i++) {
 		md_rdev_init(&rs->dev[i].rdev);
+		rs->dev[i].rdev.badblocks.shift = -1; /* No bad block support */
+	}
 
 	/*
 	 * Remaining items to be initialized by further RAID params:

Thanks, but I don't think this is the right fix. md_rdev_init really should set shift to -1, because we can only support badblocks if the metadata explicitly supports it.

Quoted 4 lines
Quoted 1 line

What do you think of this instead?

I like it much better. It means that the proper initialization is done centrally, rather than expecting every super block type to know enough to turn off things they may not know about. I considered this, but went along with the idea that it was the responsibility of the individual superblock handlers.

:-)

Does this need to go to -stable? Which versions, do you know?

Thanks,
NeilBrown

#4 lore raw
Quoted 40 lines · NeilBrown
Quoted 37 lines · On Mon, 22 Apr 2013 11:29:48 -0500 Brassow Jonathan <[email protected]> wrote:
Quoted 34 lines · NeilBrown
Quoted 16 lines · On Fri, 19 Apr 2013 08:30:24 -0500 Jonathan Brassow <[email protected]> wrote:

DM RAID: Explicitly turn off bad block support

DM RAID does not currently use the bad block tracking available in MD. 'badblocks.shift' must be set to '-1' in order to explicitly tell MD not to perform bad block related functions, like narrow_write_error().

Index: linux-upstream/drivers/md/dm-raid.c
===================================================================

drivers/md/dm-raid.c +0 -0
@@ -170,8 +170,10 @@ static struct raid_set *context_alloc(st
 	rs->md.delta_disks = 0;

drivers/md/dm-raid.c static struct raid_set *context_alloc(st · line 179

Quoted 10 lines
drivers/md/dm-raid.c +3 -1
 	rs->md.recovery_cp = 0;
 
-	for (i = 0; i < raid_devs; i++)
+	for (i = 0; i < raid_devs; i++) {
 		md_rdev_init(&rs->dev[i].rdev);
+		rs->dev[i].rdev.badblocks.shift = -1; /* No bad block support */
+	}
 
 	/*
 	 * Remaining items to be initialized by further RAID params:

Thanks, but I don't think this is the right fix. md_rdev_init really should set shift to -1, because we can only support badblocks if the metadata explicitly supports it.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

What do you think of this instead?

I like it much better. It means that the proper initialization is done centrally, rather than expecting every super block type to know enough to turn off things they may not know about. I considered this, but went along with the idea that it was the responsibility of the individual superblock handlers.

:-)

Does this need to go to -stable? Which versions, do you know?

dm-raid was introduce in 2.6.38, I believe. A quick check shows your patch applies to v3.1+ (although I've only compiled and tested 3.9-rc8). I would like to see the patch go into stable.

brassow

#5 lore raw
Quoted 45 lines · On Tue, 23 Apr 2013 22:48:50 -0500 Brassow Jonathan <[email protected]> wrote:
Quoted 42 lines · NeilBrown
Quoted 39 lines · On Mon, 22 Apr 2013 11:29:48 -0500 Brassow Jonathan <[email protected]> wrote:
Quoted 35 lines · NeilBrown
Quoted 16 lines · On Fri, 19 Apr 2013 08:30:24 -0500 Jonathan Brassow <[email protected]> wrote:

DM RAID: Explicitly turn off bad block support

DM RAID does not currently use the bad block tracking available in MD. 'badblocks.shift' must be set to '-1' in order to explicitly tell MD not to perform bad block related functions, like narrow_write_error().

Index: linux-upstream/drivers/md/dm-raid.c
===================================================================

drivers/md/dm-raid.c +0 -0
@@ -170,8 +170,10 @@ static struct raid_set *context_alloc(st
 	rs->md.delta_disks = 0;

drivers/md/dm-raid.c static struct raid_set *context_alloc(st · line 179

Quoted 10 lines
drivers/md/dm-raid.c +3 -1
 	rs->md.recovery_cp = 0;
 
-	for (i = 0; i < raid_devs; i++)
+	for (i = 0; i < raid_devs; i++) {
 		md_rdev_init(&rs->dev[i].rdev);
+		rs->dev[i].rdev.badblocks.shift = -1; /* No bad block support */
+	}
 
 	/*
 	 * Remaining items to be initialized by further RAID params:

Thanks, but I don't think this is the right fix. md_rdev_init really should set shift to -1, because we can only support badblocks if the metadata explicitly supports it.

What do you think of this instead?

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

I like it much better. It means that the proper initialization is done centrally, rather than expecting every super block type to know enough to turn off things they may not know about. I considered this, but went along with the idea that it was the responsibility of the individual superblock handlers.

:-)

Does this need to go to -stable? Which versions, do you know?

dm-raid was introduce in 2.6.38, I believe. A quick check shows your patch applies to v3.1+ (although I've only compiled and tested 3.9-rc8). I would like to see the patch go into stable.

OK, I've tagged it for -stable. I won't try to get it into 3.9 as I think it is too late, but it'll go into 3.10-rc1 and then to the relevant -stables.

Thanks,
NeilBrown