Skip to content

Commit 991a18d

Browse files
committed
nfs41: change default behaviour if no layouts types specified in export
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
1 parent f6da65f commit 991a18d

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

core/src/main/java/org/dcache/nfs/v4/OperationGETATTR.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009 - 2022 Deutsches Elektronen-Synchroton,
2+
* Copyright (c) 2009 - 2023 Deutsches Elektronen-Synchroton,
33
* Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY
44
*
55
* This library is free software; you can redistribute it and/or modify
@@ -394,11 +394,11 @@ static Optional<? extends XdrAble> fattr2xdr(int fattr, VirtualFileSystem fs, In
394394
.orElseThrow(AccessException::new) // should never happen as handled by PseudoFS first
395395
.getLayoutTypes();
396396

397-
Set<layouttype4> supportedLayouts = pnfsDeviceManager.get().getLayoutTypes();
398-
397+
Set<layouttype4> supportedLayouts = pnfsDeviceManager.get().getLayoutTypes();
399398
if (exportLayouts.isEmpty()) {
400-
// for backward compatibility, pick NFSv41_FILES layout if nothing is specified
401-
fs_layout_type.value = new int[] {layouttype4.LAYOUT4_NFSV4_1_FILES.getValue()};
399+
fs_layout_type.value = supportedLayouts.stream()
400+
.mapToInt(layouttype4::getValue)
401+
.toArray();
402402
} else {
403403
fs_layout_type.value = exportLayouts.stream()
404404
.filter(e -> supportedLayouts.contains(e))

core/src/test/java/org/dcache/nfs/v4/OperationGETATTRTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
import java.util.Optional;
88
import org.dcache.nfs.ExportFile;
99
import org.dcache.nfs.v4.xdr.fattr4_fs_layout_types;
10-
import org.dcache.nfs.v4.xdr.layouttype4;
1110
import org.dcache.nfs.v4.xdr.nfs4_prot;
1211
import org.dcache.oncrpc4j.rpc.RpcAuthTypeNone;
1312
import org.dcache.oncrpc4j.rpc.RpcCall;
1413
import org.dcache.oncrpc4j.rpc.RpcTransport;
1514

1615
import org.junit.Test;
1716

17+
import static org.dcache.nfs.v4.xdr.layouttype4.LAYOUT4_BLOCK_VOLUME;
18+
import static org.dcache.nfs.v4.xdr.layouttype4.LAYOUT4_OSD2_OBJECTS;
1819
import static org.junit.Assert.assertArrayEquals;
1920
import static org.mockito.Mockito.mock;
2021

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

36-
given(dm.getLayoutTypes()).willReturn(EnumSet.allOf(layouttype4.class));
37+
given(dm.getLayoutTypes()).willReturn(EnumSet.of(LAYOUT4_OSD2_OBJECTS, LAYOUT4_BLOCK_VOLUME));
3738
given(transport.getRemoteSocketAddress()).willReturn(new InetSocketAddress("172.16.4.1", 0));
3839

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

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

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

5354
}
5455

0 commit comments

Comments
 (0)