diff options
author | Jan Kara <jack@suse.cz> | 2014-09-04 05:47:51 -0400 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2014-09-04 05:47:51 -0400 |
commit | 8a70ee3307908c46f952df91be72a18d5f5ad0a3 (patch) | |
tree | bf5e1b58e99f4b3090d3811aec3411a728df5f40 /fs/udf | |
parent | 44bf091f508913c1c35e70ea96430454c95c78f1 (diff) |
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>
Diffstat (limited to 'fs/udf')
-rw-r--r-- | fs/udf/inode.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 236cd48184c2..e86f9b67aa16 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c | |||
@@ -1664,7 +1664,7 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1664 | FE_PERM_U_DELETE | FE_PERM_U_CHATTR)); | 1664 | FE_PERM_U_DELETE | FE_PERM_U_CHATTR)); |
1665 | fe->permissions = cpu_to_le32(udfperms); | 1665 | fe->permissions = cpu_to_le32(udfperms); |
1666 | 1666 | ||
1667 | if (S_ISDIR(inode->i_mode)) | 1667 | if (S_ISDIR(inode->i_mode) && inode->i_nlink > 0) |
1668 | fe->fileLinkCount = cpu_to_le16(inode->i_nlink - 1); | 1668 | fe->fileLinkCount = cpu_to_le16(inode->i_nlink - 1); |
1669 | else | 1669 | else |
1670 | fe->fileLinkCount = cpu_to_le16(inode->i_nlink); | 1670 | fe->fileLinkCount = cpu_to_le16(inode->i_nlink); |