From: Jan Kara Date: Thu, 4 Sep 2014 09:47:51 +0000 (+0200) Subject: udf: Avoid dir link count to go negative X-Git-Tag: v5.15~17087^2~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8a70ee3307908c46f952df91be72a18d5f5ad0a3;p=platform%2Fkernel%2Flinux-starfive.git 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 --- diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 236cd48..e86f9b6 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) FE_PERM_U_DELETE | FE_PERM_U_CHATTR)); fe->permissions = cpu_to_le32(udfperms); - if (S_ISDIR(inode->i_mode)) + if (S_ISDIR(inode->i_mode) && inode->i_nlink > 0) fe->fileLinkCount = cpu_to_le16(inode->i_nlink - 1); else fe->fileLinkCount = cpu_to_le16(inode->i_nlink);