Skip to content

Commit a54c461

Browse files
committed
ext4: fix race writing to an inline_data file while its xattrs are changing
The location of the system.data extended attribute can change whenever xattr_sem is not taken. So we need to recalculate the i_inline_off field since it mgiht have changed between ext4_write_begin() and ext4_write_end(). This means that caching i_inline_off is probably not helpful, so in the long run we should probably get rid of it and shrink the in-memory ext4 inode slightly, but let's fix the race the simple way for now. Cc: [email protected] Fixes: f19d587 ("ext4: add normal write support for inline data") Reported-by: [email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent b33d9f5 commit a54c461

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fs/ext4/inline.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,12 @@ int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
750750
ext4_write_lock_xattr(inode, &no_expand);
751751
BUG_ON(!ext4_has_inline_data(inode));
752752

753+
/*
754+
* ei->i_inline_off may have changed since ext4_write_begin()
755+
* called ext4_try_to_write_inline_data()
756+
*/
757+
(void) ext4_find_inline_data_nolock(inode);
758+
753759
kaddr = kmap_atomic(page);
754760
ext4_write_inline_data(inode, &iloc, kaddr, pos, len);
755761
kunmap_atomic(kaddr);

0 commit comments

Comments
 (0)