Unable to pwd in ZFS snapshot

Gleb Kurtsou gleb.kurtsou at gmail.com
Thu Feb 4 12:57:33 UTC 2010


On (03/02/2010 21:00), Freddie Cash wrote:
> On Wed, Feb 3, 2010 at 8:14 PM, Randy Sofia <randysofia at gmail.com> wrote:
> 
> > `pwd` returns "No such file or directory" when browsing snapshot files.
> > This
> > was addressed in:
> > http://lists.freebsd.org/pipermail/fr<http://lists.freebsd.org/pipermail/freebsd-fs/2009-February/005675.html>
> >
> >>
> >> --randy
> > eebsd-fs/2009-February/005675.html<http://lists.freebsd.org/pipermail/freebsd-fs/2009-February/005675.html> but
> > remains the same as of 8.0-RELEASE.
> >
> > I am wondering if this is the expected behavior or if this was left by the
> > wayside.
> >
> > A work around is available as per the previous discussion:
> > zfs set snapdir=visible volume
> >
> > Reproducible behavior:
> > CANAAN# zfs snapshot pithos/media at 0_day_ago
> > CANAAN# cd /pithos/media/.zfs/snapshot/0_day_ago/
> > CANAAN# pwd
> > pwd: .: No such file or directory
> > CANAAN# uname -a
> > FreeBSD CANAAN 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Fri Dec 18 00:38:33 UTC
> > 2009     root@:/usr/obj/usr/src/sys/CANAAN  amd64
> >
> 
> I believe this is a "bug" in csh, in that it doesn't have a pwd shell
> built-in, and uses /bin/pwd.  The real issue lies in /bin/pwd.
> 
> It works correctly in sh, zsh, and bash, which each have pwd built-ins.  As
> a workaround, use a non-csh-based shell.  :)
/bin/pwd is absolutely correct! It's filesystems that fail to set inode
numbers correctly. Try using pwd in fuse-sshfs (it completely ignores
inode numbers). pwd builtins cache current working directory, thus just
work.

All inode numbers are the same for snapshot entries. I'll try to find
time to look into it on the weekend.

On my machine:
/home/.zfs/snapshot % ls
2009-12-05 2009-12-25 2010-02-04
/home/.zfs/snapshot % stat -s *
st_dev=735101931 st_ino=3 st_mode=040755 st_nlink=4 st_uid=0 st_gid=0 st_rdev=0 st_size=4 st_atime=1259939945 st_mtime=1259945157 st_ctime=1259945157 st_birthtime=1259939945 st_blksize=4096 st_blocks=3 st_flags=0
st_dev=2095450778 st_ino=3 st_mode=040755 st_nlink=5 st_uid=0 st_gid=0 st_rdev=0 st_size=5 st_atime=1259939945 st_mtime=1260923930 st_ctime=1260923930 st_birthtime=1259939945 st_blksize=4096 st_blocks=3 st_flags=0
st_dev=2506498978 st_ino=3 st_mode=040755 st_nlink=5 st_uid=0 st_gid=0 st_rdev=0 st_size=5 st_atime=1259939945 st_mtime=1263206215 st_ctime=1263206215 st_birthtime=1259939945 st_blksize=4096 st_blocks=3 st_flags=0

> 
> Doing a truss on /bin/pwd when in /home/.zfs/snapshot/2009-12-31 (I snapshot
> /home daily) gives the following with snapdir=hidden:
> 
> __getcwd(0x28201400,1024)                        ERR#2 'No such file or
> directory'
> stat("/",{ mode=drwxr-xr-x ,inode=2,size=512,blksize=4096 }) = 0 (0x0)
> lstat(".",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0 (0x0)
> stat("..",{ mode=dr-xr-xr-x ,inode=2,size=24,blksize=4096 }) = 0 (0x0)
> open("..",O_NONBLOCK,05001200603)                = 3 (0x3)
> fstat(3,{ mode=dr-xr-xr-x ,inode=2,size=24,blksize=4096 }) = 0 (0x0)
> fcntl(3,F_SETFD,FD_CLOEXEC)                      = 0 (0x0)
> __sysctl(0x84bfe6a8,0x2,0x281994bc,0x84bfe6b0,0x0,0x0) = 0 (0x0)
> fstatfs(0x3,0x84bfe780,0x1,0x0,0x3,0x28073c94)   = 0 (0x0)
> fstat(3,{ mode=dr-xr-xr-x ,inode=2,size=24,blksize=4096 }) = 0 (0x0)
> getdirentries(0x3,0x2820e000,0x1000,0x2820d054,0x484328eb,0x28086400) = 1164
> (0x48c)
> lstat("../2010-01-26",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2009-12-26",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-14",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2009-12-14",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-07",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-13",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-19",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2009-12-21",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-21",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2009-12-25",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-25",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-02-03",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2009-12-17",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-17",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2009-12-04",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-04",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-03",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-09",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2009-12-09",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2009-12-03",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-31",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2009-12-31",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lseek(3,0x0,SEEK_SET)                            = 0 (0x0)
> close(3)                                         = 0 (0x0)
> lstat("../",{ mode=dr-xr-xr-x ,inode=2,size=24,blksize=4096 }) = 0 (0x0)
> stat("../..",{ mode=dr-xr-xr-x ,inode=1,size=3,blksize=4096 }) = 0 (0x0)
> open("../..",O_NONBLOCK,05001200603)             = 3 (0x3)
> fstat(3,{ mode=dr-xr-xr-x ,inode=1,size=3,blksize=4096 }) = 0 (0x0)
> fcntl(3,F_SETFD,FD_CLOEXEC)                      = 0 (0x0)
> fstatfs(0x3,0x84bfe780,0x1,0x0,0x3,0x28073c94)   = 0 (0x0)
> fstat(3,{ mode=dr-xr-xr-x ,inode=1,size=3,blksize=4096 }) = 0 (0x0)
> getdirentries(0x3,0x2820e000,0x1000,0x2820d054,0x484328eb,0x6cd7212) = 44
> (0x2c)
> lseek(3,0x0,SEEK_SET)                            = 0 (0x0)
> close(3)                                         = 0 (0x0)
> lstat("../../",{ mode=dr-xr-xr-x ,inode=1,size=3,blksize=4096 }) = 0 (0x0)
> stat("../../..",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0 (0x0)
> open("../../..",O_NONBLOCK,03777777)             = 3 (0x3)
> fstat(3,{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0 (0x0)
> fcntl(3,F_SETFD,FD_CLOEXEC)                      = 0 (0x0)
> fstatfs(0x3,0x84bfe780,0x1,0x0,0x3,0x28073c94)   = 0 (0x0)
> fstat(3,{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0 (0x0)
> getdirentries(0x3,0x2820e000,0x1000,0x2820d054,0x484328eb,0x6cd7212) = 56
> (0x38)
> getdirentries(0x3,0x2820e000,0x1000,0x2820d054,0x484328eb,0x6cd7212) = 0
> (0x0)
> lseek(3,0x0,SEEK_SET)                            = 0 (0x0)
> close(3)                                         = 0 (0x0)
> 
> 
> And gives the following when snapdir=visible:
> __getcwd(0x28201400,1024)                        ERR#2 'No such file or
> directory'
> stat("/",{ mode=drwxr-xr-x ,inode=2,size=512,blksize=4096 }) = 0
> (0x0)
> lstat(".",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> stat("..",{ mode=dr-xr-xr-x ,inode=2,size=24,blksize=4096 }) = 0
> (0x0)
> open("..",O_NONBLOCK,05001200603)                = 3
> (0x3)
> fstat(3,{ mode=dr-xr-xr-x ,inode=2,size=24,blksize=4096 }) = 0
> (0x0)
> fcntl(3,F_SETFD,FD_CLOEXEC)                      = 0
> (0x0)
> __sysctl(0x84bfe6f8,0x2,0x281994bc,0x84bfe700,0x0,0x0) = 0
> (0x0)
> fstatfs(0x3,0x84bfe7d0,0x1,0x0,0x3,0x28073c94)   = 0
> (0x0)
> fstat(3,{ mode=dr-xr-xr-x ,inode=2,size=24,blksize=4096 }) = 0
> (0x0)
> getdirentries(0x3,0x2820e000,0x1000,0x2820d054,0x484328eb,0x28086400) = 1164
> (0x48c)
> lstat("../2010-01-26",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2009-12-26",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-14",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2009-12-14",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-07",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-13",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-19",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2009-12-21",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-21",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2009-12-25",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-25",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-02-03",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2009-12-17",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-17",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2009-12-04",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-04",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-03",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-09",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2009-12-09",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2009-12-03",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2010-01-31",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lstat("../2009-12-31",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> lseek(3,0x0,SEEK_SET)                            = 0
> (0x0)
> close(3)                                         = 0
> (0x0)
> lstat("../",{ mode=dr-xr-xr-x ,inode=2,size=24,blksize=4096 }) = 0
> (0x0)
> stat("../..",{ mode=dr-xr-xr-x ,inode=1,size=3,blksize=4096 }) = 0
> (0x0)
> open("../..",O_NONBLOCK,05001200603)             = 3
> (0x3)
> fstat(3,{ mode=dr-xr-xr-x ,inode=1,size=3,blksize=4096 }) = 0
> (0x0)
> fcntl(3,F_SETFD,FD_CLOEXEC)                      = 0
> (0x0)
> fstatfs(0x3,0x84bfe7d0,0x1,0x0,0x3,0x28073c94)   = 0
> (0x0)
> fstat(3,{ mode=dr-xr-xr-x ,inode=1,size=3,blksize=4096 }) = 0
> (0x0)
> getdirentries(0x3,0x2820e000,0x1000,0x2820d054,0x484328eb,0x6cd7212) = 44
> (0x2c)
> lseek(3,0x0,SEEK_SET)                            = 0
> (0x0)
> close(3)                                         = 0
> (0x0)
> lstat("../../",{ mode=dr-xr-xr-x ,inode=1,size=3,blksize=4096 }) = 0
> (0x0)
> stat("../../..",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> open("../../..",O_NONBLOCK,03777777)             = 3
> (0x3)
> fstat(3,{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> fcntl(3,F_SETFD,FD_CLOEXEC)                      = 0
> (0x0)
> fstatfs(0x3,0x84bfe7d0,0x1,0x0,0x3,0x28073c94)   = 0
> (0x0)
> fstat(3,{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> getdirentries(0x3,0x2820e000,0x1000,0x2820d054,0x484328eb,0x6cd7212) = 72
> (0x48)
> lseek(3,0x0,SEEK_SET)                            = 0
> (0x0)
> close(3)                                         = 0
> (0x0)
> lstat("../../../",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) = 0
> (0x0)
> stat("../../../..",{ mode=drwxr-xr-x ,inode=2,size=512,blksize=4096 }) = 0
> (0x0)
> open("../../../..",O_NONBLOCK,03777777)          = 3
> (0x3)
> fstat(3,{ mode=drwxr-xr-x ,inode=2,size=512,blksize=4096 }) = 0
> (0x0)
> fcntl(3,F_SETFD,FD_CLOEXEC)                      = 0
> (0x0)
> fstatfs(0x3,0x84bfe7d0,0x1,0x0,0x3,0x28073c94)   = 0
> (0x0)
> fstat(3,{ mode=drwxr-xr-x ,inode=2,size=512,blksize=4096 }) = 0
> (0x0)
> getdirentries(0x3,0x2820e000,0x1000,0x2820d054,0x489629aa,0x0) = 512
> (0x200)
> lstat("../../../../.snap",{ mode=drwxrwxr-x ,inode=3,size=512,blksize=4096
> }) = 0 (0x0)
> lstat("../../../../dev",{ mode=dr-xr-xr-x ,inode=2,size=512,blksize=4096 })
> = 0 (0x0)
> lstat("../../../../etc",{ mode=drwxr-xr-x
> ,inode=141312,size=2560,blksize=4096 }) = 0 (0x0)
> lstat("../../../../cdrom",{ mode=drwxr-xr-x
> ,inode=211968,size=512,blksize=4096 }) = 0 (0x0)
> lstat("../../../../bin",{ mode=drwxr-xr-x
> ,inode=23552,size=1024,blksize=4096 }) = 0 (0x0)
> lstat("../../../../boot",{ mode=drwxr-xr-x
> ,inode=164864,size=1024,blksize=4096 }) = 0 (0x0)
> lstat("../../../../lib",{ mode=drwxr-xr-x
> ,inode=70656,size=2048,blksize=4096 }) = 0 (0x0)
> lstat("../../../../libexec",{ mode=drwxr-xr-x
> ,inode=117760,size=512,blksize=4096 }) = 0 (0x0)
> lstat("../../../../media",{ mode=drwxr-xr-x
> ,inode=94208,size=512,blksize=4096 }) = 0 (0x0)
> lstat("../../../../mnt",{ mode=drwxr-xr-x
> ,inode=188416,size=512,blksize=4096 }) = 0 (0x0)
> lstat("../../../../proc",{ mode=dr-xr-xr-x
> ,inode=117763,size=512,blksize=4096 }) = 0 (0x0)
> lstat("../../../../rescue",{ mode=drwxr-xr-x
> ,inode=23590,size=2560,blksize=4096 }) = 0 (0x0)
> lstat("../../../../root",{ mode=drwxr-xr-x
> ,inode=211969,size=1024,blksize=4096 }) = 0 (0x0)
> lstat("../../../../sbin",{ mode=drwxr-xr-x
> ,inode=47105,size=2560,blksize=4096 }) = 0 (0x0)
> lstat("../../../../tmp",{ mode=drwxrwxrwt ,inode=3,size=26,blksize=4096 }) =
> 0 (0x0)
> lstat("../../../../usr",{ mode=drwxr-xr-x ,inode=11,size=512,blksize=4096 })
> = 0 (0x0)
> lstat("../../../../var",{ mode=drwxr-xr-x ,inode=3,size=25,blksize=4096 }) =
> 0 (0x0)
> lstat("../../../../restoresymtable",{ mode=-rw-------
> ,inode=4,size=1948892,blksize=4096 }) = 0 (0x0)
> lstat("../../../../sys",{ mode=lrwxr-xr-x ,inode=8,size=11,blksize=4096 }) =
> 0 (0x0)
> lstat("../../../../COPYRIGHT",{ mode=-r--r--r--
> ,inode=12,size=6198,blksize=4096 }) = 0 (0x0)
> lstat("../../../../compat",{ mode=lrwxrwxrwx ,inode=7,size=10,blksize=4096
> }) = 0 (0x0)
> lstat("../../../../home",{ mode=drwxr-xr-x ,inode=3,size=4,blksize=4096 }) =
> 0 (0x0)
> lseek(3,0x0,SEEK_SET)                            = 0
> (0x0)
> close(3)                                         = 0
> (0x0)
> lstat("../../../../",{ mode=drwxr-xr-x ,inode=2,size=512,blksize=4096 }) = 0
> (0x0)
> fstat(1,{ mode=crw--w---- ,inode=145,size=0,blksize=4096 }) = 0
> (0x0)
> ioctl(1,TIOCGETA,0x84bfea10)                     = 0
> (0x0)
> /home/.zfs/snapshot/2009-12-31
> 
> write(1,"/home/.zfs/snapshot/2009-12-31\n",31)   = 31
> (0x1f)
> 
> 
> -- 
> Freddie Cash
> fjwcash at gmail.com


More information about the freebsd-fs mailing list