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

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