Skip to content

Commit 1c388f2

Browse files
committed
NFSD: Remove do_nfsd_create()
Now that its two callers have their own version-specific instance of this function, do_nfsd_create() is no longer used. Signed-off-by: Chuck Lever <[email protected]>
1 parent 254454a commit 1c388f2

File tree

2 files changed

+0
-160
lines changed

2 files changed

+0
-160
lines changed

fs/nfsd/vfs.c

Lines changed: 0 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,156 +1387,6 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
13871387
rdev, resfhp);
13881388
}
13891389

1390-
/*
1391-
* NFSv3 and NFSv4 version of nfsd_create
1392-
*/
1393-
__be32
1394-
do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
1395-
char *fname, int flen, struct iattr *iap,
1396-
struct svc_fh *resfhp, int createmode, u32 *verifier,
1397-
bool *truncp, bool *created)
1398-
{
1399-
struct dentry *dentry, *dchild = NULL;
1400-
struct inode *dirp;
1401-
__be32 err;
1402-
int host_err;
1403-
__u32 v_mtime=0, v_atime=0;
1404-
1405-
err = nfserr_perm;
1406-
if (!flen)
1407-
goto out;
1408-
err = nfserr_exist;
1409-
if (isdotent(fname, flen))
1410-
goto out;
1411-
if (!(iap->ia_valid & ATTR_MODE))
1412-
iap->ia_mode = 0;
1413-
err = fh_verify(rqstp, fhp, S_IFDIR, NFSD_MAY_EXEC);
1414-
if (err)
1415-
goto out;
1416-
1417-
dentry = fhp->fh_dentry;
1418-
dirp = d_inode(dentry);
1419-
1420-
host_err = fh_want_write(fhp);
1421-
if (host_err)
1422-
goto out_nfserr;
1423-
1424-
fh_lock_nested(fhp, I_MUTEX_PARENT);
1425-
1426-
/*
1427-
* Compose the response file handle.
1428-
*/
1429-
dchild = lookup_one_len(fname, dentry, flen);
1430-
host_err = PTR_ERR(dchild);
1431-
if (IS_ERR(dchild))
1432-
goto out_nfserr;
1433-
1434-
/* If file doesn't exist, check for permissions to create one */
1435-
if (d_really_is_negative(dchild)) {
1436-
err = fh_verify(rqstp, fhp, S_IFDIR, NFSD_MAY_CREATE);
1437-
if (err)
1438-
goto out;
1439-
}
1440-
1441-
err = fh_compose(resfhp, fhp->fh_export, dchild, fhp);
1442-
if (err)
1443-
goto out;
1444-
1445-
if (nfsd_create_is_exclusive(createmode)) {
1446-
/* solaris7 gets confused (bugid 4218508) if these have
1447-
* the high bit set, as do xfs filesystems without the
1448-
* "bigtime" feature. So just clear the high bits. If this is
1449-
* ever changed to use different attrs for storing the
1450-
* verifier, then do_open_lookup() will also need to be fixed
1451-
* accordingly.
1452-
*/
1453-
v_mtime = verifier[0]&0x7fffffff;
1454-
v_atime = verifier[1]&0x7fffffff;
1455-
}
1456-
1457-
if (d_really_is_positive(dchild)) {
1458-
err = 0;
1459-
1460-
switch (createmode) {
1461-
case NFS3_CREATE_UNCHECKED:
1462-
if (! d_is_reg(dchild))
1463-
goto out;
1464-
else if (truncp) {
1465-
/* in nfsv4, we need to treat this case a little
1466-
* differently. we don't want to truncate the
1467-
* file now; this would be wrong if the OPEN
1468-
* fails for some other reason. furthermore,
1469-
* if the size is nonzero, we should ignore it
1470-
* according to spec!
1471-
*/
1472-
*truncp = (iap->ia_valid & ATTR_SIZE) && !iap->ia_size;
1473-
}
1474-
else {
1475-
iap->ia_valid &= ATTR_SIZE;
1476-
goto set_attr;
1477-
}
1478-
break;
1479-
case NFS3_CREATE_EXCLUSIVE:
1480-
if ( d_inode(dchild)->i_mtime.tv_sec == v_mtime
1481-
&& d_inode(dchild)->i_atime.tv_sec == v_atime
1482-
&& d_inode(dchild)->i_size == 0 ) {
1483-
if (created)
1484-
*created = true;
1485-
break;
1486-
}
1487-
fallthrough;
1488-
case NFS4_CREATE_EXCLUSIVE4_1:
1489-
if ( d_inode(dchild)->i_mtime.tv_sec == v_mtime
1490-
&& d_inode(dchild)->i_atime.tv_sec == v_atime
1491-
&& d_inode(dchild)->i_size == 0 ) {
1492-
if (created)
1493-
*created = true;
1494-
goto set_attr;
1495-
}
1496-
fallthrough;
1497-
case NFS3_CREATE_GUARDED:
1498-
err = nfserr_exist;
1499-
}
1500-
goto out;
1501-
}
1502-
1503-
if (!IS_POSIXACL(dirp))
1504-
iap->ia_mode &= ~current_umask();
1505-
1506-
host_err = vfs_create(&init_user_ns, dirp, dchild, iap->ia_mode, true);
1507-
if (host_err < 0)
1508-
goto out_nfserr;
1509-
if (created)
1510-
*created = true;
1511-
1512-
nfsd_check_ignore_resizing(iap);
1513-
1514-
if (nfsd_create_is_exclusive(createmode)) {
1515-
/* Cram the verifier into atime/mtime */
1516-
iap->ia_valid = ATTR_MTIME|ATTR_ATIME
1517-
| ATTR_MTIME_SET|ATTR_ATIME_SET;
1518-
/* XXX someone who knows this better please fix it for nsec */
1519-
iap->ia_mtime.tv_sec = v_mtime;
1520-
iap->ia_atime.tv_sec = v_atime;
1521-
iap->ia_mtime.tv_nsec = 0;
1522-
iap->ia_atime.tv_nsec = 0;
1523-
}
1524-
1525-
set_attr:
1526-
err = nfsd_create_setattr(rqstp, fhp, resfhp, iap);
1527-
1528-
out:
1529-
fh_unlock(fhp);
1530-
if (dchild && !IS_ERR(dchild))
1531-
dput(dchild);
1532-
fh_drop_write(fhp);
1533-
return err;
1534-
1535-
out_nfserr:
1536-
err = nfserrno(host_err);
1537-
goto out;
1538-
}
1539-
15401390
/*
15411391
* Read a symlink. On entry, *lenp must contain the maximum path length that
15421392
* fits into the buffer. On return, it contains the true length.

fs/nfsd/vfs.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ __be32 nfsd_create(struct svc_rqst *, struct svc_fh *,
7171
__be32 nfsd_access(struct svc_rqst *, struct svc_fh *, u32 *, u32 *);
7272
__be32 nfsd_create_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
7373
struct svc_fh *resfhp, struct iattr *iap);
74-
__be32 do_nfsd_create(struct svc_rqst *, struct svc_fh *,
75-
char *name, int len, struct iattr *attrs,
76-
struct svc_fh *res, int createmode,
77-
u32 *verifier, bool *truncp, bool *created);
7874
__be32 nfsd_commit(struct svc_rqst *rqst, struct svc_fh *fhp,
7975
u64 offset, u32 count, __be32 *verf);
8076
#ifdef CONFIG_NFSD_V4
@@ -161,10 +157,4 @@ static inline __be32 fh_getattr(const struct svc_fh *fh, struct kstat *stat)
161157
AT_STATX_SYNC_AS_STAT));
162158
}
163159

164-
static inline int nfsd_create_is_exclusive(int createmode)
165-
{
166-
return createmode == NFS3_CREATE_EXCLUSIVE
167-
|| createmode == NFS4_CREATE_EXCLUSIVE4_1;
168-
}
169-
170160
#endif /* LINUX_NFSD_VFS_H */

0 commit comments

Comments
 (0)