Message ID | 20180108030512.22344-2-anand.jain@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 2018年01月08日 11:05, Anand Jain wrote: > Userland uses this flag and resets it only when changing the fsid is > complete. Its not a good idea to mount the device anything in between, > so this patch fails the mount if SB SUPER_FLAG_CHANGING_FSID is set. > > Signed-off-by: Anand Jain <anand.jain@oracle.com> > cc: wqu@suse.com > --- > fs/btrfs/disk-io.c | 7 ++++++- > include/uapi/linux/btrfs_tree.h | 1 + > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c > index a69e5944dc08..8b76faa77235 100644 > --- a/fs/btrfs/disk-io.c > +++ b/fs/btrfs/disk-io.c > @@ -61,7 +61,8 @@ > BTRFS_HEADER_FLAG_RELOC |\ > BTRFS_SUPER_FLAG_ERROR |\ > BTRFS_SUPER_FLAG_SEEDING |\ > - BTRFS_SUPER_FLAG_METADUMP) > + BTRFS_SUPER_FLAG_METADUMP |\ > + BTRFS_SUPER_FLAG_CHANGING_FSID) If we don't want the half changed fs to be mounted, it's better not to include FLAG_CHANGING_FSID into BTRFS_SUPER_FLAG_SUPP. > > static const struct extent_io_ops btree_extent_io_ops; > static void end_workqueue_fn(struct btrfs_work *work); > @@ -3906,6 +3907,10 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info) > btrfs_err(fs_info, "no valid FS found"); > ret = -EINVAL; > } > + if (btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_CHANGING_FSID) { This doesn't seems right. Shouldn't it be "btrfs_super_flags(sb) & BTRFS_SUPER_FLAG_CHANING_FSID"? Thanks, Qu > + btrfs_err(fs_info, "SUPER_FLAG_CHANGING_FSID is set"); > + ret = -EINVAL; > + } > if (btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP) > btrfs_warn(fs_info, "unrecognized super flag: %llu", > btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP); > diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h > index 38ab0e06259a..aff1356c2bb8 100644 > --- a/include/uapi/linux/btrfs_tree.h > +++ b/include/uapi/linux/btrfs_tree.h > @@ -457,6 +457,7 @@ struct btrfs_free_space_header { > #define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32) > #define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33) > #define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34) > +#define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35) > > > /* >
On 01/08/2018 12:55 PM, Qu Wenruo wrote: > > > On 2018年01月08日 11:05, Anand Jain wrote: >> Userland uses this flag and resets it only when changing the fsid is >> complete. Its not a good idea to mount the device anything in between, >> so this patch fails the mount if SB SUPER_FLAG_CHANGING_FSID is set. >> >> Signed-off-by: Anand Jain <anand.jain@oracle.com> >> cc: wqu@suse.com >> --- >> fs/btrfs/disk-io.c | 7 ++++++- >> include/uapi/linux/btrfs_tree.h | 1 + >> 2 files changed, 7 insertions(+), 1 deletion(-) >> >> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c >> index a69e5944dc08..8b76faa77235 100644 >> --- a/fs/btrfs/disk-io.c >> +++ b/fs/btrfs/disk-io.c >> @@ -61,7 +61,8 @@ >> BTRFS_HEADER_FLAG_RELOC |\ >> BTRFS_SUPER_FLAG_ERROR |\ >> BTRFS_SUPER_FLAG_SEEDING |\ >> - BTRFS_SUPER_FLAG_METADUMP) >> + BTRFS_SUPER_FLAG_METADUMP |\ >> + BTRFS_SUPER_FLAG_CHANGING_FSID) > > If we don't want the half changed fs to be mounted, it's better not to > include FLAG_CHANGING_FSID into BTRFS_SUPER_FLAG_SUPP. > >> >> static const struct extent_io_ops btree_extent_io_ops; >> static void end_workqueue_fn(struct btrfs_work *work); >> @@ -3906,6 +3907,10 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info) >> btrfs_err(fs_info, "no valid FS found"); >> ret = -EINVAL; >> } >> + if (btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_CHANGING_FSID) { > > This doesn't seems right. > > Shouldn't it be "btrfs_super_flags(sb) & BTRFS_SUPER_FLAG_CHANING_FSID"? Yep. I just noticed too. Made a mistake cut and paste. Posted v2. Thanks. Anand > Thanks, > Qu > >> + btrfs_err(fs_info, "SUPER_FLAG_CHANGING_FSID is set"); >> + ret = -EINVAL; >> + } >> if (btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP) >> btrfs_warn(fs_info, "unrecognized super flag: %llu", >> btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP); >> diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h >> index 38ab0e06259a..aff1356c2bb8 100644 >> --- a/include/uapi/linux/btrfs_tree.h >> +++ b/include/uapi/linux/btrfs_tree.h >> @@ -457,6 +457,7 @@ struct btrfs_free_space_header { >> #define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32) >> #define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33) >> #define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34) >> +#define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35) >> >> >> /* >> > -- 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
>> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c >> index a69e5944dc08..8b76faa77235 100644 >> --- a/fs/btrfs/disk-io.c >> +++ b/fs/btrfs/disk-io.c >> @@ -61,7 +61,8 @@ >> BTRFS_HEADER_FLAG_RELOC |\ >> BTRFS_SUPER_FLAG_ERROR |\ >> BTRFS_SUPER_FLAG_SEEDING |\ >> - BTRFS_SUPER_FLAG_METADUMP) >> + BTRFS_SUPER_FLAG_METADUMP |\ >> + BTRFS_SUPER_FLAG_CHANGING_FSID) > > If we don't want the half changed fs to be mounted, it's better not to > include FLAG_CHANGING_FSID into BTRFS_SUPER_FLAG_SUPP. Anyway BTRFS_SUPER_FLAG_SUPP as such does not stop to mount, it just warns. So when there is a new flag which is not supported we get this warning. As in the case with BTRFS_SUPER_FLAG_METADUMP_V2. As in 1/2 BTRFS_SUPER_FLAG_METADUMP_V2 in kernel is defined but not supported. However since we are supporting BTRFS_SUPER_FLAG_CHANGING_FSID, so adding to BTRFS_SUPER_FLAG_SUPP make sense to me. ? Thanks, Anand -- 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
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index a69e5944dc08..8b76faa77235 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -61,7 +61,8 @@ BTRFS_HEADER_FLAG_RELOC |\ BTRFS_SUPER_FLAG_ERROR |\ BTRFS_SUPER_FLAG_SEEDING |\ - BTRFS_SUPER_FLAG_METADUMP) + BTRFS_SUPER_FLAG_METADUMP |\ + BTRFS_SUPER_FLAG_CHANGING_FSID) static const struct extent_io_ops btree_extent_io_ops; static void end_workqueue_fn(struct btrfs_work *work); @@ -3906,6 +3907,10 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info) btrfs_err(fs_info, "no valid FS found"); ret = -EINVAL; } + if (btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_CHANGING_FSID) { + btrfs_err(fs_info, "SUPER_FLAG_CHANGING_FSID is set"); + ret = -EINVAL; + } if (btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP) btrfs_warn(fs_info, "unrecognized super flag: %llu", btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP); diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h index 38ab0e06259a..aff1356c2bb8 100644 --- a/include/uapi/linux/btrfs_tree.h +++ b/include/uapi/linux/btrfs_tree.h @@ -457,6 +457,7 @@ struct btrfs_free_space_header { #define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32) #define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33) #define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34) +#define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35) /*
Userland uses this flag and resets it only when changing the fsid is complete. Its not a good idea to mount the device anything in between, so this patch fails the mount if SB SUPER_FLAG_CHANGING_FSID is set. Signed-off-by: Anand Jain <anand.jain@oracle.com> cc: wqu@suse.com --- fs/btrfs/disk-io.c | 7 ++++++- include/uapi/linux/btrfs_tree.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-)