Skip to content

Commit

Permalink
nfs: prepare code for removal of redundant stateid4 class
Browse files Browse the repository at this point in the history
Motivation:
During split and refactoring of nfs4j code for backwar compatibility
with older dCache version (2.6!) we have kept the
org.dcache.chimera.nfs.v4.xdr.stateid class. Sommehot it have survived
10 years :).

Modification:
Update code to:
 - prepare pools to accept both stateid classes.
 - pools always sent stateid from nfs4j
 - doors send legacy stateid, but accept both.

With with dcache 11.0 the legacy classes can be dropped.

Result:
prepare code for legacy class removal.

Acked-by: Paul Millar
Target: master
Require-book: no
Require-notes: no
  • Loading branch information
kofemann committed Oct 10, 2023
1 parent 3d0a0bd commit 3cbe3f4
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.Serializable;
import java.util.Arrays;

@Deprecated(forRemoval = true)
public class stateid4 implements Serializable {

static final long serialVersionUID = -6677150504723505919L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.io.Serializable;

@Deprecated(forRemoval = true)
public class uint32_t implements Serializable {

static final long serialVersionUID = -6603937444681096490L;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.dcache.chimera.nfsv41.common;

import org.dcache.nfs.v4.xdr.stateid4;

/**
* Utility class to support removal of legacy stateid class.
*/
@Deprecated(forRemoval = true)
public class LegacyUtils {

private LegacyUtils() {
// no instance allowed
}

public static stateid4 toStateid(Object stateObject) {
stateid4 stateid;
if (stateObject instanceof stateid4) {
stateid = (stateid4) stateObject;
} else {
org.dcache.chimera.nfs.v4.xdr.stateid4 legacyStateid
= (org.dcache.chimera.nfs.v4.xdr.stateid4) stateObject;
stateid = new stateid4(legacyStateid.other, legacyStateid.seqid.value);
}
return stateid;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
import org.dcache.chimera.FsInode;
import org.dcache.chimera.FsInodeType;
import org.dcache.chimera.JdbcFs;
import org.dcache.chimera.nfsv41.common.LegacyUtils;
import org.dcache.chimera.nfsv41.common.StatsDecoratedOperationExecutor;
import org.dcache.chimera.nfsv41.door.proxy.NfsProxyIoFactory;
import org.dcache.chimera.nfsv41.door.proxy.ProxyIoFactory;
Expand Down Expand Up @@ -528,8 +529,7 @@ public void destroy() throws IOException {
* and NFSv4.1 device id. Finally, notify waiting request that we have got
* the reply for LAYOUTGET
*/
public void messageArrived(
PoolPassiveIoFileMessage<org.dcache.chimera.nfs.v4.xdr.stateid4> message) {
public void messageArrived(PoolPassiveIoFileMessage<?> message) {

String poolName = message.getPoolName();
long verifier = message.getVerifier();
Expand All @@ -539,9 +539,13 @@ public void messageArrived(

PoolDS device = _poolDeviceMap.getOrCreateDS(poolName, verifier, poolAddresses);

org.dcache.chimera.nfs.v4.xdr.stateid4 legacyStateid = message.challange();
NfsTransfer transfer = _transfers.get(
new stateid4(legacyStateid.other, legacyStateid.seqid.value));

// REVISIT 11.0: remove drop legacy support. Old polls will send legacy stateid.
// stateid4 stateid = message.challange();
Object stateObject = message.challange();
stateid4 stateid = LegacyUtils.toStateid(stateObject);
NfsTransfer transfer = _transfers.get(stateid);

/*
* We got a notification for a transfer which was not
* started by us.
Expand Down Expand Up @@ -591,10 +595,12 @@ public void messageArrived(DoorTransferFinishedMessage transferFinishedMessage)
}
}

public DoorValidateMoverMessage<org.dcache.chimera.nfs.v4.xdr.stateid4> messageArrived(
DoorValidateMoverMessage<org.dcache.chimera.nfs.v4.xdr.stateid4> message) {
org.dcache.chimera.nfs.v4.xdr.stateid4 legacyStateid = message.getChallenge();
stateid4 stateid = new stateid4(legacyStateid.other, legacyStateid.seqid.value);
public DoorValidateMoverMessage<?> messageArrived(DoorValidateMoverMessage<?> message) {

// REVISIT 11.0: remove drop legacy support. Old polls will send legacy stateid.
// stateid4 stateid = message.getChallenge();
Object stateObject = message.getChallenge();
stateid4 stateid = LegacyUtils.toStateid(stateObject);

boolean isValid = false;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.IOException;
import java.io.InterruptedIOException;
import java.nio.channels.CompletionHandler;
import org.dcache.chimera.nfsv41.common.LegacyUtils;
import org.dcache.nfs.ChimeraNFSException;
import org.dcache.nfs.status.NfsIoException;
import org.dcache.nfs.v4.NFS4State;
Expand All @@ -51,8 +52,13 @@ public NfsMover(ReplicaDescriptor handle, PoolIoFileMessage message, CellPath pa
NfsTransferService nfsTransferService, PnfsHandler pnfsHandler) {
super(handle, message, pathToDoor, nfsTransferService);
_nfsTransferService = nfsTransferService;
org.dcache.chimera.nfs.v4.xdr.stateid4 legacyStateid = getProtocolInfo().stateId();
_state = new MoverState(null, new stateid4(legacyStateid.other, legacyStateid.seqid.value));

// REVISIT 11.0: remove drop legacy support
// stateid4 stateid = getProtocolInfo().stateId();
Object stateObject = getProtocolInfo().stateId();
stateid4 stateid = LegacyUtils.toStateid(stateObject);

_state = new MoverState(null, stateid);
_namespace = pnfsHandler;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import javax.annotation.Nullable;
import org.dcache.auth.Subjects;
import org.dcache.cells.CellStub;
import org.dcache.chimera.nfsv41.common.LegacyUtils;
import org.dcache.chimera.nfsv41.common.StatsDecoratedOperationExecutor;
import org.dcache.commons.stats.RequestExecutionTimeGauges;
import org.dcache.nfs.ChimeraNFSException;
Expand Down Expand Up @@ -342,11 +343,16 @@ public Cancellable executeMover(final NfsMover mover,

public void notifyDoorWithRedirect(NfsMover mover) {
CellPath directDoorPath = new CellPath(mover.getPathToDoor().getDestinationAddress());
final org.dcache.chimera.nfs.v4.xdr.stateid4 legacyStateId = mover.getProtocolInfo()
.stateId();

// REVISIT 11.0: remove drop legacy support
// stateid4 stateid = mover.getProtocolInfo().stateId();
Object stateObject = mover.getProtocolInfo().stateId();
stateid4 stateid = LegacyUtils.toStateid(stateObject);

// never send legacy stateid.
_door.notify(directDoorPath,
new PoolPassiveIoFileMessage<>(_cellAddress.getCellName(), _localSocketAddresses,
legacyStateId,
stateid,
_bootVerifier));
}

Expand Down

0 comments on commit 3cbe3f4

Please sign in to comment.