From: NeilBrown <[email protected]>

afs uses ->d_fsdata to store version information for the parent
directory.  ->d_time is arguably a better field to store this
information as the version is like a time stamp, and ->d_time is an
unsigned long, while ->d_fsdata is a void *.

This will leave ->d_fsdata free for a different use ...  which
admittedly is also not a void*, but is certainly not at all a time.

Interesting the value stored in ->d_time or d_fsdata is u64 which is a
different size of 32 bit hosts.  Maybe that doesn't matter.

Signed-off-by: NeilBrown <[email protected]>
---
 fs/afs/dir.c      | 18 +++++++++---------
 fs/afs/internal.h |  8 ++++----
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 78caef3f1338..a0417292314c 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -808,7 +808,7 @@ static struct inode *afs_do_lookup(struct inode *dir, 
struct dentry *dentry)
                afs_dir_iterate(dir, &cookie->ctx, NULL, &data_version);
        }
 
-       dentry->d_fsdata = (void *)(unsigned long)data_version;
+       dentry->d_time = (unsigned long)data_version;
 
        /* Check to see if we already have an inode for the primary fid. */
        inode = ilookup5(dir->i_sb, cookie->fids[1].vnode,
@@ -895,9 +895,9 @@ static struct inode *afs_do_lookup(struct inode *dir, 
struct dentry *dentry)
        }
 
        if (op->file[0].scb.have_status)
-               dentry->d_fsdata = (void *)(unsigned 
long)op->file[0].scb.status.data_version;
+               dentry->d_time = (unsigned 
long)op->file[0].scb.status.data_version;
        else
-               dentry->d_fsdata = (void *)(unsigned long)op->file[0].dv_before;
+               dentry->d_time = (unsigned long)op->file[0].dv_before;
        ret = afs_put_operation(op);
 out:
        kfree(cookie);
@@ -1010,7 +1010,7 @@ static struct dentry *afs_lookup(struct inode *dir, 
struct dentry *dentry,
        _debug("splice %p", dentry->d_inode);
        d = d_splice_alias(inode, dentry);
        if (!IS_ERR_OR_NULL(d)) {
-               d->d_fsdata = dentry->d_fsdata;
+               d->d_time = dentry->d_time;
                trace_afs_lookup(dvnode, &d->d_name, &fid);
        } else {
                trace_afs_lookup(dvnode, &dentry->d_name, &fid);
@@ -1040,7 +1040,7 @@ static int afs_d_revalidate_rcu(struct afs_vnode *dvnode, 
struct dentry *dentry)
         * version.
         */
        dir_version = (long)READ_ONCE(dvnode->status.data_version);
-       de_version = (long)READ_ONCE(dentry->d_fsdata);
+       de_version = (long)READ_ONCE(dentry->d_time);
        if (de_version != dir_version) {
                dir_version = (long)READ_ONCE(dvnode->invalid_before);
                if (de_version - dir_version < 0)
@@ -1100,7 +1100,7 @@ static int afs_d_revalidate(struct inode *parent_dir, 
const struct qstr *name,
         * version.
         */
        dir_version = dir->status.data_version;
-       de_version = (long)dentry->d_fsdata;
+       de_version = (long)dentry->d_time;
        if (de_version == (long)dir_version)
                goto out_valid_noupdate;
 
@@ -1161,7 +1161,7 @@ static int afs_d_revalidate(struct inode *parent_dir, 
const struct qstr *name,
        }
 
 out_valid:
-       dentry->d_fsdata = (void *)(unsigned long)dir_version;
+       dentry->d_time = (unsigned long)dir_version;
 out_valid_noupdate:
        key_put(key);
        _leave(" = 1 [valid]");
@@ -1931,7 +1931,7 @@ static void afs_rename_edit_dir(struct afs_operation *op)
                spin_unlock(&new_inode->i_lock);
        }
 
-       /* Now we can update d_fsdata on the dentries to reflect their
+       /* Now we can update d_time on the dentries to reflect their
         * new parent's data_version.
         */
        afs_update_dentry_version(op, new_dvp, op->dentry);
@@ -2167,7 +2167,7 @@ static int afs_rename(struct mnt_idmap *idmap, struct 
inode *old_dir,
        }
 
        /* This bit is potentially nasty as there's a potential race with
-        * afs_d_revalidate{,_rcu}().  We have to change d_fsdata on the dentry
+        * afs_d_revalidate{,_rcu}().  We have to change d_time_ on the dentry
         * to reflect it's new parent's new data_version after the op, but
         * d_revalidate may see old_dentry between the op having taken place
         * and the version being updated.
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 009064b8d661..106a7fe06b56 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -1746,17 +1746,17 @@ static inline struct inode *AFS_VNODE_TO_I(struct 
afs_vnode *vnode)
 }
 
 /*
- * Note that a dentry got changed.  We need to set d_fsdata to the data version
+ * Note that a dentry got changed.  We need to set d_time to the data version
  * number derived from the result of the operation.  It doesn't matter if
- * d_fsdata goes backwards as we'll just revalidate.
+ * d_time goes backwards as we'll just revalidate.
  */
 static inline void afs_update_dentry_version(struct afs_operation *op,
                                             struct afs_vnode_param *dir_vp,
                                             struct dentry *dentry)
 {
        if (!op->cumul_error.error)
-               dentry->d_fsdata =
-                       (void *)(unsigned long)dir_vp->scb.status.data_version;
+               dentry->d_time =
+                       (unsigned long)dir_vp->scb.status.data_version;
 }
 
 /*
-- 
2.50.0.107.gf914562f5916.dirty


Reply via email to