Skip to content

Commit e77f5ad

Browse files
committed
nfsv41: add delegation recall callback
Motivation: If client have issued an open-delegation to client and a competing open arrived, then delegation recall must be issued. Modification: All delegation recall method to the nfs client record. Update javadocs. Result: Groundwork for implementing open-delegation. Acked-by: Dmitry Litvintsev Target: master
1 parent 4cc9e45 commit e77f5ad

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

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

+56-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009 - 2021 Deutsches Elektronen-Synchroton,
2+
* Copyright (c) 2009 - 2024 Deutsches Elektronen-Synchroton,
33
* Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY
44
*
55
* This library is free software; you can redistribute it and/or modify
@@ -28,6 +28,7 @@
2828
import org.dcache.nfs.v4.xdr.CB_LAYOUTRECALL4args;
2929
import org.dcache.nfs.v4.xdr.CB_NOTIFY_DEVICEID4args;
3030
import org.dcache.nfs.v4.xdr.CB_OFFLOAD4args;
31+
import org.dcache.nfs.v4.xdr.CB_RECALL4args;
3132
import org.dcache.nfs.v4.xdr.CB_SEQUENCE4args;
3233
import org.dcache.nfs.v4.xdr.bitmap4;
3334
import org.dcache.nfs.v4.xdr.callback_sec_parms4;
@@ -189,14 +190,52 @@ public void cbLayoutRecallFsid() throws OncRpcException, IOException {
189190
opArgs.opcblayoutrecall = cbLayoutrecall;
190191

191192
var slot = _clientSession.acquireSlot();
192-
try{
193+
try {
193194
XdrAble args = generateCompound(slot,"cb_layout_recall_fs", opArgs);
194195
_rpc.call(nfs4_prot.CB_COMPOUND_1, args, new CB_COMPOUND4res());
195196
} finally {
196197
_clientSession.releaseSlot(slot);
197198
}
198199
}
199200

201+
/**
202+
* Recall file delegation from the client.
203+
*
204+
* @param fh file handle of the file
205+
* @param stateid stateid of the delegation
206+
* @param truncate true if the client should truncate the file
207+
* @throws OncRpcException if an RPC error occurs
208+
* @throws IOException if an I/O error occurs
209+
*/
210+
public void cbDelegationRecall(nfs_fh4 fh, stateid4 stateid, boolean truncate) throws OncRpcException, IOException {
211+
212+
CB_RECALL4args cbDelegRecall = new CB_RECALL4args();
213+
214+
cbDelegRecall.stateid = stateid;
215+
cbDelegRecall.fh = fh;
216+
cbDelegRecall.truncate = truncate;
217+
218+
nfs_cb_argop4 opArgs = new nfs_cb_argop4();
219+
opArgs.argop = nfs_cb_opnum4.OP_CB_RECALL;
220+
opArgs.opcbrecall = cbDelegRecall;
221+
222+
var slot = _clientSession.acquireSlot();
223+
try {
224+
XdrAble args = generateCompound(slot,"cb_recall_delegation", opArgs);
225+
_rpc.call(nfs4_prot.CB_COMPOUND_1, args, new CB_COMPOUND4res());
226+
} finally {
227+
_clientSession.releaseSlot(slot);
228+
}
229+
}
230+
231+
/**
232+
* Recall pNFS layout from the client.
233+
*
234+
* @param fh file handle of the file
235+
* @param stateid stateid of the layout
236+
* @throws OncRpcException if an RPC error occurs
237+
* @throws IOException if an I/O error occurs
238+
*/
200239
public void cbLayoutRecallFile(nfs_fh4 fh, stateid4 stateid) throws OncRpcException, IOException {
201240

202241
CB_LAYOUTRECALL4args cbLayoutrecall = new CB_LAYOUTRECALL4args();
@@ -227,6 +266,13 @@ public void cbLayoutRecallFile(nfs_fh4 fh, stateid4 stateid) throws OncRpcExcept
227266
}
228267
}
229268

269+
/**
270+
* Notify the client that a device id has been added.
271+
*
272+
* @param id device id
273+
* @throws OncRpcException if an RPC error occurs
274+
* @throws IOException if an I/O error occurs
275+
*/
230276
public void cbDeleteDevice(deviceid4 id) throws OncRpcException, IOException {
231277

232278
CB_NOTIFY_DEVICEID4args cbDeleteDeciveId = new CB_NOTIFY_DEVICEID4args();
@@ -265,6 +311,14 @@ public void cbDeleteDevice(deviceid4 id) throws OncRpcException, IOException {
265311
}
266312
}
267313

314+
/**
315+
* Notify the client that offload copy has been completed.
316+
*
317+
* @param fh file handle of the file
318+
* @param stateid stateid of the file
319+
* @param response write response
320+
* @param status status of the offload
321+
*/
268322
public void cbOffload(nfs_fh4 fh, stateid4 stateid, write_response4 response, int status) throws OncRpcException, IOException {
269323

270324
CB_OFFLOAD4args copyOffload = new CB_OFFLOAD4args();

0 commit comments

Comments
 (0)