Skip to content

Commit

Permalink
nfs41: change default behaviour if no layouts types specified in export
Browse files Browse the repository at this point in the history
Motivation:
If no special export option is specified, the nfs server will publish
hard-coded default LAYOUT4_NFSV4_1_FILES as supported pNFS layout type.
Though this behavior is incorrect, the server might not support that
specific layout type, for example, it forced by (a) RHEL6 kernels have
picked only the first entry if multiple entries provided by server, and,
(b) RHEL6 have supported only LAYOUT4_NFSV4_1_FILES layout types. As
RHEL6 should not be in production anymore, the workaround should be
removed.

Modification:
Update GETATTR to publish all layout types that are supported by pNFS
server.

Result:
less weird workarounds.

Acked-by: Lea Morschel
Target: master
  • Loading branch information
kofemann committed Apr 13, 2023
1 parent f6da65f commit 991a18d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions core/src/main/java/org/dcache/nfs/v4/OperationGETATTR.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009 - 2022 Deutsches Elektronen-Synchroton,
* Copyright (c) 2009 - 2023 Deutsches Elektronen-Synchroton,
* Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY
*
* This library is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -394,11 +394,11 @@ static Optional<? extends XdrAble> fattr2xdr(int fattr, VirtualFileSystem fs, In
.orElseThrow(AccessException::new) // should never happen as handled by PseudoFS first
.getLayoutTypes();

Set<layouttype4> supportedLayouts = pnfsDeviceManager.get().getLayoutTypes();

Set<layouttype4> supportedLayouts = pnfsDeviceManager.get().getLayoutTypes();
if (exportLayouts.isEmpty()) {
// for backward compatibility, pick NFSv41_FILES layout if nothing is specified
fs_layout_type.value = new int[] {layouttype4.LAYOUT4_NFSV4_1_FILES.getValue()};
fs_layout_type.value = supportedLayouts.stream()
.mapToInt(layouttype4::getValue)
.toArray();
} else {
fs_layout_type.value = exportLayouts.stream()
.filter(e -> supportedLayouts.contains(e))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
import java.util.Optional;
import org.dcache.nfs.ExportFile;
import org.dcache.nfs.v4.xdr.fattr4_fs_layout_types;
import org.dcache.nfs.v4.xdr.layouttype4;
import org.dcache.nfs.v4.xdr.nfs4_prot;
import org.dcache.oncrpc4j.rpc.RpcAuthTypeNone;
import org.dcache.oncrpc4j.rpc.RpcCall;
import org.dcache.oncrpc4j.rpc.RpcTransport;

import org.junit.Test;

import static org.dcache.nfs.v4.xdr.layouttype4.LAYOUT4_BLOCK_VOLUME;
import static org.dcache.nfs.v4.xdr.layouttype4.LAYOUT4_OSD2_OBJECTS;
import static org.junit.Assert.assertArrayEquals;
import static org.mockito.Mockito.mock;

Expand All @@ -33,7 +34,7 @@ public void testDefaultLayoutType() throws IOException, URISyntaxException {
RpcTransport transport = mock(RpcTransport.class);
ExportFile exportFile = new ExportFile(ClassLoader.getSystemResource("org/dcache/nfs/exports").toURI());

given(dm.getLayoutTypes()).willReturn(EnumSet.allOf(layouttype4.class));
given(dm.getLayoutTypes()).willReturn(EnumSet.of(LAYOUT4_OSD2_OBJECTS, LAYOUT4_BLOCK_VOLUME));
given(transport.getRemoteSocketAddress()).willReturn(new InetSocketAddress("172.16.4.1", 0));

given(call.getCredential()).willReturn(new RpcAuthTypeNone());
Expand All @@ -47,8 +48,8 @@ public void testDefaultLayoutType() throws IOException, URISyntaxException {

Optional<fattr4_fs_layout_types> res = (Optional<fattr4_fs_layout_types>) OperationGETATTR.fattr2xdr(nfs4_prot.FATTR4_FS_LAYOUT_TYPES, null, null, null, context);

assertArrayEquals("export without explicit layout type must return nfsv41_files layout",
new int[] {layouttype4.LAYOUT4_NFSV4_1_FILES.getValue()}, res.get().value);
assertArrayEquals("export without explicit layout type must return all configures layout types",
new int[] {LAYOUT4_OSD2_OBJECTS.getValue(), LAYOUT4_BLOCK_VOLUME.getValue()}, res.get().value);

}

Expand Down

0 comments on commit 991a18d

Please sign in to comment.