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()
6 From: Chuck Lever <chuck.lever@oracle.com>
8 [ Upstream commit 1c388f27759c5d9271d4fca081f7ee138986eb7d ]
10 Now that its two callers have their own version-specific instance of
11 this function, do_nfsd_create() is no longer used.
13 Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 fs/nfsd/vfs.c | 150 --------------------------------------------------
16 fs/nfsd/vfs.h | 10 ----
17 2 files changed, 160 deletions(-)
19 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
20 index e4f100a43ce52..9dd14c0eaebd1 100644
23 @@ -1395,156 +1395,6 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
28 - * NFSv3 and NFSv4 version of nfsd_create
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)
36 - struct dentry *dentry, *dchild = NULL;
40 - __u32 v_mtime=0, v_atime=0;
46 - if (isdotent(fname, flen))
48 - if (!(iap->ia_valid & ATTR_MODE))
50 - err = fh_verify(rqstp, fhp, S_IFDIR, NFSD_MAY_EXEC);
54 - dentry = fhp->fh_dentry;
55 - dirp = d_inode(dentry);
57 - host_err = fh_want_write(fhp);
61 - fh_lock_nested(fhp, I_MUTEX_PARENT);
64 - * Compose the response file handle.
66 - dchild = lookup_one_len(fname, dentry, flen);
67 - host_err = PTR_ERR(dchild);
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);
78 - err = fh_compose(resfhp, fhp->fh_export, dchild, fhp);
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
90 - v_mtime = verifier[0]&0x7fffffff;
91 - v_atime = verifier[1]&0x7fffffff;
94 - if (d_really_is_positive(dchild)) {
97 - switch (createmode) {
98 - case NFS3_CREATE_UNCHECKED:
99 - if (! d_is_reg(dchild))
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!
109 - *truncp = (iap->ia_valid & ATTR_SIZE) && !iap->ia_size;
112 - iap->ia_valid &= ATTR_SIZE;
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 ) {
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 ) {
134 - case NFS3_CREATE_GUARDED:
135 - err = nfserr_exist;
140 - if (!IS_POSIXACL(dirp))
141 - iap->ia_mode &= ~current_umask();
143 - host_err = vfs_create(&init_user_ns, dirp, dchild, iap->ia_mode, true);
149 - nfsd_check_ignore_resizing(iap);
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;
163 - err = nfsd_create_setattr(rqstp, fhp, resfhp, iap);
167 - if (dchild && !IS_ERR(dchild))
169 - fh_drop_write(fhp);
173 - err = nfserrno(host_err);
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
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));
199 -static inline int nfsd_create_is_exclusive(int createmode)
201 - return createmode == NFS3_CREATE_EXCLUSIVE
202 - || createmode == NFS4_CREATE_EXCLUSIVE4_1;
205 #endif /* LINUX_NFSD_VFS_H */