kofemann / simple-nfs

dcache nfs server to export regular file system
Apache License 2.0
14 stars 14 forks source link

simple-nfs JAVA exception when Linux NFSv4.1 client uses "git clone" #28

Closed gisburn closed 10 months ago

gisburn commented 10 months ago

simple-java gets a JAVA exception when I mount the NFSv4.1 filesystem and run $ git clone ... # on it.

Steps to reproduce on Debian "bullseye":

  1. Run the NFS server as plain user "rmainz", uid=1616, gid=1616: $ mkdir tmp $ chmod a+u tmp $ echo "/ *(rw,insecure,all_squash,anonuid=1616,anongid=1616)" >exports $ java -jar ./target/simple-nfs-1.0-SNAPSHOT-jar-with-dependencies.jar -root $PWD -port 40000 -exports $PWD/exports

  2. Mount the NFSv4 filesystem on the same machine as user "root": $ mount -o rw,port=40000 ash:/ /mnt

  3. Run this as normal user (rmainz, which has uid=1616, gid=1615, matching anon_*-options above): $ cd /mnt/tmp $ git clone git://git.linux-nfs.org/projects/steved/nfs-utils.git Cloning into 'nfs-utils'... error: could not write config file /mnt/tmp/nfs-utils/.git/config: Remote I/O error fatal: could not set 'core.filemode' to 'true'

The simple-nfs server generates this exception: ---- snip ---- $ java -jar ./target/simple-nfs-1.0-SNAPSHOT-jar-with-dependencies.jar -root $PWD -port 40000 -exports $PWD/exports 2024-01-11 15:09:28.496 [] [main] INFO o.d.o.r.OncRpcSvc - Registering new program [100005:3] : org.dcache.nfs.v3.MountServer@17497425 2024-01-11 15:09:28.503 [] [main] INFO o.d.o.r.OncRpcSvc - Registering new program [100005:1] : org.dcache.nfs.v3.MountServer@17497425 2024-01-11 15:09:28.503 [] [main] INFO o.d.o.r.OncRpcSvc - Registering new program [100003:3] : org.dcache.nfs.v3.NfsServerV3@7bab3f1a 2024-01-11 15:09:28.504 [] [main] INFO o.d.o.r.OncRpcSvc - Registering new program [100003:4] : org.dcache.nfs.v4.NFSServerV41@437da279 2024-01-11 15:10:56.646 [192.168.20.170/192.168.20.170:913] [nfs@40000 (5)] ERROR o.d.n.v.NFSServerV41 - Unhandled exception: java.lang.IllegalStateException: path at org.dcache.simplenfs.LocalFileSystem.map(LocalFileSystem.java:117) at org.dcache.simplenfs.LocalFileSystem.remap(LocalFileSystem.java:134) at org.dcache.simplenfs.LocalFileSystem.move(LocalFileSystem.java:351) at org.dcache.nfs.vfs.PseudoFs.move(PseudoFs.java:267) at org.dcache.nfs.v4.OperationRENAME.process(OperationRENAME.java:83) at org.dcache.nfs.v4.AbstractOperationExecutor.execute(AbstractOperationExecutor.java:58) at org.dcache.nfs.v4.NFSServerV41.NFSPROC4_COMPOUND_4(NFSServerV41.java:188) at org.dcache.nfs.v4.xdr.nfs4_prot_NFS4_PROGRAM_ServerStub.dispatchOncRpcCall(nfs4_prot_NFS4_PROGRAM_ServerStub.java:48) at org.dcache.oncrpc4j.rpc.RpcDispatcher$1.run(RpcDispatcher.java:110) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833) ---- snip ----

gisburn commented 10 months ago

@kofemann Could you please have a look at this issue ?

kofemann commented 10 months ago

The issue is that simple-nfs is trying to use inode->file mapping which is accessible through standard java. As a result move operation doesn't work as expected. This probably can be fixed, though simple-nfs in intended for basic testing and doesn't a real server. If you run the tests on a Linux host (not in a container), then better to try https://github.com/kofemann/vfs4j, which uses a new foreign-function-interface and has native access to open-by-handle calls, thus, more capabilities than standard java API provides.

Just build and run it with java-21:

sudo /usr/lib/jvm/java-21/bin/java --enable-native-access=ALL-UNNAMED \
   --enable-preview  -jar target/vfs4j-1.0-SNAPSHOT.jar /data exports