Search in sources :

Example 1 with LAYOUTCOMMIT4args

use of org.dcache.nfs.v4.xdr.LAYOUTCOMMIT4args in project dcache by dCache.

the class NFSv41Door method layoutCommit.

@Override
public OptionalLong layoutCommit(CompoundContext context, LAYOUTCOMMIT4args args) throws IOException {
    final stateid4 stateid = Stateids.getCurrentStateidIfNeeded(context, args.loca_stateid);
    final NFS4Client client = context.getStateHandler().getClientIdByStateId(stateid);
    final NFS4State layoutState = client.state(stateid);
    final NFS4State openState = layoutState.getOpenState();
    Inode nfsInode = context.currentInode();
    _log.debug("Committing layout by stateid: {}, open-state: {}", stateid, openState.stateid());
    if (args.loca_last_write_offset.no_newoffset) {
        long currentSize = _chimeraVfs.getattr(nfsInode).getSize();
        long newSize = args.loca_last_write_offset.no_offset.value + 1;
        if (newSize > currentSize) {
            Stat newStat = new Stat();
            newStat.setSize(newSize);
            _chimeraVfs.setattr(nfsInode, newStat);
            _vfsCache.invalidateStatCache(nfsInode);
            return OptionalLong.of(newSize);
        }
    }
    return OptionalLong.empty();
}
Also used : NFS4Client(org.dcache.nfs.v4.NFS4Client) FsInode(org.dcache.chimera.FsInode) Inode(org.dcache.nfs.vfs.Inode) Stat(org.dcache.nfs.vfs.Stat) org.dcache.nfs.v4.xdr.stateid4(org.dcache.nfs.v4.xdr.stateid4) NFS4State(org.dcache.nfs.v4.NFS4State)

Aggregations

FsInode (org.dcache.chimera.FsInode)1 NFS4Client (org.dcache.nfs.v4.NFS4Client)1 NFS4State (org.dcache.nfs.v4.NFS4State)1 org.dcache.nfs.v4.xdr.stateid4 (org.dcache.nfs.v4.xdr.stateid4)1 Inode (org.dcache.nfs.vfs.Inode)1 Stat (org.dcache.nfs.vfs.Stat)1