Alternate Patch: [PATCH] Don't include device number in cache invalidation when running on NFS
- From
- Thomas Glanzmann <sithglan@stud.uni-erlangen.de>
- Date
- May 22, 2005, 21:41 UTC
- Message-ID
- <20050522214115.GD23388@cip.informatik.uni-erlangen.de>
- In-Reply-To
- <20050522212312.GC23388@cip.informatik.uni-erlangen.de>
Hello,
* Thomas Glanzmann <sithglan@stud.uni-erlangen.de> [050522 23:24]:
> Hello,
> > Sorry, I meant "rename", not "link", and yes, it should be NFS-safe. It's > > how all the mailers do things too, afaik.
> okay. I will doublecheck that and come back.
yes, you're right.
While reading liblockfile I saw the following:
/*
* See if the directory where is certain file is in
* is located on an NFS mounted volume.
*/
static int is_nfs(const char *file)
{
char dir[1024];
char *s;
struct stat st; strncpy(dir, file, sizeof(dir));
if ((s = strrchr(dir, '/')) != NULL)
*s = 0;
else
strcpy(dir, "."); if (stat(dir, &st) < 0)
return 0;return ((st.st_dev & 0xFF00) == 0); }
So here comes an alternate patch if you like to verify the st_dev for non NFS stuff. Also tested.
[PATCH] Don't include device number in cache invalidation when running on NFS
This patches includes the device number only in the cache invalidation process when not running on a NFS volume.
Signed-off-by: Thomas Glanzmann <sithglan@stud.uni-erlangen.de>
diff --git a/read-cache.c b/read-cache.c --- a/read-cache.c +++ b/read-cache.c @@ -65,8 +65,11 @@ int ce_match_stat(struct cache_entry *ce if (ce->ce_uid != htonl(st->st_uid) || ce->ce_gid != htonl(st->st_gid)) changed |= OWNER_CHANGED; - if (ce->ce_dev != htonl(st->st_dev) || - ce->ce_ino != htonl(st->st_ino)) + /* Only include device number if not running on NFS */ + if (ce->ce_dev != htonl(st->st_dev) && + ((st->st_dev & 0xFF00) == 0)) + changed |= INODE_CHANGED; + if (ce->ce_ino != htonl(st->st_ino)) changed |= INODE_CHANGED; if (ce->ce_size != htonl(st->st_size)) changed |= DATA_CHANGED;