diff options
author | David Woodhouse <David.Woodhouse@intel.com> | 2008-08-17 10:14:48 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:06 -0400 |
commit | 5ecc7e5d1d58731b3a6a69303d69aca7fb0fe1f5 (patch) | |
tree | 89c52b97b11925f99649b8025b6d206b6a80c090 /fs | |
parent | 21af804c07141c035085f99798efaabbc7836a97 (diff) |
Btrfs: Remove special cases for "." and ".."
Date: Sun, 17 Aug 2008 15:14:48 +0100
We never get asked by the VFS to lookup either of them, and we can
handle the readdir() case a lot more simply, too.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/inode.c | 52 |
1 files changed, 2 insertions, 50 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 0da1ae4ee407..4520a0e86e70 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -1702,42 +1702,9 @@ static int btrfs_inode_by_name(struct inode *dir, struct dentry *dentry, | |||
1702 | struct btrfs_root *root = BTRFS_I(dir)->root; | 1702 | struct btrfs_root *root = BTRFS_I(dir)->root; |
1703 | int ret = 0; | 1703 | int ret = 0; |
1704 | 1704 | ||
1705 | if (namelen == 1 && strcmp(name, ".") == 0) { | ||
1706 | location->objectid = dir->i_ino; | ||
1707 | location->type = BTRFS_INODE_ITEM_KEY; | ||
1708 | location->offset = 0; | ||
1709 | return 0; | ||
1710 | } | ||
1711 | path = btrfs_alloc_path(); | 1705 | path = btrfs_alloc_path(); |
1712 | BUG_ON(!path); | 1706 | BUG_ON(!path); |
1713 | 1707 | ||
1714 | if (namelen == 2 && strcmp(name, "..") == 0) { | ||
1715 | struct btrfs_key key; | ||
1716 | struct extent_buffer *leaf; | ||
1717 | int slot; | ||
1718 | |||
1719 | key.objectid = dir->i_ino; | ||
1720 | key.offset = (u64)-1; | ||
1721 | btrfs_set_key_type(&key, BTRFS_INODE_REF_KEY); | ||
1722 | if (ret < 0 || path->slots[0] == 0) | ||
1723 | goto out_err; | ||
1724 | ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); | ||
1725 | BUG_ON(ret == 0); | ||
1726 | ret = 0; | ||
1727 | leaf = path->nodes[0]; | ||
1728 | slot = path->slots[0] - 1; | ||
1729 | |||
1730 | btrfs_item_key_to_cpu(leaf, &key, slot); | ||
1731 | if (key.objectid != dir->i_ino || | ||
1732 | key.type != BTRFS_INODE_REF_KEY) { | ||
1733 | goto out_err; | ||
1734 | } | ||
1735 | location->objectid = key.offset; | ||
1736 | location->type = BTRFS_INODE_ITEM_KEY; | ||
1737 | location->offset = 0; | ||
1738 | goto out; | ||
1739 | } | ||
1740 | |||
1741 | di = btrfs_lookup_dir_item(NULL, root, path, dir->i_ino, name, | 1708 | di = btrfs_lookup_dir_item(NULL, root, path, dir->i_ino, name, |
1742 | namelen, 0); | 1709 | namelen, 0); |
1743 | if (IS_ERR(di)) | 1710 | if (IS_ERR(di)) |
@@ -1960,29 +1927,14 @@ static int btrfs_real_readdir(struct file *filp, void *dirent, | |||
1960 | 1927 | ||
1961 | /* special case for .., just use the back ref */ | 1928 | /* special case for .., just use the back ref */ |
1962 | if (filp->f_pos == 1) { | 1929 | if (filp->f_pos == 1) { |
1963 | btrfs_set_key_type(&key, BTRFS_INODE_REF_KEY); | 1930 | u64 pino = parent_ino(filp->f_path.dentry); |
1964 | key.offset = (u64)-1; | ||
1965 | ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); | ||
1966 | if (ret < 0 || path->slots[0] == 0) { | ||
1967 | btrfs_release_path(root, path); | ||
1968 | goto read_dir_items; | ||
1969 | } | ||
1970 | BUG_ON(ret == 0); | ||
1971 | leaf = path->nodes[0]; | ||
1972 | slot = path->slots[0] - 1; | ||
1973 | btrfs_item_key_to_cpu(leaf, &found_key, slot); | ||
1974 | btrfs_release_path(root, path); | ||
1975 | if (found_key.objectid != key.objectid || | ||
1976 | found_key.type != BTRFS_INODE_REF_KEY) | ||
1977 | goto read_dir_items; | ||
1978 | over = filldir(dirent, "..", 2, | 1931 | over = filldir(dirent, "..", 2, |
1979 | 2, found_key.offset, DT_DIR); | 1932 | 2, pino, DT_DIR); |
1980 | if (over) | 1933 | if (over) |
1981 | goto nopos; | 1934 | goto nopos; |
1982 | filp->f_pos = 2; | 1935 | filp->f_pos = 2; |
1983 | } | 1936 | } |
1984 | 1937 | ||
1985 | read_dir_items: | ||
1986 | btrfs_set_key_type(&key, key_type); | 1938 | btrfs_set_key_type(&key, key_type); |
1987 | key.offset = filp->f_pos; | 1939 | key.offset = filp->f_pos; |
1988 | 1940 | ||