public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* Invalidating NFS attribute cache
@ 2009-07-09 12:34 Hans Kramer
       [not found] ` <1247142894.7427.43.camel-6FgEqA8bTCrD1MxPaE+0Y3nhMCiq3JZZ@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Hans Kramer @ 2009-07-09 12:34 UTC (permalink / raw)
  To: linux-nfs

Hi,

For some silly reason I have an application that needs to poll for the
existence of a certain file on a NFS share. 
(This is done from Sybase ASE ;-)

Now I run into the issue of attribute caching. Turning of the attribute
cache with the mount option of -o noac easily solves all the issues.

However, it would be nice if we could still use attribute caching and
force to invalidate on-demand the attribute cache.

After a lot of trying, the following solution seems to work for me now:
(pathname is the test file)   

#define _GNU_SOURCE

    char *copy = strdup(pathname);
    char *path = dirname(copy);

    int fd = open(path, O_DIRECTORY);
    if (fd >= 0)
        close(fd);

    free(copy);

    return access(pathname, F_OK);

Just opening the parent directory with O_DIRECTORY seems to do the
trick.

My questions: Is this hack going to work under every circumstance or
could it fail in the future with some update. Is there a ioctl call that
could the the same thing? That is invalidate the parent directory cache.
Or do I miss something completely ?-)

Thanks in advance

Hans  


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

* Re: Invalidating NFS attribute cache
       [not found] ` <1247142894.7427.43.camel-6FgEqA8bTCrD1MxPaE+0Y3nhMCiq3JZZ@public.gmane.org>
@ 2009-07-09 14:10   ` Chuck Lever
  2009-07-09 14:39     ` Hans Kramer
  0 siblings, 1 reply; 3+ messages in thread
From: Chuck Lever @ 2009-07-09 14:10 UTC (permalink / raw)
  To: Hans Kramer; +Cc: linux-nfs

On Jul 9, 2009, at 8:34 AM, Hans Kramer wrote:
> Hi,
>
> For some silly reason I have an application that needs to poll for the
> existence of a certain file on a NFS share.
> (This is done from Sybase ASE ;-)
>
> Now I run into the issue of attribute caching. Turning of the  
> attribute
> cache with the mount option of -o noac easily solves all the issues.
>
> However, it would be nice if we could still use attribute caching and
> force to invalidate on-demand the attribute cache.

Since you are only concerned with the existence of a file (and not its  
mtime, say). have you considered the new directory cache mount option:  
lookupcache=?

I see it's not mentioned in nfs(8) so you should probably look in  
recent archives of this mailing list for information.

> After a lot of trying, the following solution seems to work for me  
> now:
> (pathname is the test file)
>
> #define _GNU_SOURCE
>
>    char *copy = strdup(pathname);
>    char *path = dirname(copy);
>
>    int fd = open(path, O_DIRECTORY);
>    if (fd >= 0)
>        close(fd);
>
>    free(copy);
>
>    return access(pathname, F_OK);
>
> Just opening the parent directory with O_DIRECTORY seems to do the
> trick.
>
> My questions: Is this hack going to work under every circumstance or
> could it fail in the future with some update. Is there a ioctl call  
> that
> could the the same thing? That is invalidate the parent directory  
> cache.
> Or do I miss something completely ?-)
>
> Thanks in advance
>
> Hans
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs"  
> in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Chuck Lever
chuck[dot]lever[at]oracle[dot]com





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

* Re: Invalidating NFS attribute cache
  2009-07-09 14:10   ` Chuck Lever
@ 2009-07-09 14:39     ` Hans Kramer
  0 siblings, 0 replies; 3+ messages in thread
From: Hans Kramer @ 2009-07-09 14:39 UTC (permalink / raw)
  To: Chuck Lever; +Cc: linux-nfs

[-- Attachment #1: Type: text/plain, Size: 2020 bytes --]

Thanks Chuck,

I was not aware of this mount option.

I will try it.

Thanks!


On Thu, 2009-07-09 at 10:10 -0400, Chuck Lever wrote:
> On Jul 9, 2009, at 8:34 AM, Hans Kramer wrote:
> > Hi,
> >
> > For some silly reason I have an application that needs to poll for the
> > existence of a certain file on a NFS share.
> > (This is done from Sybase ASE ;-)
> >
> > Now I run into the issue of attribute caching. Turning of the  
> > attribute
> > cache with the mount option of -o noac easily solves all the issues.
> >
> > However, it would be nice if we could still use attribute caching and
> > force to invalidate on-demand the attribute cache.
> 
> Since you are only concerned with the existence of a file (and not its  
> mtime, say). have you considered the new directory cache mount option:  
> lookupcache=?
> 
> I see it's not mentioned in nfs(8) so you should probably look in  
> recent archives of this mailing list for information.
> 
> > After a lot of trying, the following solution seems to work for me  
> > now:
> > (pathname is the test file)
> >
> > #define _GNU_SOURCE
> >
> >    char *copy = strdup(pathname);
> >    char *path = dirname(copy);
> >
> >    int fd = open(path, O_DIRECTORY);
> >    if (fd >= 0)
> >        close(fd);
> >
> >    free(copy);
> >
> >    return access(pathname, F_OK);
> >
> > Just opening the parent directory with O_DIRECTORY seems to do the
> > trick.
> >
> > My questions: Is this hack going to work under every circumstance or
> > could it fail in the future with some update. Is there a ioctl call  
> > that
> > could the the same thing? That is invalidate the parent directory  
> > cache.
> > Or do I miss something completely ?-)
> >
> > Thanks in advance
> >
> > Hans
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-nfs"  
> > in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

end of thread, other threads:[~2009-07-09 14:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-09 12:34 Invalidating NFS attribute cache Hans Kramer
     [not found] ` <1247142894.7427.43.camel-6FgEqA8bTCrD1MxPaE+0Y3nhMCiq3JZZ@public.gmane.org>
2009-07-09 14:10   ` Chuck Lever
2009-07-09 14:39     ` Hans Kramer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox