diff options
Diffstat (limited to 'fs/f2fs/sysfs.c')
-rw-r--r-- | fs/f2fs/sysfs.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 714a3e47bbe8..9adc202fcd6f 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c | |||
@@ -30,6 +30,7 @@ enum { | |||
30 | FAULT_INFO_RATE, /* struct f2fs_fault_info */ | 30 | FAULT_INFO_RATE, /* struct f2fs_fault_info */ |
31 | FAULT_INFO_TYPE, /* struct f2fs_fault_info */ | 31 | FAULT_INFO_TYPE, /* struct f2fs_fault_info */ |
32 | #endif | 32 | #endif |
33 | RESERVED_BLOCKS, | ||
33 | }; | 34 | }; |
34 | 35 | ||
35 | struct f2fs_attr { | 36 | struct f2fs_attr { |
@@ -51,7 +52,7 @@ static unsigned char *__struct_ptr(struct f2fs_sb_info *sbi, int struct_type) | |||
51 | return (unsigned char *)SM_I(sbi)->dcc_info; | 52 | return (unsigned char *)SM_I(sbi)->dcc_info; |
52 | else if (struct_type == NM_INFO) | 53 | else if (struct_type == NM_INFO) |
53 | return (unsigned char *)NM_I(sbi); | 54 | return (unsigned char *)NM_I(sbi); |
54 | else if (struct_type == F2FS_SBI) | 55 | else if (struct_type == F2FS_SBI || struct_type == RESERVED_BLOCKS) |
55 | return (unsigned char *)sbi; | 56 | return (unsigned char *)sbi; |
56 | #ifdef CONFIG_F2FS_FAULT_INJECTION | 57 | #ifdef CONFIG_F2FS_FAULT_INJECTION |
57 | else if (struct_type == FAULT_INFO_RATE || | 58 | else if (struct_type == FAULT_INFO_RATE || |
@@ -111,6 +112,17 @@ static ssize_t f2fs_sbi_store(struct f2fs_attr *a, | |||
111 | if (a->struct_type == FAULT_INFO_TYPE && t >= (1 << FAULT_MAX)) | 112 | if (a->struct_type == FAULT_INFO_TYPE && t >= (1 << FAULT_MAX)) |
112 | return -EINVAL; | 113 | return -EINVAL; |
113 | #endif | 114 | #endif |
115 | if (a->struct_type == RESERVED_BLOCKS) { | ||
116 | spin_lock(&sbi->stat_lock); | ||
117 | if ((unsigned long)sbi->total_valid_block_count + t > | ||
118 | (unsigned long)sbi->user_block_count) { | ||
119 | spin_unlock(&sbi->stat_lock); | ||
120 | return -EINVAL; | ||
121 | } | ||
122 | *ui = t; | ||
123 | spin_unlock(&sbi->stat_lock); | ||
124 | return count; | ||
125 | } | ||
114 | *ui = t; | 126 | *ui = t; |
115 | return count; | 127 | return count; |
116 | } | 128 | } |
@@ -165,6 +177,7 @@ F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_no_gc_sleep_time, no_gc_sleep_time); | |||
165 | F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_idle, gc_idle); | 177 | F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_idle, gc_idle); |
166 | F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, reclaim_segments, rec_prefree_segments); | 178 | F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, reclaim_segments, rec_prefree_segments); |
167 | F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_small_discards, max_discards); | 179 | F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_small_discards, max_discards); |
180 | F2FS_RW_ATTR(RESERVED_BLOCKS, f2fs_sb_info, reserved_blocks, reserved_blocks); | ||
168 | F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, batched_trim_sections, trim_sections); | 181 | F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, batched_trim_sections, trim_sections); |
169 | F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, ipu_policy, ipu_policy); | 182 | F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, ipu_policy, ipu_policy); |
170 | F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_ipu_util, min_ipu_util); | 183 | F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_ipu_util, min_ipu_util); |
@@ -208,6 +221,7 @@ static struct attribute *f2fs_attrs[] = { | |||
208 | ATTR_LIST(inject_type), | 221 | ATTR_LIST(inject_type), |
209 | #endif | 222 | #endif |
210 | ATTR_LIST(lifetime_write_kbytes), | 223 | ATTR_LIST(lifetime_write_kbytes), |
224 | ATTR_LIST(reserved_blocks), | ||
211 | NULL, | 225 | NULL, |
212 | }; | 226 | }; |
213 | 227 | ||