Skip to contentSkip to conversation

ext4: atomically read inode size

PATCH In review Fabian Frederick 2 participants 2 messages Jan 23, 2017 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: atomically read inode size

See i_size_read() comments in include/linux/fs.h

---
 fs/ext4/super.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/super.c +2 -1
index 9d15a62..3746f77 100644
@@ -3798,7 +3798,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 		goto cantfind_ext4;
 
 	/* check blocks count against device size */
-	blocks_count = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits;
+	blocks_count = i_size_read(sb->s_bdev->bd_inode) >>
+		       sb->s_blocksize_bits;
 	if (blocks_count && ext4_blocks_count(es) > blocks_count) {
 		ext4_msg(sb, KERN_WARNING, "bad geometry: block count %llu "
 		       "exceeds size of device (%llu blocks)",
Signature · 1 line
2.9.3
maintainer
#1 lore raw
Quoted 12 lines · Fabian Frederick

See i_size_read() comments in include/linux/fs.h

---
 fs/ext4/super.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/super.c +0 -0
index 9d15a62..3746f77 100644

fs/ext4/super.c static int ext4_fill_super(struct super_block *sb, void *data, int silent) · line 3805

Quoted 9 lines
fs/ext4/super.c +2 -1
@@ -3798,7 +3798,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 		goto cantfind_ext4;
 
 	/* check blocks count against device size */
-	blocks_count = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits;
+	blocks_count = i_size_read(sb->s_bdev->bd_inode) >>
+		       sb->s_blocksize_bits;
 	if (blocks_count && ext4_blocks_count(es) > blocks_count) {
 		ext4_msg(sb, KERN_WARNING, "bad geometry: block count %llu "
 		       "exceeds size of device (%llu blocks)",

Um, this is at mount time, and we're talking about the i_size of the block device --- which typically isn't moving around a huge amount.

- Ted