2008-01-15 16:29:07

by Bob Bell

[permalink] [raw]
Subject: [PATCH 1/3] NFS: Check nlinks count

From: Philippe Armangau <[email protected]>

Check the nlink count when updating an NFS inode, and mark the
attributes invalid if it has changed. If the inode is a directory, also
invalidate the cached data so that the directory's contents will be
refreshed.

Signed-off-by: Philippe Armangau <[email protected]>
Acked-by: Bob Bell <[email protected]>
---
fs/nfs/inode.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 5747d49..3e85a70 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1063,6 +1063,12 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
nfsi->change_attr = fattr->change_attr;

+ if (inode->i_nlink != fattr->nlink) {
+ invalid |= NFS_INO_INVALID_ATTR;
+ if (S_ISDIR(inode->i_mode))
+ invalid |= NFS_INO_INVALID_DATA;
+ }
+
if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) ||
inode->i_uid != fattr->uid ||
inode->i_gid != fattr->gid)