Skip to contentSkip to conversation

f2fs: Clean up the loop outside of f2fs_invalidate_blocks()

PATCH Applied Yi Sun 3 participants 3 messages Jan 13, 2025 – Jan 22, 2025 F2FS file system

lore
Share & tools
lore

Yi Sun

author
#0 lore raw

PATCH 1/1 f2fs: Clean up the loop outside of f2fs_invalidate_blocks()

Now f2fs_invalidate_blocks() supports a continuous range of addresses, so the for loop can be omitted.

---
 fs/f2fs/file.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/f2fs/file.c +1 -3
index 9980d17ef9f5..4baafad7a00c 100644
@@ -811,10 +811,8 @@ int f2fs_do_truncate_blocks(struct inode *inode, u64 from, bool lock)
 	if (IS_DEVICE_ALIASING(inode)) {
 		struct extent_tree *et = F2FS_I(inode)->extent_tree[EX_READ];
 		struct extent_info ei = et->largest;
-		unsigned int i;
 
-		for (i = 0; i < ei.len; i++)
-			f2fs_invalidate_blocks(sbi, ei.blk + i, 1);
+		f2fs_invalidate_blocks(sbi, ei.blk, ei.len);
 
 		dec_valid_block_count(sbi, inode, ei.len);
 		f2fs_update_time(sbi, REQ_TIME);
Signature · 8 lines
2.25.1



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Yi Sun

Now f2fs_invalidate_blocks() supports a continuous range of addresses, so the for loop can be omitted.

Actually, this can be merged into "f2fs: add parameter @len to f2fs_invalidate_blocks()", but, anyway, I guess it's fine to merge it separately.

Thanks,

Quoted 20 lines
---
  fs/f2fs/file.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
fs/f2fs/file.c +1 -3
index 9980d17ef9f5..4baafad7a00c 100644
@@ -811,10 +811,8 @@ int f2fs_do_truncate_blocks(struct inode *inode, u64 from, bool lock)
  	if (IS_DEVICE_ALIASING(inode)) {
  		struct extent_tree *et = F2FS_I(inode)->extent_tree[EX_READ];
  		struct extent_info ei = et->largest;
-		unsigned int i;
 
-		for (i = 0; i < ei.len; i++)
-			f2fs_invalidate_blocks(sbi, ei.blk + i, 1);
+		f2fs_invalidate_blocks(sbi, ei.blk, ei.len);
 
  		dec_valid_block_count(sbi, inode, ei.len);
  		f2fs_update_time(sbi, REQ_TIME);
#2 lore raw
In reply to Yi Sun
This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <[email protected]>:

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:

Quoted 8 lines · On Mon, 13 Jan 2025 09:47:02 +0800 you wrote:

Now f2fs_invalidate_blocks() supports a continuous range of addresses, so the for loop can be omitted.

---
 fs/f2fs/file.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Here is the summary with links:
- [f2fs-dev] f2fs: Clean up the loop outside of f2fs_invalidate_blocks()

    https://git.kernel.org/jaegeuk/f2fs/c/6d4008dc4a8e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html