Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save h2onda/4f92d7cf4f3196343bfc to your computer and use it in GitHub Desktop.
Save h2onda/4f92d7cf4f3196343bfc to your computer and use it in GitHub Desktop.
cifs: update the inode cache with the results from a FIND_*
Subject: cifs: update the inode cache with the results from a FIND_*
See also: https://github.com/torvalds/linux/commit/cd60042cc1392e79410dc8de9e9c1abb38a29e57
See also: https://github.com/torvalds/linux/commit/2f2591a34db6c9361faa316c91a6e320cb4e6aee
================================
diff -uNrp kernel-2.6.32-504.el6.orig/linux-2.6.32-504.el6.x86_64/fs/cifs/readdir.c kernel-2.6.32-504.el6.new/linux-2.6.32-504.el6.x86_64/fs/cifs/readdir.c
--- linux-2.6.32-504.el6.x86_64/fs/cifs/readdir.c 2014-09-16 14:20:00.000000000 +0900
+++ linux-2.6.32-504.el6.x86_64/fs/cifs/readdir.c 2014-11-07 06:51:30.746015526 +0900
@@ -74,6 +74,7 @@ cifs_readdir_lookup(struct dentry *paren
struct dentry *dentry, *alias;
struct inode *inode;
struct super_block *sb = parent->d_inode->i_sb;
+ struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
cFYI(1, "For %s", name->name);
@@ -84,11 +85,28 @@ cifs_readdir_lookup(struct dentry *paren
dentry = d_lookup(parent, name);
if (dentry) {
- /* FIXME: check for inode number changes? */
- if (dentry->d_inode != NULL)
- return dentry;
- d_drop(dentry);
+ int err;
+
+ inode = dentry->d_inode;
+ if (inode) {
+ /*
+ * If we're generating inode numbers, then we don't
+ * want to clobber the existing one with the one that
+ * the readdir code created.
+ */
+ if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM))
+ fattr->cf_uniqueid = CIFS_I(inode)->uniqueid;
+
+ /* update inode in place if i_ino didn't change */
+ if (CIFS_I(inode)->uniqueid == fattr->cf_uniqueid) {
+ cifs_fattr_to_inode(inode, fattr);
+ return dentry;
+ }
+ }
+ err = d_invalidate(dentry);
dput(dentry);
+ if (err)
+ return NULL;
}
/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment