* Re: [PATCH] btrfs: fix disk-io.c/btrfs_read_dev_super with BTRFS_SUPER_MIRROR_MAX to control the loops
2012-09-10 6:38 [PATCH] btrfs: fix disk-io.c/btrfs_read_dev_super with BTRFS_SUPER_MIRROR_MAX to control the loops Wang Sheng-Hui
@ 2012-09-10 7:24 ` cwillu
2012-09-10 16:14 ` Josef Bacik
2012-09-11 5:14 ` Goffredo Baroncelli
2 siblings, 0 replies; 4+ messages in thread
From: cwillu @ 2012-09-10 7:24 UTC (permalink / raw)
To: Wang Sheng-Hui; +Cc: chris.mason, linux-btrfs, linux-kernel
On Mon, Sep 10, 2012 at 12:38 AM, Wang Sheng-Hui <shhuiw@gmail.com> wrote:
> To check the duplicated super blocks, use BTRFS_SUPER_MIRROR_MAX
> as the loops limit.
>
> Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
> ---
> 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;
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Please fix the comment as well; if we check all the supers, then
mounting as btrfs _will_ succeed after a different (non-btrfs)
filesystem is created on the partition/device, pretty much
guaranteeing it will be corrupted.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] btrfs: fix disk-io.c/btrfs_read_dev_super with BTRFS_SUPER_MIRROR_MAX to control the loops
2012-09-10 6:38 [PATCH] btrfs: fix disk-io.c/btrfs_read_dev_super with BTRFS_SUPER_MIRROR_MAX to control the loops Wang Sheng-Hui
2012-09-10 7:24 ` cwillu
@ 2012-09-10 16:14 ` Josef Bacik
2012-09-11 5:14 ` Goffredo Baroncelli
2 siblings, 0 replies; 4+ messages in thread
From: Josef Bacik @ 2012-09-10 16:14 UTC (permalink / raw)
To: Wang Sheng-Hui
Cc: Chris L. Mason, linux-btrfs@vger.kernel.org,
linux-kernel@vger.kernel.org
On Mon, Sep 10, 2012 at 12:38:35AM -0600, 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@gmail.com>
> ---
> 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;
We don't want to do this, it should be left for -o recovery or some such mount
option. Thanks,
Josef
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] btrfs: fix disk-io.c/btrfs_read_dev_super with BTRFS_SUPER_MIRROR_MAX to control the loops
2012-09-10 6:38 [PATCH] btrfs: fix disk-io.c/btrfs_read_dev_super with BTRFS_SUPER_MIRROR_MAX to control the loops Wang Sheng-Hui
2012-09-10 7:24 ` cwillu
2012-09-10 16:14 ` Josef Bacik
@ 2012-09-11 5:14 ` Goffredo Baroncelli
2 siblings, 0 replies; 4+ messages in thread
From: Goffredo Baroncelli @ 2012-09-11 5:14 UTC (permalink / raw)
To: Wang Sheng-Hui
Cc: chris.mason, linux-btrfs, linux-kernel, cwillu, Josef Bacik
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@gmail.com>
> ---
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread