nfs4: Use RELEASE_LOCKOWNER when we close a file

We create a new lock_owner for every open(), to reduce pressure on the
servers lock_owner cache  we can tell it that this lock_owner will not
be used again and it can drop it from the cache.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
master
Ronnie Sahlberg 2022-01-05 16:41:34 +10:00
parent 0550a5c83f
commit f85c21755e
2 changed files with 23 additions and 2 deletions

View File

@ -405,6 +405,7 @@ struct nfsfh {
/* NFSv4 */
struct stateid stateid;
uint32_t lock_owner;
/* locking */
uint32_t open_seqid;
uint32_t lock_seqid;

View File

@ -643,6 +643,21 @@ nfs4_op_commit(struct nfs_context *nfs, nfs_argop4 *op)
return 1;
}
static int
nfs4_op_release_lockowner(struct nfs_context *nfs, nfs_argop4 *op, struct nfsfh *fh)
{
RELEASE_LOCKOWNER4args *rlargs;
op->argop = OP_RELEASE_LOCKOWNER;
rlargs = &op->nfs_argop4_u.oprelease_lockowner;
rlargs->lock_owner.clientid = nfs->clientid;
rlargs->lock_owner.owner.owner_len = 4;
rlargs->lock_owner.owner.owner_val = (char *)&fh->lock_owner;
return 1;
}
static int
nfs4_op_close(struct nfs_context *nfs, nfs_argop4 *op, struct nfsfh *fh)
{
@ -659,6 +674,10 @@ nfs4_op_close(struct nfs_context *nfs, nfs_argop4 *op, struct nfsfh *fh)
clargs->open_stateid.seqid = fh->stateid.seqid;
memcpy(clargs->open_stateid.other, fh->stateid.other, 12);
#ifdef HAVE_MULTITHREADING
i += nfs4_op_release_lockowner(nfs, &op[i], fh);
#endif
return i;
}
@ -2123,7 +2142,8 @@ nfs4_open_cb(struct rpc_context *rpc, int status, void *command_data,
}
memcpy(fh->fh.val, gresok->object.nfs_fh4_val, fh->fh.len);
fh->open_seqid = 1;
fh->lock_owner = data->lock_owner;
if (data->filler.flags & O_SYNC) {
fh->is_sync = 1;
}
@ -2666,7 +2686,7 @@ nfs4_close_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb,
void *private_data)
{
COMPOUND4args args;
nfs_argop4 op[3];
nfs_argop4 op[4];
struct nfs4_cb_data *data;
int i;