Skip to content

Commit 6d8ef53

Browse files
committed
Merge tag 'f2fs-for-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs
Pull f2fs updates from Jaegeuk Kim: "In this round, we've mostly tuned f2fs to provide better user experience for Android. Especially, we've worked on atomic write feature again with SQLite community in order to support it officially. And we added or modified several facilities to analyze and enhance IO behaviors. Major changes include: - add app/fs io stat - add inode checksum feature - support project/journalled quota - enhance atomic write with new ioctl() which exposes feature set - enhance background gc/discard/fstrim flows with new gc_urgent mode - add F2FS_IOC_FS{GET,SET}XATTR - fix some quota flows" * tag 'f2fs-for-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (63 commits) f2fs: hurry up to issue discard after io interruption f2fs: fix to show correct discard_granularity in sysfs f2fs: detect dirty inode in evict_inode f2fs: clear radix tree dirty tag of pages whose dirty flag is cleared f2fs: speed up gc_urgent mode with SSR f2fs: better to wait for fstrim completion f2fs: avoid race in between read xattr & write xattr f2fs: make get_lock_data_page to handle encrypted inode f2fs: use generic terms used for encrypted block management f2fs: introduce f2fs_encrypted_file for clean-up Revert "f2fs: add a new function get_ssr_cost" f2fs: constify super_operations f2fs: fix to wake up all sleeping flusher f2fs: avoid race in between atomic_read & atomic_inc f2fs: remove unneeded parameter of change_curseg f2fs: update i_flags correctly f2fs: don't check inode's checksum if it was dirtied or writebacked f2fs: don't need to update inode checksum for recovery f2fs: trigger fdatasync for non-atomic_write file f2fs: fix to avoid race in between aio and gc ...
2 parents cdb897e + e6c6de1 commit 6d8ef53

File tree

22 files changed

+2228
-511
lines changed

22 files changed

+2228
-511
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ Contact: "Jaegeuk Kim" <[email protected]>
5757
Description:
5858
Controls the issue rate of small discard commands.
5959

60+
What: /sys/fs/f2fs/<disk>/discard_granularity
61+
Date: July 2017
62+
Contact: "Chao Yu" <[email protected]>
63+
Description:
64+
Controls discard granularity of inner discard thread, inner thread
65+
will not issue discards with size that is smaller than granularity.
66+
The unit size is one block, now only support configuring in range
67+
of [1, 512].
68+
6069
What: /sys/fs/f2fs/<disk>/max_victim_search
6170
Date: January 2014
6271
Contact: "Jaegeuk Kim" <[email protected]>
@@ -130,3 +139,15 @@ Date: June 2017
130139
Contact: "Chao Yu" <[email protected]>
131140
Description:
132141
Controls current reserved blocks in system.
142+
143+
What: /sys/fs/f2fs/<disk>/gc_urgent
144+
Date: August 2017
145+
Contact: "Jaegeuk Kim" <[email protected]>
146+
Description:
147+
Do background GC agressively
148+
149+
What: /sys/fs/f2fs/<disk>/gc_urgent_sleep_time
150+
Date: August 2017
151+
Contact: "Jaegeuk Kim" <[email protected]>
152+
Description:
153+
Controls sleep time of GC urgent mode

Documentation/filesystems/f2fs.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,16 @@ io_bits=%u Set the bit size of write IO requests. It should be set
164164
with "mode=lfs".
165165
usrquota Enable plain user disk quota accounting.
166166
grpquota Enable plain group disk quota accounting.
167+
prjquota Enable plain project quota accounting.
168+
usrjquota=<file> Appoint specified file and type during mount, so that quota
169+
grpjquota=<file> information can be properly updated during recovery flow,
170+
prjjquota=<file> <quota file>: must be in root directory;
171+
jqfmt=<quota type> <quota type>: [vfsold,vfsv0,vfsv1].
172+
offusrjquota Turn off user journelled quota.
173+
offgrpjquota Turn off group journelled quota.
174+
offprjjquota Turn off project journelled quota.
175+
quota Enable plain user disk quota accounting.
176+
noquota Disable all plain disk quota option.
167177

168178
================================================================================
169179
DEBUGFS ENTRIES
@@ -209,6 +219,15 @@ Files in /sys/fs/f2fs/<devname>
209219
gc_idle = 1 will select the Cost Benefit approach
210220
& setting gc_idle = 2 will select the greedy approach.
211221

222+
gc_urgent This parameter controls triggering background GCs
223+
urgently or not. Setting gc_urgent = 0 [default]
224+
makes back to default behavior, while if it is set
225+
to 1, background thread starts to do GC by given
226+
gc_urgent_sleep_time interval.
227+
228+
gc_urgent_sleep_time This parameter controls sleep time for gc_urgent.
229+
500 ms is set by default. See above gc_urgent.
230+
212231
reclaim_segments This parameter controls the number of prefree
213232
segments to be reclaimed. If the number of prefree
214233
segments is larger than the number of segments

fs/f2fs/acl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,16 @@ static int __f2fs_set_acl(struct inode *inode, int type,
207207
void *value = NULL;
208208
size_t size = 0;
209209
int error;
210+
umode_t mode = inode->i_mode;
210211

211212
switch (type) {
212213
case ACL_TYPE_ACCESS:
213214
name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS;
214215
if (acl && !ipage) {
215-
error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
216+
error = posix_acl_update_mode(inode, &mode, &acl);
216217
if (error)
217218
return error;
218-
set_acl_inode(inode, inode->i_mode);
219+
set_acl_inode(inode, mode);
219220
}
220221
break;
221222

fs/f2fs/checkpoint.c

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,9 @@ void ra_meta_pages_cond(struct f2fs_sb_info *sbi, pgoff_t index)
230230
ra_meta_pages(sbi, index, BIO_MAX_PAGES, META_POR, true);
231231
}
232232

233-
static int f2fs_write_meta_page(struct page *page,
234-
struct writeback_control *wbc)
233+
static int __f2fs_write_meta_page(struct page *page,
234+
struct writeback_control *wbc,
235+
enum iostat_type io_type)
235236
{
236237
struct f2fs_sb_info *sbi = F2FS_P_SB(page);
237238

@@ -244,7 +245,7 @@ static int f2fs_write_meta_page(struct page *page,
244245
if (unlikely(f2fs_cp_error(sbi)))
245246
goto redirty_out;
246247

247-
write_meta_page(sbi, page);
248+
write_meta_page(sbi, page, io_type);
248249
dec_page_count(sbi, F2FS_DIRTY_META);
249250

250251
if (wbc->for_reclaim)
@@ -263,6 +264,12 @@ static int f2fs_write_meta_page(struct page *page,
263264
return AOP_WRITEPAGE_ACTIVATE;
264265
}
265266

267+
static int f2fs_write_meta_page(struct page *page,
268+
struct writeback_control *wbc)
269+
{
270+
return __f2fs_write_meta_page(page, wbc, FS_META_IO);
271+
}
272+
266273
static int f2fs_write_meta_pages(struct address_space *mapping,
267274
struct writeback_control *wbc)
268275
{
@@ -283,7 +290,7 @@ static int f2fs_write_meta_pages(struct address_space *mapping,
283290

284291
trace_f2fs_writepages(mapping->host, wbc, META);
285292
diff = nr_pages_to_write(sbi, META, wbc);
286-
written = sync_meta_pages(sbi, META, wbc->nr_to_write);
293+
written = sync_meta_pages(sbi, META, wbc->nr_to_write, FS_META_IO);
287294
mutex_unlock(&sbi->cp_mutex);
288295
wbc->nr_to_write = max((long)0, wbc->nr_to_write - written - diff);
289296
return 0;
@@ -295,7 +302,7 @@ static int f2fs_write_meta_pages(struct address_space *mapping,
295302
}
296303

297304
long sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
298-
long nr_to_write)
305+
long nr_to_write, enum iostat_type io_type)
299306
{
300307
struct address_space *mapping = META_MAPPING(sbi);
301308
pgoff_t index = 0, end = ULONG_MAX, prev = ULONG_MAX;
@@ -346,7 +353,7 @@ long sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
346353
if (!clear_page_dirty_for_io(page))
347354
goto continue_unlock;
348355

349-
if (mapping->a_ops->writepage(page, &wbc)) {
356+
if (__f2fs_write_meta_page(page, &wbc, io_type)) {
350357
unlock_page(page);
351358
break;
352359
}
@@ -581,11 +588,24 @@ static int recover_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
581588
int recover_orphan_inodes(struct f2fs_sb_info *sbi)
582589
{
583590
block_t start_blk, orphan_blocks, i, j;
584-
int err;
591+
unsigned int s_flags = sbi->sb->s_flags;
592+
int err = 0;
585593

586594
if (!is_set_ckpt_flags(sbi, CP_ORPHAN_PRESENT_FLAG))
587595
return 0;
588596

597+
if (s_flags & MS_RDONLY) {
598+
f2fs_msg(sbi->sb, KERN_INFO, "orphan cleanup on readonly fs");
599+
sbi->sb->s_flags &= ~MS_RDONLY;
600+
}
601+
602+
#ifdef CONFIG_QUOTA
603+
/* Needed for iput() to work correctly and not trash data */
604+
sbi->sb->s_flags |= MS_ACTIVE;
605+
/* Turn on quotas so that they are updated correctly */
606+
f2fs_enable_quota_files(sbi);
607+
#endif
608+
589609
start_blk = __start_cp_addr(sbi) + 1 + __cp_payload(sbi);
590610
orphan_blocks = __start_sum_addr(sbi) - 1 - __cp_payload(sbi);
591611

@@ -601,14 +621,21 @@ int recover_orphan_inodes(struct f2fs_sb_info *sbi)
601621
err = recover_orphan_inode(sbi, ino);
602622
if (err) {
603623
f2fs_put_page(page, 1);
604-
return err;
624+
goto out;
605625
}
606626
}
607627
f2fs_put_page(page, 1);
608628
}
609629
/* clear Orphan Flag */
610630
clear_ckpt_flags(sbi, CP_ORPHAN_PRESENT_FLAG);
611-
return 0;
631+
out:
632+
#ifdef CONFIG_QUOTA
633+
/* Turn quotas off */
634+
f2fs_quota_off_umount(sbi->sb);
635+
#endif
636+
sbi->sb->s_flags = s_flags; /* Restore MS_RDONLY status */
637+
638+
return err;
612639
}
613640

614641
static void write_orphan_inodes(struct f2fs_sb_info *sbi, block_t start_blk)
@@ -904,7 +931,14 @@ int sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
904931
if (inode) {
905932
unsigned long cur_ino = inode->i_ino;
906933

934+
if (is_dir)
935+
F2FS_I(inode)->cp_task = current;
936+
907937
filemap_fdatawrite(inode->i_mapping);
938+
939+
if (is_dir)
940+
F2FS_I(inode)->cp_task = NULL;
941+
908942
iput(inode);
909943
/* We need to give cpu to another writers. */
910944
if (ino == cur_ino) {
@@ -1017,7 +1051,7 @@ static int block_operations(struct f2fs_sb_info *sbi)
10171051

10181052
if (get_pages(sbi, F2FS_DIRTY_NODES)) {
10191053
up_write(&sbi->node_write);
1020-
err = sync_node_pages(sbi, &wbc);
1054+
err = sync_node_pages(sbi, &wbc, false, FS_CP_NODE_IO);
10211055
if (err) {
10221056
up_write(&sbi->node_change);
10231057
f2fs_unlock_all(sbi);
@@ -1115,7 +1149,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
11151149

11161150
/* Flush all the NAT/SIT pages */
11171151
while (get_pages(sbi, F2FS_DIRTY_META)) {
1118-
sync_meta_pages(sbi, META, LONG_MAX);
1152+
sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
11191153
if (unlikely(f2fs_cp_error(sbi)))
11201154
return -EIO;
11211155
}
@@ -1194,7 +1228,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
11941228

11951229
/* Flush all the NAT BITS pages */
11961230
while (get_pages(sbi, F2FS_DIRTY_META)) {
1197-
sync_meta_pages(sbi, META, LONG_MAX);
1231+
sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
11981232
if (unlikely(f2fs_cp_error(sbi)))
11991233
return -EIO;
12001234
}
@@ -1249,7 +1283,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
12491283
percpu_counter_set(&sbi->alloc_valid_block_count, 0);
12501284

12511285
/* Here, we only have one bio having CP pack */
1252-
sync_meta_pages(sbi, META_FLUSH, LONG_MAX);
1286+
sync_meta_pages(sbi, META_FLUSH, LONG_MAX, FS_CP_META_IO);
12531287

12541288
/* wait for previous submitted meta pages writeback */
12551289
wait_on_all_pages_writeback(sbi);

0 commit comments

Comments
 (0)