Unable to pwd in ZFS snapshot

Jaakko Heinonen jh at FreeBSD.org
Wed Feb 10 20:09:30 UTC 2010


On 2010-02-05, Gleb Kurtsou wrote:
> Comments in zfs_ctldir.c explain the inode numbering scheme under .zfs
> in detail, each snapshot node has to have unique inode number.  Correct
> inode number is returned by READDIR call, but not by GETATTR for the
> same vnode. This breaks our pwd (getcwd). The patch attached adds a hack
> to VOP_GETATTR to return expected inode numbers.
> 
> Also, with r197513 reverted all inode numbers are still the same, but it
> seems to work as expected.

r196309 added a VOP_VPTOCNP(9) implementation for snapshots. However due
to changes made in r197513 zfsctl_snapshot_vptocnp() never gets called.

There's also another problem with the hidden .zfs directory: if the
directory is not in the name cache, __getcwd() will fail. To reproduce
this set debug.vfscache sysctl to 0 before the directory enters to
cache.

# sysctl debug.vfscache=0
# cd /scratch/.zfs
# /bin/pwd
pwd: .: No such file or directory

Here's a patch which tries to fix/work around these problems:

	http://people.freebsd.org/~jh/patches/zfs-ctldir-vptocnp.diff

The patch needs more work and I have tested it only very lightly.

-- 
Jaakko


More information about the freebsd-fs mailing list