Skip to content

Commit db78368

Browse files
jtlaytonamschuma-ntap
authored andcommitted
nfs: add handling for CB_NOTIFY_LOCK in client
For now, the callback doesn't do anything. Support for that will be added in later patches. Signed-off-by: Jeff Layton <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent a8ce377 commit db78368

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

fs/nfs/callback.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,15 @@ extern __be32 nfs4_callback_devicenotify(
179179
struct cb_devicenotifyargs *args,
180180
void *dummy, struct cb_process_state *cps);
181181

182+
struct cb_notify_lock_args {
183+
struct nfs_fh cbnl_fh;
184+
struct nfs_lowner cbnl_owner;
185+
bool cbnl_valid;
186+
};
187+
188+
extern __be32 nfs4_callback_notify_lock(struct cb_notify_lock_args *args,
189+
void *dummy,
190+
struct cb_process_state *cps);
182191
#endif /* CONFIG_NFS_V4_1 */
183192
extern int check_gss_callback_principal(struct nfs_client *, struct svc_rqst *);
184193
extern __be32 nfs4_callback_getattr(struct cb_getattrargs *args,

fs/nfs/callback_proc.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,4 +628,16 @@ __be32 nfs4_callback_recallslot(struct cb_recallslotargs *args, void *dummy,
628628
dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
629629
return status;
630630
}
631+
632+
__be32 nfs4_callback_notify_lock(struct cb_notify_lock_args *args, void *dummy,
633+
struct cb_process_state *cps)
634+
{
635+
if (!cps->clp) /* set in cb_sequence */
636+
return htonl(NFS4ERR_OP_NOT_IN_SESSION);
637+
638+
dprintk_rcu("NFS: CB_NOTIFY_LOCK request from %s\n",
639+
rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR));
640+
641+
return htonl(NFS4_OK);
642+
}
631643
#endif /* CONFIG_NFS_V4_1 */

fs/nfs/callback_xdr.c

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
(1 + 3) * 4) // seqid, 3 slotids
3636
#define CB_OP_RECALLANY_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ)
3737
#define CB_OP_RECALLSLOT_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ)
38+
#define CB_OP_NOTIFY_LOCK_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ)
3839
#endif /* CONFIG_NFS_V4_1 */
3940

4041
#define NFSDBG_FACILITY NFSDBG_CALLBACK
@@ -534,6 +535,49 @@ static __be32 decode_recallslot_args(struct svc_rqst *rqstp,
534535
return 0;
535536
}
536537

538+
static __be32 decode_lockowner(struct xdr_stream *xdr, struct cb_notify_lock_args *args)
539+
{
540+
__be32 *p;
541+
unsigned int len;
542+
543+
p = read_buf(xdr, 12);
544+
if (unlikely(p == NULL))
545+
return htonl(NFS4ERR_BADXDR);
546+
547+
p = xdr_decode_hyper(p, &args->cbnl_owner.clientid);
548+
len = be32_to_cpu(*p);
549+
550+
p = read_buf(xdr, len);
551+
if (unlikely(p == NULL))
552+
return htonl(NFS4ERR_BADXDR);
553+
554+
/* Only try to decode if the length is right */
555+
if (len == 20) {
556+
p += 2; /* skip "lock id:" */
557+
args->cbnl_owner.s_dev = be32_to_cpu(*p++);
558+
xdr_decode_hyper(p, &args->cbnl_owner.id);
559+
args->cbnl_valid = true;
560+
} else {
561+
args->cbnl_owner.s_dev = 0;
562+
args->cbnl_owner.id = 0;
563+
args->cbnl_valid = false;
564+
}
565+
return 0;
566+
}
567+
568+
static __be32 decode_notify_lock_args(struct svc_rqst *rqstp, struct xdr_stream *xdr, struct cb_notify_lock_args *args)
569+
{
570+
__be32 status;
571+
572+
status = decode_fh(xdr, &args->cbnl_fh);
573+
if (unlikely(status != 0))
574+
goto out;
575+
status = decode_lockowner(xdr, args);
576+
out:
577+
dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
578+
return status;
579+
}
580+
537581
#endif /* CONFIG_NFS_V4_1 */
538582

539583
static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
@@ -746,14 +790,14 @@ preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op)
746790
case OP_CB_RECALL_SLOT:
747791
case OP_CB_LAYOUTRECALL:
748792
case OP_CB_NOTIFY_DEVICEID:
793+
case OP_CB_NOTIFY_LOCK:
749794
*op = &callback_ops[op_nr];
750795
break;
751796

752797
case OP_CB_NOTIFY:
753798
case OP_CB_PUSH_DELEG:
754799
case OP_CB_RECALLABLE_OBJ_AVAIL:
755800
case OP_CB_WANTS_CANCELLED:
756-
case OP_CB_NOTIFY_LOCK:
757801
return htonl(NFS4ERR_NOTSUPP);
758802

759803
default:
@@ -1006,6 +1050,11 @@ static struct callback_op callback_ops[] = {
10061050
.decode_args = (callback_decode_arg_t)decode_recallslot_args,
10071051
.res_maxsize = CB_OP_RECALLSLOT_RES_MAXSZ,
10081052
},
1053+
[OP_CB_NOTIFY_LOCK] = {
1054+
.process_op = (callback_process_op_t)nfs4_callback_notify_lock,
1055+
.decode_args = (callback_decode_arg_t)decode_notify_lock_args,
1056+
.res_maxsize = CB_OP_NOTIFY_LOCK_RES_MAXSZ,
1057+
},
10091058
#endif /* CONFIG_NFS_V4_1 */
10101059
};
10111060

0 commit comments

Comments
 (0)