Skip to contentSkip to conversation

ext4: Do not unnecessarily allocate buffer in recently_deleted()

PATCH Applied Wang Shilong 2 participants 2 messages Aug 20, 2017 – Aug 24, 2017 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 ext4: Do not unnecessarily allocate buffer in recently_deleted()

From: Jan Kara <[email protected]>

From: Jan Kara <[email protected]>

In recently_deleted() function we want to check whether inode is still cached in buffer cache. Use sb_find_get_block() for that instead of sb_getblk() to avoid unnecessary allocation of bdev page and buffer heads.

---
 fs/ext4/ialloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ext4/ialloc.c +2 -2
index 507bfb3..0d03e73 100644
@@ -707,9 +707,9 @@ static int recently_deleted(struct super_block *sb, ext4_group_t group, int ino)
 	if (unlikely(!gdp))
 		return 0;
 
-	bh = sb_getblk(sb, ext4_inode_table(sb, gdp) +
+	bh = sb_find_get_block(sb, ext4_inode_table(sb, gdp) +
 		       (ino / inodes_per_block));
-	if (unlikely(!bh) || !buffer_uptodate(bh))
+	if (!bh || !buffer_uptodate(bh))
 		/*
 		 * If the block is not in the buffer cache, then it
 		 * must have been written out.
Signature · 1 line
2.9.3
maintainer Applied
#1 lore raw
Quoted 10 lines · Wang Shilong

From: Jan Kara <[email protected]>

From: Jan Kara <[email protected]>

In recently_deleted() function we want to check whether inode is still cached in buffer cache. Use sb_find_get_block() for that instead of sb_getblk() to avoid unnecessary allocation of bdev page and buffer heads.

Thanks, applied.

- Ted