Skip to content

Commit 6d61a53

Browse files
committed
Merge tag 'f2fs-for-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs
Pull f2fs updates from Jaegeuk Kim: "In this series, there are several major improvements such as folio conversion by Matthew, speed-up of block truncation, and caching more dentry pages. In addition, we implemented a linear dentry search to address recent unicode regression, and figured out some false alarms that we could get rid of. Enhancements: - foilio conversion in various IO paths - optimize f2fs_truncate_data_blocks_range() - cache more dentry pages - remove unnecessary blk_finish_plug - procfs: show mtime in segment_bits Bug fixes: - introduce linear search for dentries - don't call block truncation for aliased file - fix using wrong 'submitted' value in f2fs_write_cache_pages - fix to do sanity check correctly on i_inline_xattr_size - avoid trying to get invalid block address - fix inconsistent dirty state of atomic file" * tag 'f2fs-for-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (32 commits) f2fs: fix inconsistent dirty state of atomic file f2fs: fix to avoid changing 'check only' behaior of recovery f2fs: Clean up the loop outside of f2fs_invalidate_blocks() f2fs: procfs: show mtime in segment_bits f2fs: fix to avoid return invalid mtime from f2fs_get_section_mtime() f2fs: Fix format specifier in sanity_check_inode() f2fs: avoid trying to get invalid block address f2fs: fix to do sanity check correctly on i_inline_xattr_size f2fs: remove blk_finish_plug f2fs: Optimize f2fs_truncate_data_blocks_range() f2fs: fix using wrong 'submitted' value in f2fs_write_cache_pages f2fs: add parameter @len to f2fs_invalidate_blocks() f2fs: update_sit_entry_for_release() supports consecutive blocks. f2fs: introduce update_sit_entry_for_release/alloc() f2fs: don't call block truncation for aliased file f2fs: Introduce linear search for dentries f2fs: add parameter @len to f2fs_invalidate_internal_cache() f2fs: expand f2fs_invalidate_compress_page() to f2fs_invalidate_compress_pages_range() f2fs: ensure that node info flags are always initialized f2fs: The GC triggered by ioctl also needs to mark the segno as victim ...
2 parents f34b580 + 03511e9 commit 6d61a53

File tree

14 files changed

+324
-201
lines changed

14 files changed

+324
-201
lines changed

fs/f2fs/compress.c

+23-15
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t index)
846846
bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct page **pages,
847847
int index, int nr_pages, bool uptodate)
848848
{
849-
unsigned long pgidx = pages[index]->index;
849+
unsigned long pgidx = page_folio(pages[index])->index;
850850
int i = uptodate ? 0 : 1;
851851

852852
/*
@@ -860,9 +860,11 @@ bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct page **pages,
860860
return false;
861861

862862
for (; i < cc->cluster_size; i++) {
863-
if (pages[index + i]->index != pgidx + i)
863+
struct folio *folio = page_folio(pages[index + i]);
864+
865+
if (folio->index != pgidx + i)
864866
return false;
865-
if (uptodate && !PageUptodate(pages[index + i]))
867+
if (uptodate && !folio_test_uptodate(folio))
866868
return false;
867869
}
868870

@@ -1195,7 +1197,8 @@ bool f2fs_compress_write_end(struct inode *inode, void *fsdata,
11951197
.cluster_size = F2FS_I(inode)->i_cluster_size,
11961198
.rpages = fsdata,
11971199
};
1198-
bool first_index = (index == cc.rpages[0]->index);
1200+
struct folio *folio = page_folio(cc.rpages[0]);
1201+
bool first_index = (index == folio->index);
11991202

12001203
if (copied)
12011204
set_cluster_dirty(&cc);
@@ -1239,13 +1242,14 @@ int f2fs_truncate_partial_cluster(struct inode *inode, u64 from, bool lock)
12391242
int i;
12401243

12411244
for (i = cluster_size - 1; i >= 0; i--) {
1242-
loff_t start = rpages[i]->index << PAGE_SHIFT;
1245+
struct folio *folio = page_folio(rpages[i]);
1246+
loff_t start = folio->index << PAGE_SHIFT;
12431247

12441248
if (from <= start) {
1245-
zero_user_segment(rpages[i], 0, PAGE_SIZE);
1249+
folio_zero_segment(folio, 0, folio_size(folio));
12461250
} else {
1247-
zero_user_segment(rpages[i], from - start,
1248-
PAGE_SIZE);
1251+
folio_zero_segment(folio, from - start,
1252+
folio_size(folio));
12491253
break;
12501254
}
12511255
}
@@ -1278,6 +1282,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
12781282
.encrypted = fscrypt_inode_uses_fs_layer_crypto(cc->inode) ?
12791283
1 : 0,
12801284
};
1285+
struct folio *folio;
12811286
struct dnode_of_data dn;
12821287
struct node_info ni;
12831288
struct compress_io_ctx *cic;
@@ -1289,7 +1294,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
12891294

12901295
/* we should bypass data pages to proceed the kworker jobs */
12911296
if (unlikely(f2fs_cp_error(sbi))) {
1292-
mapping_set_error(cc->rpages[0]->mapping, -EIO);
1297+
mapping_set_error(inode->i_mapping, -EIO);
12931298
goto out_free;
12941299
}
12951300

@@ -1316,7 +1321,8 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
13161321
goto out_put_dnode;
13171322
}
13181323

1319-
psize = (loff_t)(cc->rpages[last_index]->index + 1) << PAGE_SHIFT;
1324+
folio = page_folio(cc->rpages[last_index]);
1325+
psize = folio_pos(folio) + folio_size(folio);
13201326

13211327
err = f2fs_get_node_info(fio.sbi, dn.nid, &ni, false);
13221328
if (err)
@@ -1339,7 +1345,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
13391345

13401346
for (i = 0; i < cc->valid_nr_cpages; i++) {
13411347
f2fs_set_compressed_page(cc->cpages[i], inode,
1342-
cc->rpages[i + 1]->index, cic);
1348+
page_folio(cc->rpages[i + 1])->index, cic);
13431349
fio.compressed_page = cc->cpages[i];
13441350

13451351
fio.old_blkaddr = data_blkaddr(dn.inode, dn.node_page,
@@ -1374,7 +1380,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
13741380
if (blkaddr == COMPRESS_ADDR)
13751381
fio.compr_blocks++;
13761382
if (__is_valid_data_blkaddr(blkaddr))
1377-
f2fs_invalidate_blocks(sbi, blkaddr);
1383+
f2fs_invalidate_blocks(sbi, blkaddr, 1);
13781384
f2fs_update_data_blkaddr(&dn, COMPRESS_ADDR);
13791385
goto unlock_continue;
13801386
}
@@ -1384,7 +1390,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
13841390

13851391
if (i > cc->valid_nr_cpages) {
13861392
if (__is_valid_data_blkaddr(blkaddr)) {
1387-
f2fs_invalidate_blocks(sbi, blkaddr);
1393+
f2fs_invalidate_blocks(sbi, blkaddr, 1);
13881394
f2fs_update_data_blkaddr(&dn, NEW_ADDR);
13891395
}
13901396
goto unlock_continue;
@@ -1545,6 +1551,7 @@ static int f2fs_write_raw_pages(struct compress_ctx *cc,
15451551
if (!clear_page_dirty_for_io(cc->rpages[i]))
15461552
goto continue_unlock;
15471553

1554+
submitted = 0;
15481555
ret = f2fs_write_single_data_page(page_folio(cc->rpages[i]),
15491556
&submitted,
15501557
NULL, NULL, wbc, io_type,
@@ -1903,11 +1910,12 @@ struct address_space *COMPRESS_MAPPING(struct f2fs_sb_info *sbi)
19031910
return sbi->compress_inode->i_mapping;
19041911
}
19051912

1906-
void f2fs_invalidate_compress_page(struct f2fs_sb_info *sbi, block_t blkaddr)
1913+
void f2fs_invalidate_compress_pages_range(struct f2fs_sb_info *sbi,
1914+
block_t blkaddr, unsigned int len)
19071915
{
19081916
if (!sbi->compress_inode)
19091917
return;
1910-
invalidate_mapping_pages(COMPRESS_MAPPING(sbi), blkaddr, blkaddr);
1918+
invalidate_mapping_pages(COMPRESS_MAPPING(sbi), blkaddr, blkaddr + len - 1);
19111919
}
19121920

19131921
void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page,

fs/f2fs/data.c

+25-37
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ bool f2fs_is_cp_guaranteed(struct page *page)
7070
return false;
7171
}
7272

73-
static enum count_type __read_io_type(struct page *page)
73+
static enum count_type __read_io_type(struct folio *folio)
7474
{
75-
struct address_space *mapping = page_file_mapping(page);
75+
struct address_space *mapping = folio->mapping;
7676

7777
if (mapping) {
7878
struct inode *inode = mapping->host;
@@ -136,27 +136,22 @@ struct bio_post_read_ctx {
136136
*/
137137
static void f2fs_finish_read_bio(struct bio *bio, bool in_task)
138138
{
139-
struct bio_vec *bv;
140-
struct bvec_iter_all iter_all;
139+
struct folio_iter fi;
141140
struct bio_post_read_ctx *ctx = bio->bi_private;
142141

143-
bio_for_each_segment_all(bv, bio, iter_all) {
144-
struct page *page = bv->bv_page;
142+
bio_for_each_folio_all(fi, bio) {
143+
struct folio *folio = fi.folio;
145144

146-
if (f2fs_is_compressed_page(page)) {
145+
if (f2fs_is_compressed_page(&folio->page)) {
147146
if (ctx && !ctx->decompression_attempted)
148-
f2fs_end_read_compressed_page(page, true, 0,
147+
f2fs_end_read_compressed_page(&folio->page, true, 0,
149148
in_task);
150-
f2fs_put_page_dic(page, in_task);
149+
f2fs_put_page_dic(&folio->page, in_task);
151150
continue;
152151
}
153152

154-
if (bio->bi_status)
155-
ClearPageUptodate(page);
156-
else
157-
SetPageUptodate(page);
158-
dec_page_count(F2FS_P_SB(page), __read_io_type(page));
159-
unlock_page(page);
153+
dec_page_count(F2FS_F_SB(folio), __read_io_type(folio));
154+
folio_end_read(folio, bio->bi_status == 0);
160155
}
161156

162157
if (ctx)
@@ -516,10 +511,6 @@ static void f2fs_submit_write_bio(struct f2fs_sb_info *sbi, struct bio *bio,
516511
enum page_type type)
517512
{
518513
WARN_ON_ONCE(is_read_io(bio_op(bio)));
519-
520-
if (f2fs_lfs_mode(sbi) && current->plug && PAGE_TYPE_ON_MAIN(type))
521-
blk_finish_plug(current->plug);
522-
523514
trace_f2fs_submit_write_bio(sbi->sb, type, bio);
524515
iostat_update_submit_ctx(bio, type);
525516
submit_bio(bio);
@@ -689,33 +680,29 @@ void f2fs_flush_merged_writes(struct f2fs_sb_info *sbi)
689680
int f2fs_submit_page_bio(struct f2fs_io_info *fio)
690681
{
691682
struct bio *bio;
692-
struct page *page = fio->encrypted_page ?
693-
fio->encrypted_page : fio->page;
683+
struct folio *fio_folio = page_folio(fio->page);
684+
struct folio *data_folio = fio->encrypted_page ?
685+
page_folio(fio->encrypted_page) : fio_folio;
694686

695687
if (!f2fs_is_valid_blkaddr(fio->sbi, fio->new_blkaddr,
696688
fio->is_por ? META_POR : (__is_meta_io(fio) ?
697689
META_GENERIC : DATA_GENERIC_ENHANCE)))
698690
return -EFSCORRUPTED;
699691

700-
trace_f2fs_submit_page_bio(page, fio);
692+
trace_f2fs_submit_folio_bio(data_folio, fio);
701693

702694
/* Allocate a new bio */
703695
bio = __bio_alloc(fio, 1);
704696

705-
f2fs_set_bio_crypt_ctx(bio, fio->page->mapping->host,
706-
page_folio(fio->page)->index, fio, GFP_NOIO);
707-
708-
if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
709-
bio_put(bio);
710-
return -EFAULT;
711-
}
697+
f2fs_set_bio_crypt_ctx(bio, fio_folio->mapping->host,
698+
fio_folio->index, fio, GFP_NOIO);
699+
bio_add_folio_nofail(bio, data_folio, folio_size(data_folio), 0);
712700

713701
if (fio->io_wbc && !is_read_io(fio->op))
714-
wbc_account_cgroup_owner(fio->io_wbc, page_folio(fio->page),
715-
PAGE_SIZE);
702+
wbc_account_cgroup_owner(fio->io_wbc, fio_folio, PAGE_SIZE);
716703

717704
inc_page_count(fio->sbi, is_read_io(fio->op) ?
718-
__read_io_type(page) : WB_DATA_TYPE(fio->page, false));
705+
__read_io_type(data_folio) : WB_DATA_TYPE(fio->page, false));
719706

720707
if (is_read_io(bio_op(bio)))
721708
f2fs_submit_read_bio(fio->sbi, bio, fio->type);
@@ -894,7 +881,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
894881
__is_meta_io(fio) ? META_GENERIC : DATA_GENERIC))
895882
return -EFSCORRUPTED;
896883

897-
trace_f2fs_submit_page_bio(page, fio);
884+
trace_f2fs_submit_folio_bio(page_folio(page), fio);
898885

899886
if (bio && !page_is_mergeable(fio->sbi, bio, *fio->last_block,
900887
fio->new_blkaddr))
@@ -1018,7 +1005,7 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio)
10181005

10191006
io->last_block_in_bio = fio->new_blkaddr;
10201007

1021-
trace_f2fs_submit_page_write(fio->page, fio);
1008+
trace_f2fs_submit_folio_write(page_folio(fio->page), fio);
10221009
#ifdef CONFIG_BLK_DEV_ZONED
10231010
if (f2fs_sb_has_blkzoned(sbi) && btype < META &&
10241011
is_end_zone_blkaddr(sbi, fio->new_blkaddr)) {
@@ -1289,7 +1276,7 @@ struct page *f2fs_find_data_page(struct inode *inode, pgoff_t index,
12891276
struct address_space *mapping = inode->i_mapping;
12901277
struct page *page;
12911278

1292-
page = find_get_page(mapping, index);
1279+
page = find_get_page_flags(mapping, index, FGP_ACCESSED);
12931280
if (page && PageUptodate(page))
12941281
return page;
12951282
f2fs_put_page(page, 0);
@@ -1423,7 +1410,7 @@ static int __allocate_data_block(struct dnode_of_data *dn, int seg_type)
14231410
return err;
14241411

14251412
if (GET_SEGNO(sbi, old_blkaddr) != NULL_SEGNO)
1426-
f2fs_invalidate_internal_cache(sbi, old_blkaddr);
1413+
f2fs_invalidate_internal_cache(sbi, old_blkaddr, 1);
14271414

14281415
f2fs_update_data_blkaddr(dn, dn->data_blkaddr);
14291416
return 0;
@@ -2464,7 +2451,7 @@ static int f2fs_mpage_readpages(struct inode *inode,
24642451

24652452
static int f2fs_read_data_folio(struct file *file, struct folio *folio)
24662453
{
2467-
struct inode *inode = folio_file_mapping(folio)->host;
2454+
struct inode *inode = folio->mapping->host;
24682455
int ret = -EAGAIN;
24692456

24702457
trace_f2fs_readpage(folio, DATA);
@@ -3163,6 +3150,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
31633150
continue;
31643151
}
31653152
#endif
3153+
submitted = 0;
31663154
ret = f2fs_write_single_data_page(folio,
31673155
&submitted, &bio, &last_block,
31683156
wbc, io_type, 0, true);

0 commit comments

Comments
 (0)