Commit f1626dc7 authored by Tigran Mkrtchyan's avatar Tigran Mkrtchyan
Browse files

nfsv4.1: resulting notification bitmap should match requests length

Motivation:
Though bitmap can have an arbitrary length, the linux 5.10 client expects
device notification bitmap to be size of one (1).

Modification:
Update OperationGETDEVICEINFO to initialize resulting notification bitmap
with the length that matches requested notification bitmap.

Result:
Linux 5.10 client processes the result of getdeviceinfo operation as expected.

Target: 0.22, master
Acked-by: Paul Millar
Acked-by: Albert Rossi
(cherry picked from commit 8ede287c

)
Signed-off-by: Tigran Mkrtchyan's avatarTigran Mkrtchyan <tigran.mkrtchyan@desy.de>
parent 846af415
......@@ -72,7 +72,8 @@ public class OperationGETDEVICEINFO extends AbstractNFSv4Operation {
}
res.gdir_resok4.gdir_device_addr = deviceInfo;
res.gdir_resok4.gdir_notification = new bitmap4();
// expect the returned notification bitmap to be the same size as requested by client.
res.gdir_resok4.gdir_notification = new bitmap4(new int[_args.opgetdeviceinfo.gdia_notify_types.value.length]);
/*
* provide faked notification only if client expects them
*/
......
package org.dcache.nfs.v4;
import com.google.common.collect.Sets;
import java.io.IOException;
import java.net.URISyntaxException;
import org.dcache.nfs.v4.xdr.COMPOUND4args;
import org.dcache.nfs.v4.xdr.COMPOUND4res;
import org.dcache.nfs.v4.xdr.device_addr4;
import org.dcache.nfs.v4.xdr.deviceid4;
import org.dcache.nfs.v4.xdr.layouttype4;
import org.junit.Test;
import static org.dcache.nfs.v4.NfsTestUtils.generateRpcCall;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.BDDMockito.given;
import static org.dcache.nfs.v4.NfsTestUtils.execute;
/**
*
*/
public class OperationGETDEVICEINFOTest {
@Test
public void testNotificationBitmapSize() throws IOException, URISyntaxException {
NFSv41DeviceManager dm = mock(NFSv41DeviceManager.class);
given(dm.getDeviceInfo(any(), any())).willReturn(mock(device_addr4.class));
given(dm.getLayoutTypes()).willReturn(Sets.newHashSet(layouttype4.values()));
CompoundContext context = new CompoundContextBuilder()
.withDeviceManager(dm)
.withCall(generateRpcCall())
.build();
COMPOUND4args gdiArgs = new CompoundBuilder()
.withGetdeviceinfo(new deviceid4(new byte[] {0x7}))
.build();
COMPOUND4res res = execute(context, gdiArgs);
assertEquals("invalid notification bitmap size", 1, res.resarray.get(0).opgetdeviceinfo.gdir_resok4.gdir_notification.value.length);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment