]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.15/nfsd-remove-do_nfsd_create.patch
Fixes for 5.15
[thirdparty/kernel/stable-queue.git] / queue-5.15 / nfsd-remove-do_nfsd_create.patch
1 From fcd4e3c5a6f4b315cc4bc05083031e5aba7a11ca Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Mon, 28 Mar 2022 15:36:58 -0400
4 Subject: NFSD: Remove do_nfsd_create()
5
6 From: Chuck Lever <chuck.lever@oracle.com>
7
8 [ Upstream commit 1c388f27759c5d9271d4fca081f7ee138986eb7d ]
9
10 Now that its two callers have their own version-specific instance of
11 this function, do_nfsd_create() is no longer used.
12
13 Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
14 ---
15 fs/nfsd/vfs.c | 150 --------------------------------------------------
16 fs/nfsd/vfs.h | 10 ----
17 2 files changed, 160 deletions(-)
18
19 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
20 index e4f100a43ce52..9dd14c0eaebd1 100644
21 --- a/fs/nfsd/vfs.c
22 +++ b/fs/nfsd/vfs.c
23 @@ -1395,156 +1395,6 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
24 rdev, resfhp);
25 }
26
27 -/*
28 - * NFSv3 and NFSv4 version of nfsd_create
29 - */
30 -__be32
31 -do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
32 - char *fname, int flen, struct iattr *iap,
33 - struct svc_fh *resfhp, int createmode, u32 *verifier,
34 - bool *truncp, bool *created)
35 -{
36 - struct dentry *dentry, *dchild = NULL;
37 - struct inode *dirp;
38 - __be32 err;
39 - int host_err;
40 - __u32 v_mtime=0, v_atime=0;
41 -
42 - err = nfserr_perm;
43 - if (!flen)
44 - goto out;
45 - err = nfserr_exist;
46 - if (isdotent(fname, flen))
47 - goto out;
48 - if (!(iap->ia_valid & ATTR_MODE))
49 - iap->ia_mode = 0;
50 - err = fh_verify(rqstp, fhp, S_IFDIR, NFSD_MAY_EXEC);
51 - if (err)
52 - goto out;
53 -
54 - dentry = fhp->fh_dentry;
55 - dirp = d_inode(dentry);
56 -
57 - host_err = fh_want_write(fhp);
58 - if (host_err)
59 - goto out_nfserr;
60 -
61 - fh_lock_nested(fhp, I_MUTEX_PARENT);
62 -
63 - /*
64 - * Compose the response file handle.
65 - */
66 - dchild = lookup_one_len(fname, dentry, flen);
67 - host_err = PTR_ERR(dchild);
68 - if (IS_ERR(dchild))
69 - goto out_nfserr;
70 -
71 - /* If file doesn't exist, check for permissions to create one */
72 - if (d_really_is_negative(dchild)) {
73 - err = fh_verify(rqstp, fhp, S_IFDIR, NFSD_MAY_CREATE);
74 - if (err)
75 - goto out;
76 - }
77 -
78 - err = fh_compose(resfhp, fhp->fh_export, dchild, fhp);
79 - if (err)
80 - goto out;
81 -
82 - if (nfsd_create_is_exclusive(createmode)) {
83 - /* solaris7 gets confused (bugid 4218508) if these have
84 - * the high bit set, as do xfs filesystems without the
85 - * "bigtime" feature. So just clear the high bits. If this is
86 - * ever changed to use different attrs for storing the
87 - * verifier, then do_open_lookup() will also need to be fixed
88 - * accordingly.
89 - */
90 - v_mtime = verifier[0]&0x7fffffff;
91 - v_atime = verifier[1]&0x7fffffff;
92 - }
93 -
94 - if (d_really_is_positive(dchild)) {
95 - err = 0;
96 -
97 - switch (createmode) {
98 - case NFS3_CREATE_UNCHECKED:
99 - if (! d_is_reg(dchild))
100 - goto out;
101 - else if (truncp) {
102 - /* in nfsv4, we need to treat this case a little
103 - * differently. we don't want to truncate the
104 - * file now; this would be wrong if the OPEN
105 - * fails for some other reason. furthermore,
106 - * if the size is nonzero, we should ignore it
107 - * according to spec!
108 - */
109 - *truncp = (iap->ia_valid & ATTR_SIZE) && !iap->ia_size;
110 - }
111 - else {
112 - iap->ia_valid &= ATTR_SIZE;
113 - goto set_attr;
114 - }
115 - break;
116 - case NFS3_CREATE_EXCLUSIVE:
117 - if ( d_inode(dchild)->i_mtime.tv_sec == v_mtime
118 - && d_inode(dchild)->i_atime.tv_sec == v_atime
119 - && d_inode(dchild)->i_size == 0 ) {
120 - if (created)
121 - *created = true;
122 - break;
123 - }
124 - fallthrough;
125 - case NFS4_CREATE_EXCLUSIVE4_1:
126 - if ( d_inode(dchild)->i_mtime.tv_sec == v_mtime
127 - && d_inode(dchild)->i_atime.tv_sec == v_atime
128 - && d_inode(dchild)->i_size == 0 ) {
129 - if (created)
130 - *created = true;
131 - goto set_attr;
132 - }
133 - fallthrough;
134 - case NFS3_CREATE_GUARDED:
135 - err = nfserr_exist;
136 - }
137 - goto out;
138 - }
139 -
140 - if (!IS_POSIXACL(dirp))
141 - iap->ia_mode &= ~current_umask();
142 -
143 - host_err = vfs_create(&init_user_ns, dirp, dchild, iap->ia_mode, true);
144 - if (host_err < 0)
145 - goto out_nfserr;
146 - if (created)
147 - *created = true;
148 -
149 - nfsd_check_ignore_resizing(iap);
150 -
151 - if (nfsd_create_is_exclusive(createmode)) {
152 - /* Cram the verifier into atime/mtime */
153 - iap->ia_valid = ATTR_MTIME|ATTR_ATIME
154 - | ATTR_MTIME_SET|ATTR_ATIME_SET;
155 - /* XXX someone who knows this better please fix it for nsec */
156 - iap->ia_mtime.tv_sec = v_mtime;
157 - iap->ia_atime.tv_sec = v_atime;
158 - iap->ia_mtime.tv_nsec = 0;
159 - iap->ia_atime.tv_nsec = 0;
160 - }
161 -
162 - set_attr:
163 - err = nfsd_create_setattr(rqstp, fhp, resfhp, iap);
164 -
165 - out:
166 - fh_unlock(fhp);
167 - if (dchild && !IS_ERR(dchild))
168 - dput(dchild);
169 - fh_drop_write(fhp);
170 - return err;
171 -
172 - out_nfserr:
173 - err = nfserrno(host_err);
174 - goto out;
175 -}
176 -
177 /*
178 * Read a symlink. On entry, *lenp must contain the maximum path length that
179 * fits into the buffer. On return, it contains the true length.
180 diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h
181 index 1f32a83456b03..f99794b033a55 100644
182 --- a/fs/nfsd/vfs.h
183 +++ b/fs/nfsd/vfs.h
184 @@ -71,10 +71,6 @@ __be32 nfsd_create(struct svc_rqst *, struct svc_fh *,
185 __be32 nfsd_access(struct svc_rqst *, struct svc_fh *, u32 *, u32 *);
186 __be32 nfsd_create_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
187 struct svc_fh *resfhp, struct iattr *iap);
188 -__be32 do_nfsd_create(struct svc_rqst *, struct svc_fh *,
189 - char *name, int len, struct iattr *attrs,
190 - struct svc_fh *res, int createmode,
191 - u32 *verifier, bool *truncp, bool *created);
192 __be32 nfsd_commit(struct svc_rqst *rqst, struct svc_fh *fhp,
193 u64 offset, u32 count, __be32 *verf);
194 #ifdef CONFIG_NFSD_V4
195 @@ -161,10 +157,4 @@ static inline __be32 fh_getattr(const struct svc_fh *fh, struct kstat *stat)
196 AT_STATX_SYNC_AS_STAT));
197 }
198
199 -static inline int nfsd_create_is_exclusive(int createmode)
200 -{
201 - return createmode == NFS3_CREATE_EXCLUSIVE
202 - || createmode == NFS4_CREATE_EXCLUSIVE4_1;
203 -}
204 -
205 #endif /* LINUX_NFSD_VFS_H */
206 --
207 2.43.0
208