From 853dcc385efa14cdabc26014eeaccbef28482a98 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Fri, 10 Dec 2010 14:49:30 -0500 Subject: [PATCH] recovery: lock_owner to open_owner if we're recovering a lock stateid for a LOCK operation, and the file has no outstanding locks, we won't be able to recover a lock stateid. resend the LOCK with an open stateid instead Signed-off-by: Casey Bodley --- daemon/nfs41_compound.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/daemon/nfs41_compound.c b/daemon/nfs41_compound.c index b90f277..ef9b9cb 100644 --- a/daemon/nfs41_compound.c +++ b/daemon/nfs41_compound.c @@ -174,6 +174,8 @@ static int recover_open( /* if we got a lock stateid back, save the lock with the open */ if (stateid.type == STATEID_LOCK) memcpy(&open->locks.stateid, &stateid.stateid, sizeof(stateid4)); + else + open->locks.stateid.seqid = 0; } ReleaseSRWLockExclusive(&open->lock); @@ -261,6 +263,15 @@ static bool_t recover_stateid(nfs_argop4 *argop, nfs41_session *session) /* if the source stateid is different, update and retry */ AcquireSRWLockShared(&stateid->open->lock); if (memcmp(&stateid->stateid, source, sizeof(stateid4))) { + /* if it was a lock stateid that was cleared, resend it with an open stateid */ + if (argop->op == OP_LOCK && stateid->type == STATEID_LOCK && source->seqid == 0) { + nfs41_lock_args *lock = (nfs41_lock_args*)argop->arg; + lock->locker.new_lock_owner = 1; + lock->locker.u.open_owner.open_stateid = stateid; + lock->locker.u.open_owner.lock_owner = &stateid->open->owner; + source = &stateid->open->stateid; + } + memcpy(&stateid->stateid, source, sizeof(stateid4)); retry = TRUE; }