Skip to content

Commit

Permalink
nfsv4.1: resulting notification bitmap should match requests length
Browse files Browse the repository at this point in the history
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 8ede287)
Signed-off-by: Tigran Mkrtchyan <[email protected]>
  • Loading branch information
kofemann committed Dec 9, 2020
1 parent 846af41 commit f1626dc
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public void process(CompoundContext context, nfs_resop4 result) throws IOExcepti
}

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
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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);
}
}

0 comments on commit f1626dc

Please sign in to comment.