Skip to content

Commit

Permalink
nfs: fix compatibility with 2.6
Browse files Browse the repository at this point in the history
post 2.6 nfs code has changes package name from

org.dcache.chimera.nfs => org.dcache.nfs
Nevertheless one class is used inside
a message sent to a pool and brakes
compatibility with.

this change restores compatibility.

Notice, this makes 2.7.6 not compatible in mixed
setup.

Acked-by: Gerd Behrmann
Target: master, 2.7
Require-book: no
Require-notes: no
  • Loading branch information
kofemann committed Jan 20, 2014
1 parent c7b6aa3 commit be1b718
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 10 deletions.
@@ -0,0 +1,69 @@
/*
* Copyright (c) 2009 - 2014 Deutsches Elektronen-Synchroton,
* Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program (see the file COPYING.LIB for more
* details); if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package org.dcache.chimera.nfs.v4.xdr;
import java.util.Arrays;

import java.io.Serializable;
import org.dcache.utils.Bytes;

public class stateid4 implements Serializable {

static final long serialVersionUID = -6677150504723505919L;

public uint32_t seqid;
public byte [] other;

public stateid4(byte[] other, int seq) {
this.other = other;
seqid = new uint32_t(seq);
}

public stateid4(org.dcache.nfs.v4.xdr.stateid4 stateid) {
this(stateid.other, stateid.seqid.value);
}

@Override
public boolean equals(Object obj) {

if( obj == this) return true;
if( !(obj instanceof stateid4) ) return false;

final stateid4 other_id = (stateid4) obj;

return Arrays.equals(this.other, other_id.other);
}

@Override
public int hashCode() {
return Arrays.hashCode(other);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();

sb.append("[");
sb.append(Bytes.toHexString(other));
sb.append(", seq: ").append(seqid.value).append("]");
return sb.toString();
}

}
// End of stateid4.java
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2009 - 2014 Deutsches Elektronen-Synchroton,
* Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program (see the file COPYING.LIB for more
* details); if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package org.dcache.chimera.nfs.v4.xdr;

import java.io.Serializable;

public class uint32_t implements Serializable {

static final long serialVersionUID = -6603937444681096490L;

public int value;

public uint32_t(int value) {
this.value = value;
}

}
// End of uint32_t.java
Expand Up @@ -296,7 +296,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<stateid4> message) {
public void messageArrived(PoolPassiveIoFileMessage<org.dcache.chimera.nfs.v4.xdr.stateid4> message) {

String poolName = message.getPoolName();

Expand All @@ -316,16 +316,17 @@ public void messageArrived(PoolPassiveIoFileMessage<stateid4> message) {
device = newDevice;
}

stateid4 stateid = message.challange();
NfsTransfer transfer = _ioMessages.get(stateid);
org.dcache.chimera.nfs.v4.xdr.stateid4 legacyStateid = message.challange();
NfsTransfer transfer = _ioMessages.get(new stateid4(legacyStateid.other, legacyStateid.seqid.value));
transfer.redirect(device);
}

public void messageArrived(DoorTransferFinishedMessage transferFinishedMessage) {

NFS4ProtocolInfo protocolInfo = (NFS4ProtocolInfo)transferFinishedMessage.getProtocolInfo();
_log.debug("Mover {} done.", protocolInfo.stateId());
Transfer transfer = _ioMessages.remove(protocolInfo.stateId());
org.dcache.chimera.nfs.v4.xdr.stateid4 legacyStateid = protocolInfo.stateId();
Transfer transfer = _ioMessages.remove(new stateid4(legacyStateid.other, legacyStateid.seqid.value));
if(transfer != null) {
transfer.finished(transferFinishedMessage);
transfer.notifyBilling(transferFinishedMessage.getReturnCode(), "");
Expand Down Expand Up @@ -394,7 +395,7 @@ public Layout layoutGet(CompoundContext context, Inode nfsInode, int ioMode, sta
} else {
final InetSocketAddress remote = context.getRpcCall().getTransport().getRemoteSocketAddress();
final PnfsId pnfsId = new PnfsId(inode.toString());
final NFS4ProtocolInfo protocolInfo = new NFS4ProtocolInfo(remote, stateid);
final NFS4ProtocolInfo protocolInfo = new NFS4ProtocolInfo(remote, new org.dcache.chimera.nfs.v4.xdr.stateid4(stateid));

Transfer.initSession();
final NfsTransfer transfer = new NfsTransfer(_pnfsHandler,
Expand All @@ -410,7 +411,7 @@ public Layout layoutGet(CompoundContext context, Inode nfsInode, int ioMode, sta
transfer.setClientAddress(remote);
transfer.readNameSpaceEntry();

_ioMessages.put(protocolInfo.stateId(), transfer);
_ioMessages.put(stateid, transfer);

PoolDS ds = getPool(transfer, protocolInfo, ioMode);
deviceid = ds.getDeviceId();
Expand Down
Expand Up @@ -4,7 +4,7 @@

import diskCacheV111.vehicles.IpProtocolInfo;

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

public class NFS4ProtocolInfo implements IpProtocolInfo {

Expand Down
Expand Up @@ -65,7 +65,8 @@ public Set<Checksum> getExpectedChecksums() {
}

public stateid4 getStateId() {
return getProtocolInfo().stateId();
org.dcache.chimera.nfs.v4.xdr.stateid4 legacyStateid = getProtocolInfo().stateId();
return new stateid4(legacyStateid.other, legacyStateid.seqid.value);
}

@Override
Expand Down Expand Up @@ -146,7 +147,7 @@ synchronized void detachSession() {
private class MoverState extends NFS4State {

MoverState() {
super(NfsMover.this.getProtocolInfo().stateId());
super(NfsMover.this.getStateId());
}

@Override
Expand Down
Expand Up @@ -102,7 +102,8 @@ public Cancellable execute(final NfsMover mover, final CompletionHandler<Void,Vo
final Cancellable cancellableMover = mover.enable(completionHandler);

CellPath directDoorPath = new CellPath(mover.getPathToDoor().getDestinationAddress());
_door.send(directDoorPath, new PoolPassiveIoFileMessage<>(getCellName(), _localSocketAddresses, mover.getStateId()));
final org.dcache.chimera.nfs.v4.xdr.stateid4 legacyStateId = mover.getProtocolInfo().stateId();
_door.send(directDoorPath, new PoolPassiveIoFileMessage<>(getCellName(), _localSocketAddresses, legacyStateId));

/* An NFS mover doesn't complete until it is cancelled (the door sends a mover kill
* message when the file is closed).
Expand Down

0 comments on commit be1b718

Please sign in to comment.