xetdata / nfsserve

A Rust NFS Server implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Demo doesn't work on Ubuntu 22.04

mblythe86 opened this issue · comments

I followed the directions on the main page, but it's not working for me:

> git clone https://github.com/xetdata/nfsserve.git
> cd nfsserve/
> cargo build
> ./target/debug/nfsserve

In another shell:

> sudo mkdir /mnt/demo
> sudo mount.nfs -o user,noacl,nolock,vers=3,tcp,wsize=1048576,rsize=131072,actimeo=120,port=11111,mountport=11111 localhost:/ /mnt/demo
> ls -l /mnt/
ls: cannot access '/mnt/demo': Stale file handle
total 47
d?????????  ? ?    ?       ?            ? demo
> sudo ls -l /mnt
ls: cannot access '/mnt/demo': Stale file handle
total 47
d?????????  ? ?    ?       ?            ? demo
> sudo umount /mnt/demo

Here's the output from nfsserve during the attempted accesses above:

2023-09-21T06:54:26.578579Z  INFO nfsserve::tcp: Listening on "127.0.0.1:11111"
2023-09-21T06:54:31.642605Z  INFO nfsserve::tcp: Accepting socket PollEvented { io: Some(TcpStream { addr: 127.0.0.1:11111, peer: 127.0.0.1:762, fd: 7 }) } RPCContext { local_port: 11111, client_addr: "127.0.0.1:762", auth: auth_unix { stamp: 0, machinename: [], uid: 0, gid: 0, gids: [] } }
2023-09-21T06:54:31.643807Z DEBUG nfsserve::mount_handlers: mountproc3_null(2882213060) 
2023-09-21T06:54:31.643863Z DEBUG nfsserve::mount_handlers: 	2882213060 --> rpc_msg { xid: 2882213060, body: REPLY(MSG_ACCEPTED(accepted_reply { verf: opaque_auth { flavor: AUTH_NULL, body: [] }, reply_data: SUCCESS })) }
2023-09-21T06:54:31.644593Z DEBUG nfsserve::mount_handlers: mountproc3_mnt(2898990276,"/") 
2023-09-21T06:54:31.644660Z DEBUG nfsserve::mount_handlers: 2898990276 --> mountres3_ok { fhandle: [220, 206, 132, 182, 138, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], auth_flavors: [0, 1] }
2023-09-21T06:54:31.645528Z  INFO nfsserve::tcp: Message loop broken due to early eof
2023-09-21T06:54:31.645807Z  INFO nfsserve::tcp: Accepting socket PollEvented { io: Some(TcpStream { addr: 127.0.0.1:11111, peer: 127.0.0.1:908, fd: 7 }) } RPCContext { local_port: 11111, client_addr: "127.0.0.1:908", auth: auth_unix { stamp: 0, machinename: [], uid: 0, gid: 0, gids: [] } }
2023-09-21T06:54:31.646608Z DEBUG nfsserve::nfs_handlers: nfsproc3_null(3965011991) 
2023-09-21T06:54:31.646648Z DEBUG nfsserve::nfs_handlers: 	3965011991 --> rpc_msg { xid: 3965011991, body: REPLY(MSG_ACCEPTED(accepted_reply { verf: opaque_auth { flavor: AUTH_NULL, body: [] }, reply_data: SUCCESS })) }
2023-09-21T06:54:31.647560Z DEBUG nfsserve::nfs_handlers: nfsproc3_fsinfo(3981789207,nfs_fh3 { data: [220, 206, 132, 182, 138, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0] }) 
2023-09-21T06:54:31.647689Z DEBUG nfsserve::nfs_handlers:  3981789207 ---> FSINFO3resok { obj_attributes: attributes(fattr3 { ftype: NF3DIR, mode: 511, nlink: 0, uid: 507, gid: 507, size: 0, used: 0, rdev: specdata3 { specdata1: 0, specdata2: 0 }, fsid: 0, fileid: 1, atime: nfstime3 { seconds: 0, nseconds: 0 }, mtime: nfstime3 { seconds: 0, nseconds: 0 }, ctime: nfstime3 { seconds: 0, nseconds: 0 } }), rtmax: 1048576, rtpref: 126976, rtmult: 1048576, wtmax: 1048576, wtpref: 1048576, wtmult: 1048576, dtpref: 1048576, maxfilesize: 137438953472, time_delta: nfstime3 { seconds: 0, nseconds: 1000000 }, properties: 26 }
2023-09-21T06:54:31.648325Z DEBUG nfsserve::nfs_handlers: nfsproc3_pathconf(3998566423,nfs_fh3 { data: [220, 206, 132, 182, 138, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0] })
2023-09-21T06:54:31.648400Z DEBUG nfsserve::nfs_handlers:  3998566423 ---> PATHCONF3resok { obj_attributes: attributes(fattr3 { ftype: NF3DIR, mode: 511, nlink: 0, uid: 507, gid: 507, size: 0, used: 0, rdev: specdata3 { specdata1: 0, specdata2: 0 }, fsid: 0, fileid: 1, atime: nfstime3 { seconds: 0, nseconds: 0 }, mtime: nfstime3 { seconds: 0, nseconds: 0 }, ctime: nfstime3 { seconds: 0, nseconds: 0 } }), linkmax: 0, name_max: 32768, no_trunc: true, chown_restricted: true, case_insensitive: false, case_preserving: true }
2023-09-21T06:54:31.649133Z DEBUG nfsserve::nfs_handlers: nfsproc3_fsinfo(4015343639,nfs_fh3 { data: [220, 206, 132, 182, 138, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0] }) 
2023-09-21T06:54:31.649231Z DEBUG nfsserve::nfs_handlers:  4015343639 ---> FSINFO3resok { obj_attributes: attributes(fattr3 { ftype: NF3DIR, mode: 511, nlink: 0, uid: 507, gid: 507, size: 0, used: 0, rdev: specdata3 { specdata1: 0, specdata2: 0 }, fsid: 0, fileid: 1, atime: nfstime3 { seconds: 0, nseconds: 0 }, mtime: nfstime3 { seconds: 0, nseconds: 0 }, ctime: nfstime3 { seconds: 0, nseconds: 0 } }), rtmax: 1048576, rtpref: 126976, rtmult: 1048576, wtmax: 1048576, wtpref: 1048576, wtmult: 1048576, dtpref: 1048576, maxfilesize: 137438953472, time_delta: nfstime3 { seconds: 0, nseconds: 1000000 }, properties: 26 }
2023-09-21T06:54:31.651414Z DEBUG nfsserve::nfs_handlers: nfsproc3_getattr(4032120855,nfs_fh3 { data: [220, 206, 132, 182, 138, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0] }) 
2023-09-21T06:54:31.651473Z DEBUG nfsserve::nfs_handlers:  4032120855 --> fattr3 { ftype: NF3DIR, mode: 511, nlink: 0, uid: 507, gid: 507, size: 0, used: 0, rdev: specdata3 { specdata1: 0, specdata2: 0 }, fsid: 0, fileid: 1, atime: nfstime3 { seconds: 0, nseconds: 0 }, mtime: nfstime3 { seconds: 0, nseconds: 0 }, ctime: nfstime3 { seconds: 0, nseconds: 0 } }
2023-09-21T06:54:34.071138Z DEBUG nfsserve::nfs_handlers: nfsproc3_getattr(4048898071,nfs_fh3 { data: [220, 206, 132, 182, 138, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0] }) 
2023-09-21T06:54:34.071179Z DEBUG nfsserve::nfs_handlers:  4048898071 --> fattr3 { ftype: NF3DIR, mode: 511, nlink: 0, uid: 507, gid: 507, size: 0, used: 0, rdev: specdata3 { specdata1: 0, specdata2: 0 }, fsid: 0, fileid: 1, atime: nfstime3 { seconds: 0, nseconds: 0 }, mtime: nfstime3 { seconds: 0, nseconds: 0 }, ctime: nfstime3 { seconds: 0, nseconds: 0 } }
2023-09-21T06:54:36.401530Z DEBUG nfsserve::nfs_handlers: nfsproc3_getattr(4065675287,nfs_fh3 { data: [220, 206, 132, 182, 138, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0] }) 
2023-09-21T06:54:36.401601Z DEBUG nfsserve::nfs_handlers:  4065675287 --> fattr3 { ftype: NF3DIR, mode: 511, nlink: 0, uid: 507, gid: 507, size: 0, used: 0, rdev: specdata3 { specdata1: 0, specdata2: 0 }, fsid: 0, fileid: 1, atime: nfstime3 { seconds: 0, nseconds: 0 }, mtime: nfstime3 { seconds: 0, nseconds: 0 }, ctime: nfstime3 { seconds: 0, nseconds: 0 } }
2023-09-21T06:54:39.577394Z DEBUG nfsserve::nfs_handlers: nfsproc3_getattr(4082452503,nfs_fh3 { data: [220, 206, 132, 182, 138, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0] }) 
2023-09-21T06:54:39.577521Z DEBUG nfsserve::nfs_handlers:  4082452503 --> fattr3 { ftype: NF3DIR, mode: 511, nlink: 0, uid: 507, gid: 507, size: 0, used: 0, rdev: specdata3 { specdata1: 0, specdata2: 0 }, fsid: 0, fileid: 1, atime: nfstime3 { seconds: 0, nseconds: 0 }, mtime: nfstime3 { seconds: 0, nseconds: 0 }, ctime: nfstime3 { seconds: 0, nseconds: 0 } }
2023-09-21T06:54:39.654821Z  INFO nfsserve::tcp: Message loop broken due to early eof

Same for me on archlinux with

❯ mount.nfs -V
mount.nfs: (linux nfs-utils 2.6.3)
commented

Same here, Gentoo 64:

mount.nfs -V
mount.nfs: (linux nfs-utils 2.6.3)
cd demo
bash: cd: demo: Stale file handle

Logs from nfsserver when trying to go inside:

2023-09-25T17:29:19.690681Z DEBUG nfsserve::nfs_handlers: nfsproc3_getattr(4138113970,nfs_fh3 { data: [88, 14, 98, 205, 138, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0] }) 
2023-09-25T17:29:19.690724Z DEBUG nfsserve::nfs_handlers:  4138113970 --> fattr3 { ftype: NF3DIR, mode: 511, nlink: 0, uid: 507, gid: 507, size: 0, used: 0, rdev: specdata3 { specdata1: 0, specdata2: 0 }, fsid: 0, fileid: 1, atime: nfstime3 { seconds: 0, nseconds: 0 }, mtime: nfstime3 { seconds: 0, nseconds: 0 }, ctime: nfstime3 { seconds: 0, nseconds: 0 } }
2023-09-25T17:29:19.690979Z DEBUG nfsserve::nfs_handlers: nfsproc3_getattr(4154891186,nfs_fh3 { data: [88, 14, 98, 205, 138, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0] }) 
2023-09-25T17:29:19.691002Z DEBUG nfsserve::nfs_handlers:  4154891186 --> fattr3 { ftype: NF3DIR, mode: 511, nlink: 0, uid: 507, gid: 507, size: 0, used: 0, rdev: specdata3 { specdata1: 0, specdata2: 0 }, fsid: 0, fileid: 1, atime: nfstime3 { seconds: 0, nseconds: 0 }, mtime: nfstime3 { seconds: 0, nseconds: 0 }, ctime: nfstime3 { seconds: 0, nseconds: 0 } }
2023-09-25T17:29:19.691214Z DEBUG nfsserve::nfs_handlers: nfsproc3_getattr(4171668402,nfs_fh3 { data: [88, 14, 98, 205, 138, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0] }) 
2023-09-25T17:29:19.691235Z DEBUG nfsserve::nfs_handlers:  4171668402 --> fattr3 { ftype: NF3DIR, mode: 511, nlink: 0, uid: 507, gid: 507, size: 0, used: 0, rdev: specdata3 { specdata1: 0, specdata2: 0 }, fsid: 0, fileid: 1, atime: nfstime3 { seconds: 0, nseconds: 0 }, mtime: nfstime3 { seconds: 0, nseconds: 0 }, ctime: nfstime3 { seconds: 0, nseconds: 0 } }

Interesting. Let me investigate....

I reproduced the problem on NixOS. Couldn't reproduce it on my Mac.

Found while debugging that the nlink value is set to 0 in demofs. Changing it to 1 makes it work.

I believe this to be fixed now thanks to @utsl42 !
Sorry I have not had the time to look into this.