Skip to contentSkip to conversation

btrfs: change mount_opt to u64

PATCH In review Arnd Bergmann 3 participants 4 messages Jul 19, 2024 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: change mount_opt to u64

From: Arnd Bergmann <[email protected]>

The newly added BTRFS_MOUNT_IGNORESUPERFLAGS flag does not fit into a 32-bit flags word, as shown by this warning on 32-bit architectures:

fs/btrfs/super.c: In function 'btrfs_check_options':
fs/btrfs/super.c:666:48: error: conversion from 'enum <anonymous>' to 'long unsigned int' changes value from '4294967296' to '0' [-Werror=overflow]
666 | check_ro_option(info, *mount_opt, BTRFS_MOUNT_IGNORESUPERFLAGS, "ignoresuperflags")))

      |                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change all interfaces that deal with mount flags to use a 64-bit type on all architectures instead.

Fixes 32e6216512b4 ("btrfs: introduce new "rescue=ignoresuperflags" mount option")

----
Please double-check that I got all the instances. I only looked at where the obvious users are, but did not actually try to run this on a 32-bit target

---
 fs/btrfs/fs.h    | 2 +-
 fs/btrfs/super.c | 6 +++---
 fs/btrfs/super.h | 2 +-
 fs/btrfs/zoned.c | 2 +-
 fs/btrfs/zoned.h | 4 ++--
 5 files changed, 8 insertions(+), 8 deletions(-)
fs/btrfs/fs.h +1 -1
index 1b2a7aa0af36..20900c7cc35d 100644
@@ -481,7 +481,7 @@ struct btrfs_fs_info {
 	 * required instead of the faster short fsync log commits
 	 */
 	u64 last_trans_log_full_commit;
-	unsigned long mount_opt;
+	u64 mount_opt;
 
 	unsigned long compress_type:4;
 	unsigned int compress_level;
fs/btrfs/super.c +3 -3
index 43052acd7a48..ea7141330e87 100644
@@ -82,7 +82,7 @@ struct btrfs_fs_context {
 	u32 commit_interval;
 	u32 metadata_ratio;
 	u32 thread_pool_size;
-	unsigned long mount_opt;
+	u64 mount_opt;
 	unsigned long compress_type:4;
 	unsigned int compress_level;
 	refcount_t refs;
@@ -642,7 +642,7 @@ static void btrfs_clear_oneshot_options(struct btrfs_fs_info *fs_info)
 }
 
 static bool check_ro_option(const struct btrfs_fs_info *fs_info,
-			    unsigned long mount_opt, unsigned long opt,
+			    u64 mount_opt, u64 opt,
 			    const char *opt_name)
 {
 	if (mount_opt & opt) {
@@ -653,7 +653,7 @@ static bool check_ro_option(const struct btrfs_fs_info *fs_info,
 	return false;
 }
 
-bool btrfs_check_options(const struct btrfs_fs_info *info, unsigned long *mount_opt,
+bool btrfs_check_options(const struct btrfs_fs_info *info, u64 *mount_opt,
 			 unsigned long flags)
 {
 	bool ret = true;
fs/btrfs/super.h +1 -1
index d2b8ebb46bc6..98e2444c0d82 100644
@@ -10,7 +10,7 @@
 struct super_block;
 struct btrfs_fs_info;
 
-bool btrfs_check_options(const struct btrfs_fs_info *info, unsigned long *mount_opt,
+bool btrfs_check_options(const struct btrfs_fs_info *info, u64 *mount_opt,
 			 unsigned long flags);
 int btrfs_sync_fs(struct super_block *sb, int wait);
 char *btrfs_get_subvol_name_from_objectid(struct btrfs_fs_info *fs_info,
fs/btrfs/zoned.c +1 -1
index df7733044f7e..debab1ab9e71 100644
@@ -767,7 +767,7 @@ int btrfs_check_zoned_mode(struct btrfs_fs_info *fs_info)
 	return 0;
 }
 
-int btrfs_check_mountopts_zoned(const struct btrfs_fs_info *info, unsigned long *mount_opt)
+int btrfs_check_mountopts_zoned(const struct btrfs_fs_info *info, u64 *mount_opt)
 {
 	if (!btrfs_is_zoned(info))
 		return 0;
fs/btrfs/zoned.h +2 -2
index d66d00c08001..037697878b2a 100644
@@ -58,7 +58,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache);
 void btrfs_destroy_dev_zone_info(struct btrfs_device *device);
 struct btrfs_zoned_device_info *btrfs_clone_dev_zone_info(struct btrfs_device *orig_dev);
 int btrfs_check_zoned_mode(struct btrfs_fs_info *fs_info);
-int btrfs_check_mountopts_zoned(const struct btrfs_fs_info *info, unsigned long *mount_opt);
+int btrfs_check_mountopts_zoned(const struct btrfs_fs_info *info, u64 *mount_opt);
 int btrfs_sb_log_location_bdev(struct block_device *bdev, int mirror, int rw,
 			       u64 *bytenr_ret);
 int btrfs_sb_log_location(struct btrfs_device *device, int mirror, int rw,
@@ -130,7 +130,7 @@ static inline int btrfs_check_zoned_mode(const struct btrfs_fs_info *fs_info)
 }
 
 static inline int btrfs_check_mountopts_zoned(const struct btrfs_fs_info *info,
-					      unsigned long *mount_opt)
+					      u64 *mount_opt)
 {
 	return 0;
 }
Signature · 1 line
2.39.2
#1 lore raw
Quoted 8 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The newly added BTRFS_MOUNT_IGNORESUPERFLAGS flag does not fit into a 32-bit flags word, as shown by this warning on 32-bit architectures:

fs/btrfs/super.c: In function 'btrfs_check_options':
fs/btrfs/super.c:666:48: error: conversion from 'enum <anonymous>' to 'long unsigned int' changes value from '4294967296' to '0' [-Werror=overflow]
666 | check_ro_option(info, *mount_opt, BTRFS_MOUNT_IGNORESUPERFLAGS, "ignoresuperflags")))

Quoted 7 lines
       |                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change all interfaces that deal with mount flags to use a 64-bit type on all architectures instead.

Fixes 32e6216512b4 ("btrfs: introduce new "rescue=ignoresuperflags" mount option")

There is already a patch submitted:

https://lore.kernel.org/linux-btrfs/0955d2c5675a7fe3146292aaa766755f22bcd94b.1720865683.git.wqu@suse.com/

Thanks,
Qu

Quoted 103 lines

----
Please double-check that I got all the instances. I only looked at where the obvious users are, but did not actually try to run this on a 32-bit target

---
  fs/btrfs/fs.h    | 2 +-
  fs/btrfs/super.c | 6 +++---
  fs/btrfs/super.h | 2 +-
  fs/btrfs/zoned.c | 2 +-
  fs/btrfs/zoned.h | 4 ++--
  5 files changed, 8 insertions(+), 8 deletions(-)
fs/btrfs/fs.h +1 -1
index 1b2a7aa0af36..20900c7cc35d 100644
@@ -481,7 +481,7 @@ struct btrfs_fs_info {
  	 * required instead of the faster short fsync log commits
  	 */
  	u64 last_trans_log_full_commit;
-	unsigned long mount_opt;
+	u64 mount_opt;
 
  	unsigned long compress_type:4;
  	unsigned int compress_level;
fs/btrfs/super.c +3 -3
index 43052acd7a48..ea7141330e87 100644
@@ -82,7 +82,7 @@ struct btrfs_fs_context {
  	u32 commit_interval;
  	u32 metadata_ratio;
  	u32 thread_pool_size;
-	unsigned long mount_opt;
+	u64 mount_opt;
  	unsigned long compress_type:4;
  	unsigned int compress_level;
  	refcount_t refs;
@@ -642,7 +642,7 @@ static void btrfs_clear_oneshot_options(struct btrfs_fs_info *fs_info)
  }
 
  static bool check_ro_option(const struct btrfs_fs_info *fs_info,
-			    unsigned long mount_opt, unsigned long opt,
+			    u64 mount_opt, u64 opt,
  			    const char *opt_name)
  {
  	if (mount_opt & opt) {
@@ -653,7 +653,7 @@ static bool check_ro_option(const struct btrfs_fs_info *fs_info,
  	return false;
  }
 
-bool btrfs_check_options(const struct btrfs_fs_info *info, unsigned long *mount_opt,
+bool btrfs_check_options(const struct btrfs_fs_info *info, u64 *mount_opt,
  			 unsigned long flags)
  {
  	bool ret = true;
fs/btrfs/super.h +1 -1
index d2b8ebb46bc6..98e2444c0d82 100644
@@ -10,7 +10,7 @@
  struct super_block;
  struct btrfs_fs_info;
 
-bool btrfs_check_options(const struct btrfs_fs_info *info, unsigned long *mount_opt,
+bool btrfs_check_options(const struct btrfs_fs_info *info, u64 *mount_opt,
  			 unsigned long flags);
  int btrfs_sync_fs(struct super_block *sb, int wait);
  char *btrfs_get_subvol_name_from_objectid(struct btrfs_fs_info *fs_info,
fs/btrfs/zoned.c +1 -1
index df7733044f7e..debab1ab9e71 100644
@@ -767,7 +767,7 @@ int btrfs_check_zoned_mode(struct btrfs_fs_info *fs_info)
  	return 0;
  }
 
-int btrfs_check_mountopts_zoned(const struct btrfs_fs_info *info, unsigned long *mount_opt)
+int btrfs_check_mountopts_zoned(const struct btrfs_fs_info *info, u64 *mount_opt)
  {
  	if (!btrfs_is_zoned(info))
  		return 0;
fs/btrfs/zoned.h +2 -2
index d66d00c08001..037697878b2a 100644
@@ -58,7 +58,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache);
  void btrfs_destroy_dev_zone_info(struct btrfs_device *device);
  struct btrfs_zoned_device_info *btrfs_clone_dev_zone_info(struct btrfs_device *orig_dev);
  int btrfs_check_zoned_mode(struct btrfs_fs_info *fs_info);
-int btrfs_check_mountopts_zoned(const struct btrfs_fs_info *info, unsigned long *mount_opt);
+int btrfs_check_mountopts_zoned(const struct btrfs_fs_info *info, u64 *mount_opt);
  int btrfs_sb_log_location_bdev(struct block_device *bdev, int mirror, int rw,
  			       u64 *bytenr_ret);
  int btrfs_sb_log_location(struct btrfs_device *device, int mirror, int rw,
@@ -130,7 +130,7 @@ static inline int btrfs_check_zoned_mode(const struct btrfs_fs_info *fs_info)
  }
 
  static inline int btrfs_check_mountopts_zoned(const struct btrfs_fs_info *info,
-					      unsigned long *mount_opt)
+					      u64 *mount_opt)
  {
  	return 0;
  }
#2 lore raw
In reply to Arnd Bergmann
Quoted 10 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The newly added BTRFS_MOUNT_IGNORESUPERFLAGS flag does not fit into a 32-bit flags word, as shown by this warning on 32-bit architectures:

fs/btrfs/super.c: In function 'btrfs_check_options':
fs/btrfs/super.c:666:48: error: conversion from 'enum <anonymous>' to 'long unsigned int' changes value from '4294967296' to '0' [-Werror=overflow]
666 | check_ro_option(info, *mount_opt, BTRFS_MOUNT_IGNORESUPERFLAGS, "ignoresuperflags")))

      |                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 8 lines

Change all interfaces that deal with mount flags to use a 64-bit type on all architectures instead.

Fixes 32e6216512b4 ("btrfs: introduce new "rescue=ignoresuperflags" mount option")

----
Please double-check that I got all the instances. I only looked at where the obvious users are, but did not actually try to run this on a 32-bit target

Thanks, the build issue is known and fix will be sent in 2nd pull reuqest on Monday.

#3 lore raw
Quoted 14 lines · David Sterba
Quoted 13 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The newly added BTRFS_MOUNT_IGNORESUPERFLAGS flag does not fit into a 32-bit flags word, as shown by this warning on 32-bit architectures:

fs/btrfs/super.c: In function 'btrfs_check_options':
fs/btrfs/super.c:666:48: error: conversion from 'enum <anonymous>' to 'long unsigned int' changes value from '4294967296' to '0' [-Werror=overflow]
666 | check_ro_option(info, *mount_opt, BTRFS_MOUNT_IGNORESUPERFLAGS, "ignoresuperflags")))

      |                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change all interfaces that deal with mount flags to use a 64-bit type on all architectures instead.

Quoted 8 lines
Quoted 5 lines
Fixes 32e6216512b4 ("btrfs: introduce new "rescue=ignoresuperflags" mount option")

----
Please double-check that I got all the instances. I only looked at where the obvious users are, but did not actually try to run this on a 32-bit target

Thanks, the build issue is known and fix will be sent in 2nd pull reuqest on Monday.

             ^^^^^^

I'll send the pull request rather today.