Skip to content

Commit

Permalink
nfs4: initialize newly created state ids with sequence zero
Browse files Browse the repository at this point in the history
Motivation:
typically, every time when file's open/lock/layout state id is used to
change file's state, the sequence number is incremented. Thus newly
created stateid should have sequence zero, as it will be bumped during
processing. As currently sequence number initialized with one (1), fresh
created lock and layout state ids have sequence 2 when sent to the
clients.

Modification:
Initialize sequence number of newly created state ids with zero.
Increment open state id's sequence number for all state ids.

Result:
better spec compliance, as lock and layout state ids will start with
sequence 1.

Acked-by: Jürgen Starek
Target: master, 0.19
  • Loading branch information
kofemann committed Jul 25, 2019
1 parent 8aed1f0 commit 0d385e4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions core/src/main/java/org/dcache/nfs/v4/FileTracker.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017 Deutsches Elektronen-Synchroton,
* Copyright (c) 2017 - 2019 Deutsches Elektronen-Synchroton,
* Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY
*
* This library is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -129,7 +129,6 @@ public stateid4 addOpen(NFS4Client client, StateOwner owner, Inode inode, int sh
os.getOwner().equals(owner)) {
os.shareAccess |= shareAccess;
os.shareDeny |= shareDeny;
os.stateid.seqid.value++;
return os.stateid;
}
}
Expand Down
Expand Up @@ -57,7 +57,7 @@ public class NFSv4StateHandler {
/**
* initial value of new state's sequence number.
*/
private final static int STATE_INITIAL_SEQUENCE = 1;
private final static int STATE_INITIAL_SEQUENCE = 0;

/**
* client id generator.
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/org/dcache/nfs/v4/OperationOPEN.java
Expand Up @@ -271,6 +271,7 @@ public void process(CompoundContext context, nfs_resop4 result) throws ChimeraNF
_args.opopen.share_access.value,
_args.opopen.share_deny.value);

stateid.seqid.value++;
context.currentStateid(stateid);
res.resok4.stateid = stateid;
res.status = nfsstat.NFS_OK;
Expand Down

0 comments on commit 0d385e4

Please sign in to comment.