pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


SimpleNfs patches (-nfsvers option, diag msg and bump to nfs4j-core 0.25)
Posted by Anonymous on Tue 16th Jan 2024 00:57
raw | new post

  1. From 9e4ff94c4f543142dade3da2b53367a5a5f56e7d Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Tue, 16 Jan 2024 01:45:55 +0100
  4. Subject: [PATCH 1/3] LocalFileSystem: Add better diag message
  5.  
  6. Add better debug message in case something goes wrong
  7. ---
  8.  src/main/java/org/dcache/simplenfs/LocalFileSystem.java | 2 +-
  9.  1 file changed, 1 insertion(+), 1 deletion(-)
  10.  
  11. diff --git a/src/main/java/org/dcache/simplenfs/LocalFileSystem.java b/src/main/java/org/dcache/simplenfs/LocalFileSystem.java
  12. index 82fcf33..af56d6b 100644
  13. --- a/src/main/java/org/dcache/simplenfs/LocalFileSystem.java
  14. +++ b/src/main/java/org/dcache/simplenfs/LocalFileSystem.java
  15. @@ -114,7 +114,7 @@ public class LocalFileSystem implements VirtualFileSystem {
  16.              if (inodeToPath.remove(inodeNumber) != path) {
  17.                  throw new IllegalStateException("cant map, rollback failed");
  18.              }
  19. -            throw new IllegalStateException("path ");
  20. +            throw new IllegalStateException("path='"+path+"', inodeNumber="+inodeNumber+", otherInodeNumber=" +otherInodeNumber);
  21.          }
  22.      }
  23.  
  24. --
  25. 2.30.2
  26.  
  27. From f406e5402a4e1d2137c9b3ea3e2e34a9e2283e2f Mon Sep 17 00:00:00 2001
  28. From: Roland Mainz <roland.mainz@nrubsig.org>
  29. Date: Tue, 16 Jan 2024 01:47:24 +0100
  30. Subject: [PATCH 2/3] SimpleNfsServer: Add -nfsvers option to specify NFS
  31.  version
  32.  
  33. Add -nfsvers option to specify which NFS versions should be supported
  34. by the server (3, 4, or 0 for both 3+4).
  35. ---
  36.  src/main/java/org/dcache/simplenfs/App.java   |  4 +-
  37.  .../org/dcache/simplenfs/SimpleNfsServer.java | 40 +++++++++++++------
  38.  2 files changed, 31 insertions(+), 13 deletions(-)
  39.  
  40. diff --git a/src/main/java/org/dcache/simplenfs/App.java b/src/main/java/org/dcache/simplenfs/App.java
  41. index 58b846f..d34ed0f 100644
  42. --- a/src/main/java/org/dcache/simplenfs/App.java
  43. +++ b/src/main/java/org/dcache/simplenfs/App.java
  44. @@ -18,6 +18,8 @@ public class App {
  45.      private Path root;
  46.      @Option(name = "-exports", usage = "path to file with export tables", metaVar = "<file>")
  47.      private Path exportsFile;
  48. +    @Option(name = "-nfsvers", usage = "NFS version (3, 4, 0==3+4) to use", metaVar = "<int>")
  49. +    private int nfsVers = 0;
  50.      @Option(name = "-port", usage = "TCP port to use", metaVar = "<port>")
  51.      private int rpcPort = 2049;
  52.      @Option(name = "-with-portmap", usage = "start embedded portmap")
  53. @@ -52,7 +54,7 @@ public class App {
  54.              new OncRpcEmbeddedPortmap();
  55.          }
  56.  
  57. -        try (SimpleNfsServer ignored = new SimpleNfsServer(rpcPort, root, exportFile, null)) {
  58. +        try (SimpleNfsServer ignored = new SimpleNfsServer(nfsVers, rpcPort, root, exportFile, null)) {
  59.              //noinspection ResultOfMethodCallIgnored
  60.              System.in.read(); //any key to shutdown
  61.          }
  62. diff --git a/src/main/java/org/dcache/simplenfs/SimpleNfsServer.java b/src/main/java/org/dcache/simplenfs/SimpleNfsServer.java
  63. index 0067f89..c7542e2 100644
  64. --- a/src/main/java/org/dcache/simplenfs/SimpleNfsServer.java
  65. +++ b/src/main/java/org/dcache/simplenfs/SimpleNfsServer.java
  66. @@ -28,11 +28,16 @@ public class SimpleNfsServer implements Closeable {
  67.      private final String name;
  68.  
  69.      public SimpleNfsServer(Path root) {
  70. -        this(2049, root, null, null);
  71. +        this(0, 2049, root, null, null);
  72.      }
  73.  
  74. -    public SimpleNfsServer(int port, Path root, ExportFile exportFile, String name) {
  75. +    public SimpleNfsServer(int nfsVers, int port, Path root, ExportFile exportFile, String name) {
  76.          try {
  77. +            NfsServerV3 nfs3 = null;
  78. +            NFSServerV41 nfs4 = null;
  79. +            boolean startNfsV3 = ((nfsVers == 0) || (nfsVers == 3));
  80. +            boolean startNfsV4 = ((nfsVers == 0) || (nfsVers == 4));
  81. +
  82.              if (exportFile == null) {
  83.                  exportFile = new ExportFile(new InputStreamReader(SimpleNfsServer.class.getClassLoader().getResourceAsStream("exports")));
  84.              }
  85. @@ -59,19 +64,30 @@ public class SimpleNfsServer implements Closeable {
  86.                      .withServiceName(this.name)
  87.                      .build();
  88.  
  89. -            NFSServerV41 nfs4 = new NFSServerV41.Builder()
  90. -                    .withVfs(vfs)
  91. -                    .withOperationExecutor(new MDSOperationExecutor())
  92. -                    .withExportTable(exportFile)
  93. -                    .build();
  94. +            if (startNfsV4) {
  95. +                nfs4 = new NFSServerV41.Builder()
  96. +                        .withVfs(vfs)
  97. +                        .withOperationExecutor(new MDSOperationExecutor())
  98. +                        .withExportTable(exportFile)
  99. +                        .build();
  100. +            }
  101. +
  102. +            if (startNfsV3) {
  103. +                nfs3 = new NfsServerV3(exportFile, vfs);
  104. +            }
  105.  
  106. -            NfsServerV3 nfs3 = new NfsServerV3(exportFile, vfs);
  107.              MountServer mountd = new MountServer(exportFile, vfs);
  108.  
  109. -            nfsSvc.register(new OncRpcProgram(mount_prot.MOUNT_PROGRAM, mount_prot.MOUNT_V3), mountd);
  110. -            nfsSvc.register(new OncRpcProgram(mount_prot.MOUNT_PROGRAM, mount_prot.MOUNT_V1), mountd);
  111. -            nfsSvc.register(new OncRpcProgram(nfs3_prot.NFS_PROGRAM, nfs3_prot.NFS_V3), nfs3);
  112. -            nfsSvc.register(new OncRpcProgram(nfs4_prot.NFS4_PROGRAM, nfs4_prot.NFS_V4), nfs4);
  113. +            if (startNfsV3) {
  114. +                nfsSvc.register(new OncRpcProgram(mount_prot.MOUNT_PROGRAM, mount_prot.MOUNT_V3), mountd);
  115. +                nfsSvc.register(new OncRpcProgram(mount_prot.MOUNT_PROGRAM, mount_prot.MOUNT_V1), mountd);
  116. +                nfsSvc.register(new OncRpcProgram(nfs3_prot.NFS_PROGRAM, nfs3_prot.NFS_V3), nfs3);
  117. +            }
  118. +
  119. +            if (startNfsV4) {
  120. +                nfsSvc.register(new OncRpcProgram(nfs4_prot.NFS4_PROGRAM, nfs4_prot.NFS_V4), nfs4);
  121. +            }
  122. +
  123.              nfsSvc.start();
  124.          } catch (IOException e) {
  125.              throw new UncheckedIOException(e);
  126. --
  127. 2.30.2
  128.  
  129. From 0c5128f03b3ff49ed5776d4a3f8aaa0b5f6a84d3 Mon Sep 17 00:00:00 2001
  130. From: Roland Mainz <roland.mainz@nrubsig.org>
  131. Date: Tue, 16 Jan 2024 01:49:02 +0100
  132. Subject: [PATCH 3/3] Update to nfs4j-core 0.25 and bump version to 1.1
  133.  
  134. Update to nfs4j-core 0.25 and bump our version to 1.1
  135. ---
  136.  pom.xml | 4 ++--
  137.  1 file changed, 2 insertions(+), 2 deletions(-)
  138.  
  139. diff --git a/pom.xml b/pom.xml
  140. index 6d4517b..2c346b9 100644
  141. --- a/pom.xml
  142. +++ b/pom.xml
  143. @@ -4,7 +4,7 @@
  144.  
  145.      <groupId>org.dcache</groupId>
  146.      <artifactId>simple-nfs</artifactId>
  147. -    <version>1.0-SNAPSHOT</version>
  148. +    <version>1.1-SNAPSHOT</version>
  149.  
  150.      <name>Simple nfs server</name>
  151.      <url>http://www.dcache.org/</url>
  152. @@ -65,7 +65,7 @@
  153.          <dependency>
  154.              <groupId>org.dcache</groupId>
  155.              <artifactId>nfs4j-core</artifactId>
  156. -            <version>0.23.0</version>
  157. +            <version>0.25.0</version>
  158.          </dependency>
  159.          <dependency>
  160.              <groupId>org.slf4j</groupId>
  161. --
  162. 2.30.2

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at