Skip to content

Commit 3959066

Browse files
daimngoChuck Lever
authored andcommitted
NFSD: add support for sending CB_RECALL_ANY
Add XDR encode and decode function for CB_RECALL_ANY. Signed-off-by: Dai Ngo <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent a1049eb commit 3959066

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

fs/nfsd/nfs4callback.c

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ static __be32 *xdr_encode_empty_array(__be32 *p)
7676
* 1 Protocol"
7777
*/
7878

79+
static void encode_uint32(struct xdr_stream *xdr, u32 n)
80+
{
81+
WARN_ON_ONCE(xdr_stream_encode_u32(xdr, n) < 0);
82+
}
83+
84+
static void encode_bitmap4(struct xdr_stream *xdr, const __u32 *bitmap,
85+
size_t len)
86+
{
87+
WARN_ON_ONCE(xdr_stream_encode_uint32_array(xdr, bitmap, len) < 0);
88+
}
89+
7990
/*
8091
* nfs_cb_opnum4
8192
*
@@ -328,6 +339,24 @@ static void encode_cb_recall4args(struct xdr_stream *xdr,
328339
hdr->nops++;
329340
}
330341

342+
/*
343+
* CB_RECALLANY4args
344+
*
345+
* struct CB_RECALLANY4args {
346+
* uint32_t craa_objects_to_keep;
347+
* bitmap4 craa_type_mask;
348+
* };
349+
*/
350+
static void
351+
encode_cb_recallany4args(struct xdr_stream *xdr,
352+
struct nfs4_cb_compound_hdr *hdr, struct nfsd4_cb_recall_any *ra)
353+
{
354+
encode_nfs_cb_opnum4(xdr, OP_CB_RECALL_ANY);
355+
encode_uint32(xdr, ra->ra_keep);
356+
encode_bitmap4(xdr, ra->ra_bmval, ARRAY_SIZE(ra->ra_bmval));
357+
hdr->nops++;
358+
}
359+
331360
/*
332361
* CB_SEQUENCE4args
333362
*
@@ -482,6 +511,26 @@ static void nfs4_xdr_enc_cb_recall(struct rpc_rqst *req, struct xdr_stream *xdr,
482511
encode_cb_nops(&hdr);
483512
}
484513

514+
/*
515+
* 20.6. Operation 8: CB_RECALL_ANY - Keep Any N Recallable Objects
516+
*/
517+
static void
518+
nfs4_xdr_enc_cb_recall_any(struct rpc_rqst *req,
519+
struct xdr_stream *xdr, const void *data)
520+
{
521+
const struct nfsd4_callback *cb = data;
522+
struct nfsd4_cb_recall_any *ra;
523+
struct nfs4_cb_compound_hdr hdr = {
524+
.ident = cb->cb_clp->cl_cb_ident,
525+
.minorversion = cb->cb_clp->cl_minorversion,
526+
};
527+
528+
ra = container_of(cb, struct nfsd4_cb_recall_any, ra_cb);
529+
encode_cb_compound4args(xdr, &hdr);
530+
encode_cb_sequence4args(xdr, cb, &hdr);
531+
encode_cb_recallany4args(xdr, &hdr, ra);
532+
encode_cb_nops(&hdr);
533+
}
485534

486535
/*
487536
* NFSv4.0 and NFSv4.1 XDR decode functions
@@ -520,6 +569,28 @@ static int nfs4_xdr_dec_cb_recall(struct rpc_rqst *rqstp,
520569
return decode_cb_op_status(xdr, OP_CB_RECALL, &cb->cb_status);
521570
}
522571

572+
/*
573+
* 20.6. Operation 8: CB_RECALL_ANY - Keep Any N Recallable Objects
574+
*/
575+
static int
576+
nfs4_xdr_dec_cb_recall_any(struct rpc_rqst *rqstp,
577+
struct xdr_stream *xdr,
578+
void *data)
579+
{
580+
struct nfsd4_callback *cb = data;
581+
struct nfs4_cb_compound_hdr hdr;
582+
int status;
583+
584+
status = decode_cb_compound4res(xdr, &hdr);
585+
if (unlikely(status))
586+
return status;
587+
status = decode_cb_sequence4res(xdr, cb);
588+
if (unlikely(status || cb->cb_seq_status))
589+
return status;
590+
status = decode_cb_op_status(xdr, OP_CB_RECALL_ANY, &cb->cb_status);
591+
return status;
592+
}
593+
523594
#ifdef CONFIG_NFSD_PNFS
524595
/*
525596
* CB_LAYOUTRECALL4args
@@ -783,6 +854,7 @@ static const struct rpc_procinfo nfs4_cb_procedures[] = {
783854
#endif
784855
PROC(CB_NOTIFY_LOCK, COMPOUND, cb_notify_lock, cb_notify_lock),
785856
PROC(CB_OFFLOAD, COMPOUND, cb_offload, cb_offload),
857+
PROC(CB_RECALL_ANY, COMPOUND, cb_recall_any, cb_recall_any),
786858
};
787859

788860
static unsigned int nfs4_cb_counts[ARRAY_SIZE(nfs4_cb_procedures)];

fs/nfsd/state.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ enum nfsd4_cb_op {
636636
NFSPROC4_CLNT_CB_OFFLOAD,
637637
NFSPROC4_CLNT_CB_SEQUENCE,
638638
NFSPROC4_CLNT_CB_NOTIFY_LOCK,
639+
NFSPROC4_CLNT_CB_RECALL_ANY,
639640
};
640641

641642
/* Returns true iff a is later than b: */

fs/nfsd/xdr4.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,5 +896,10 @@ struct nfsd4_operation {
896896
union nfsd4_op_u *);
897897
};
898898

899+
struct nfsd4_cb_recall_any {
900+
struct nfsd4_callback ra_cb;
901+
u32 ra_keep;
902+
u32 ra_bmval[1];
903+
};
899904

900905
#endif

fs/nfsd/xdr4cb.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,9 @@
4848
#define NFS4_dec_cb_offload_sz (cb_compound_dec_hdr_sz + \
4949
cb_sequence_dec_sz + \
5050
op_dec_sz)
51+
#define NFS4_enc_cb_recall_any_sz (cb_compound_enc_hdr_sz + \
52+
cb_sequence_enc_sz + \
53+
1 + 1 + 1)
54+
#define NFS4_dec_cb_recall_any_sz (cb_compound_dec_hdr_sz + \
55+
cb_sequence_dec_sz + \
56+
op_dec_sz)

0 commit comments

Comments
 (0)