[PATCH v2 1/2] smb/client: use d_time to store a timestamp in dentry, not d_fsdata

NeilBrown <[email protected]>
Newsgroups org.kernel.vger.linux-cifs,org.kernel.vger.linux-fsdevel
Message-ID <[email protected]>
From: NeilBrown <[email protected]>

smb/client uses d_fsdata is exactly the way that d_time is intended to
be used.  It previous used d_time but this was changed in
  Commit: a00be0e31f8d ("cifs: don't use ->d_time")
without any reason being given.

This patch effectively reverts that patch (though it doesn't remove the
helpers) so that d_fsdata can be used for something more generic.

As ->d_time is NOT initialised by d_alloc() (unlike ->d_fsdata), it is
important to initialise it in atomic_open (all dentries go through
either ->lookup or ->atomic_open before being hashed, and both of these
now initialise ->d_time).

Cc: Miklos Szeredi <[email protected]>
Signed-off-by: NeilBrown <[email protected]>
---
 fs/smb/client/cifsfs.h | 4 ++--
 fs/smb/client/dir.c    | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h
index 901e1340c986..e489aaf206b2 100644
--- a/fs/smb/client/cifsfs.h
+++ b/fs/smb/client/cifsfs.h
@@ -34,12 +34,12 @@ cifs_uniqueid_to_ino_t(u64 fileid)
 
 static inline void cifs_set_time(struct dentry *dentry, unsigned long time)
 {
-	dentry->d_fsdata = (void *) time;
+	dentry->d_time = time;
 }
 
 static inline unsigned long cifs_get_time(struct dentry *dentry)
 {
-	return (unsigned long) dentry->d_fsdata;
+	return dentry->d_time;
 }
 
 extern struct file_system_type cifs_fs_type, smb3_fs_type;
diff --git a/fs/smb/client/dir.c b/fs/smb/client/dir.c
index 88a4a1787ff0..bd9684b61c2b 100644
--- a/fs/smb/client/dir.c
+++ b/fs/smb/client/dir.c
@@ -598,6 +598,7 @@ int cifs_atomic_open(struct inode *dir, struct dentry *direntry,
 	} else {
 		d_instantiate(direntry, inode);
 	}
+	cifs_set_time(direntry, jiffies);
 
 	if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
 		file->f_mode |= FMODE_CREATED;
-- 
2.50.0.107.gf914562f5916.dirty
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.