dir.c (0898782247ae533d1f4e47a06bc5d4870931b284) dir.c (406cd91533dcc5e82ef2373c39e6a531d944131e)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * linux/fs/nfs/dir.c
4 *
5 * Copyright (C) 1992 Rick Sladkey
6 *
7 * nfs directory handling functions
8 *

--- 1655 unchanged lines hidden (view full) ---

1664static int nfs4_lookup_revalidate(struct dentry *dentry, unsigned int flags)
1665{
1666 return __nfs_lookup_revalidate(dentry, flags,
1667 nfs4_do_lookup_revalidate);
1668}
1669
1670#endif /* CONFIG_NFSV4 */
1671
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * linux/fs/nfs/dir.c
4 *
5 * Copyright (C) 1992 Rick Sladkey
6 *
7 * nfs directory handling functions
8 *

--- 1655 unchanged lines hidden (view full) ---

1664static int nfs4_lookup_revalidate(struct dentry *dentry, unsigned int flags)
1665{
1666 return __nfs_lookup_revalidate(dentry, flags,
1667 nfs4_do_lookup_revalidate);
1668}
1669
1670#endif /* CONFIG_NFSV4 */
1671
1672/*
1673 * Code common to create, mkdir, and mknod.
1674 */
1675int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle,
1672struct dentry *
1673nfs_add_or_obtain(struct dentry *dentry, struct nfs_fh *fhandle,
1676 struct nfs_fattr *fattr,
1677 struct nfs4_label *label)
1678{
1679 struct dentry *parent = dget_parent(dentry);
1680 struct inode *dir = d_inode(parent);
1681 struct inode *inode;
1674 struct nfs_fattr *fattr,
1675 struct nfs4_label *label)
1676{
1677 struct dentry *parent = dget_parent(dentry);
1678 struct inode *dir = d_inode(parent);
1679 struct inode *inode;
1682 struct dentry *d;
1683 int error = -EACCES;
1680 struct dentry *d = NULL;
1681 int error;
1684
1685 d_drop(dentry);
1686
1687 /* We may have been initialized further down */
1688 if (d_really_is_positive(dentry))
1689 goto out;
1682
1683 d_drop(dentry);
1684
1685 /* We may have been initialized further down */
1686 if (d_really_is_positive(dentry))
1687 goto out;
1688
1690 if (fhandle->size == 0) {
1691 error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, NULL);
1692 if (error)
1693 goto out_error;
1694 }
1695 nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
1696 if (!(fattr->valid & NFS_ATTR_FATTR)) {
1697 struct nfs_server *server = NFS_SB(dentry->d_sb);
1698 error = server->nfs_client->rpc_ops->getattr(server, fhandle,
1699 fattr, NULL, NULL);
1700 if (error < 0)
1701 goto out_error;
1702 }
1703 inode = nfs_fhget(dentry->d_sb, fhandle, fattr, label);
1704 d = d_splice_alias(inode, dentry);
1689 if (fhandle->size == 0) {
1690 error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, NULL);
1691 if (error)
1692 goto out_error;
1693 }
1694 nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
1695 if (!(fattr->valid & NFS_ATTR_FATTR)) {
1696 struct nfs_server *server = NFS_SB(dentry->d_sb);
1697 error = server->nfs_client->rpc_ops->getattr(server, fhandle,
1698 fattr, NULL, NULL);
1699 if (error < 0)
1700 goto out_error;
1701 }
1702 inode = nfs_fhget(dentry->d_sb, fhandle, fattr, label);
1703 d = d_splice_alias(inode, dentry);
1705 if (IS_ERR(d)) {
1706 error = PTR_ERR(d);
1707 goto out_error;
1708 }
1709 dput(d);
1710out:
1711 dput(parent);
1704out:
1705 dput(parent);
1712 return 0;
1706 return d;
1713out_error:
1714 nfs_mark_for_revalidate(dir);
1707out_error:
1708 nfs_mark_for_revalidate(dir);
1715 dput(parent);
1716 return error;
1709 d = ERR_PTR(error);
1710 goto out;
1717}
1711}
1712EXPORT_SYMBOL_GPL(nfs_add_or_obtain);
1713
1714/*
1715 * Code common to create, mkdir, and mknod.
1716 */
1717int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle,
1718 struct nfs_fattr *fattr,
1719 struct nfs4_label *label)
1720{
1721 struct dentry *d;
1722
1723 d = nfs_add_or_obtain(dentry, fhandle, fattr, label);
1724 if (IS_ERR(d))
1725 return PTR_ERR(d);
1726
1727 /* Callers don't care */
1728 dput(d);
1729 return 0;
1730}
1718EXPORT_SYMBOL_GPL(nfs_instantiate);
1719
1720/*
1721 * Following a failed create operation, we drop the dentry rather
1722 * than retain a negative dentry. This avoids a problem in the event
1723 * that the operation succeeded on the server, but an error in the
1724 * reply path made it appear to have failed.
1725 */

--- 893 unchanged lines hidden ---
1731EXPORT_SYMBOL_GPL(nfs_instantiate);
1732
1733/*
1734 * Following a failed create operation, we drop the dentry rather
1735 * than retain a negative dentry. This avoids a problem in the event
1736 * that the operation succeeded on the server, but an error in the
1737 * reply path made it appear to have failed.
1738 */

--- 893 unchanged lines hidden ---