Re: [PATCH] cifs: use sensible file nlink values if unprovided

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I merged an equivalent but slightly smaller version of your patch into
cifs-2.6.git (see below) and added stable since we should not be
returning nlink of 0.  Let me know if any objections.

[CIFS] use sensible file nlink values if unprovided

    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@xxxxxxxxxxxxxxx>
    Signed-off-by: David Disseldorp <ddiss@xxxxxxx>
    Signed-off-by: Steve French <smfrench@xxxxxxxxx>

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 20efd81..449b6cf 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -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;


On Thu, Jul 4, 2013 at 1:06 PM, David Disseldorp <ddiss@xxxxxxx> wrote:
> 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().
>
> Signed-off-by: David Disseldorp <ddiss@xxxxxxx>
> ---
>  fs/cifs/inode.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
> index 6f37228..8c48027 100644
> --- a/fs/cifs/inode.c
> +++ b/fs/cifs/inode.c
> @@ -532,6 +532,8 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
>         fattr->cf_bytes = le64_to_cpu(info->AllocationSize);
>         fattr->cf_createtime = le64_to_cpu(info->CreationTime);
>
> +       fattr->cf_nlink = le32_to_cpu(info->NumberOfLinks);
> +
>         if (fattr->cf_cifsattrs & ATTR_DIRECTORY) {
>                 fattr->cf_mode = S_IFDIR | cifs_sb->mnt_dir_mode;
>                 fattr->cf_dtype = DT_DIR;
> @@ -542,9 +544,13 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
>                 /* clear write bits if ATTR_READONLY is set */
>                 if (fattr->cf_cifsattrs & ATTR_READONLY)
>                         fattr->cf_mode &= ~(S_IWUGO);
> -       }
>
> -       fattr->cf_nlink = le32_to_cpu(info->NumberOfLinks);
> +               if (fattr->cf_nlink < 1) {
> +                       cFYI(1, "replacing bogus file nlink value %u",
> +                               fattr->cf_nlink);
> +                       fattr->cf_nlink = 1;
> +               }
> +       }
>
>         fattr->cf_uid = cifs_sb->mnt_uid;
>         fattr->cf_gid = cifs_sb->mnt_gid;
> --
> 1.8.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Thanks,

Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux