Skip to content

Commit 5ad7ff8

Browse files
committed
Merge tag 'f2fs-for-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs
Pull f2fs updates from Jaegeuk Kim: "A pretty small update including mostly minor bug fixes in zoned storage along with the large section support. Enhancements: - add support for FS_IOC_GETFSSYSFSPATH - enable atgc dynamically if conditions are met - use new ioprio Macro to get ckpt thread ioprio level - remove unreachable lazytime mount option parsing Bug fixes: - fix null reference error when checking end of zone - fix start segno of large section - fix to cover read extent cache access with lock - don't dirty inode for readonly filesystem - allocate a new section if curseg is not the first seg in its zone - only fragment segment in the same section - truncate preallocated blocks in f2fs_file_open() - fix to avoid use SSR allocate when do defragment - fix to force buffered IO on inline_data inode And some minor code clean-ups and sanity checks" * tag 'f2fs-for-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (26 commits) f2fs: clean up addrs_per_{inode,block}() f2fs: clean up F2FS_I() f2fs: use meta inode for GC of COW file f2fs: use meta inode for GC of atomic file f2fs: only fragment segment in the same section f2fs: fix to update user block counts in block_operations() f2fs: remove unreachable lazytime mount option parsing f2fs: fix null reference error when checking end of zone f2fs: fix start segno of large section f2fs: remove redundant sanity check in sanity_check_inode() f2fs: assign CURSEG_ALL_DATA_ATGC if blkaddr is valid f2fs: fix to use mnt_{want,drop}_write_file replace file_{start,end}_wrtie f2fs: clean up set REQ_RAHEAD given rac f2fs: enable atgc dynamically if conditions are met f2fs: fix to truncate preallocated blocks in f2fs_file_open() f2fs: fix to cover read extent cache access with lock f2fs: fix return value of f2fs_convert_inline_inode() f2fs: use new ioprio Macro to get ckpt thread ioprio level f2fs: fix to don't dirty inode for readonly filesystem f2fs: fix to avoid use SSR allocate when do defragment ...
2 parents 371c141 + bed6b03 commit 5ad7ff8

File tree

16 files changed

+329
-226
lines changed

16 files changed

+329
-226
lines changed

fs/f2fs/checkpoint.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,11 @@ static void __prepare_cp_block(struct f2fs_sb_info *sbi)
11861186
ckpt->valid_node_count = cpu_to_le32(valid_node_count(sbi));
11871187
ckpt->valid_inode_count = cpu_to_le32(valid_inode_count(sbi));
11881188
ckpt->next_free_nid = cpu_to_le32(last_nid);
1189+
1190+
/* update user_block_counts */
1191+
sbi->last_valid_block_count = sbi->total_valid_block_count;
1192+
percpu_counter_set(&sbi->alloc_valid_block_count, 0);
1193+
percpu_counter_set(&sbi->rf_node_block_count, 0);
11891194
}
11901195

11911196
static bool __need_flush_quota(struct f2fs_sb_info *sbi)
@@ -1575,11 +1580,6 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
15751580
start_blk += NR_CURSEG_NODE_TYPE;
15761581
}
15771582

1578-
/* update user_block_counts */
1579-
sbi->last_valid_block_count = sbi->total_valid_block_count;
1580-
percpu_counter_set(&sbi->alloc_valid_block_count, 0);
1581-
percpu_counter_set(&sbi->rf_node_block_count, 0);
1582-
15831583
/* Here, we have one bio having CP pack except cp pack 2 page */
15841584
f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
15851585
/* Wait for all dirty meta pages to be submitted for IO */
@@ -1718,6 +1718,7 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
17181718
}
17191719

17201720
f2fs_restore_inmem_curseg(sbi);
1721+
f2fs_reinit_atgc_curseg(sbi);
17211722
stat_inc_cp_count(sbi);
17221723
stop:
17231724
unblock_operations(sbi);

fs/f2fs/compress.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
11001100
struct bio *bio = NULL;
11011101

11021102
ret = f2fs_read_multi_pages(cc, &bio, cc->cluster_size,
1103-
&last_block_in_bio, false, true);
1103+
&last_block_in_bio, NULL, true);
11041104
f2fs_put_rpages(cc);
11051105
f2fs_destroy_compress_ctx(cc, true);
11061106
if (ret)

fs/f2fs/data.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
925925
#ifdef CONFIG_BLK_DEV_ZONED
926926
static bool is_end_zone_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr)
927927
{
928+
struct block_device *bdev = sbi->sb->s_bdev;
928929
int devi = 0;
929930

930931
if (f2fs_is_multi_device(sbi)) {
@@ -935,8 +936,9 @@ static bool is_end_zone_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr)
935936
return false;
936937
}
937938
blkaddr -= FDEV(devi).start_blk;
939+
bdev = FDEV(devi).bdev;
938940
}
939-
return bdev_is_zoned(FDEV(devi).bdev) &&
941+
return bdev_is_zoned(bdev) &&
940942
f2fs_blkz_is_seq(sbi, devi, blkaddr) &&
941943
(blkaddr % sbi->blocks_per_blkz == sbi->blocks_per_blkz - 1);
942944
}
@@ -2067,12 +2069,17 @@ static inline loff_t f2fs_readpage_limit(struct inode *inode)
20672069
return i_size_read(inode);
20682070
}
20692071

2072+
static inline blk_opf_t f2fs_ra_op_flags(struct readahead_control *rac)
2073+
{
2074+
return rac ? REQ_RAHEAD : 0;
2075+
}
2076+
20702077
static int f2fs_read_single_page(struct inode *inode, struct folio *folio,
20712078
unsigned nr_pages,
20722079
struct f2fs_map_blocks *map,
20732080
struct bio **bio_ret,
20742081
sector_t *last_block_in_bio,
2075-
bool is_readahead)
2082+
struct readahead_control *rac)
20762083
{
20772084
struct bio *bio = *bio_ret;
20782085
const unsigned blocksize = blks_to_bytes(inode, 1);
@@ -2148,7 +2155,7 @@ static int f2fs_read_single_page(struct inode *inode, struct folio *folio,
21482155
}
21492156
if (bio == NULL) {
21502157
bio = f2fs_grab_read_bio(inode, block_nr, nr_pages,
2151-
is_readahead ? REQ_RAHEAD : 0, index,
2158+
f2fs_ra_op_flags(rac), index,
21522159
false);
21532160
if (IS_ERR(bio)) {
21542161
ret = PTR_ERR(bio);
@@ -2178,7 +2185,7 @@ static int f2fs_read_single_page(struct inode *inode, struct folio *folio,
21782185
#ifdef CONFIG_F2FS_FS_COMPRESSION
21792186
int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
21802187
unsigned nr_pages, sector_t *last_block_in_bio,
2181-
bool is_readahead, bool for_write)
2188+
struct readahead_control *rac, bool for_write)
21822189
{
21832190
struct dnode_of_data dn;
21842191
struct inode *inode = cc->inode;
@@ -2301,7 +2308,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
23012308

23022309
if (!bio) {
23032310
bio = f2fs_grab_read_bio(inode, blkaddr, nr_pages,
2304-
is_readahead ? REQ_RAHEAD : 0,
2311+
f2fs_ra_op_flags(rac),
23052312
page->index, for_write);
23062313
if (IS_ERR(bio)) {
23072314
ret = PTR_ERR(bio);
@@ -2399,7 +2406,7 @@ static int f2fs_mpage_readpages(struct inode *inode,
23992406
ret = f2fs_read_multi_pages(&cc, &bio,
24002407
max_nr_pages,
24012408
&last_block_in_bio,
2402-
rac != NULL, false);
2409+
rac, false);
24032410
f2fs_destroy_compress_ctx(&cc, false);
24042411
if (ret)
24052412
goto set_error_page;
@@ -2449,7 +2456,7 @@ static int f2fs_mpage_readpages(struct inode *inode,
24492456
ret = f2fs_read_multi_pages(&cc, &bio,
24502457
max_nr_pages,
24512458
&last_block_in_bio,
2452-
rac != NULL, false);
2459+
rac, false);
24532460
f2fs_destroy_compress_ctx(&cc, false);
24542461
}
24552462
}
@@ -2601,7 +2608,7 @@ bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio)
26012608
return true;
26022609
if (IS_NOQUOTA(inode))
26032610
return true;
2604-
if (f2fs_is_atomic_file(inode))
2611+
if (f2fs_used_in_atomic_write(inode))
26052612
return true;
26062613
/* rewrite low ratio compress data w/ OPU mode to avoid fragmentation */
26072614
if (f2fs_compressed_file(inode) &&
@@ -2688,7 +2695,7 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio)
26882695
}
26892696

26902697
/* wait for GCed page writeback via META_MAPPING */
2691-
if (fio->post_read)
2698+
if (fio->meta_gc)
26922699
f2fs_wait_on_block_writeback(inode, fio->old_blkaddr);
26932700

26942701
/*
@@ -2783,7 +2790,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
27832790
.submitted = 0,
27842791
.compr_blocks = compr_blocks,
27852792
.need_lock = compr_blocks ? LOCK_DONE : LOCK_RETRY,
2786-
.post_read = f2fs_post_read_required(inode) ? 1 : 0,
2793+
.meta_gc = f2fs_meta_inode_gc_required(inode) ? 1 : 0,
27872794
.io_type = io_type,
27882795
.io_wbc = wbc,
27892796
.bio = bio,

fs/f2fs/extent_cache.c

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,23 @@
1919
#include "node.h"
2020
#include <trace/events/f2fs.h>
2121

22-
bool sanity_check_extent_cache(struct inode *inode)
22+
bool sanity_check_extent_cache(struct inode *inode, struct page *ipage)
2323
{
2424
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
25-
struct f2fs_inode_info *fi = F2FS_I(inode);
26-
struct extent_tree *et = fi->extent_tree[EX_READ];
27-
struct extent_info *ei;
28-
29-
if (!et)
30-
return true;
25+
struct f2fs_extent *i_ext = &F2FS_INODE(ipage)->i_ext;
26+
struct extent_info ei;
3127

32-
ei = &et->largest;
33-
if (!ei->len)
34-
return true;
28+
get_read_extent_info(&ei, i_ext);
3529

36-
/* Let's drop, if checkpoint got corrupted. */
37-
if (is_set_ckpt_flags(sbi, CP_ERROR_FLAG)) {
38-
ei->len = 0;
39-
et->largest_updated = true;
30+
if (!ei.len)
4031
return true;
41-
}
4232

43-
if (!f2fs_is_valid_blkaddr(sbi, ei->blk, DATA_GENERIC_ENHANCE) ||
44-
!f2fs_is_valid_blkaddr(sbi, ei->blk + ei->len - 1,
33+
if (!f2fs_is_valid_blkaddr(sbi, ei.blk, DATA_GENERIC_ENHANCE) ||
34+
!f2fs_is_valid_blkaddr(sbi, ei.blk + ei.len - 1,
4535
DATA_GENERIC_ENHANCE)) {
4636
f2fs_warn(sbi, "%s: inode (ino=%lx) extent info [%u, %u, %u] is incorrect, run fsck to fix",
4737
__func__, inode->i_ino,
48-
ei->blk, ei->fofs, ei->len);
38+
ei.blk, ei.fofs, ei.len);
4939
return false;
5040
}
5141
return true;
@@ -394,24 +384,22 @@ void f2fs_init_read_extent_tree(struct inode *inode, struct page *ipage)
394384

395385
if (!__may_extent_tree(inode, EX_READ)) {
396386
/* drop largest read extent */
397-
if (i_ext && i_ext->len) {
387+
if (i_ext->len) {
398388
f2fs_wait_on_page_writeback(ipage, NODE, true, true);
399389
i_ext->len = 0;
400390
set_page_dirty(ipage);
401391
}
402-
goto out;
392+
set_inode_flag(inode, FI_NO_EXTENT);
393+
return;
403394
}
404395

405396
et = __grab_extent_tree(inode, EX_READ);
406397

407-
if (!i_ext || !i_ext->len)
408-
goto out;
409-
410398
get_read_extent_info(&ei, i_ext);
411399

412400
write_lock(&et->lock);
413-
if (atomic_read(&et->node_cnt))
414-
goto unlock_out;
401+
if (atomic_read(&et->node_cnt) || !ei.len)
402+
goto skip;
415403

416404
en = __attach_extent_node(sbi, et, &ei, NULL,
417405
&et->root.rb_root.rb_node, true);
@@ -423,11 +411,13 @@ void f2fs_init_read_extent_tree(struct inode *inode, struct page *ipage)
423411
list_add_tail(&en->list, &eti->extent_list);
424412
spin_unlock(&eti->extent_lock);
425413
}
426-
unlock_out:
414+
skip:
415+
/* Let's drop, if checkpoint got corrupted. */
416+
if (f2fs_cp_error(sbi)) {
417+
et->largest.len = 0;
418+
et->largest_updated = true;
419+
}
427420
write_unlock(&et->lock);
428-
out:
429-
if (!F2FS_I(inode)->extent_tree[EX_READ])
430-
set_inode_flag(inode, FI_NO_EXTENT);
431421
}
432422

433423
void f2fs_init_age_extent_tree(struct inode *inode)

0 commit comments

Comments
 (0)