]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.15/nfsd-move-filehandle-format-declarations-out-of-uapi.patch
Fixes for 5.15
[thirdparty/kernel/stable-queue.git] / queue-5.15 / nfsd-move-filehandle-format-declarations-out-of-uapi.patch
1 From 9f526d4537f7b46d119df8206c32483f9dcac572 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Thu, 2 Sep 2021 11:14:47 +1000
4 Subject: NFSD: move filehandle format declarations out of "uapi".
5
6 From: NeilBrown <neilb@suse.de>
7
8 [ Upstream commit ef5825e3cf0d0af657f5fb4dd86d750ed42fee0a ]
9
10 A small part of the declaration concerning filehandle format are
11 currently in the "uapi" include directory:
12 include/uapi/linux/nfsd/nfsfh.h
13
14 There is a lot more to the filehandle format, including "enum fid_type"
15 and "enum nfsd_fsid" which are not exported via "uapi".
16
17 This small part of the filehandle definition is of minimal use outside
18 of the kernel, and I can find no evidence that an other code is using
19 it. Certainly nfs-utils and wireshark (The most likely candidates) do not
20 use these declarations.
21
22 So move it out of "uapi" by copying the content from
23 include/uapi/linux/nfsd/nfsfh.h
24 into
25 fs/nfsd/nfsfh.h
26
27 A few unnecessary "#include" directives are not copied, and neither is
28 the #define of fh_auth, which is annotated as being for userspace only.
29
30 The copyright claims in the uapi file are identical to those in the nfsd
31 file, so there is no need to copy those.
32
33 The "__u32" style integer types are only needed in "uapi". In
34 kernel-only code we can use the more familiar "u32" style.
35
36 Signed-off-by: NeilBrown <neilb@suse.de>
37 Signed-off-by: J. Bruce Fields <bfields@redhat.com>
38 Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
39 ---
40 fs/nfsd/nfsfh.h | 97 ++++++++++++++++++++++++++-
41 fs/nfsd/vfs.c | 1 +
42 include/uapi/linux/nfsd/nfsfh.h | 115 --------------------------------
43 3 files changed, 97 insertions(+), 116 deletions(-)
44 delete mode 100644 include/uapi/linux/nfsd/nfsfh.h
45
46 diff --git a/fs/nfsd/nfsfh.h b/fs/nfsd/nfsfh.h
47 index 6106697adc04b..ad47f16676a8c 100644
48 --- a/fs/nfsd/nfsfh.h
49 +++ b/fs/nfsd/nfsfh.h
50 @@ -10,9 +10,104 @@
51
52 #include <linux/crc32.h>
53 #include <linux/sunrpc/svc.h>
54 -#include <uapi/linux/nfsd/nfsfh.h>
55 #include <linux/iversion.h>
56 #include <linux/exportfs.h>
57 +#include <linux/nfs4.h>
58 +
59 +
60 +/*
61 + * This is the old "dentry style" Linux NFSv2 file handle.
62 + *
63 + * The xino and xdev fields are currently used to transport the
64 + * ino/dev of the exported inode.
65 + */
66 +struct nfs_fhbase_old {
67 + u32 fb_dcookie; /* dentry cookie - always 0xfeebbaca */
68 + u32 fb_ino; /* our inode number */
69 + u32 fb_dirino; /* dir inode number, 0 for directories */
70 + u32 fb_dev; /* our device */
71 + u32 fb_xdev;
72 + u32 fb_xino;
73 + u32 fb_generation;
74 +};
75 +
76 +/*
77 + * This is the new flexible, extensible style NFSv2/v3/v4 file handle.
78 + *
79 + * The file handle starts with a sequence of four-byte words.
80 + * The first word contains a version number (1) and three descriptor bytes
81 + * that tell how the remaining 3 variable length fields should be handled.
82 + * These three bytes are auth_type, fsid_type and fileid_type.
83 + *
84 + * All four-byte values are in host-byte-order.
85 + *
86 + * The auth_type field is deprecated and must be set to 0.
87 + *
88 + * The fsid_type identifies how the filesystem (or export point) is
89 + * encoded.
90 + * Current values:
91 + * 0 - 4 byte device id (ms-2-bytes major, ls-2-bytes minor), 4byte inode number
92 + * NOTE: we cannot use the kdev_t device id value, because kdev_t.h
93 + * says we mustn't. We must break it up and reassemble.
94 + * 1 - 4 byte user specified identifier
95 + * 2 - 4 byte major, 4 byte minor, 4 byte inode number - DEPRECATED
96 + * 3 - 4 byte device id, encoded for user-space, 4 byte inode number
97 + * 4 - 4 byte inode number and 4 byte uuid
98 + * 5 - 8 byte uuid
99 + * 6 - 16 byte uuid
100 + * 7 - 8 byte inode number and 16 byte uuid
101 + *
102 + * The fileid_type identified how the file within the filesystem is encoded.
103 + * The values for this field are filesystem specific, exccept that
104 + * filesystems must not use the values '0' or '0xff'. 'See enum fid_type'
105 + * in include/linux/exportfs.h for currently registered values.
106 + */
107 +struct nfs_fhbase_new {
108 + union {
109 + struct {
110 + u8 fb_version_aux; /* == 1, even => nfs_fhbase_old */
111 + u8 fb_auth_type_aux;
112 + u8 fb_fsid_type_aux;
113 + u8 fb_fileid_type_aux;
114 + u32 fb_auth[1];
115 + /* u32 fb_fsid[0]; floating */
116 + /* u32 fb_fileid[0]; floating */
117 + };
118 + struct {
119 + u8 fb_version; /* == 1, even => nfs_fhbase_old */
120 + u8 fb_auth_type;
121 + u8 fb_fsid_type;
122 + u8 fb_fileid_type;
123 + u32 fb_auth_flex[]; /* flexible-array member */
124 + };
125 + };
126 +};
127 +
128 +struct knfsd_fh {
129 + unsigned int fh_size; /* significant for NFSv3.
130 + * Points to the current size while building
131 + * a new file handle
132 + */
133 + union {
134 + struct nfs_fhbase_old fh_old;
135 + u32 fh_pad[NFS4_FHSIZE/4];
136 + struct nfs_fhbase_new fh_new;
137 + } fh_base;
138 +};
139 +
140 +#define ofh_dcookie fh_base.fh_old.fb_dcookie
141 +#define ofh_ino fh_base.fh_old.fb_ino
142 +#define ofh_dirino fh_base.fh_old.fb_dirino
143 +#define ofh_dev fh_base.fh_old.fb_dev
144 +#define ofh_xdev fh_base.fh_old.fb_xdev
145 +#define ofh_xino fh_base.fh_old.fb_xino
146 +#define ofh_generation fh_base.fh_old.fb_generation
147 +
148 +#define fh_version fh_base.fh_new.fb_version
149 +#define fh_fsid_type fh_base.fh_new.fb_fsid_type
150 +#define fh_auth_type fh_base.fh_new.fb_auth_type
151 +#define fh_fileid_type fh_base.fh_new.fb_fileid_type
152 +#define fh_fsid fh_base.fh_new.fb_auth_flex
153
154 static inline __u32 ino_t_to_u32(ino_t ino)
155 {
156 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
157 index c39b8a6538042..24a5b5cfcfb03 100644
158 --- a/fs/nfsd/vfs.c
159 +++ b/fs/nfsd/vfs.c
160 @@ -244,6 +244,7 @@ nfsd_lookup_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp,
161 * returned. Otherwise the covered directory is returned.
162 * NOTE: this mountpoint crossing is not supported properly by all
163 * clients and is explicitly disallowed for NFSv3
164 + * NeilBrown <neilb@cse.unsw.edu.au>
165 */
166 __be32
167 nfsd_lookup(struct svc_rqst *rqstp, struct svc_fh *fhp, const char *name,
168 diff --git a/include/uapi/linux/nfsd/nfsfh.h b/include/uapi/linux/nfsd/nfsfh.h
169 deleted file mode 100644
170 index e29e8accc4f4d..0000000000000
171 --- a/include/uapi/linux/nfsd/nfsfh.h
172 +++ /dev/null
173 @@ -1,115 +0,0 @@
174 -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
175 -/*
176 - * This file describes the layout of the file handles as passed
177 - * over the wire.
178 - *
179 - * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de>
180 - */
181 -
182 -#ifndef _UAPI_LINUX_NFSD_FH_H
183 -#define _UAPI_LINUX_NFSD_FH_H
184 -
185 -#include <linux/types.h>
186 -#include <linux/nfs.h>
187 -#include <linux/nfs2.h>
188 -#include <linux/nfs3.h>
189 -#include <linux/nfs4.h>
190 -
191 -/*
192 - * This is the old "dentry style" Linux NFSv2 file handle.
193 - *
194 - * The xino and xdev fields are currently used to transport the
195 - * ino/dev of the exported inode.
196 - */
197 -struct nfs_fhbase_old {
198 - __u32 fb_dcookie; /* dentry cookie - always 0xfeebbaca */
199 - __u32 fb_ino; /* our inode number */
200 - __u32 fb_dirino; /* dir inode number, 0 for directories */
201 - __u32 fb_dev; /* our device */
202 - __u32 fb_xdev;
203 - __u32 fb_xino;
204 - __u32 fb_generation;
205 -};
206 -
207 -/*
208 - * This is the new flexible, extensible style NFSv2/v3/v4 file handle.
209 - *
210 - * The file handle starts with a sequence of four-byte words.
211 - * The first word contains a version number (1) and three descriptor bytes
212 - * that tell how the remaining 3 variable length fields should be handled.
213 - * These three bytes are auth_type, fsid_type and fileid_type.
214 - *
215 - * All four-byte values are in host-byte-order.
216 - *
217 - * The auth_type field is deprecated and must be set to 0.
218 - *
219 - * The fsid_type identifies how the filesystem (or export point) is
220 - * encoded.
221 - * Current values:
222 - * 0 - 4 byte device id (ms-2-bytes major, ls-2-bytes minor), 4byte inode number
223 - * NOTE: we cannot use the kdev_t device id value, because kdev_t.h
224 - * says we mustn't. We must break it up and reassemble.
225 - * 1 - 4 byte user specified identifier
226 - * 2 - 4 byte major, 4 byte minor, 4 byte inode number - DEPRECATED
227 - * 3 - 4 byte device id, encoded for user-space, 4 byte inode number
228 - * 4 - 4 byte inode number and 4 byte uuid
229 - * 5 - 8 byte uuid
230 - * 6 - 16 byte uuid
231 - * 7 - 8 byte inode number and 16 byte uuid
232 - *
233 - * The fileid_type identified how the file within the filesystem is encoded.
234 - * The values for this field are filesystem specific, exccept that
235 - * filesystems must not use the values '0' or '0xff'. 'See enum fid_type'
236 - * in include/linux/exportfs.h for currently registered values.
237 - */
238 -struct nfs_fhbase_new {
239 - union {
240 - struct {
241 - __u8 fb_version_aux; /* == 1, even => nfs_fhbase_old */
242 - __u8 fb_auth_type_aux;
243 - __u8 fb_fsid_type_aux;
244 - __u8 fb_fileid_type_aux;
245 - __u32 fb_auth[1];
246 - /* __u32 fb_fsid[0]; floating */
247 - /* __u32 fb_fileid[0]; floating */
248 - };
249 - struct {
250 - __u8 fb_version; /* == 1, even => nfs_fhbase_old */
251 - __u8 fb_auth_type;
252 - __u8 fb_fsid_type;
253 - __u8 fb_fileid_type;
254 - __u32 fb_auth_flex[]; /* flexible-array member */
255 - };
256 - };
257 -};
258 -
259 -struct knfsd_fh {
260 - unsigned int fh_size; /* significant for NFSv3.
261 - * Points to the current size while building
262 - * a new file handle
263 - */
264 - union {
265 - struct nfs_fhbase_old fh_old;
266 - __u32 fh_pad[NFS4_FHSIZE/4];
267 - struct nfs_fhbase_new fh_new;
268 - } fh_base;
269 -};
270 -
271 -#define ofh_dcookie fh_base.fh_old.fb_dcookie
272 -#define ofh_ino fh_base.fh_old.fb_ino
273 -#define ofh_dirino fh_base.fh_old.fb_dirino
274 -#define ofh_dev fh_base.fh_old.fb_dev
275 -#define ofh_xdev fh_base.fh_old.fb_xdev
276 -#define ofh_xino fh_base.fh_old.fb_xino
277 -#define ofh_generation fh_base.fh_old.fb_generation
278 -
279 -#define fh_version fh_base.fh_new.fb_version
280 -#define fh_fsid_type fh_base.fh_new.fb_fsid_type
281 -#define fh_auth_type fh_base.fh_new.fb_auth_type
282 -#define fh_fileid_type fh_base.fh_new.fb_fileid_type
283 -#define fh_fsid fh_base.fh_new.fb_auth_flex
284 -
285 -/* Do not use, provided for userspace compatiblity. */
286 -#define fh_auth fh_base.fh_new.fb_auth
287 -
288 -#endif /* _UAPI_LINUX_NFSD_FH_H */
289 --
290 2.43.0
291