Commit 43209ada authored by Phoebe Buckheister's avatar Phoebe Buckheister 🦎

meta: correctly lock items in MovingDirInsertMsg

 * toDir always resides on the local node, so previously we would never
   have locked anything at all. check for locally generates requests
   instead.
 * also lock the parent/name of the new dentry to comply with the
   resyncer protocol

(cherry picked from commit b40c93c1fa1bb3ca44644c197c22b3936cc8553e)
parent 12ccc042
......@@ -12,6 +12,8 @@ bool MovingDirInsertMsgEx::processIncoming(ResponseContext& ctx)
LOG_DEBUG_CONTEXT(log, 4, "Received a MovingDirInsertMsg from: " + ctx.peerName() );
rctx = &ctx;
return BaseType::processIncoming(ctx);
}
......
......@@ -9,7 +9,8 @@
// Move directory to another meta-data server
class MovingDirInsertMsgEx : public MirroredMessage<MovingDirInsertMsg, DirIDLock>
class MovingDirInsertMsgEx : public MirroredMessage<MovingDirInsertMsg,
std::tuple<DirIDLock, ParentNameLock>>
{
public:
typedef ErrorCodeResponseState<MovingDirInsertRespMsg, NETMSGTYPE_MovingDirInsert>
......@@ -17,21 +18,25 @@ class MovingDirInsertMsgEx : public MirroredMessage<MovingDirInsertMsg, DirIDLoc
virtual bool processIncoming(ResponseContext& ctx) override;
DirIDLock lock(EntryLockStore& store) override
std::tuple<DirIDLock, ParentNameLock> lock(EntryLockStore& store) override
{
// we must not lock the directory if it is owned by the current node. if it is, the
// current message was also sent by the local node, specifically by a RmDirMsgEx, which
// also locks the directory for write
uint16_t localID = Program::getApp()->getMetaBuddyGroupMapper()->getLocalGroupID();
if (getToDirInfo()->getOwnerNodeID().val() == localID)
if (rctx->isLocallyGenerated())
return {};
return {&store, getToDirInfo()->getEntryID(), true};
DirIDLock dirLock(&store, getToDirInfo()->getEntryID(), true);
ParentNameLock nameLock(&store, getToDirInfo()->getEntryID(), getNewName());
return std::make_tuple(std::move(dirLock), std::move(nameLock));
}
bool isMirrored() override { return getToDirInfo()->getIsBuddyMirrored(); }
private:
ResponseContext* rctx;
std::unique_ptr<MirroredMessageResponseState> executeLocally(ResponseContext& ctx,
bool isSecondary) override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment