Re: [PATCH] btrfs: fix disk-io.c/btrfs_read_dev_super with BTRFS_SUPER_MIRROR_MAXto control the loops

From: Goffredo Baroncelli
Date: Tue Sep 11 2012 - 01:19:10 EST


Hi,

On 09/10/2012 08:38 AM, Wang Sheng-Hui wrote:
To check the duplicated super blocks, use BTRFS_SUPER_MIRROR_MAX
as the loops limit.

Signed-off-by: Wang Sheng-Hui<shhuiw@xxxxxxxxx>
---
fs/btrfs/disk-io.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 22e98e0..a431144 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2723,7 +2723,7 @@ struct buffer_head *btrfs_read_dev_super(struct block_device *bdev)
* So, we need to add a special mount option to scan for
* later supers, using BTRFS_SUPER_MIRROR_MAX instead
*/
- for (i = 0; i< 1; i++) {
+ for (i = 0; i< BTRFS_SUPER_MIRROR_MAX; i++) {
bytenr = btrfs_sb_offset(i);
if (bytenr + 4096>= i_size_read(bdev->bd_inode))
break;


Pay attention that when a device is removed from a filesystem by the command "btrfs device delete", *only* the 1st superblock btrfs signature is zeroed [1]. This means that the other (backup) superblocks will be considered valid with your change.



[1] See the function btrfs_rm_device() in volume.c




--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/