All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] NFS: Zap entire 'struct inode' in nfs_zap_caches_locked().
@ 2011-02-14 21:56 Jesper Juhl
  2011-02-14 22:09 ` Trond Myklebust
  0 siblings, 1 reply; 4+ messages in thread
From: Jesper Juhl @ 2011-02-14 21:56 UTC (permalink / raw)
  To: linux-nfs; +Cc: linux-kernel, Trond Myklebust

nfs_zap_caches_locked() attempts to zero all of the 'struct inode' that's 
passed in via the pointer variable 'inode'. Unfortunately it only manages 
to zero the size of a 'pointer to struct inode'. Fix that.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 inode.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

 compile tested only

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 1cc600e..6c4236e 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -145,7 +145,7 @@ static void nfs_zap_caches_locked(struct inode *inode)
 	nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
 	nfsi->attrtimeo_timestamp = jiffies;
 
-	memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode)));
+	memset(NFS_COOKIEVERF(inode), 0, sizeof(*NFS_COOKIEVERF(inode)));
 	if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode))
 		nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE;
 	else


-- 
Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
Plain text mails only, please.
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] NFS: Zap entire 'struct inode' in nfs_zap_caches_locked().
  2011-02-14 21:56 [PATCH] NFS: Zap entire 'struct inode' in nfs_zap_caches_locked() Jesper Juhl
@ 2011-02-14 22:09 ` Trond Myklebust
  2011-02-14 22:12   ` Jesper Juhl
  0 siblings, 1 reply; 4+ messages in thread
From: Trond Myklebust @ 2011-02-14 22:09 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: linux-nfs, linux-kernel

On Mon, 2011-02-14 at 22:56 +0100, Jesper Juhl wrote: 
> nfs_zap_caches_locked() attempts to zero all of the 'struct inode' that's 
> passed in via the pointer variable 'inode'. Unfortunately it only manages 
> to zero the size of a 'pointer to struct inode'. Fix that.
> 
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
>  inode.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
>  compile tested only
> 
> diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
> index 1cc600e..6c4236e 100644
> --- a/fs/nfs/inode.c
> +++ b/fs/nfs/inode.c
> @@ -145,7 +145,7 @@ static void nfs_zap_caches_locked(struct inode *inode)
>  	nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
>  	nfsi->attrtimeo_timestamp = jiffies;
>  
> -	memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode)));
> +	memset(NFS_COOKIEVERF(inode), 0, sizeof(*NFS_COOKIEVERF(inode)));
>  	if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode))
>  		nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE;
>  	else

That's incorrect.

NFS_COOKIEVERF(inode) expands to NFS_I(inode)->cookieverf, and since
cookieverf is declared inside the struct nfs_inode as 

	u32	cookieverf[2];

the sizeof(NFS_I(inode)->cookieverf) should expand to the size of the
cookieverf array (i.e. 8 bytes).

Cheers
  Trond

-- 
Trond Myklebust
Linux NFS client maintainer

NetApp
Trond.Myklebust@netapp.com
www.netapp.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] NFS: Zap entire 'struct inode' in nfs_zap_caches_locked().
  2011-02-14 22:09 ` Trond Myklebust
@ 2011-02-14 22:12   ` Jesper Juhl
  2011-02-14 22:23     ` Trond Myklebust
  0 siblings, 1 reply; 4+ messages in thread
From: Jesper Juhl @ 2011-02-14 22:12 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: linux-nfs, linux-kernel

On Mon, 14 Feb 2011, Trond Myklebust wrote:

> On Mon, 2011-02-14 at 22:56 +0100, Jesper Juhl wrote: 
> > nfs_zap_caches_locked() attempts to zero all of the 'struct inode' that's 
> > passed in via the pointer variable 'inode'. Unfortunately it only manages 
> > to zero the size of a 'pointer to struct inode'. Fix that.
> > 
> > Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> > ---
> >  inode.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> >  compile tested only
> > 
> > diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
> > index 1cc600e..6c4236e 100644
> > --- a/fs/nfs/inode.c
> > +++ b/fs/nfs/inode.c
> > @@ -145,7 +145,7 @@ static void nfs_zap_caches_locked(struct inode *inode)
> >  	nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
> >  	nfsi->attrtimeo_timestamp = jiffies;
> >  
> > -	memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode)));
> > +	memset(NFS_COOKIEVERF(inode), 0, sizeof(*NFS_COOKIEVERF(inode)));
> >  	if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode))
> >  		nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE;
> >  	else
> 
> That's incorrect.
> 
> NFS_COOKIEVERF(inode) expands to NFS_I(inode)->cookieverf, and since
> cookieverf is declared inside the struct nfs_inode as 
> 
> 	u32	cookieverf[2];
> 
> the sizeof(NFS_I(inode)->cookieverf) should expand to the size of the
> cookieverf array (i.e. 8 bytes).
> 
Ouch, I completely misread/misunderstood that. Thanks for the 
clarification and please ignore the patch...

-- 
Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
Plain text mails only, please.
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] NFS: Zap entire 'struct inode' in nfs_zap_caches_locked().
  2011-02-14 22:12   ` Jesper Juhl
@ 2011-02-14 22:23     ` Trond Myklebust
  0 siblings, 0 replies; 4+ messages in thread
From: Trond Myklebust @ 2011-02-14 22:23 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: linux-nfs, linux-kernel

On Mon, 2011-02-14 at 23:12 +0100, Jesper Juhl wrote: 
> On Mon, 14 Feb 2011, Trond Myklebust wrote:
> 
> > On Mon, 2011-02-14 at 22:56 +0100, Jesper Juhl wrote: 
> > > nfs_zap_caches_locked() attempts to zero all of the 'struct inode' that's 
> > > passed in via the pointer variable 'inode'. Unfortunately it only manages 
> > > to zero the size of a 'pointer to struct inode'. Fix that.
> > > 
> > > Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> > > ---
> > >  inode.c |    2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > >  compile tested only
> > > 
> > > diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
> > > index 1cc600e..6c4236e 100644
> > > --- a/fs/nfs/inode.c
> > > +++ b/fs/nfs/inode.c
> > > @@ -145,7 +145,7 @@ static void nfs_zap_caches_locked(struct inode *inode)
> > >  	nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
> > >  	nfsi->attrtimeo_timestamp = jiffies;
> > >  
> > > -	memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode)));
> > > +	memset(NFS_COOKIEVERF(inode), 0, sizeof(*NFS_COOKIEVERF(inode)));
> > >  	if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode))
> > >  		nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE;
> > >  	else
> > 
> > That's incorrect.
> > 
> > NFS_COOKIEVERF(inode) expands to NFS_I(inode)->cookieverf, and since
> > cookieverf is declared inside the struct nfs_inode as 
> > 
> > 	u32	cookieverf[2];
> > 
> > the sizeof(NFS_I(inode)->cookieverf) should expand to the size of the
> > cookieverf array (i.e. 8 bytes).
> > 
> Ouch, I completely misread/misunderstood that. Thanks for the 
> clarification and please ignore the patch...

No problem. I can see how the NFS_COOKIEVERF() macro can be confusing. I
should post a patch to get rid of that macro for 2.6.39 and just open
code the few instances that care about accessing the cookieverf field.

Other macros that have outlived their usefulness include NFS_FH(),
NFS_FILEID(), NFS_CLIENT() and possibly NFS_SERVER()...

-- 
Trond Myklebust
Linux NFS client maintainer

NetApp
Trond.Myklebust@netapp.com
www.netapp.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-02-14 22:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-14 21:56 [PATCH] NFS: Zap entire 'struct inode' in nfs_zap_caches_locked() Jesper Juhl
2011-02-14 22:09 ` Trond Myklebust
2011-02-14 22:12   ` Jesper Juhl
2011-02-14 22:23     ` Trond Myklebust

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.