Skip to contentSkip to conversation

nfs_refresh_verifier / nfs_renew_times confusion

DISCUSSION Chuck Lever 2 participants 4 messages Sep 19, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Trond-

I'm reviewing 2.6.23-rc6 + NFS_ALL to prepare for porting my BKL elimination patch series. I'm confused by a couple of things I found in fs/nfs/dir.c.

1.

static int nfs_check_verifier(struct inode *dir, struct dentry *dentry)

{
        unsigned long verf;

        if (IS_ROOT(dentry))
                return 1;
        verf = dentry->d_time;
        if (nfs_caches_unstable(dir)
                        || verf != NFS_I(dir)->cache_change_attribute)
                return 0;
        return 1;
}

Why use the extra variable "verf" here?

2.

Three functions are defined:

static inline void nfs_set_verifier(struct dentry * dentry, unsigned long verf)

{
        dentry->d_time = verf;
}

static void nfs_refresh_verifier(struct dentry * dentry, unsigned long verf)

{
        nfs_set_verifier(dentry, verf);
}

static inline void nfs_renew_times(struct dentry * dentry)

{
        dentry->d_time = jiffies;
}

but later in the code I see this sequence several times:

        nfs_renew_times(dentry);
        nfs_refresh_verifier(dentry, verifier);

as well as this sequence:

        nfs_renew_times(dentry);
        nfs_set_verifier(dentry, nfs_save_change_attribute(dir));

In both cases, the second call overwrites the dentry's d_time field which was set to "jiffies" in the first call.

begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
url:http://oss.oracle.com/~cel
version:2.1
end:vcard

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#1 lore raw
Quoted 21 lines · Chuck Lever

Hi Trond-

I'm reviewing 2.6.23-rc6 + NFS_ALL to prepare for porting my BKL elimination patch series. I'm confused by a couple of things I found in fs/nfs/dir.c.

1.

static int nfs_check_verifier(struct inode *dir, struct dentry *dentry)

{
         unsigned long verf;

         if (IS_ROOT(dentry))
                 return 1;
         verf = dentry->d_time;
         if (nfs_caches_unstable(dir)
                         || verf != NFS_I(dir)->cache_change_attribute)
                 return 0;
         return 1;
}
Quoted 1 line

Why use the extra variable "verf" here?

Historical reasons: we used to cache the verifier in the dentry->d_fsdata, which is a (void *). The new sillyrename code OTOH, needs d_fsdata in order to cache the asynchronous unlink data, so the verifier was moved into d_time.

Quoted 25 lines

2.

Three functions are defined:

static inline void nfs_set_verifier(struct dentry * dentry, unsigned long verf)

{
         dentry->d_time = verf;
}

static void nfs_refresh_verifier(struct dentry * dentry, unsigned long verf)

{
         nfs_set_verifier(dentry, verf);
}

static inline void nfs_renew_times(struct dentry * dentry)

{
         dentry->d_time = jiffies;
}

but later in the code I see this sequence several times:

         nfs_renew_times(dentry);
         nfs_refresh_verifier(dentry, verifier);
Quoted 7 lines

as well as this sequence:

         nfs_renew_times(dentry);
         nfs_set_verifier(dentry, nfs_save_change_attribute(dir));

In both cases, the second call overwrites the dentry's d_time field which was set to "jiffies" in the first call.

Time to clean all that up. The legacy nfs_renew_times() has no meaning now that we use d_time to cache the verifier. Would you like to send me a patch removing them?

Trond

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#2 lore raw
Quoted 3 lines · Trond Myklebust

Time to clean all that up. The legacy nfs_renew_times() has no meaning now that we use d_time to cache the verifier. Would you like to send me a patch removing them?

I can -- there are some minor nits.

In nfs_dentry_iput() we have this:

static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode)

{
        nfs_inode_return_delegation(inode);
        if (S_ISDIR(inode->i_mode))
                /* drop any readdir cache as it could easily be old */
                NFS_I(inode)->cache_validity |= NFS_INO_INVALID_DATA;

        if (dentry->d_flags & DCACHE_NFSFS_RENAMED) {
                lock_kernel();
                drop_nlink(inode);
                nfs_complete_unlink(dentry, inode);
                unlock_kernel();
        }
        /* When creating a negative dentry, we want to renew d_time */
        nfs_renew_times(dentry);
        ^^^^^^^^^^^^^^^^^^^^^^^^
        iput(inode);
}

This is the only instance of nfs_renew_times() by itself. Seems like this might break the behavior of negative dentry caching. Should this be removed entirely, or replaced somehow with nfs_refresh_verifier()?

It looks like nfs_set_verifier() and nfs_refresh_verifier() reduce to exactly the same logic, but we have this at the end of nfs_readdir_lookup:

        nfs_renew_times(dentry);
        nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
        return dentry;
out_renew:
        nfs_renew_times(dentry);
        nfs_refresh_verifier(dentry, nfs_save_change_attribute(dir));
        return dentry;
}

Both of which are exactly equivalent now. I can address this as well.

begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
url:http://oss.oracle.com/~cel
version:2.1
end:vcard

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#3 lore raw
Quoted 28 lines · Chuck Lever
Quoted 3 lines · Trond Myklebust

Time to clean all that up. The legacy nfs_renew_times() has no meaning now that we use d_time to cache the verifier. Would you like to send me a patch removing them?

I can -- there are some minor nits.

In nfs_dentry_iput() we have this:

static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode)

{
         nfs_inode_return_delegation(inode);
         if (S_ISDIR(inode->i_mode))
                 /* drop any readdir cache as it could easily be old */
                 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_DATA;

         if (dentry->d_flags & DCACHE_NFSFS_RENAMED) {
                 lock_kernel();
                 drop_nlink(inode);
                 nfs_complete_unlink(dentry, inode);
                 unlock_kernel();
         }
         /* When creating a negative dentry, we want to renew d_time */
         nfs_renew_times(dentry);
         ^^^^^^^^^^^^^^^^^^^^^^^^
         iput(inode);
}
Quoted 3 lines

This is the only instance of nfs_renew_times() by itself. Seems like this might break the behavior of negative dentry caching. Should this be removed entirely, or replaced somehow with nfs_refresh_verifier()?

Just remove it. Unfortunately I don't think that we can avoid revalidating the resulting negative dentry since the UNLINK call is asynchronous, and so the new verifier on the directory will only be known a posteriori.

Quoted 12 lines

It looks like nfs_set_verifier() and nfs_refresh_verifier() reduce to exactly the same logic, but we have this at the end of nfs_readdir_lookup:

         nfs_renew_times(dentry);
         nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
         return dentry;
out_renew:
         nfs_renew_times(dentry);
         nfs_refresh_verifier(dentry, nfs_save_change_attribute(dir));
         return dentry;
}
Quoted 1 line

Both of which are exactly equivalent now. I can address this as well.

Thanks.

Trond

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs