aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dcache.c
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2014-02-14 17:35:37 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2014-08-07 14:40:10 -0400
commit1a0a397e41cb1bf70cfe45fd0eeff08c7c501ec0 (patch)
treec02c59997a3849bb1bfdcc3ac371bb1e4d2f81bc /fs/dcache.c
parentda093a9b76efca0a7a217af538929e1ecb204466 (diff)
dcache: d_obtain_alias callers don't all want DISCONNECTED
There are a few d_obtain_alias callers that are using it to get the root of a filesystem which may already have an alias somewhere else. This is not the same as the filehandle-lookup case, and none of them actually need DCACHE_DISCONNECTED set. It isn't really a serious problem, but it would really be clearer if we reserved DCACHE_DISCONNECTED for those cases where it's actually needed. In the btrfs case this was causing a spurious printk from nfsd/nfsfh.c:fh_verify when it found an unexpected DCACHE_DISCONNECTED dentry. Josef worked around this by unsetting DCACHE_DISCONNECTED manually in 3a0dfa6a12e "Btrfs: unset DCACHE_DISCONNECTED when mounting default subvol", and this replaces that workaround. Cc: Josef Bacik <jbacik@fb.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/dcache.c')
-rw-r--r--fs/dcache.c69
1 files changed, 49 insertions, 20 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index 3ed095363997..63d556c0e698 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1781,25 +1781,7 @@ struct dentry *d_find_any_alias(struct inode *inode)
1781} 1781}
1782EXPORT_SYMBOL(d_find_any_alias); 1782EXPORT_SYMBOL(d_find_any_alias);
1783 1783
1784/** 1784struct dentry *__d_obtain_alias(struct inode *inode, int disconnected)
1785 * d_obtain_alias - find or allocate a dentry for a given inode
1786 * @inode: inode to allocate the dentry for
1787 *
1788 * Obtain a dentry for an inode resulting from NFS filehandle conversion or
1789 * similar open by handle operations. The returned dentry may be anonymous,
1790 * or may have a full name (if the inode was already in the cache).
1791 *
1792 * When called on a directory inode, we must ensure that the inode only ever
1793 * has one dentry. If a dentry is found, that is returned instead of
1794 * allocating a new one.
1795 *
1796 * On successful return, the reference to the inode has been transferred
1797 * to the dentry. In case of an error the reference on the inode is released.
1798 * To make it easier to use in export operations a %NULL or IS_ERR inode may
1799 * be passed in and will be the error will be propagate to the return value,
1800 * with a %NULL @inode replaced by ERR_PTR(-ESTALE).
1801 */
1802struct dentry *d_obtain_alias(struct inode *inode)
1803{ 1785{
1804 static const struct qstr anonstring = QSTR_INIT("/", 1); 1786 static const struct qstr anonstring = QSTR_INIT("/", 1);
1805 struct dentry *tmp; 1787 struct dentry *tmp;
@@ -1830,7 +1812,10 @@ struct dentry *d_obtain_alias(struct inode *inode)
1830 } 1812 }
1831 1813
1832 /* attach a disconnected dentry */ 1814 /* attach a disconnected dentry */
1833 add_flags = d_flags_for_inode(inode) | DCACHE_DISCONNECTED; 1815 add_flags = d_flags_for_inode(inode);
1816
1817 if (disconnected)
1818 add_flags |= DCACHE_DISCONNECTED;
1834 1819
1835 spin_lock(&tmp->d_lock); 1820 spin_lock(&tmp->d_lock);
1836 tmp->d_inode = inode; 1821 tmp->d_inode = inode;
@@ -1851,9 +1836,53 @@ struct dentry *d_obtain_alias(struct inode *inode)
1851 iput(inode); 1836 iput(inode);
1852 return res; 1837 return res;
1853} 1838}
1839
1840/**
1841 * d_obtain_alias - find or allocate a DISCONNECTED dentry for a given inode
1842 * @inode: inode to allocate the dentry for
1843 *
1844 * Obtain a dentry for an inode resulting from NFS filehandle conversion or
1845 * similar open by handle operations. The returned dentry may be anonymous,
1846 * or may have a full name (if the inode was already in the cache).
1847 *
1848 * When called on a directory inode, we must ensure that the inode only ever
1849 * has one dentry. If a dentry is found, that is returned instead of
1850 * allocating a new one.
1851 *
1852 * On successful return, the reference to the inode has been transferred
1853 * to the dentry. In case of an error the reference on the inode is released.
1854 * To make it easier to use in export operations a %NULL or IS_ERR inode may
1855 * be passed in and the error will be propagated to the return value,
1856 * with a %NULL @inode replaced by ERR_PTR(-ESTALE).
1857 */
1858struct dentry *d_obtain_alias(struct inode *inode)
1859{
1860 return __d_obtain_alias(inode, 1);
1861}
1854EXPORT_SYMBOL(d_obtain_alias); 1862EXPORT_SYMBOL(d_obtain_alias);
1855 1863
1856/** 1864/**
1865 * d_obtain_root - find or allocate a dentry for a given inode
1866 * @inode: inode to allocate the dentry for
1867 *
1868 * Obtain an IS_ROOT dentry for the root of a filesystem.
1869 *
1870 * We must ensure that directory inodes only ever have one dentry. If a
1871 * dentry is found, that is returned instead of allocating a new one.
1872 *
1873 * On successful return, the reference to the inode has been transferred
1874 * to the dentry. In case of an error the reference on the inode is
1875 * released. A %NULL or IS_ERR inode may be passed in and will be the
1876 * error will be propagate to the return value, with a %NULL @inode
1877 * replaced by ERR_PTR(-ESTALE).
1878 */
1879struct dentry *d_obtain_root(struct inode *inode)
1880{
1881 return __d_obtain_alias(inode, 0);
1882}
1883EXPORT_SYMBOL(d_obtain_root);
1884
1885/**
1857 * d_add_ci - lookup or allocate new dentry with case-exact name 1886 * d_add_ci - lookup or allocate new dentry with case-exact name
1858 * @inode: the inode case-insensitive lookup has found 1887 * @inode: the inode case-insensitive lookup has found
1859 * @dentry: the negative dentry that was passed to the parent's lookup func 1888 * @dentry: the negative dentry that was passed to the parent's lookup func