Skip to content

Commit 8a70ee3

Browse files
committed
udf: Avoid dir link count to go negative
If we are writing back inode of unlinked directory, its link count ends up being (u16)-1. Although the inode is deleted, udf_iget() can load the inode when NFS uses stale file handle and get confused. Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 44bf091 commit 8a70ee3

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎fs/udf/inode.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1664,7 +1664,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
16641664
FE_PERM_U_DELETE | FE_PERM_U_CHATTR));
16651665
fe->permissions = cpu_to_le32(udfperms);
16661666

1667-
if (S_ISDIR(inode->i_mode))
1667+
if (S_ISDIR(inode->i_mode) && inode->i_nlink > 0)
16681668
fe->fileLinkCount = cpu_to_le16(inode->i_nlink - 1);
16691669
else
16701670
fe->fileLinkCount = cpu_to_le16(inode->i_nlink);

0 commit comments

Comments
 (0)