Commit 2f2591a34db6c9361faa316c91a6e320cb4e6aee

Authored by Jeff Layton
Committed by Steve French
1 parent 8367224b2e

cifs: don't compare uniqueids in cifs_prime_dcache unless server inode numbers are in use

Oliver reported that commit cd60042c caused his cifs mounts to
continually thrash through new inodes on readdir. His servers are not
sending inode numbers (or he's not using them), and the new test in
that function doesn't account for that sort of setup correctly.

If we're not using server inode numbers, then assume that the inode
attached to the dentry hasn't changed. Go ahead and update the
attributes in place, but keep the same inode number.

Cc: <stable@vger.kernel.org> # v3.5+
Reported-and-Tested-by: Oliver Mössinger <Oliver.Moessinger@ichaus.de>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>

Showing 1 changed file with 15 additions and 4 deletions Side-by-side Diff

... ... @@ -78,6 +78,7 @@
78 78 struct dentry *dentry, *alias;
79 79 struct inode *inode;
80 80 struct super_block *sb = parent->d_inode->i_sb;
  81 + struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
81 82  
82 83 cFYI(1, "%s: for %s", __func__, name->name);
83 84  
... ... @@ -91,10 +92,20 @@
91 92 int err;
92 93  
93 94 inode = dentry->d_inode;
94   - /* update inode in place if i_ino didn't change */
95   - if (inode && CIFS_I(inode)->uniqueid == fattr->cf_uniqueid) {
96   - cifs_fattr_to_inode(inode, fattr);
97   - goto out;
  95 + if (inode) {
  96 + /*
  97 + * If we're generating inode numbers, then we don't
  98 + * want to clobber the existing one with the one that
  99 + * the readdir code created.
  100 + */
  101 + if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM))
  102 + fattr->cf_uniqueid = CIFS_I(inode)->uniqueid;
  103 +
  104 + /* update inode in place if i_ino didn't change */
  105 + if (CIFS_I(inode)->uniqueid == fattr->cf_uniqueid) {
  106 + cifs_fattr_to_inode(inode, fattr);
  107 + goto out;
  108 + }
98 109 }
99 110 err = d_invalidate(dentry);
100 111 dput(dentry);