Commit 8ede287c authored by Tigran Mkrtchyan's avatar Tigran Mkrtchyan
Browse files

nfsv4.1: resulting notification bitmap should match requests length

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

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

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

Target: 0.22, master
Acked-by: Paul Millar
Acked-by: Albert Rossi
parent ac82ca1b
Pipeline #1536 passed with stage
in 1 minute and 10 seconds
...@@ -72,7 +72,8 @@ public class OperationGETDEVICEINFO extends AbstractNFSv4Operation { ...@@ -72,7 +72,8 @@ public class OperationGETDEVICEINFO extends AbstractNFSv4Operation {
} }
res.gdir_resok4.gdir_device_addr = deviceInfo; 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 * provide faked notification only if client expects them
*/ */
package org.dcache.nfs.v4;
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 {
public void testNotificationBitmapSize() throws IOException, URISyntaxException {
NFSv41DeviceManager dm = mock(NFSv41DeviceManager.class);
given(dm.getDeviceInfo(any(), any())).willReturn(mock(device_addr4.class));
CompoundContext context = new CompoundContextBuilder()
COMPOUND4args gdiArgs = new CompoundBuilder()
.withGetdeviceinfo(new deviceid4(new byte[] {0x7}))
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