Skip to content

Commit 22a341b

Browse files
author
Jaegeuk Kim
committed
f2fs: should use a temp extent_info for lookup
Otherwise, __lookup_extent_tree() will override the given extent_info which will be used by caller. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent ed27247 commit 22a341b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

fs/f2fs/extent_cache.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,7 @@ static int __get_new_block_age(struct inode *inode, struct extent_info *ei,
888888
loff_t f_size = i_size_read(inode);
889889
unsigned long long cur_blocks =
890890
atomic64_read(&sbi->allocated_data_blocks);
891+
struct extent_info tei = *ei; /* only fofs and len are valid */
891892

892893
/*
893894
* When I/O is not aligned to a PAGE_SIZE, update will happen to the last
@@ -898,17 +899,17 @@ static int __get_new_block_age(struct inode *inode, struct extent_info *ei,
898899
blkaddr == NEW_ADDR)
899900
return -EINVAL;
900901

901-
if (__lookup_extent_tree(inode, ei->fofs, ei, EX_BLOCK_AGE)) {
902+
if (__lookup_extent_tree(inode, ei->fofs, &tei, EX_BLOCK_AGE)) {
902903
unsigned long long cur_age;
903904

904-
if (cur_blocks >= ei->last_blocks)
905-
cur_age = cur_blocks - ei->last_blocks;
905+
if (cur_blocks >= tei.last_blocks)
906+
cur_age = cur_blocks - tei.last_blocks;
906907
else
907908
/* allocated_data_blocks overflow */
908-
cur_age = ULLONG_MAX - ei->last_blocks + cur_blocks;
909+
cur_age = ULLONG_MAX - tei.last_blocks + cur_blocks;
909910

910-
if (ei->age)
911-
ei->age = __calculate_block_age(cur_age, ei->age);
911+
if (tei.age)
912+
ei->age = __calculate_block_age(cur_age, tei.age);
912913
else
913914
ei->age = cur_age;
914915
ei->last_blocks = cur_blocks;

0 commit comments

Comments
 (0)