Skip to content

Commit d035c36

Browse files
Trond MyklebustTrond Myklebust
authored andcommitted
NFSv4: Ensure continued open and lockowner name uniqueness
In order to enable migration support, we will want to move some of the structures that are subject to migration into the struct nfs_server. In particular, if we are to move the state_owner and state_owner_id to being a per-filesystem structure, then we should label the resulting open/lock owners with a per-filesytem label to ensure global uniqueness. This patch does so by adding the super block s_dev to the open/lock owner name. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1 parent d3978bb commit d035c36

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

fs/nfs/nfs4proc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3779,6 +3779,7 @@ static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock
37793779
goto out;
37803780
lsp = request->fl_u.nfs4_fl.owner;
37813781
arg.lock_owner.id = lsp->ls_id.id;
3782+
arg.lock_owner.s_dev = server->s_dev;
37823783
status = nfs4_call_sync(server, &msg, &arg, &res, 1);
37833784
switch (status) {
37843785
case 0:
@@ -4024,6 +4025,7 @@ static struct nfs4_lockdata *nfs4_alloc_lockdata(struct file_lock *fl,
40244025
p->arg.lock_stateid = &lsp->ls_stateid;
40254026
p->arg.lock_owner.clientid = server->nfs_client->cl_clientid;
40264027
p->arg.lock_owner.id = lsp->ls_id.id;
4028+
p->arg.lock_owner.s_dev = server->s_dev;
40274029
p->res.lock_seqid = p->arg.lock_seqid;
40284030
p->lsp = lsp;
40294031
p->server = server;
@@ -4428,6 +4430,7 @@ void nfs4_release_lockowner(const struct nfs4_lock_state *lsp)
44284430
return;
44294431
args->lock_owner.clientid = server->nfs_client->cl_clientid;
44304432
args->lock_owner.id = lsp->ls_id.id;
4433+
args->lock_owner.s_dev = server->s_dev;
44314434
msg.rpc_argp = args;
44324435
rpc_call_async(server->client, &msg, 0, &nfs4_release_lockowner_ops, args);
44334436
}

fs/nfs/nfs4xdr.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ static int nfs4_stat_to_errno(int);
7171
/* lock,open owner id:
7272
* we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2)
7373
*/
74-
#define open_owner_id_maxsz (1 + 4)
75-
#define lock_owner_id_maxsz (1 + 4)
74+
#define open_owner_id_maxsz (1 + 1 + 4)
75+
#define lock_owner_id_maxsz (1 + 1 + 4)
7676
#define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
7777
#define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
7878
#define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
@@ -1088,10 +1088,11 @@ static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lo
10881088
{
10891089
__be32 *p;
10901090

1091-
p = reserve_space(xdr, 28);
1091+
p = reserve_space(xdr, 32);
10921092
p = xdr_encode_hyper(p, lowner->clientid);
1093-
*p++ = cpu_to_be32(16);
1093+
*p++ = cpu_to_be32(20);
10941094
p = xdr_encode_opaque_fixed(p, "lock id:", 8);
1095+
*p++ = cpu_to_be32(lowner->s_dev);
10951096
xdr_encode_hyper(p, lowner->id);
10961097
}
10971098

@@ -1210,10 +1211,11 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena
12101211
*p++ = cpu_to_be32(OP_OPEN);
12111212
*p = cpu_to_be32(arg->seqid->sequence->counter);
12121213
encode_share_access(xdr, arg->fmode);
1213-
p = reserve_space(xdr, 28);
1214+
p = reserve_space(xdr, 32);
12141215
p = xdr_encode_hyper(p, arg->clientid);
1215-
*p++ = cpu_to_be32(16);
1216+
*p++ = cpu_to_be32(20);
12161217
p = xdr_encode_opaque_fixed(p, "open id:", 8);
1218+
*p++ = cpu_to_be32(arg->server->s_dev);
12171219
xdr_encode_hyper(p, arg->id);
12181220
}
12191221

include/linux/nfs_xdr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ struct nfs_closeres {
317317
struct nfs_lowner {
318318
__u64 clientid;
319319
__u64 id;
320+
dev_t s_dev;
320321
};
321322

322323
struct nfs_lock_args {

0 commit comments

Comments
 (0)