vfs.c (bb4d53d66e4b8c8b8e5634802262e53851a2d2db) | vfs.c (dd8dd403d7b223cc77ee89d8d09caf045e90e648) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * File operations used by nfsd. Some of these have been ripped from 4 * other parts of the kernel because they weren't exported, others 5 * are partial duplicates with added or changed functionality. 6 * 7 * Note that several functions dget() the dentry upon which they want 8 * to act, most notably those that create directory entries. Response --- 1251 unchanged lines hidden (view full) --- 1260 struct iattr *iap = attrs->na_iattr; 1261 __be32 err; 1262 int host_err; 1263 1264 dentry = fhp->fh_dentry; 1265 dirp = d_inode(dentry); 1266 1267 dchild = dget(resfhp->fh_dentry); | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * File operations used by nfsd. Some of these have been ripped from 4 * other parts of the kernel because they weren't exported, others 5 * are partial duplicates with added or changed functionality. 6 * 7 * Note that several functions dget() the dentry upon which they want 8 * to act, most notably those that create directory entries. Response --- 1251 unchanged lines hidden (view full) --- 1260 struct iattr *iap = attrs->na_iattr; 1261 __be32 err; 1262 int host_err; 1263 1264 dentry = fhp->fh_dentry; 1265 dirp = d_inode(dentry); 1266 1267 dchild = dget(resfhp->fh_dentry); |
1268 if (!fhp->fh_locked) { 1269 WARN_ONCE(1, "nfsd_create: parent %pd2 not locked!\n", 1270 dentry); 1271 err = nfserr_io; 1272 goto out; 1273 } 1274 | |
1275 err = nfsd_permission(rqstp, fhp->fh_export, dentry, NFSD_MAY_CREATE); 1276 if (err) 1277 goto out; 1278 1279 if (!(iap->ia_valid & ATTR_MODE)) 1280 iap->ia_mode = 0; 1281 iap->ia_mode = (iap->ia_mode & S_IALLUGO) | type; 1282 --- 346 unchanged lines hidden (view full) --- 1629 1630retry: 1631 host_err = fh_want_write(ffhp); 1632 if (host_err) { 1633 err = nfserrno(host_err); 1634 goto out; 1635 } 1636 | 1268 err = nfsd_permission(rqstp, fhp->fh_export, dentry, NFSD_MAY_CREATE); 1269 if (err) 1270 goto out; 1271 1272 if (!(iap->ia_valid & ATTR_MODE)) 1273 iap->ia_mode = 0; 1274 iap->ia_mode = (iap->ia_mode & S_IALLUGO) | type; 1275 --- 346 unchanged lines hidden (view full) --- 1622 1623retry: 1624 host_err = fh_want_write(ffhp); 1625 if (host_err) { 1626 err = nfserrno(host_err); 1627 goto out; 1628 } 1629 |
1637 /* cannot use fh_lock as we need deadlock protective ordering 1638 * so do it by hand */ | |
1639 trap = lock_rename(tdentry, fdentry); | 1630 trap = lock_rename(tdentry, fdentry); |
1640 ffhp->fh_locked = tfhp->fh_locked = true; | |
1641 fh_fill_pre_attrs(ffhp); 1642 fh_fill_pre_attrs(tfhp); 1643 1644 odentry = lookup_one_len(fname, fdentry, flen); 1645 host_err = PTR_ERR(odentry); 1646 if (IS_ERR(odentry)) 1647 goto out_nfserr; 1648 --- 39 unchanged lines hidden (view full) --- 1688 } 1689 } 1690 out_dput_new: 1691 dput(ndentry); 1692 out_dput_old: 1693 dput(odentry); 1694 out_nfserr: 1695 err = nfserrno(host_err); | 1631 fh_fill_pre_attrs(ffhp); 1632 fh_fill_pre_attrs(tfhp); 1633 1634 odentry = lookup_one_len(fname, fdentry, flen); 1635 host_err = PTR_ERR(odentry); 1636 if (IS_ERR(odentry)) 1637 goto out_nfserr; 1638 --- 39 unchanged lines hidden (view full) --- 1678 } 1679 } 1680 out_dput_new: 1681 dput(ndentry); 1682 out_dput_old: 1683 dput(odentry); 1684 out_nfserr: 1685 err = nfserrno(host_err); |
1696 /* 1697 * We cannot rely on fh_unlock on the two filehandles, 1698 * as that would do the wrong thing if the two directories 1699 * were the same, so again we do it by hand. 1700 */ | 1686 |
1701 if (!close_cached) { 1702 fh_fill_post_attrs(ffhp); 1703 fh_fill_post_attrs(tfhp); 1704 } 1705 unlock_rename(tdentry, fdentry); | 1687 if (!close_cached) { 1688 fh_fill_post_attrs(ffhp); 1689 fh_fill_post_attrs(tfhp); 1690 } 1691 unlock_rename(tdentry, fdentry); |
1706 ffhp->fh_locked = tfhp->fh_locked = false; | |
1707 fh_drop_write(ffhp); 1708 1709 /* 1710 * If the target dentry has cached open files, then we need to try to 1711 * close them prior to doing the rename. Flushing delayed fput 1712 * shouldn't be done with locks held however, so we delay it until this 1713 * point and then reattempt the whole shebang. 1714 */ --- 593 unchanged lines hidden --- | 1692 fh_drop_write(ffhp); 1693 1694 /* 1695 * If the target dentry has cached open files, then we need to try to 1696 * close them prior to doing the rename. Flushing delayed fput 1697 * shouldn't be done with locks held however, so we delay it until this 1698 * point and then reattempt the whole shebang. 1699 */ --- 593 unchanged lines hidden --- |