Skip to content

Commit ee0ed02

Browse files
jankaratytso
authored andcommitted
ext4: do not delete unlinked inode from orphan list on failed truncate
It is possible that unlinked inode enters ext4_setattr() (e.g. if somebody calls ftruncate(2) on unlinked but still open file). In such case we should not delete the inode from the orphan list if truncate fails. Note that this is mostly a theoretical concern as filesystem is corrupted if we reach this path anyway but let's be consistent in our orphan handling. Reviewed-by: Ira Weiny <[email protected]> Signed-off-by: Jan Kara <[email protected]> Signed-off-by: Theodore Ts'o <[email protected]> Cc: [email protected]
1 parent 82a25b0 commit ee0ed02

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/ext4/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5625,7 +5625,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
56255625
up_write(&EXT4_I(inode)->i_data_sem);
56265626
ext4_journal_stop(handle);
56275627
if (error) {
5628-
if (orphan)
5628+
if (orphan && inode->i_nlink)
56295629
ext4_orphan_del(NULL, inode);
56305630
goto err_out;
56315631
}

0 commit comments

Comments
 (0)