Commit c3ece6b7 authored by Qu Wenruo's avatar Qu Wenruo Committed by David Sterba

btrfs: change BTRFS_MOUNT_* flags to 64bit type

Currently the BTRFS_MOUNT_* flags are already beyond 32 bits, this is
going to cause compilation errors for some 32 bit systems, as their
unsigned long is only 32 bits long, thus flag
BTRFS_MOUNT_IGNORESUPERFLAGS overflows and can lead to errors.

Fix the problem by:

- Migrate all existing BTRFS_MOUNT_* flags to unsigned long long
- Migrate all mount option related variables to unsigned long long
  * btrfs_fs_info::mount_opt
  * btrfs_fs_context::mount_opt
  * mount_opt parameter of btrfs_check_options()
  * old_opts parameter of btrfs_remount_begin()
  * old_opts parameter of btrfs_remount_cleanup()
  * mount_opt parameter of btrfs_check_mountopts_zoned()
  * mount_opt and opt parameters of check_ro_option()

Fixes: 32e62165 ("btrfs: introduce new "rescue=ignoresuperflags" mount option")
Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 8e786054
......@@ -195,38 +195,38 @@ enum {
* Note: don't forget to add new options to btrfs_show_options()
*/
enum {
BTRFS_MOUNT_NODATASUM = (1UL << 0),
BTRFS_MOUNT_NODATACOW = (1UL << 1),
BTRFS_MOUNT_NOBARRIER = (1UL << 2),
BTRFS_MOUNT_SSD = (1UL << 3),
BTRFS_MOUNT_DEGRADED = (1UL << 4),
BTRFS_MOUNT_COMPRESS = (1UL << 5),
BTRFS_MOUNT_NOTREELOG = (1UL << 6),
BTRFS_MOUNT_FLUSHONCOMMIT = (1UL << 7),
BTRFS_MOUNT_SSD_SPREAD = (1UL << 8),
BTRFS_MOUNT_NOSSD = (1UL << 9),
BTRFS_MOUNT_DISCARD_SYNC = (1UL << 10),
BTRFS_MOUNT_FORCE_COMPRESS = (1UL << 11),
BTRFS_MOUNT_SPACE_CACHE = (1UL << 12),
BTRFS_MOUNT_CLEAR_CACHE = (1UL << 13),
BTRFS_MOUNT_USER_SUBVOL_RM_ALLOWED = (1UL << 14),
BTRFS_MOUNT_ENOSPC_DEBUG = (1UL << 15),
BTRFS_MOUNT_AUTO_DEFRAG = (1UL << 16),
BTRFS_MOUNT_USEBACKUPROOT = (1UL << 17),
BTRFS_MOUNT_SKIP_BALANCE = (1UL << 18),
BTRFS_MOUNT_PANIC_ON_FATAL_ERROR = (1UL << 19),
BTRFS_MOUNT_RESCAN_UUID_TREE = (1UL << 20),
BTRFS_MOUNT_FRAGMENT_DATA = (1UL << 21),
BTRFS_MOUNT_FRAGMENT_METADATA = (1UL << 22),
BTRFS_MOUNT_FREE_SPACE_TREE = (1UL << 23),
BTRFS_MOUNT_NOLOGREPLAY = (1UL << 24),
BTRFS_MOUNT_REF_VERIFY = (1UL << 25),
BTRFS_MOUNT_DISCARD_ASYNC = (1UL << 26),
BTRFS_MOUNT_IGNOREBADROOTS = (1UL << 27),
BTRFS_MOUNT_IGNOREDATACSUMS = (1UL << 28),
BTRFS_MOUNT_NODISCARD = (1UL << 29),
BTRFS_MOUNT_NOSPACECACHE = (1UL << 30),
BTRFS_MOUNT_IGNOREMETACSUMS = (1UL << 31),
BTRFS_MOUNT_NODATASUM = (1ULL << 0),
BTRFS_MOUNT_NODATACOW = (1ULL << 1),
BTRFS_MOUNT_NOBARRIER = (1ULL << 2),
BTRFS_MOUNT_SSD = (1ULL << 3),
BTRFS_MOUNT_DEGRADED = (1ULL << 4),
BTRFS_MOUNT_COMPRESS = (1ULL << 5),
BTRFS_MOUNT_NOTREELOG = (1ULL << 6),
BTRFS_MOUNT_FLUSHONCOMMIT = (1ULL << 7),
BTRFS_MOUNT_SSD_SPREAD = (1ULL << 8),
BTRFS_MOUNT_NOSSD = (1ULL << 9),
BTRFS_MOUNT_DISCARD_SYNC = (1ULL << 10),
BTRFS_MOUNT_FORCE_COMPRESS = (1ULL << 11),
BTRFS_MOUNT_SPACE_CACHE = (1ULL << 12),
BTRFS_MOUNT_CLEAR_CACHE = (1ULL << 13),
BTRFS_MOUNT_USER_SUBVOL_RM_ALLOWED = (1ULL << 14),
BTRFS_MOUNT_ENOSPC_DEBUG = (1ULL << 15),
BTRFS_MOUNT_AUTO_DEFRAG = (1ULL << 16),
BTRFS_MOUNT_USEBACKUPROOT = (1ULL << 17),
BTRFS_MOUNT_SKIP_BALANCE = (1ULL << 18),
BTRFS_MOUNT_PANIC_ON_FATAL_ERROR = (1ULL << 19),
BTRFS_MOUNT_RESCAN_UUID_TREE = (1ULL << 20),
BTRFS_MOUNT_FRAGMENT_DATA = (1ULL << 21),
BTRFS_MOUNT_FRAGMENT_METADATA = (1ULL << 22),
BTRFS_MOUNT_FREE_SPACE_TREE = (1ULL << 23),
BTRFS_MOUNT_NOLOGREPLAY = (1ULL << 24),
BTRFS_MOUNT_REF_VERIFY = (1ULL << 25),
BTRFS_MOUNT_DISCARD_ASYNC = (1ULL << 26),
BTRFS_MOUNT_IGNOREBADROOTS = (1ULL << 27),
BTRFS_MOUNT_IGNOREDATACSUMS = (1ULL << 28),
BTRFS_MOUNT_NODISCARD = (1ULL << 29),
BTRFS_MOUNT_NOSPACECACHE = (1ULL << 30),
BTRFS_MOUNT_IGNOREMETACSUMS = (1ULL << 31),
BTRFS_MOUNT_IGNORESUPERFLAGS = (1ULL << 32),
};
......@@ -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;
unsigned long long mount_opt;
unsigned long compress_type:4;
unsigned int compress_level;
......
......@@ -82,7 +82,7 @@ struct btrfs_fs_context {
u32 commit_interval;
u32 metadata_ratio;
u32 thread_pool_size;
unsigned long mount_opt;
unsigned long long 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,
unsigned long long mount_opt, unsigned long long opt,
const char *opt_name)
{
if (mount_opt & opt) {
......@@ -653,7 +653,8 @@ 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,
unsigned long long *mount_opt,
unsigned long flags)
{
bool ret = true;
......@@ -1231,7 +1232,7 @@ static void btrfs_resize_thread_pool(struct btrfs_fs_info *fs_info,
}
static inline void btrfs_remount_begin(struct btrfs_fs_info *fs_info,
unsigned long old_opts, int flags)
unsigned long long old_opts, int flags)
{
if (btrfs_raw_test_opt(old_opts, AUTO_DEFRAG) &&
(!btrfs_raw_test_opt(fs_info->mount_opt, AUTO_DEFRAG) ||
......@@ -1245,7 +1246,7 @@ static inline void btrfs_remount_begin(struct btrfs_fs_info *fs_info,
}
static inline void btrfs_remount_cleanup(struct btrfs_fs_info *fs_info,
unsigned long old_opts)
unsigned long long old_opts)
{
const bool cache_opt = btrfs_test_opt(fs_info, SPACE_CACHE);
......
......@@ -10,7 +10,8 @@
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,
unsigned long long *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,
......
......@@ -767,7 +767,8 @@ 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,
unsigned long long *mount_opt)
{
if (!btrfs_is_zoned(info))
return 0;
......
......@@ -58,7 +58,8 @@ 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,
unsigned long long *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 +131,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)
unsigned long long *mount_opt)
{
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment