Skip to content

Commit 06ea697

Browse files
committed
nfs4: squash opens only if open_owners are the same
Fixes: 9288056 ("nfs4: voluntarily offer delegation id there are multiple opens on the file") Motivation: The NFSv4.x server allowed to merge different opens only if they comes from the same client and owner, as per rfc 7530 Modification: check owners before merging states. added unit test Result: regression fixed, better spec compliance Acked-by: Marina Sahakyan Target: master, 0.27 (cherry picked from commit 6e33634) Signed-off-by: Tigran Mkrtchyan <[email protected]>
1 parent e6dfbc7 commit 06ea697

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public OpenRecord addOpen(NFS4Client client, StateOwner owner, Inode inode, int
311311
// access mode and return the same stateid as required by rfc5661#18.16.3
312312

313313
for (OpenState os : opens) {
314-
if (os.client.getId() == client.getId()) {
314+
if (os.client.getId() == client.getId() && os.getOwner().equals(owner)) {
315315
os.shareAccess |= shareAccess;
316316
os.shareDeny |= shareDeny;
317317

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,21 @@ public void shouldReturnSameStateIdForSameClient() throws Exception {
9393
assertEquals("New stateid returned", openRecord1.openStateId(), openRecord2.openStateId());
9494
}
9595

96+
@Test
97+
public void shouldReturnDifferentStateIdForDifferentOwners() throws Exception {
98+
99+
NFS4Client client1 = createClient(sh);
100+
StateOwner stateOwner1 = client1.getOrCreateOwner("client1".getBytes(StandardCharsets.UTF_8), new seqid4(0));
101+
StateOwner stateOwner2 = client1.getOrCreateOwner("client2".getBytes(StandardCharsets.UTF_8), new seqid4(0));
102+
103+
nfs_fh4 fh = generateFileHandle();
104+
Inode inode = Inode.forFile(fh.value);
105+
106+
var openRecord1 = tracker.addOpen(client1, stateOwner1, inode, OPEN4_SHARE_ACCESS_READ, 0);
107+
var openRecord2 = tracker.addOpen(client1, stateOwner2, inode, OPEN4_SHARE_ACCESS_READ, 0);
108+
assertNotEquals("Same stateid for different owners returned", openRecord1.openStateId(), openRecord2.openStateId());
109+
}
110+
96111
@Test
97112
public void shouldMergeAccessModesOnMultipleOpenes() throws Exception {
98113

0 commit comments

Comments
 (0)