From: Hans Kramer <hans.kramer@xs4all.nl>
To: linux-nfs@vger.kernel.org
Subject: Invalidating NFS attribute cache
Date: Thu, 09 Jul 2009 14:34:54 +0200 [thread overview]
Message-ID: <1247142894.7427.43.camel@cancun.hanskramer.com> (raw)
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
next reply other threads:[~2009-07-09 12:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-09 12:34 Hans Kramer [this message]
[not found] ` <1247142894.7427.43.camel-6FgEqA8bTCrD1MxPaE+0Y3nhMCiq3JZZ@public.gmane.org>
2009-07-09 14:10 ` Invalidating NFS attribute cache Chuck Lever
2009-07-09 14:39 ` Hans Kramer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1247142894.7427.43.camel@cancun.hanskramer.com \
--to=hans.kramer@xs4all.nl \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox