Commit 91ba2eee authored by Trond Myklebust's avatar Trond Myklebust

NFSv4: Add post-op attributes to nfs4_proc_link()

 Optimise attribute revalidation when hardlinking. Add post-op attributes
 for the directory and the original inode.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent cf809556
...@@ -1724,22 +1724,34 @@ static int nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name, ...@@ -1724,22 +1724,34 @@ static int nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name,
static int _nfs4_proc_link(struct inode *inode, struct inode *dir, struct qstr *name) static int _nfs4_proc_link(struct inode *inode, struct inode *dir, struct qstr *name)
{ {
struct nfs_server *server = NFS_SERVER(inode);
struct nfs4_link_arg arg = { struct nfs4_link_arg arg = {
.fh = NFS_FH(inode), .fh = NFS_FH(inode),
.dir_fh = NFS_FH(dir), .dir_fh = NFS_FH(dir),
.name = name, .name = name,
.bitmask = server->attr_bitmask,
};
struct nfs_fattr fattr, dir_attr;
struct nfs4_link_res res = {
.server = server,
.fattr = &fattr,
.dir_attr = &dir_attr,
}; };
struct nfs4_change_info cinfo = { };
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LINK], .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LINK],
.rpc_argp = &arg, .rpc_argp = &arg,
.rpc_resp = &cinfo, .rpc_resp = &res,
}; };
int status; int status;
status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); nfs_fattr_init(res.fattr);
if (!status) nfs_fattr_init(res.dir_attr);
update_changeattr(dir, &cinfo); status = rpc_call_sync(server->client, &msg, 0);
if (!status) {
update_changeattr(dir, &res.cinfo);
nfs_post_op_update_inode(dir, res.dir_attr);
nfs_refresh_inode(inode, res.fattr);
}
return status; return status;
} }
......
...@@ -324,12 +324,18 @@ static int nfs_stat_to_errno(int); ...@@ -324,12 +324,18 @@ static int nfs_stat_to_errno(int);
encode_putfh_maxsz + \ encode_putfh_maxsz + \
encode_savefh_maxsz + \ encode_savefh_maxsz + \
encode_putfh_maxsz + \ encode_putfh_maxsz + \
encode_link_maxsz) encode_link_maxsz + \
decode_getattr_maxsz + \
encode_restorefh_maxsz + \
decode_getattr_maxsz)
#define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \ #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \
decode_putfh_maxsz + \ decode_putfh_maxsz + \
decode_savefh_maxsz + \ decode_savefh_maxsz + \
decode_putfh_maxsz + \ decode_putfh_maxsz + \
decode_link_maxsz) decode_link_maxsz + \
decode_getattr_maxsz + \
decode_restorefh_maxsz + \
decode_getattr_maxsz)
#define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \ #define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \
encode_putfh_maxsz + \ encode_putfh_maxsz + \
encode_symlink_maxsz + \ encode_symlink_maxsz + \
...@@ -1357,7 +1363,7 @@ static int nfs4_xdr_enc_link(struct rpc_rqst *req, uint32_t *p, const struct nfs ...@@ -1357,7 +1363,7 @@ static int nfs4_xdr_enc_link(struct rpc_rqst *req, uint32_t *p, const struct nfs
{ {
struct xdr_stream xdr; struct xdr_stream xdr;
struct compound_hdr hdr = { struct compound_hdr hdr = {
.nops = 4, .nops = 7,
}; };
int status; int status;
...@@ -1369,7 +1375,13 @@ static int nfs4_xdr_enc_link(struct rpc_rqst *req, uint32_t *p, const struct nfs ...@@ -1369,7 +1375,13 @@ static int nfs4_xdr_enc_link(struct rpc_rqst *req, uint32_t *p, const struct nfs
goto out; goto out;
if ((status = encode_putfh(&xdr, args->dir_fh)) != 0) if ((status = encode_putfh(&xdr, args->dir_fh)) != 0)
goto out; goto out;
status = encode_link(&xdr, args->name); if ((status = encode_link(&xdr, args->name)) != 0)
goto out;
if ((status = encode_getfattr(&xdr, args->bitmask)) != 0)
goto out;
if ((status = encode_restorefh(&xdr)) != 0)
goto out;
status = encode_getfattr(&xdr, args->bitmask);
out: out:
return status; return status;
} }
...@@ -3529,7 +3541,7 @@ out: ...@@ -3529,7 +3541,7 @@ out:
/* /*
* Decode LINK response * Decode LINK response
*/ */
static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_change_info *cinfo) static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_link_res *res)
{ {
struct xdr_stream xdr; struct xdr_stream xdr;
struct compound_hdr hdr; struct compound_hdr hdr;
...@@ -3544,7 +3556,17 @@ static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_ch ...@@ -3544,7 +3556,17 @@ static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_ch
goto out; goto out;
if ((status = decode_putfh(&xdr)) != 0) if ((status = decode_putfh(&xdr)) != 0)
goto out; goto out;
status = decode_link(&xdr, cinfo); if ((status = decode_link(&xdr, &res->cinfo)) != 0)
goto out;
/*
* Note order: OP_LINK leaves the directory as the current
* filehandle.
*/
if (decode_getfattr(&xdr, res->dir_attr, res->server) != 0)
goto out;
if ((status = decode_restorefh(&xdr)) != 0)
goto out;
decode_getfattr(&xdr, res->fattr, res->server);
out: out:
return status; return status;
} }
......
...@@ -566,8 +566,17 @@ struct nfs4_link_arg { ...@@ -566,8 +566,17 @@ struct nfs4_link_arg {
const struct nfs_fh * fh; const struct nfs_fh * fh;
const struct nfs_fh * dir_fh; const struct nfs_fh * dir_fh;
const struct qstr * name; const struct qstr * name;
const u32 * bitmask;
};
struct nfs4_link_res {
const struct nfs_server * server;
struct nfs_fattr * fattr;
struct nfs4_change_info cinfo;
struct nfs_fattr * dir_attr;
}; };
struct nfs4_lookup_arg { struct nfs4_lookup_arg {
const struct nfs_fh * dir_fh; const struct nfs_fh * dir_fh;
const struct qstr * name; const struct qstr * name;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment