Skip to content

Commit 72ece20

Browse files
committed
Merge tag 'f2fs-for-6.10.rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs
Pull f2fs updates from Jaegeuk Kim: "In this round, we've tried to address some performance issues on zoned storage such as direct IO and write_hints. In addition, we've migrated some IO paths using folio. Meanwhile, there are multiple bug fixes in the compression paths, sanity check conditions, and error handlers. Enhancements: - allow direct io of pinned files for zoned storage - assign the write hint per stream by default - convert read paths and test_writeback to folio - avoid allocating WARM_DATA segment for direct IO Bug fixes: - fix false alarm on invalid block address - fix to add missing iput() in gc_data_segment() - fix to release node block count in error path of f2fs_new_node_page() - compress: - don't allow unaligned truncation on released compress inode - cover {reserve,release}_compress_blocks() w/ cp_rwsem lock - fix error path of inc_valid_block_count() - fix to update i_compr_blocks correctly - fix block migration when section is not aligned to pow2 - don't trigger OPU on pinfile for direct IO - fix to do sanity check on i_xattr_nid in sanity_check_inode() - write missing last sum blk of file pinning section - clear writeback when compression failed - fix to adjust appropirate defragment pg_end As usual, there are several minor code clean-ups, and fixes to manage missing corner cases in the error paths" * tag 'f2fs-for-6.10.rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (50 commits) f2fs: initialize last_block_in_bio variable f2fs: Add inline to f2fs_build_fault_attr() stub f2fs: fix some ambiguous comments f2fs: fix to add missing iput() in gc_data_segment() f2fs: allow dirty sections with zero valid block for checkpoint disabled f2fs: compress: don't allow unaligned truncation on released compress inode f2fs: fix to release node block count in error path of f2fs_new_node_page() f2fs: compress: fix to cover {reserve,release}_compress_blocks() w/ cp_rwsem lock f2fs: compress: fix error path of inc_valid_block_count() f2fs: compress: fix typo in f2fs_reserve_compress_blocks() f2fs: compress: fix to update i_compr_blocks correctly f2fs: check validation of fault attrs in f2fs_build_fault_attr() f2fs: fix to limit gc_pin_file_threshold f2fs: remove unused GC_FAILURE_PIN f2fs: use f2fs_{err,info}_ratelimited() for cleanup f2fs: fix block migration when section is not aligned to pow2 f2fs: zone: fix to don't trigger OPU on pinfile for direct IO f2fs: fix to do sanity check on i_xattr_nid in sanity_check_inode() f2fs: fix to avoid allocating WARM_DATA segment for direct IO f2fs: remove redundant parameter in is_next_segment_free() ...
2 parents 119d1b8 + 16409fd commit 72ece20

File tree

18 files changed

+688
-374
lines changed

18 files changed

+688
-374
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ Date: January 2018
331331
Contact: Jaegeuk Kim <jaegeuk@kernel.org>
332332
Description: This indicates how many GC can be failed for the pinned
333333
file. If it exceeds this, F2FS doesn't guarantee its pinning
334-
state. 2048 trials is set by default.
334+
state. 2048 trials is set by default, and 65535 as maximum.
335335

336336
What: /sys/fs/f2fs/<disk>/extension_list
337337
Date: February 2018

Documentation/filesystems/f2fs.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,35 @@ In order to identify whether the data in the victim segment are valid or not,
774774
F2FS manages a bitmap. Each bit represents the validity of a block, and the
775775
bitmap is composed of a bit stream covering whole blocks in main area.
776776

777+
Write-hint Policy
778+
-----------------
779+
780+
F2FS sets the whint all the time with the below policy.
781+
782+
===================== ======================== ===================
783+
User F2FS Block
784+
===================== ======================== ===================
785+
N/A META WRITE_LIFE_NONE|REQ_META
786+
N/A HOT_NODE WRITE_LIFE_NONE
787+
N/A WARM_NODE WRITE_LIFE_MEDIUM
788+
N/A COLD_NODE WRITE_LIFE_LONG
789+
ioctl(COLD) COLD_DATA WRITE_LIFE_EXTREME
790+
extension list " "
791+
792+
-- buffered io
793+
N/A COLD_DATA WRITE_LIFE_EXTREME
794+
N/A HOT_DATA WRITE_LIFE_SHORT
795+
N/A WARM_DATA WRITE_LIFE_NOT_SET
796+
797+
-- direct io
798+
WRITE_LIFE_EXTREME COLD_DATA WRITE_LIFE_EXTREME
799+
WRITE_LIFE_SHORT HOT_DATA WRITE_LIFE_SHORT
800+
WRITE_LIFE_NOT_SET WARM_DATA WRITE_LIFE_NOT_SET
801+
WRITE_LIFE_NONE " WRITE_LIFE_NONE
802+
WRITE_LIFE_MEDIUM " WRITE_LIFE_MEDIUM
803+
WRITE_LIFE_LONG " WRITE_LIFE_LONG
804+
===================== ======================== ===================
805+
777806
Fallocate(2) Policy
778807
-------------------
779808

fs/f2fs/checkpoint.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,22 +179,22 @@ static bool __f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
179179
break;
180180
case META_SIT:
181181
if (unlikely(blkaddr >= SIT_BLK_CNT(sbi)))
182-
goto err;
182+
goto check_only;
183183
break;
184184
case META_SSA:
185185
if (unlikely(blkaddr >= MAIN_BLKADDR(sbi) ||
186186
blkaddr < SM_I(sbi)->ssa_blkaddr))
187-
goto err;
187+
goto check_only;
188188
break;
189189
case META_CP:
190190
if (unlikely(blkaddr >= SIT_I(sbi)->sit_base_addr ||
191191
blkaddr < __start_cp_addr(sbi)))
192-
goto err;
192+
goto check_only;
193193
break;
194194
case META_POR:
195195
if (unlikely(blkaddr >= MAX_BLKADDR(sbi) ||
196196
blkaddr < MAIN_BLKADDR(sbi)))
197-
goto err;
197+
goto check_only;
198198
break;
199199
case DATA_GENERIC:
200200
case DATA_GENERIC_ENHANCE:
@@ -228,6 +228,7 @@ static bool __f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
228228
return true;
229229
err:
230230
f2fs_handle_error(sbi, ERROR_INVALID_BLKADDR);
231+
check_only:
231232
return false;
232233
}
233234

@@ -345,7 +346,7 @@ static int __f2fs_write_meta_page(struct page *page,
345346
{
346347
struct f2fs_sb_info *sbi = F2FS_P_SB(page);
347348

348-
trace_f2fs_writepage(page, META);
349+
trace_f2fs_writepage(page_folio(page), META);
349350

350351
if (unlikely(f2fs_cp_error(sbi))) {
351352
if (is_sbi_flag_set(sbi, SBI_IS_CLOSE)) {
@@ -492,7 +493,7 @@ long f2fs_sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
492493
static bool f2fs_dirty_meta_folio(struct address_space *mapping,
493494
struct folio *folio)
494495
{
495-
trace_f2fs_set_page_dirty(&folio->page, META);
496+
trace_f2fs_set_page_dirty(folio, META);
496497

497498
if (!folio_test_uptodate(folio))
498499
folio_mark_uptodate(folio);

fs/f2fs/compress.c

Lines changed: 63 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ static int lzo_compress_pages(struct compress_ctx *cc)
198198
ret = lzo1x_1_compress(cc->rbuf, cc->rlen, cc->cbuf->cdata,
199199
&cc->clen, cc->private);
200200
if (ret != LZO_E_OK) {
201-
printk_ratelimited("%sF2FS-fs (%s): lzo compress failed, ret:%d\n",
202-
KERN_ERR, F2FS_I_SB(cc->inode)->sb->s_id, ret);
201+
f2fs_err_ratelimited(F2FS_I_SB(cc->inode),
202+
"lzo compress failed, ret:%d", ret);
203203
return -EIO;
204204
}
205205
return 0;
@@ -212,17 +212,15 @@ static int lzo_decompress_pages(struct decompress_io_ctx *dic)
212212
ret = lzo1x_decompress_safe(dic->cbuf->cdata, dic->clen,
213213
dic->rbuf, &dic->rlen);
214214
if (ret != LZO_E_OK) {
215-
printk_ratelimited("%sF2FS-fs (%s): lzo decompress failed, ret:%d\n",
216-
KERN_ERR, F2FS_I_SB(dic->inode)->sb->s_id, ret);
215+
f2fs_err_ratelimited(F2FS_I_SB(dic->inode),
216+
"lzo decompress failed, ret:%d", ret);
217217
return -EIO;
218218
}
219219

220220
if (dic->rlen != PAGE_SIZE << dic->log_cluster_size) {
221-
printk_ratelimited("%sF2FS-fs (%s): lzo invalid rlen:%zu, "
222-
"expected:%lu\n", KERN_ERR,
223-
F2FS_I_SB(dic->inode)->sb->s_id,
224-
dic->rlen,
225-
PAGE_SIZE << dic->log_cluster_size);
221+
f2fs_err_ratelimited(F2FS_I_SB(dic->inode),
222+
"lzo invalid rlen:%zu, expected:%lu",
223+
dic->rlen, PAGE_SIZE << dic->log_cluster_size);
226224
return -EIO;
227225
}
228226
return 0;
@@ -294,16 +292,15 @@ static int lz4_decompress_pages(struct decompress_io_ctx *dic)
294292
ret = LZ4_decompress_safe(dic->cbuf->cdata, dic->rbuf,
295293
dic->clen, dic->rlen);
296294
if (ret < 0) {
297-
printk_ratelimited("%sF2FS-fs (%s): lz4 decompress failed, ret:%d\n",
298-
KERN_ERR, F2FS_I_SB(dic->inode)->sb->s_id, ret);
295+
f2fs_err_ratelimited(F2FS_I_SB(dic->inode),
296+
"lz4 decompress failed, ret:%d", ret);
299297
return -EIO;
300298
}
301299

302300
if (ret != PAGE_SIZE << dic->log_cluster_size) {
303-
printk_ratelimited("%sF2FS-fs (%s): lz4 invalid ret:%d, "
304-
"expected:%lu\n", KERN_ERR,
305-
F2FS_I_SB(dic->inode)->sb->s_id, ret,
306-
PAGE_SIZE << dic->log_cluster_size);
301+
f2fs_err_ratelimited(F2FS_I_SB(dic->inode),
302+
"lz4 invalid ret:%d, expected:%lu",
303+
ret, PAGE_SIZE << dic->log_cluster_size);
307304
return -EIO;
308305
}
309306
return 0;
@@ -350,9 +347,8 @@ static int zstd_init_compress_ctx(struct compress_ctx *cc)
350347

351348
stream = zstd_init_cstream(&params, 0, workspace, workspace_size);
352349
if (!stream) {
353-
printk_ratelimited("%sF2FS-fs (%s): %s zstd_init_cstream failed\n",
354-
KERN_ERR, F2FS_I_SB(cc->inode)->sb->s_id,
355-
__func__);
350+
f2fs_err_ratelimited(F2FS_I_SB(cc->inode),
351+
"%s zstd_init_cstream failed", __func__);
356352
kvfree(workspace);
357353
return -EIO;
358354
}
@@ -390,16 +386,16 @@ static int zstd_compress_pages(struct compress_ctx *cc)
390386

391387
ret = zstd_compress_stream(stream, &outbuf, &inbuf);
392388
if (zstd_is_error(ret)) {
393-
printk_ratelimited("%sF2FS-fs (%s): %s zstd_compress_stream failed, ret: %d\n",
394-
KERN_ERR, F2FS_I_SB(cc->inode)->sb->s_id,
389+
f2fs_err_ratelimited(F2FS_I_SB(cc->inode),
390+
"%s zstd_compress_stream failed, ret: %d",
395391
__func__, zstd_get_error_code(ret));
396392
return -EIO;
397393
}
398394

399395
ret = zstd_end_stream(stream, &outbuf);
400396
if (zstd_is_error(ret)) {
401-
printk_ratelimited("%sF2FS-fs (%s): %s zstd_end_stream returned %d\n",
402-
KERN_ERR, F2FS_I_SB(cc->inode)->sb->s_id,
397+
f2fs_err_ratelimited(F2FS_I_SB(cc->inode),
398+
"%s zstd_end_stream returned %d",
403399
__func__, zstd_get_error_code(ret));
404400
return -EIO;
405401
}
@@ -432,9 +428,8 @@ static int zstd_init_decompress_ctx(struct decompress_io_ctx *dic)
432428

433429
stream = zstd_init_dstream(max_window_size, workspace, workspace_size);
434430
if (!stream) {
435-
printk_ratelimited("%sF2FS-fs (%s): %s zstd_init_dstream failed\n",
436-
KERN_ERR, F2FS_I_SB(dic->inode)->sb->s_id,
437-
__func__);
431+
f2fs_err_ratelimited(F2FS_I_SB(dic->inode),
432+
"%s zstd_init_dstream failed", __func__);
438433
kvfree(workspace);
439434
return -EIO;
440435
}
@@ -469,16 +464,15 @@ static int zstd_decompress_pages(struct decompress_io_ctx *dic)
469464

470465
ret = zstd_decompress_stream(stream, &outbuf, &inbuf);
471466
if (zstd_is_error(ret)) {
472-
printk_ratelimited("%sF2FS-fs (%s): %s zstd_decompress_stream failed, ret: %d\n",
473-
KERN_ERR, F2FS_I_SB(dic->inode)->sb->s_id,
467+
f2fs_err_ratelimited(F2FS_I_SB(dic->inode),
468+
"%s zstd_decompress_stream failed, ret: %d",
474469
__func__, zstd_get_error_code(ret));
475470
return -EIO;
476471
}
477472

478473
if (dic->rlen != outbuf.pos) {
479-
printk_ratelimited("%sF2FS-fs (%s): %s ZSTD invalid rlen:%zu, "
480-
"expected:%lu\n", KERN_ERR,
481-
F2FS_I_SB(dic->inode)->sb->s_id,
474+
f2fs_err_ratelimited(F2FS_I_SB(dic->inode),
475+
"%s ZSTD invalid rlen:%zu, expected:%lu",
482476
__func__, dic->rlen,
483477
PAGE_SIZE << dic->log_cluster_size);
484478
return -EIO;
@@ -1031,6 +1025,31 @@ static void set_cluster_writeback(struct compress_ctx *cc)
10311025
}
10321026
}
10331027

1028+
static void cancel_cluster_writeback(struct compress_ctx *cc,
1029+
struct compress_io_ctx *cic, int submitted)
1030+
{
1031+
int i;
1032+
1033+
/* Wait for submitted IOs. */
1034+
if (submitted > 1) {
1035+
f2fs_submit_merged_write(F2FS_I_SB(cc->inode), DATA);
1036+
while (atomic_read(&cic->pending_pages) !=
1037+
(cc->valid_nr_cpages - submitted + 1))
1038+
f2fs_io_schedule_timeout(DEFAULT_IO_TIMEOUT);
1039+
}
1040+
1041+
/* Cancel writeback and stay locked. */
1042+
for (i = 0; i < cc->cluster_size; i++) {
1043+
if (i < submitted) {
1044+
inode_inc_dirty_pages(cc->inode);
1045+
lock_page(cc->rpages[i]);
1046+
}
1047+
clear_page_private_gcing(cc->rpages[i]);
1048+
if (folio_test_writeback(page_folio(cc->rpages[i])))
1049+
end_page_writeback(cc->rpages[i]);
1050+
}
1051+
}
1052+
10341053
static void set_cluster_dirty(struct compress_ctx *cc)
10351054
{
10361055
int i;
@@ -1232,7 +1251,6 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
12321251
.page = NULL,
12331252
.encrypted_page = NULL,
12341253
.compressed_page = NULL,
1235-
.submitted = 0,
12361254
.io_type = io_type,
12371255
.io_wbc = wbc,
12381256
.encrypted = fscrypt_inode_uses_fs_layer_crypto(cc->inode) ?
@@ -1358,7 +1376,16 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
13581376
fio.compressed_page = cc->cpages[i - 1];
13591377

13601378
cc->cpages[i - 1] = NULL;
1379+
fio.submitted = 0;
13611380
f2fs_outplace_write_data(&dn, &fio);
1381+
if (unlikely(!fio.submitted)) {
1382+
cancel_cluster_writeback(cc, cic, i);
1383+
1384+
/* To call fscrypt_finalize_bounce_page */
1385+
i = cc->valid_nr_cpages;
1386+
*submitted = 0;
1387+
goto out_destroy_crypt;
1388+
}
13621389
(*submitted)++;
13631390
unlock_continue:
13641391
inode_dec_dirty_pages(cc->inode);
@@ -1392,8 +1419,11 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
13921419
out_destroy_crypt:
13931420
page_array_free(cc->inode, cic->rpages, cc->cluster_size);
13941421

1395-
for (--i; i >= 0; i--)
1422+
for (--i; i >= 0; i--) {
1423+
if (!cc->cpages[i])
1424+
continue;
13961425
fscrypt_finalize_bounce_page(&cc->cpages[i]);
1426+
}
13971427
out_put_cic:
13981428
kmem_cache_free(cic_entry_slab, cic);
13991429
out_put_dnode:
@@ -1484,7 +1514,7 @@ static int f2fs_write_raw_pages(struct compress_ctx *cc,
14841514
if (!PageDirty(cc->rpages[i]))
14851515
goto continue_unlock;
14861516

1487-
if (PageWriteback(cc->rpages[i])) {
1517+
if (folio_test_writeback(page_folio(cc->rpages[i]))) {
14881518
if (wbc->sync_mode == WB_SYNC_NONE)
14891519
goto continue_unlock;
14901520
f2fs_wait_on_page_writeback(cc->rpages[i], DATA, true, true);

0 commit comments

Comments
 (0)