[CIFS] use sensible file nlink values if unprovided
authorSteve French <smfrench@gmail.com>
Thu, 4 Jul 2013 19:38:48 +0000 (14:38 -0500)
committerSteve French <smfrench@gmail.com>
Thu, 4 Jul 2013 19:38:48 +0000 (14:38 -0500)
Certain servers may not set the NumberOfLinks field in query file/path
info responses. In such a case, cifs_inode_needs_reval() assumes that
all regular files are hardlinks and triggers revalidation, leading to
excessive and unnecessary network traffic.

This change hardcodes cf_nlink (and subsequently i_nlink) when not
returned by the server, similar to what already occurs in cifs_mkdir().

Cc: <stable@vger.kernel.org>
Signed-off-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Steve French <smfrench@gmail.com>
fs/cifs/inode.c

index 20efd81266c643338bcd81b434edfe9fbcacc0ac..449b6cf09b09dbc15e90f311e09bc011a0157b44 100644 (file)
@@ -558,6 +558,11 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
                        fattr->cf_mode &= ~(S_IWUGO);
 
                fattr->cf_nlink = le32_to_cpu(info->NumberOfLinks);
+               if (fattr->cf_nlink < 1) {
+                       cifs_dbg(1, "replacing bogus file nlink value %u\n",
+                               fattr->cf_nlink);
+                       fattr->cf_nlink = 1;
+               }
        }
 
        fattr->cf_uid = cifs_sb->mnt_uid;