remarkable-linux/fs/btrfs
Josef Bacik 2ede0daf01 Btrfs: handle NFS lookups properly
People kept reporting NFS issues, specifically getting ESTALE alot.  I figured
out how to reproduce the problem

SERVER
mkfs.btrfs /dev/sda1
mount /dev/sda1 /mnt/btrfs-test
<add /mnt/btrfs-test to /etc/exports>
btrfs subvol create /mnt/btrfs-test/foo
service nfs start

CLIENT
mount server:/mnt/btrfs /mnt/test
cd /mnt/test/foo
ls

SERVER
echo 3 > /proc/sys/vm/drop_caches

CLIENT
ls			<-- get an ESTALE here

This is because the standard way to lookup a name in nfsd is to use readdir, and
what it does is do a readdir on the parent directory looking for the inode of
the child.  So in this case the parent being / and the child being foo.  Well
subvols all have the same inode number, so doing a readdir of / looking for
inode 256 will return '.', which obviously doesn't match foo.  So instead we
need to have our own .get_name so that we can find the right name.

Our .get_name will either lookup the inode backref or the root backref,
whichever we're looking for, and return the name we find.  Running the above
reproducer with this patch results in everything acting the way its supposed to.
Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2010-11-21 22:26:08 -05:00
..
acl.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable 2010-06-11 14:18:47 -07:00
async-thread.c Btrfs: don't walk around with task->state != TASK_RUNNING 2010-05-25 10:34:58 -04:00
async-thread.h Btrfs: fix deadlock on async thread startup 2009-10-05 09:44:45 -04:00
btrfs_inode.h Btrfs: Metadata reservation for orphan inodes 2010-05-25 10:34:52 -04:00
compat.h Btrfs: drop remaining LINUX_KERNEL_VERSION checks and compat code 2009-01-06 09:38:55 -05:00
compression.c btrfs: cleanup duplicate bio allocating functions 2010-11-21 22:26:03 -05:00
compression.h Btrfs: Add zlib compression support 2008-10-29 14:49:59 -04:00
ctree.c Btrfs: cleanup warnings from gcc 4.6 (nonbugs) 2010-10-29 15:14:37 -04:00
ctree.h btrfs: make 1-bit signed fileds unsigned 2010-11-21 22:26:07 -05:00
delayed-ref.c Btrfs: Integrate metadata reservation with start_transaction 2010-05-25 10:34:50 -04:00
delayed-ref.h Btrfs: Integrate metadata reservation with start_transaction 2010-05-25 10:34:50 -04:00
dir-item.c Btrfs: Fix variables set but not read (bugs found by gcc 4.6) 2010-10-29 15:14:31 -04:00
disk-io.c Btrfs: add migrate page for metadata inode 2010-11-21 22:26:02 -05:00
disk-io.h Btrfs: use async helpers for DIO write checksumming 2010-05-25 10:34:58 -04:00
export.c Btrfs: handle NFS lookups properly 2010-11-21 22:26:08 -05:00
export.h NFS support for btrfs - v3 2008-09-25 11:04:06 -04:00
extent-tree.c btrfs: Fix early enospc because 'unused' calculated with wrong sign. 2010-11-21 22:26:04 -05:00
extent_io.c btrfs: cleanup duplicate bio allocating functions 2010-11-21 22:26:03 -05:00
extent_io.h btrfs: cleanup duplicate bio allocating functions 2010-11-21 22:26:03 -05:00
extent_map.c Btrfs: Use ERR_CAST helpers 2010-10-29 15:14:23 -04:00
extent_map.h Btrfs: search for an allocation hint while filling file COW 2009-09-18 16:08:52 -04:00
file-item.c Btrfs: add basic DIO read/write support 2010-05-25 10:34:57 -04:00
file.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable 2010-06-11 14:18:47 -07:00
free-space-cache.c Btrfs: Add a clear_cache mount option 2010-10-29 09:26:36 -04:00
free-space-cache.h Btrfs: load free space cache if it exists 2010-10-29 09:26:35 -04:00
hash.h Btrfs: remove crc32c.h and use libcrc32c directly. 2009-06-10 11:29:53 -04:00
inode-item.c Btrfs: Integrate metadata reservation with start_transaction 2010-05-25 10:34:50 -04:00
inode-map.c Btrfs: do not reuse objectid of deleted snapshot/subvol 2009-09-21 15:56:00 -04:00
inode.c btrfs: Show device attr correctly for symlinks 2010-11-21 22:26:07 -05:00
ioctl.c btrfs: Set file size correctly in file clone 2010-11-21 22:26:06 -05:00
ioctl.h Btrfs: add SNAP_CREATE_ASYNC ioctl 2010-10-29 21:41:57 -04:00
Kconfig Revert "task_struct: make journal_info conditional" 2009-12-17 13:23:24 -08:00
locking.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
locking.h Btrfs: fix spinlock assertions on UP systems 2009-03-09 11:45:38 -04:00
Makefile Btrfs: Mixed back reference (FORWARD ROLLING FORMAT CHANGE) 2009-06-10 11:29:46 -04:00
ordered-data.c Btrfs: cleanup warnings from gcc 4.6 (nonbugs) 2010-10-29 15:14:37 -04:00
ordered-data.h Btrfs: add basic DIO read/write support 2010-05-25 10:34:57 -04:00
orphan.c Btrfs: change how subvolumes are organized 2009-09-21 15:56:00 -04:00
print-tree.c Btrfs: remove of redundant btrfs_header_level 2009-07-22 16:52:13 -04:00
print-tree.h Btrfs: Create extent_buffer interface for large blocksizes 2008-09-25 11:03:56 -04:00
ref-cache.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
ref-cache.h Btrfs: use RB_ROOT to intialize rb_trees instead of setting rb_node to NULL 2010-03-08 16:26:50 -05:00
relocation.c Btrfs: Fix variables set but not read (bugs found by gcc 4.6) 2010-10-29 15:14:31 -04:00
root-tree.c Btrfs: cleanup warnings from gcc 4.6 (nonbugs) 2010-10-29 15:14:37 -04:00
struct-funcs.c Btrfs: Fix checkpatch.pl warnings 2009-01-05 21:25:51 -05:00
super.c Btrfs: handle the space_cache option properly 2010-11-21 22:26:05 -05:00
sysfs.c Driver core: Constify struct sysfs_ops in struct kobj_type 2010-03-07 17:04:49 -08:00
transaction.c Btrfs: add START_SYNC, WAIT_SYNC ioctls 2010-10-29 15:41:32 -04:00
transaction.h Btrfs: add START_SYNC, WAIT_SYNC ioctls 2010-10-29 15:41:32 -04:00
tree-defrag.c Btrfs: cleanup warnings from gcc 4.6 (nonbugs) 2010-10-29 15:14:37 -04:00
tree-log.c Btrfs: cleanup warnings from gcc 4.6 (nonbugs) 2010-10-29 15:14:37 -04:00
tree-log.h Btrfs: Metadata ENOSPC handling for tree log 2010-05-25 10:34:53 -04:00
version.h Update Btrfs files for in-kernel usage 2008-09-25 15:41:59 -04:00
version.sh Btrfs: Fixes for 2.6.28-rc API changes 2008-11-19 21:17:22 -05:00
volumes.c Btrfs: cleanup warnings from gcc 4.6 (nonbugs) 2010-10-29 15:14:37 -04:00
volumes.h Btrfs: make balance code choose more wisely when relocating 2009-09-21 19:23:48 -04:00
xattr.c Btrfs: cleanup warnings from gcc 4.6 (nonbugs) 2010-10-29 15:14:37 -04:00
xattr.h btrfs: constify xattr_handler 2010-05-21 18:31:18 -04:00
zlib.c Btrfs: cleanup warnings from gcc 4.6 (nonbugs) 2010-10-29 15:14:37 -04:00