Skip to content

Commit 25c4e6c

Browse files
committed
Merge tag 'for-f2fs-4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs
Pull f2fs updates from Jaegeuk Kim: "This round introduces several interesting features such as on-disk NAT bitmaps, IO alignment, and a discard thread. And it includes a couple of major bug fixes as below. Enhancements: - introduce on-disk bitmaps to avoid scanning NAT blocks when getting free nids - support IO alignment to prepare open-channel SSD integration in future - introduce a discard thread to avoid long latency during checkpoint and fstrim - use SSR for warm node and enable inline_xattr by default - introduce in-memory bitmaps to check FS consistency for debugging - improve write_begin by avoiding needless read IO Bug fixes: - fix broken zone_reset behavior for SMR drive - fix wrong victim selection policy during GC - fix missing behavior when preparing discard commands - fix bugs in atomic write support and fiemap - workaround to handle multiple f2fs_add_link calls having same name ... and it includes a bunch of clean-up patches as well" * tag 'for-f2fs-4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (97 commits) f2fs: avoid to flush nat journal entries f2fs: avoid to issue redundant discard commands f2fs: fix a plint compile warning f2fs: add f2fs_drop_inode tracepoint f2fs: Fix zoned block device support f2fs: remove redundant set_page_dirty() f2fs: fix to enlarge size of write_io_dummy mempool f2fs: fix memory leak of write_io_dummy mempool during umount f2fs: fix to update F2FS_{CP_}WB_DATA count correctly f2fs: use MAX_FREE_NIDS for the free nids target f2fs: introduce free nid bitmap f2fs: new helper cur_cp_crc() getting crc in f2fs_checkpoint f2fs: update the comment of default nr_pages to skipping f2fs: drop the duplicate pval in f2fs_getxattr f2fs: Don't update the xattr data that same as the exist f2fs: kill __is_extent_same f2fs: avoid bggc->fggc when enough free segments are avaliable after cp f2fs: select target segment with closer temperature in SSR mode f2fs: show simple call stack in fault injection message f2fs: no need lock_op in f2fs_write_inline_data ...
2 parents 6053dc9 + 900f736 commit 25c4e6c

File tree

21 files changed

+1966
-810
lines changed

21 files changed

+1966
-810
lines changed

Documentation/filesystems/f2fs.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,14 @@ active_logs=%u Support configuring the number of active logs. In the
125125
disable_ext_identify Disable the extension list configured by mkfs, so f2fs
126126
does not aware of cold files such as media files.
127127
inline_xattr Enable the inline xattrs feature.
128+
noinline_xattr Disable the inline xattrs feature.
128129
inline_data Enable the inline data feature: New created small(<~3.4k)
129130
files can be written into inode block.
130131
inline_dentry Enable the inline dir feature: data in new created
131132
directory entries can be written into inode block. The
132133
space of inode block which is used to store inline
133134
dentries is limited to ~3.4k.
134-
noinline_dentry Diable the inline dentry feature.
135+
noinline_dentry Disable the inline dentry feature.
135136
flush_merge Merge concurrent cache_flush commands as much as possible
136137
to eliminate redundant command issues. If the underlying
137138
device handles the cache_flush command relatively slowly,
@@ -157,6 +158,8 @@ data_flush Enable data flushing before checkpoint in order to
157158
mode=%s Control block allocation mode which supports "adaptive"
158159
and "lfs". In "lfs" mode, there should be no random
159160
writes towards main area.
161+
io_bits=%u Set the bit size of write IO requests. It should be set
162+
with "mode=lfs".
160163

161164
================================================================================
162165
DEBUGFS ENTRIES
@@ -174,7 +177,7 @@ f2fs. Each file shows the whole f2fs information.
174177
SYSFS ENTRIES
175178
================================================================================
176179

177-
Information about mounted f2f2 file systems can be found in
180+
Information about mounted f2fs file systems can be found in
178181
/sys/fs/f2fs. Each mounted filesystem will have a directory in
179182
/sys/fs/f2fs based on its device name (i.e., /sys/fs/f2fs/sda).
180183
The files in each per-device directory are shown in table below.

fs/f2fs/checkpoint.c

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ static int f2fs_write_meta_page(struct page *page,
249249
dec_page_count(sbi, F2FS_DIRTY_META);
250250

251251
if (wbc->for_reclaim)
252-
f2fs_submit_merged_bio_cond(sbi, NULL, page, 0, META, WRITE);
252+
f2fs_submit_merged_bio_cond(sbi, page->mapping->host,
253+
0, page->index, META, WRITE);
253254

254255
unlock_page(page);
255256

@@ -493,6 +494,7 @@ int acquire_orphan_inode(struct f2fs_sb_info *sbi)
493494
#ifdef CONFIG_F2FS_FAULT_INJECTION
494495
if (time_to_inject(sbi, FAULT_ORPHAN)) {
495496
spin_unlock(&im->ino_lock);
497+
f2fs_show_injection_info(FAULT_ORPHAN);
496498
return -ENOSPC;
497499
}
498500
#endif
@@ -681,8 +683,7 @@ static int get_checkpoint_version(struct f2fs_sb_info *sbi, block_t cp_addr,
681683
return -EINVAL;
682684
}
683685

684-
crc = le32_to_cpu(*((__le32 *)((unsigned char *)*cp_block
685-
+ crc_offset)));
686+
crc = cur_cp_crc(*cp_block);
686687
if (!f2fs_crc_valid(sbi, crc, *cp_block, crc_offset)) {
687688
f2fs_msg(sbi->sb, KERN_WARNING, "invalid crc value");
688689
return -EINVAL;
@@ -891,7 +892,7 @@ int sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
891892
F2FS_DIRTY_DENTS : F2FS_DIRTY_DATA));
892893
return 0;
893894
}
894-
fi = list_entry(head->next, struct f2fs_inode_info, dirty_list);
895+
fi = list_first_entry(head, struct f2fs_inode_info, dirty_list);
895896
inode = igrab(&fi->vfs_inode);
896897
spin_unlock(&sbi->inode_lock[type]);
897898
if (inode) {
@@ -924,7 +925,7 @@ int f2fs_sync_inode_meta(struct f2fs_sb_info *sbi)
924925
spin_unlock(&sbi->inode_lock[DIRTY_META]);
925926
return 0;
926927
}
927-
fi = list_entry(head->next, struct f2fs_inode_info,
928+
fi = list_first_entry(head, struct f2fs_inode_info,
928929
gdirty_list);
929930
inode = igrab(&fi->vfs_inode);
930931
spin_unlock(&sbi->inode_lock[DIRTY_META]);
@@ -998,8 +999,6 @@ static int block_operations(struct f2fs_sb_info *sbi)
998999
static void unblock_operations(struct f2fs_sb_info *sbi)
9991000
{
10001001
up_write(&sbi->node_write);
1001-
1002-
build_free_nids(sbi, false);
10031002
f2fs_unlock_all(sbi);
10041003
}
10051004

@@ -1025,6 +1024,10 @@ static void update_ckpt_flags(struct f2fs_sb_info *sbi, struct cp_control *cpc)
10251024

10261025
spin_lock(&sbi->cp_lock);
10271026

1027+
if (cpc->reason == CP_UMOUNT && ckpt->cp_pack_total_block_count >
1028+
sbi->blocks_per_seg - NM_I(sbi)->nat_bits_blocks)
1029+
disable_nat_bits(sbi, false);
1030+
10281031
if (cpc->reason == CP_UMOUNT)
10291032
__set_ckpt_flags(ckpt, CP_UMOUNT_FLAG);
10301033
else
@@ -1137,6 +1140,28 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
11371140

11381141
start_blk = __start_cp_next_addr(sbi);
11391142

1143+
/* write nat bits */
1144+
if (enabled_nat_bits(sbi, cpc)) {
1145+
__u64 cp_ver = cur_cp_version(ckpt);
1146+
unsigned int i;
1147+
block_t blk;
1148+
1149+
cp_ver |= ((__u64)crc32 << 32);
1150+
*(__le64 *)nm_i->nat_bits = cpu_to_le64(cp_ver);
1151+
1152+
blk = start_blk + sbi->blocks_per_seg - nm_i->nat_bits_blocks;
1153+
for (i = 0; i < nm_i->nat_bits_blocks; i++)
1154+
update_meta_page(sbi, nm_i->nat_bits +
1155+
(i << F2FS_BLKSIZE_BITS), blk + i);
1156+
1157+
/* Flush all the NAT BITS pages */
1158+
while (get_pages(sbi, F2FS_DIRTY_META)) {
1159+
sync_meta_pages(sbi, META, LONG_MAX);
1160+
if (unlikely(f2fs_cp_error(sbi)))
1161+
return -EIO;
1162+
}
1163+
}
1164+
11401165
/* need to wait for end_io results */
11411166
wait_on_all_pages_writeback(sbi);
11421167
if (unlikely(f2fs_cp_error(sbi)))
@@ -1248,15 +1273,20 @@ int write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
12481273
f2fs_flush_merged_bios(sbi);
12491274

12501275
/* this is the case of multiple fstrims without any changes */
1251-
if (cpc->reason == CP_DISCARD && !is_sbi_flag_set(sbi, SBI_IS_DIRTY)) {
1252-
f2fs_bug_on(sbi, NM_I(sbi)->dirty_nat_cnt);
1253-
f2fs_bug_on(sbi, SIT_I(sbi)->dirty_sentries);
1254-
f2fs_bug_on(sbi, prefree_segments(sbi));
1255-
flush_sit_entries(sbi, cpc);
1256-
clear_prefree_segments(sbi, cpc);
1257-
f2fs_wait_all_discard_bio(sbi);
1258-
unblock_operations(sbi);
1259-
goto out;
1276+
if (cpc->reason == CP_DISCARD) {
1277+
if (!exist_trim_candidates(sbi, cpc)) {
1278+
unblock_operations(sbi);
1279+
goto out;
1280+
}
1281+
1282+
if (NM_I(sbi)->dirty_nat_cnt == 0 &&
1283+
SIT_I(sbi)->dirty_sentries == 0 &&
1284+
prefree_segments(sbi) == 0) {
1285+
flush_sit_entries(sbi, cpc);
1286+
clear_prefree_segments(sbi, cpc);
1287+
unblock_operations(sbi);
1288+
goto out;
1289+
}
12601290
}
12611291

12621292
/*
@@ -1268,17 +1298,15 @@ int write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
12681298
ckpt->checkpoint_ver = cpu_to_le64(++ckpt_ver);
12691299

12701300
/* write cached NAT/SIT entries to NAT/SIT area */
1271-
flush_nat_entries(sbi);
1301+
flush_nat_entries(sbi, cpc);
12721302
flush_sit_entries(sbi, cpc);
12731303

12741304
/* unlock all the fs_lock[] in do_checkpoint() */
12751305
err = do_checkpoint(sbi, cpc);
1276-
if (err) {
1306+
if (err)
12771307
release_discard_addrs(sbi);
1278-
} else {
1308+
else
12791309
clear_prefree_segments(sbi, cpc);
1280-
f2fs_wait_all_discard_bio(sbi);
1281-
}
12821310

12831311
unblock_operations(sbi);
12841312
stat_inc_cp_count(sbi->stat_info);

0 commit comments

Comments
 (0)