diff options
author | J. Bruce Fields <bfields@redhat.com> | 2014-02-18 14:11:26 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-08-07 14:40:10 -0400 |
commit | 3f70bd51cb4405dc5cf8624292ffa474679fc9c7 (patch) | |
tree | 7f1d04eec7cb1c89f339b9c674dda266f257e2c4 /fs/dcache.c | |
parent | d03b29a271eb1d6de5af0f46cf0e7487e9e9284b (diff) |
dcache: move d_splice_alias
Just a trivial move to locate it near (similar) d_materialise_unique
code and save some forward references in a following patch.
Reviewed-by: Christoph Hellwig <hch@lst.de>
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.c | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index 06f65857a855..8bdae36a095f 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -1854,58 +1854,6 @@ struct dentry *d_obtain_alias(struct inode *inode) | |||
1854 | EXPORT_SYMBOL(d_obtain_alias); | 1854 | EXPORT_SYMBOL(d_obtain_alias); |
1855 | 1855 | ||
1856 | /** | 1856 | /** |
1857 | * d_splice_alias - splice a disconnected dentry into the tree if one exists | ||
1858 | * @inode: the inode which may have a disconnected dentry | ||
1859 | * @dentry: a negative dentry which we want to point to the inode. | ||
1860 | * | ||
1861 | * If inode is a directory and has a 'disconnected' dentry (i.e. IS_ROOT and | ||
1862 | * DCACHE_DISCONNECTED), then d_move that in place of the given dentry | ||
1863 | * and return it, else simply d_add the inode to the dentry and return NULL. | ||
1864 | * | ||
1865 | * This is needed in the lookup routine of any filesystem that is exportable | ||
1866 | * (via knfsd) so that we can build dcache paths to directories effectively. | ||
1867 | * | ||
1868 | * If a dentry was found and moved, then it is returned. Otherwise NULL | ||
1869 | * is returned. This matches the expected return value of ->lookup. | ||
1870 | * | ||
1871 | * Cluster filesystems may call this function with a negative, hashed dentry. | ||
1872 | * In that case, we know that the inode will be a regular file, and also this | ||
1873 | * will only occur during atomic_open. So we need to check for the dentry | ||
1874 | * being already hashed only in the final case. | ||
1875 | */ | ||
1876 | struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) | ||
1877 | { | ||
1878 | struct dentry *new = NULL; | ||
1879 | |||
1880 | if (IS_ERR(inode)) | ||
1881 | return ERR_CAST(inode); | ||
1882 | |||
1883 | if (inode && S_ISDIR(inode->i_mode)) { | ||
1884 | spin_lock(&inode->i_lock); | ||
1885 | new = __d_find_alias(inode, 1); | ||
1886 | if (new) { | ||
1887 | BUG_ON(!(new->d_flags & DCACHE_DISCONNECTED)); | ||
1888 | spin_unlock(&inode->i_lock); | ||
1889 | security_d_instantiate(new, inode); | ||
1890 | d_move(new, dentry); | ||
1891 | iput(inode); | ||
1892 | } else { | ||
1893 | /* already taking inode->i_lock, so d_add() by hand */ | ||
1894 | __d_instantiate(dentry, inode); | ||
1895 | spin_unlock(&inode->i_lock); | ||
1896 | security_d_instantiate(dentry, inode); | ||
1897 | d_rehash(dentry); | ||
1898 | } | ||
1899 | } else { | ||
1900 | d_instantiate(dentry, inode); | ||
1901 | if (d_unhashed(dentry)) | ||
1902 | d_rehash(dentry); | ||
1903 | } | ||
1904 | return new; | ||
1905 | } | ||
1906 | EXPORT_SYMBOL(d_splice_alias); | ||
1907 | |||
1908 | /** | ||
1909 | * d_add_ci - lookup or allocate new dentry with case-exact name | 1857 | * d_add_ci - lookup or allocate new dentry with case-exact name |
1910 | * @inode: the inode case-insensitive lookup has found | 1858 | * @inode: the inode case-insensitive lookup has found |
1911 | * @dentry: the negative dentry that was passed to the parent's lookup func | 1859 | * @dentry: the negative dentry that was passed to the parent's lookup func |
@@ -2697,6 +2645,58 @@ static void __d_materialise_dentry(struct dentry *dentry, struct dentry *anon) | |||
2697 | } | 2645 | } |
2698 | 2646 | ||
2699 | /** | 2647 | /** |
2648 | * d_splice_alias - splice a disconnected dentry into the tree if one exists | ||
2649 | * @inode: the inode which may have a disconnected dentry | ||
2650 | * @dentry: a negative dentry which we want to point to the inode. | ||
2651 | * | ||
2652 | * If inode is a directory and has a 'disconnected' dentry (i.e. IS_ROOT and | ||
2653 | * DCACHE_DISCONNECTED), then d_move that in place of the given dentry | ||
2654 | * and return it, else simply d_add the inode to the dentry and return NULL. | ||
2655 | * | ||
2656 | * This is needed in the lookup routine of any filesystem that is exportable | ||
2657 | * (via knfsd) so that we can build dcache paths to directories effectively. | ||
2658 | * | ||
2659 | * If a dentry was found and moved, then it is returned. Otherwise NULL | ||
2660 | * is returned. This matches the expected return value of ->lookup. | ||
2661 | * | ||
2662 | * Cluster filesystems may call this function with a negative, hashed dentry. | ||
2663 | * In that case, we know that the inode will be a regular file, and also this | ||
2664 | * will only occur during atomic_open. So we need to check for the dentry | ||
2665 | * being already hashed only in the final case. | ||
2666 | */ | ||
2667 | struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) | ||
2668 | { | ||
2669 | struct dentry *new = NULL; | ||
2670 | |||
2671 | if (IS_ERR(inode)) | ||
2672 | return ERR_CAST(inode); | ||
2673 | |||
2674 | if (inode && S_ISDIR(inode->i_mode)) { | ||
2675 | spin_lock(&inode->i_lock); | ||
2676 | new = __d_find_alias(inode, 1); | ||
2677 | if (new) { | ||
2678 | BUG_ON(!(new->d_flags & DCACHE_DISCONNECTED)); | ||
2679 | spin_unlock(&inode->i_lock); | ||
2680 | security_d_instantiate(new, inode); | ||
2681 | d_move(new, dentry); | ||
2682 | iput(inode); | ||
2683 | } else { | ||
2684 | /* already taking inode->i_lock, so d_add() by hand */ | ||
2685 | __d_instantiate(dentry, inode); | ||
2686 | spin_unlock(&inode->i_lock); | ||
2687 | security_d_instantiate(dentry, inode); | ||
2688 | d_rehash(dentry); | ||
2689 | } | ||
2690 | } else { | ||
2691 | d_instantiate(dentry, inode); | ||
2692 | if (d_unhashed(dentry)) | ||
2693 | d_rehash(dentry); | ||
2694 | } | ||
2695 | return new; | ||
2696 | } | ||
2697 | EXPORT_SYMBOL(d_splice_alias); | ||
2698 | |||
2699 | /** | ||
2700 | * d_materialise_unique - introduce an inode into the tree | 2700 | * d_materialise_unique - introduce an inode into the tree |
2701 | * @dentry: candidate dentry | 2701 | * @dentry: candidate dentry |
2702 | * @inode: inode to bind to the dentry, to which aliases may be attached | 2702 | * @inode: inode to bind to the dentry, to which aliases may be attached |