Skip to content

Commit 1627a30

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: expand scalability of f2fs mount option
opt field in structure f2fs_mount_info and opt_mask field in structure f2fs_fs_context is 32-bits variable, now we're running out of available bits in them, let's expand them to 64-bits for better scalability. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent d31e0de commit 1627a30

File tree

2 files changed

+63
-58
lines changed

2 files changed

+63
-58
lines changed

fs/f2fs/f2fs.h

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -96,47 +96,52 @@ extern const char *f2fs_fault_name[FAULT_MAX];
9696
/*
9797
* For mount options
9898
*/
99-
#define F2FS_MOUNT_DISABLE_ROLL_FORWARD 0x00000001
100-
#define F2FS_MOUNT_DISCARD 0x00000002
101-
#define F2FS_MOUNT_NOHEAP 0x00000004
102-
#define F2FS_MOUNT_XATTR_USER 0x00000008
103-
#define F2FS_MOUNT_POSIX_ACL 0x00000010
104-
#define F2FS_MOUNT_DISABLE_EXT_IDENTIFY 0x00000020
105-
#define F2FS_MOUNT_INLINE_XATTR 0x00000040
106-
#define F2FS_MOUNT_INLINE_DATA 0x00000080
107-
#define F2FS_MOUNT_INLINE_DENTRY 0x00000100
108-
#define F2FS_MOUNT_FLUSH_MERGE 0x00000200
109-
#define F2FS_MOUNT_NOBARRIER 0x00000400
110-
#define F2FS_MOUNT_FASTBOOT 0x00000800
111-
#define F2FS_MOUNT_READ_EXTENT_CACHE 0x00001000
112-
#define F2FS_MOUNT_DATA_FLUSH 0x00002000
113-
#define F2FS_MOUNT_FAULT_INJECTION 0x00004000
114-
#define F2FS_MOUNT_USRQUOTA 0x00008000
115-
#define F2FS_MOUNT_GRPQUOTA 0x00010000
116-
#define F2FS_MOUNT_PRJQUOTA 0x00020000
117-
#define F2FS_MOUNT_QUOTA 0x00040000
118-
#define F2FS_MOUNT_INLINE_XATTR_SIZE 0x00080000
119-
#define F2FS_MOUNT_RESERVE_ROOT 0x00100000
120-
#define F2FS_MOUNT_DISABLE_CHECKPOINT 0x00200000
121-
#define F2FS_MOUNT_NORECOVERY 0x00400000
122-
#define F2FS_MOUNT_ATGC 0x00800000
123-
#define F2FS_MOUNT_MERGE_CHECKPOINT 0x01000000
124-
#define F2FS_MOUNT_GC_MERGE 0x02000000
125-
#define F2FS_MOUNT_COMPRESS_CACHE 0x04000000
126-
#define F2FS_MOUNT_AGE_EXTENT_CACHE 0x08000000
127-
#define F2FS_MOUNT_NAT_BITS 0x10000000
128-
#define F2FS_MOUNT_INLINECRYPT 0x20000000
129-
/*
130-
* Some f2fs environments expect to be able to pass the "lazytime" option
131-
* string rather than using the MS_LAZYTIME flag, so this must remain.
132-
*/
133-
#define F2FS_MOUNT_LAZYTIME 0x40000000
134-
#define F2FS_MOUNT_RESERVE_NODE 0x80000000
99+
enum f2fs_mount_opt {
100+
F2FS_MOUNT_DISABLE_ROLL_FORWARD,
101+
F2FS_MOUNT_DISCARD,
102+
F2FS_MOUNT_NOHEAP,
103+
F2FS_MOUNT_XATTR_USER,
104+
F2FS_MOUNT_POSIX_ACL,
105+
F2FS_MOUNT_DISABLE_EXT_IDENTIFY,
106+
F2FS_MOUNT_INLINE_XATTR,
107+
F2FS_MOUNT_INLINE_DATA,
108+
F2FS_MOUNT_INLINE_DENTRY,
109+
F2FS_MOUNT_FLUSH_MERGE,
110+
F2FS_MOUNT_NOBARRIER,
111+
F2FS_MOUNT_FASTBOOT,
112+
F2FS_MOUNT_READ_EXTENT_CACHE,
113+
F2FS_MOUNT_DATA_FLUSH,
114+
F2FS_MOUNT_FAULT_INJECTION,
115+
F2FS_MOUNT_USRQUOTA,
116+
F2FS_MOUNT_GRPQUOTA,
117+
F2FS_MOUNT_PRJQUOTA,
118+
F2FS_MOUNT_QUOTA,
119+
F2FS_MOUNT_INLINE_XATTR_SIZE,
120+
F2FS_MOUNT_RESERVE_ROOT,
121+
F2FS_MOUNT_DISABLE_CHECKPOINT,
122+
F2FS_MOUNT_NORECOVERY,
123+
F2FS_MOUNT_ATGC,
124+
F2FS_MOUNT_MERGE_CHECKPOINT,
125+
F2FS_MOUNT_GC_MERGE,
126+
F2FS_MOUNT_COMPRESS_CACHE,
127+
F2FS_MOUNT_AGE_EXTENT_CACHE,
128+
F2FS_MOUNT_NAT_BITS,
129+
F2FS_MOUNT_INLINECRYPT,
130+
/*
131+
* Some f2fs environments expect to be able to pass the "lazytime" option
132+
* string rather than using the MS_LAZYTIME flag, so this must remain.
133+
*/
134+
F2FS_MOUNT_LAZYTIME,
135+
F2FS_MOUNT_RESERVE_NODE,
136+
};
135137

136138
#define F2FS_OPTION(sbi) ((sbi)->mount_opt)
137-
#define clear_opt(sbi, option) (F2FS_OPTION(sbi).opt &= ~F2FS_MOUNT_##option)
138-
#define set_opt(sbi, option) (F2FS_OPTION(sbi).opt |= F2FS_MOUNT_##option)
139-
#define test_opt(sbi, option) (F2FS_OPTION(sbi).opt & F2FS_MOUNT_##option)
139+
#define clear_opt(sbi, option) \
140+
(F2FS_OPTION(sbi).opt &= ~BIT(F2FS_MOUNT_##option))
141+
#define set_opt(sbi, option) \
142+
(F2FS_OPTION(sbi).opt |= BIT(F2FS_MOUNT_##option))
143+
#define test_opt(sbi, option) \
144+
(F2FS_OPTION(sbi).opt & BIT(F2FS_MOUNT_##option))
140145

141146
#define ver_after(a, b) (typecheck(unsigned long long, a) && \
142147
typecheck(unsigned long long, b) && \
@@ -183,7 +188,7 @@ struct f2fs_rwsem {
183188
};
184189

185190
struct f2fs_mount_info {
186-
unsigned int opt;
191+
unsigned long long opt;
187192
block_t root_reserved_blocks; /* root reserved blocks */
188193
block_t root_reserved_nodes; /* root reserved nodes */
189194
kuid_t s_resuid; /* reserved blocks for uid */

fs/f2fs/super.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -352,31 +352,31 @@ static match_table_t f2fs_checkpoint_tokens = {
352352

353353
struct f2fs_fs_context {
354354
struct f2fs_mount_info info;
355-
unsigned int opt_mask; /* Bits changed */
355+
unsigned long long opt_mask; /* Bits changed */
356356
unsigned int spec_mask;
357357
unsigned short qname_mask;
358358
};
359359

360360
#define F2FS_CTX_INFO(ctx) ((ctx)->info)
361361

362362
static inline void ctx_set_opt(struct f2fs_fs_context *ctx,
363-
unsigned int flag)
363+
enum f2fs_mount_opt flag)
364364
{
365-
ctx->info.opt |= flag;
366-
ctx->opt_mask |= flag;
365+
ctx->info.opt |= BIT(flag);
366+
ctx->opt_mask |= BIT(flag);
367367
}
368368

369369
static inline void ctx_clear_opt(struct f2fs_fs_context *ctx,
370-
unsigned int flag)
370+
enum f2fs_mount_opt flag)
371371
{
372-
ctx->info.opt &= ~flag;
373-
ctx->opt_mask |= flag;
372+
ctx->info.opt &= ~BIT(flag);
373+
ctx->opt_mask |= BIT(flag);
374374
}
375375

376376
static inline bool ctx_test_opt(struct f2fs_fs_context *ctx,
377-
unsigned int flag)
377+
enum f2fs_mount_opt flag)
378378
{
379-
return ctx->info.opt & flag;
379+
return ctx->info.opt & BIT(flag);
380380
}
381381

382382
void f2fs_printk(struct f2fs_sb_info *sbi, bool limit_rate,
@@ -1371,7 +1371,7 @@ static int f2fs_check_compression(struct fs_context *fc,
13711371
ctx_test_opt(ctx, F2FS_MOUNT_COMPRESS_CACHE))
13721372
f2fs_info(sbi, "Image doesn't support compression");
13731373
clear_compression_spec(ctx);
1374-
ctx->opt_mask &= ~F2FS_MOUNT_COMPRESS_CACHE;
1374+
ctx->opt_mask &= ~BIT(F2FS_MOUNT_COMPRESS_CACHE);
13751375
return 0;
13761376
}
13771377
if (ctx->spec_mask & F2FS_SPEC_compress_extension) {
@@ -1439,42 +1439,42 @@ static int f2fs_check_opt_consistency(struct fs_context *fc,
14391439
return -EINVAL;
14401440

14411441
if (f2fs_hw_should_discard(sbi) &&
1442-
(ctx->opt_mask & F2FS_MOUNT_DISCARD) &&
1442+
(ctx->opt_mask & BIT(F2FS_MOUNT_DISCARD)) &&
14431443
!ctx_test_opt(ctx, F2FS_MOUNT_DISCARD)) {
14441444
f2fs_warn(sbi, "discard is required for zoned block devices");
14451445
return -EINVAL;
14461446
}
14471447

14481448
if (!f2fs_hw_support_discard(sbi) &&
1449-
(ctx->opt_mask & F2FS_MOUNT_DISCARD) &&
1449+
(ctx->opt_mask & BIT(F2FS_MOUNT_DISCARD)) &&
14501450
ctx_test_opt(ctx, F2FS_MOUNT_DISCARD)) {
14511451
f2fs_warn(sbi, "device does not support discard");
14521452
ctx_clear_opt(ctx, F2FS_MOUNT_DISCARD);
1453-
ctx->opt_mask &= ~F2FS_MOUNT_DISCARD;
1453+
ctx->opt_mask &= ~BIT(F2FS_MOUNT_DISCARD);
14541454
}
14551455

14561456
if (f2fs_sb_has_device_alias(sbi) &&
1457-
(ctx->opt_mask & F2FS_MOUNT_READ_EXTENT_CACHE) &&
1457+
(ctx->opt_mask & BIT(F2FS_MOUNT_READ_EXTENT_CACHE)) &&
14581458
!ctx_test_opt(ctx, F2FS_MOUNT_READ_EXTENT_CACHE)) {
14591459
f2fs_err(sbi, "device aliasing requires extent cache");
14601460
return -EINVAL;
14611461
}
14621462

14631463
if (test_opt(sbi, RESERVE_ROOT) &&
1464-
(ctx->opt_mask & F2FS_MOUNT_RESERVE_ROOT) &&
1464+
(ctx->opt_mask & BIT(F2FS_MOUNT_RESERVE_ROOT)) &&
14651465
ctx_test_opt(ctx, F2FS_MOUNT_RESERVE_ROOT)) {
14661466
f2fs_info(sbi, "Preserve previous reserve_root=%u",
14671467
F2FS_OPTION(sbi).root_reserved_blocks);
14681468
ctx_clear_opt(ctx, F2FS_MOUNT_RESERVE_ROOT);
1469-
ctx->opt_mask &= ~F2FS_MOUNT_RESERVE_ROOT;
1469+
ctx->opt_mask &= ~BIT(F2FS_MOUNT_RESERVE_ROOT);
14701470
}
14711471
if (test_opt(sbi, RESERVE_NODE) &&
1472-
(ctx->opt_mask & F2FS_MOUNT_RESERVE_NODE) &&
1472+
(ctx->opt_mask & BIT(F2FS_MOUNT_RESERVE_NODE)) &&
14731473
ctx_test_opt(ctx, F2FS_MOUNT_RESERVE_NODE)) {
14741474
f2fs_info(sbi, "Preserve previous reserve_node=%u",
14751475
F2FS_OPTION(sbi).root_reserved_nodes);
14761476
ctx_clear_opt(ctx, F2FS_MOUNT_RESERVE_NODE);
1477-
ctx->opt_mask &= ~F2FS_MOUNT_RESERVE_NODE;
1477+
ctx->opt_mask &= ~BIT(F2FS_MOUNT_RESERVE_NODE);
14781478
}
14791479

14801480
err = f2fs_check_test_dummy_encryption(fc, sb);

0 commit comments

Comments
 (0)