Skip to content

Commit 8dfbea8

Browse files
jtlaytonchucklever
authored andcommitted
nfsd: switch to autogenerated definitions for open_delegation_type4
Rename the enum with the same name in include/linux/nfs4.h, add the proper enum to nfs4_1.x and regenerate the headers and source files. Do a mass rename of all NFS4_OPEN_DELEGATE_* to OPEN_DELEGATE_* in the nfsd directory. Signed-off-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 8e1d322 commit 8dfbea8

File tree

7 files changed

+61
-26
lines changed

7 files changed

+61
-26
lines changed

Documentation/sunrpc/xdr/nfs4_1.x

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ pragma public fattr4_time_deleg_modify;
161161
const FATTR4_TIME_DELEG_ACCESS = 84;
162162
const FATTR4_TIME_DELEG_MODIFY = 85;
163163

164-
165164
const OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS = 0x100000;
166165

166+
enum open_delegation_type4 {
167+
OPEN_DELEGATE_NONE = 0,
168+
OPEN_DELEGATE_READ = 1,
169+
OPEN_DELEGATE_WRITE = 2,
170+
OPEN_DELEGATE_NONE_EXT = 3, /* new to v4.1 */
171+
OPEN_DELEGATE_READ_ATTRS_DELEG = 4,
172+
OPEN_DELEGATE_WRITE_ATTRS_DELEG = 5
173+
};

fs/nfsd/nfs4state.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2965,7 +2965,7 @@ static int nfs4_show_deleg(struct seq_file *s, struct nfs4_stid *st)
29652965
seq_puts(s, ": { type: deleg, ");
29662966

29672967
seq_printf(s, "access: %s",
2968-
ds->dl_type == NFS4_OPEN_DELEGATE_READ ? "r" : "w");
2968+
ds->dl_type == OPEN_DELEGATE_READ ? "r" : "w");
29692969

29702970
/* XXX: lease time, whether it's being recalled. */
29712971

@@ -5581,7 +5581,7 @@ nfsd4_process_open1(struct nfsd4_compound_state *cstate,
55815581
static inline __be32
55825582
nfs4_check_delegmode(struct nfs4_delegation *dp, int flags)
55835583
{
5584-
if ((flags & WR_STATE) && (dp->dl_type == NFS4_OPEN_DELEGATE_READ))
5584+
if ((flags & WR_STATE) && (dp->dl_type == OPEN_DELEGATE_READ))
55855585
return nfserr_openmode;
55865586
else
55875587
return nfs_ok;
@@ -5823,7 +5823,7 @@ static struct file_lease *nfs4_alloc_init_lease(struct nfs4_delegation *dp,
58235823
return NULL;
58245824
fl->fl_lmops = &nfsd_lease_mng_ops;
58255825
fl->c.flc_flags = FL_DELEG;
5826-
fl->c.flc_type = flag == NFS4_OPEN_DELEGATE_READ? F_RDLCK: F_WRLCK;
5826+
fl->c.flc_type = flag == OPEN_DELEGATE_READ ? F_RDLCK : F_WRLCK;
58275827
fl->c.flc_owner = (fl_owner_t)dp;
58285828
fl->c.flc_pid = current->tgid;
58295829
fl->c.flc_file = dp->dl_stid.sc_file->fi_deleg_file->nf_file;
@@ -5969,7 +5969,7 @@ nfs4_set_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp,
59695969
*/
59705970
if ((open->op_share_access & NFS4_SHARE_ACCESS_BOTH) == NFS4_SHARE_ACCESS_BOTH) {
59715971
nf = find_rw_file(fp);
5972-
dl_type = NFS4_OPEN_DELEGATE_WRITE;
5972+
dl_type = OPEN_DELEGATE_WRITE;
59735973
}
59745974

59755975
/*
@@ -5978,7 +5978,7 @@ nfs4_set_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp,
59785978
*/
59795979
if (!nf && (open->op_share_access & NFS4_SHARE_ACCESS_READ)) {
59805980
nf = find_readable_file(fp);
5981-
dl_type = NFS4_OPEN_DELEGATE_READ;
5981+
dl_type = OPEN_DELEGATE_READ;
59825982
}
59835983

59845984
if (!nf)
@@ -6067,7 +6067,7 @@ nfs4_set_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp,
60676067

60686068
static void nfsd4_open_deleg_none_ext(struct nfsd4_open *open, int status)
60696069
{
6070-
open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE_EXT;
6070+
open->op_delegate_type = OPEN_DELEGATE_NONE_EXT;
60716071
if (status == -EAGAIN)
60726072
open->op_why_no_deleg = WND4_CONTENTION;
60736073
else {
@@ -6183,20 +6183,20 @@ nfs4_open_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp,
61836183
destroy_delegation(dp);
61846184
goto out_no_deleg;
61856185
}
6186-
open->op_delegate_type = NFS4_OPEN_DELEGATE_WRITE;
6186+
open->op_delegate_type = OPEN_DELEGATE_WRITE;
61876187
dp->dl_cb_fattr.ncf_cur_fsize = stat.size;
61886188
dp->dl_cb_fattr.ncf_initial_cinfo = nfsd4_change_attribute(&stat);
61896189
trace_nfsd_deleg_write(&dp->dl_stid.sc_stateid);
61906190
} else {
6191-
open->op_delegate_type = NFS4_OPEN_DELEGATE_READ;
6191+
open->op_delegate_type = OPEN_DELEGATE_READ;
61926192
trace_nfsd_deleg_read(&dp->dl_stid.sc_stateid);
61936193
}
61946194
nfs4_put_stid(&dp->dl_stid);
61956195
return;
61966196
out_no_deleg:
6197-
open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE;
6197+
open->op_delegate_type = OPEN_DELEGATE_NONE;
61986198
if (open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS &&
6199-
open->op_delegate_type != NFS4_OPEN_DELEGATE_NONE) {
6199+
open->op_delegate_type != OPEN_DELEGATE_NONE) {
62006200
dprintk("NFSD: WARNING: refusing delegation reclaim\n");
62016201
open->op_recall = true;
62026202
}
@@ -6211,17 +6211,17 @@ static void nfsd4_deleg_xgrade_none_ext(struct nfsd4_open *open,
62116211
struct nfs4_delegation *dp)
62126212
{
62136213
if (open->op_deleg_want == NFS4_SHARE_WANT_READ_DELEG &&
6214-
dp->dl_type == NFS4_OPEN_DELEGATE_WRITE) {
6215-
open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE_EXT;
6214+
dp->dl_type == OPEN_DELEGATE_WRITE) {
6215+
open->op_delegate_type = OPEN_DELEGATE_NONE_EXT;
62166216
open->op_why_no_deleg = WND4_NOT_SUPP_DOWNGRADE;
62176217
} else if (open->op_deleg_want == NFS4_SHARE_WANT_WRITE_DELEG &&
6218-
dp->dl_type == NFS4_OPEN_DELEGATE_WRITE) {
6219-
open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE_EXT;
6218+
dp->dl_type == OPEN_DELEGATE_WRITE) {
6219+
open->op_delegate_type = OPEN_DELEGATE_NONE_EXT;
62206220
open->op_why_no_deleg = WND4_NOT_SUPP_UPGRADE;
62216221
}
62226222
/* Otherwise the client must be confused wanting a delegation
62236223
* it already has, therefore we don't return
6224-
* NFS4_OPEN_DELEGATE_NONE_EXT and reason.
6224+
* OPEN_DELEGATE_NONE_EXT and reason.
62256225
*/
62266226
}
62276227

@@ -6311,7 +6311,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
63116311

63126312
if (nfsd4_has_session(&resp->cstate)) {
63136313
if (open->op_deleg_want & NFS4_SHARE_WANT_NO_DELEG) {
6314-
open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE_EXT;
6314+
open->op_delegate_type = OPEN_DELEGATE_NONE_EXT;
63156315
open->op_why_no_deleg = WND4_NOT_WANTED;
63166316
goto nodeleg;
63176317
}
@@ -6327,7 +6327,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
63276327
trace_nfsd_open(&stp->st_stid.sc_stateid);
63286328
out:
63296329
/* 4.1 client trying to upgrade/downgrade delegation? */
6330-
if (open->op_delegate_type == NFS4_OPEN_DELEGATE_NONE && dp &&
6330+
if (open->op_delegate_type == OPEN_DELEGATE_NONE && dp &&
63316331
open->op_deleg_want)
63326332
nfsd4_deleg_xgrade_none_ext(open, dp);
63336333

fs/nfsd/nfs4xdr.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4233,18 +4233,18 @@ nfsd4_encode_open_delegation4(struct xdr_stream *xdr, struct nfsd4_open *open)
42334233
if (xdr_stream_encode_u32(xdr, open->op_delegate_type) != XDR_UNIT)
42344234
return nfserr_resource;
42354235
switch (open->op_delegate_type) {
4236-
case NFS4_OPEN_DELEGATE_NONE:
4236+
case OPEN_DELEGATE_NONE:
42374237
status = nfs_ok;
42384238
break;
4239-
case NFS4_OPEN_DELEGATE_READ:
4239+
case OPEN_DELEGATE_READ:
42404240
/* read */
42414241
status = nfsd4_encode_open_read_delegation4(xdr, open);
42424242
break;
4243-
case NFS4_OPEN_DELEGATE_WRITE:
4243+
case OPEN_DELEGATE_WRITE:
42444244
/* write */
42454245
status = nfsd4_encode_open_write_delegation4(xdr, open);
42464246
break;
4247-
case NFS4_OPEN_DELEGATE_NONE_EXT:
4247+
case OPEN_DELEGATE_NONE_EXT:
42484248
/* od_whynone */
42494249
status = nfsd4_encode_open_none_delegation4(xdr, open);
42504250
break;

fs/nfsd/nfs4xdr_gen.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22
// Generated by xdrgen. Manual edits will be lost.
33
// XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x
4-
// XDR specification modification time: Thu Oct 3 11:30:59 2024
4+
// XDR specification modification time: Sat Oct 12 08:10:54 2024
55

66
#include <linux/sunrpc/svc.h>
77

@@ -135,6 +135,17 @@ xdrgen_decode_fattr4_time_deleg_modify(struct xdr_stream *xdr, fattr4_time_deleg
135135
return xdrgen_decode_nfstime4(xdr, ptr);
136136
};
137137

138+
static bool __maybe_unused
139+
xdrgen_decode_open_delegation_type4(struct xdr_stream *xdr, open_delegation_type4 *ptr)
140+
{
141+
u32 val;
142+
143+
if (xdr_stream_decode_u32(xdr, &val) < 0)
144+
return false;
145+
*ptr = val;
146+
return true;
147+
}
148+
138149
static bool __maybe_unused
139150
xdrgen_encode_int64_t(struct xdr_stream *xdr, const int64_t value)
140151
{
@@ -237,3 +248,9 @@ xdrgen_encode_fattr4_time_deleg_modify(struct xdr_stream *xdr, const fattr4_time
237248
{
238249
return xdrgen_encode_nfstime4(xdr, value);
239250
};
251+
252+
static bool __maybe_unused
253+
xdrgen_encode_open_delegation_type4(struct xdr_stream *xdr, open_delegation_type4 value)
254+
{
255+
return xdr_stream_encode_u32(xdr, value) == XDR_UNIT;
256+
}

fs/nfsd/nfs4xdr_gen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
/* Generated by xdrgen. Manual edits will be lost. */
33
/* XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x */
4-
/* XDR specification modification time: Thu Oct 3 11:30:59 2024 */
4+
/* XDR specification modification time: Sat Oct 12 08:10:54 2024 */
55

66
#ifndef _LINUX_XDRGEN_NFS4_1_DECL_H
77
#define _LINUX_XDRGEN_NFS4_1_DECL_H

include/linux/nfs4.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ enum limit_by4 {
366366
NFS4_LIMIT_BLOCKS = 2
367367
};
368368

369-
enum open_delegation_type4 {
369+
enum nfs4_open_delegation_type4 {
370370
NFS4_OPEN_DELEGATE_NONE = 0,
371371
NFS4_OPEN_DELEGATE_READ = 1,
372372
NFS4_OPEN_DELEGATE_WRITE = 2,

include/linux/sunrpc/xdrgen/nfs4_1.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
/* Generated by xdrgen. Manual edits will be lost. */
33
/* XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x */
4-
/* XDR specification modification time: Thu Oct 3 11:30:59 2024 */
4+
/* XDR specification modification time: Sat Oct 12 08:10:54 2024 */
55

66
#ifndef _LINUX_XDRGEN_NFS4_1_DEF_H
77
#define _LINUX_XDRGEN_NFS4_1_DEF_H
@@ -98,6 +98,16 @@ enum { FATTR4_TIME_DELEG_MODIFY = 85 };
9898

9999
enum { OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS = 0x100000 };
100100

101+
enum open_delegation_type4 {
102+
OPEN_DELEGATE_NONE = 0,
103+
OPEN_DELEGATE_READ = 1,
104+
OPEN_DELEGATE_WRITE = 2,
105+
OPEN_DELEGATE_NONE_EXT = 3,
106+
OPEN_DELEGATE_READ_ATTRS_DELEG = 4,
107+
OPEN_DELEGATE_WRITE_ATTRS_DELEG = 5,
108+
};
109+
typedef enum open_delegation_type4 open_delegation_type4;
110+
101111
#define NFS4_int64_t_sz \
102112
(XDR_hyper)
103113
#define NFS4_uint32_t_sz \
@@ -120,5 +130,6 @@ enum { OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS = 0x100000 };
120130
(NFS4_nfstime4_sz)
121131
#define NFS4_fattr4_time_deleg_modify_sz \
122132
(NFS4_nfstime4_sz)
133+
#define NFS4_open_delegation_type4_sz (XDR_int)
123134

124135
#endif /* _LINUX_XDRGEN_NFS4_1_DEF_H */

0 commit comments

Comments
 (0)