NFSv4: Detect nlink changes on cross-directory renames too
If the object being renamed from one directory to another is also a directory, then 'nlink' will change for both directories. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
parent
3c591175d6
commit
5636ec4eb6
|
@ -1094,13 +1094,14 @@ nfs4_dec_nlink_locked(struct inode *inode)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_changeattr_locked(struct inode *dir, struct nfs4_change_info *cinfo,
|
update_changeattr_locked(struct inode *dir, struct nfs4_change_info *cinfo,
|
||||||
unsigned long timestamp)
|
unsigned long timestamp, unsigned long cache_validity)
|
||||||
{
|
{
|
||||||
struct nfs_inode *nfsi = NFS_I(dir);
|
struct nfs_inode *nfsi = NFS_I(dir);
|
||||||
|
|
||||||
nfsi->cache_validity |= NFS_INO_INVALID_CTIME
|
nfsi->cache_validity |= NFS_INO_INVALID_CTIME
|
||||||
| NFS_INO_INVALID_MTIME
|
| NFS_INO_INVALID_MTIME
|
||||||
| NFS_INO_INVALID_DATA;
|
| NFS_INO_INVALID_DATA
|
||||||
|
| cache_validity;
|
||||||
if (cinfo->atomic && cinfo->before == inode_peek_iversion_raw(dir)) {
|
if (cinfo->atomic && cinfo->before == inode_peek_iversion_raw(dir)) {
|
||||||
nfsi->cache_validity &= ~NFS_INO_REVAL_PAGECACHE;
|
nfsi->cache_validity &= ~NFS_INO_REVAL_PAGECACHE;
|
||||||
nfsi->attrtimeo_timestamp = jiffies;
|
nfsi->attrtimeo_timestamp = jiffies;
|
||||||
|
@ -1118,10 +1119,10 @@ update_changeattr_locked(struct inode *dir, struct nfs4_change_info *cinfo,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo,
|
update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo,
|
||||||
unsigned long timestamp)
|
unsigned long timestamp, unsigned long cache_validity)
|
||||||
{
|
{
|
||||||
spin_lock(&dir->i_lock);
|
spin_lock(&dir->i_lock);
|
||||||
update_changeattr_locked(dir, cinfo, timestamp);
|
update_changeattr_locked(dir, cinfo, timestamp, cache_validity);
|
||||||
spin_unlock(&dir->i_lock);
|
spin_unlock(&dir->i_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2514,7 +2515,7 @@ static int _nfs4_proc_open(struct nfs4_opendata *data,
|
||||||
if (data->file_created ||
|
if (data->file_created ||
|
||||||
inode_peek_iversion_raw(dir) != o_res->cinfo.after)
|
inode_peek_iversion_raw(dir) != o_res->cinfo.after)
|
||||||
update_changeattr(dir, &o_res->cinfo,
|
update_changeattr(dir, &o_res->cinfo,
|
||||||
o_res->f_attr->time_start);
|
o_res->f_attr->time_start, 0);
|
||||||
}
|
}
|
||||||
if ((o_res->rflags & NFS4_OPEN_RESULT_LOCKTYPE_POSIX) == 0)
|
if ((o_res->rflags & NFS4_OPEN_RESULT_LOCKTYPE_POSIX) == 0)
|
||||||
server->caps &= ~NFS_CAP_POSIX_LOCK;
|
server->caps &= ~NFS_CAP_POSIX_LOCK;
|
||||||
|
@ -4292,7 +4293,7 @@ _nfs4_proc_remove(struct inode *dir, const struct qstr *name, u32 ftype)
|
||||||
status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 1);
|
status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 1);
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
spin_lock(&dir->i_lock);
|
spin_lock(&dir->i_lock);
|
||||||
update_changeattr_locked(dir, &res.cinfo, timestamp);
|
update_changeattr_locked(dir, &res.cinfo, timestamp, 0);
|
||||||
/* Removing a directory decrements nlink in the parent */
|
/* Removing a directory decrements nlink in the parent */
|
||||||
if (ftype == NF4DIR && dir->i_nlink > 2)
|
if (ftype == NF4DIR && dir->i_nlink > 2)
|
||||||
nfs4_dec_nlink_locked(dir);
|
nfs4_dec_nlink_locked(dir);
|
||||||
|
@ -4372,7 +4373,8 @@ static int nfs4_proc_unlink_done(struct rpc_task *task, struct inode *dir)
|
||||||
&data->timeout) == -EAGAIN)
|
&data->timeout) == -EAGAIN)
|
||||||
return 0;
|
return 0;
|
||||||
if (task->tk_status == 0)
|
if (task->tk_status == 0)
|
||||||
update_changeattr(dir, &res->cinfo, res->dir_attr->time_start);
|
update_changeattr(dir, &res->cinfo,
|
||||||
|
res->dir_attr->time_start, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4414,9 +4416,18 @@ static int nfs4_proc_rename_done(struct rpc_task *task, struct inode *old_dir,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (task->tk_status == 0) {
|
if (task->tk_status == 0) {
|
||||||
update_changeattr(old_dir, &res->old_cinfo, res->old_fattr->time_start);
|
if (new_dir != old_dir) {
|
||||||
if (new_dir != old_dir)
|
/* Note: If we moved a directory, nlink will change */
|
||||||
update_changeattr(new_dir, &res->new_cinfo, res->new_fattr->time_start);
|
update_changeattr(old_dir, &res->old_cinfo,
|
||||||
|
res->old_fattr->time_start,
|
||||||
|
NFS_INO_INVALID_OTHER);
|
||||||
|
update_changeattr(new_dir, &res->new_cinfo,
|
||||||
|
res->new_fattr->time_start,
|
||||||
|
NFS_INO_INVALID_OTHER);
|
||||||
|
} else
|
||||||
|
update_changeattr(old_dir, &res->old_cinfo,
|
||||||
|
res->old_fattr->time_start,
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -4457,7 +4468,7 @@ static int _nfs4_proc_link(struct inode *inode, struct inode *dir, const struct
|
||||||
|
|
||||||
status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1);
|
status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
update_changeattr(dir, &res.cinfo, res.fattr->time_start);
|
update_changeattr(dir, &res.cinfo, res.fattr->time_start, 0);
|
||||||
status = nfs_post_op_update_inode(inode, res.fattr);
|
status = nfs_post_op_update_inode(inode, res.fattr);
|
||||||
if (!status)
|
if (!status)
|
||||||
nfs_setsecurity(inode, res.fattr, res.label);
|
nfs_setsecurity(inode, res.fattr, res.label);
|
||||||
|
@ -4534,7 +4545,7 @@ static int nfs4_do_create(struct inode *dir, struct dentry *dentry, struct nfs4_
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
spin_lock(&dir->i_lock);
|
spin_lock(&dir->i_lock);
|
||||||
update_changeattr_locked(dir, &data->res.dir_cinfo,
|
update_changeattr_locked(dir, &data->res.dir_cinfo,
|
||||||
data->res.fattr->time_start);
|
data->res.fattr->time_start, 0);
|
||||||
/* Creating a directory bumps nlink in the parent */
|
/* Creating a directory bumps nlink in the parent */
|
||||||
if (data->arg.ftype == NF4DIR)
|
if (data->arg.ftype == NF4DIR)
|
||||||
nfs4_inc_nlink_locked(dir);
|
nfs4_inc_nlink_locked(dir);
|
||||||
|
|
Loading…
Reference in New Issue