Commit 1c316f79 authored by Phoebe Buckheister's avatar Phoebe Buckheister 🦎

meta: lock created file in MkFileWithPatternMsg

lock the newly created file as required by the resyncer locking
protocol. effectively the lock is not necessary because the parent
directory is already locked and modsync cannot pick up the file before
we return Success, but it is better to follow the protocol here than it
is to optimize.

(cherry picked from commit 3a98b0c532780ef54e7a043cab59cf795f4cfa50)
parent 770e1a73
......@@ -12,7 +12,8 @@
// Called from fhgfs-ctl (online_cfg) to create a file on a specific node.
std::tuple<DirIDLock, ParentNameLock> MkFileWithPatternMsgEx::lock(EntryLockStore& store)
std::tuple<DirIDLock, ParentNameLock, FileIDLock> MkFileWithPatternMsgEx::lock(
EntryLockStore& store)
// no need to lock the created file as well, since
// a) no other operation can create the same file id
......@@ -20,8 +21,9 @@ std::tuple<DirIDLock, ParentNameLock> MkFileWithPatternMsgEx::lock(EntryLockStor
// c) if bulk resync gets the file while it is incomplete, individual resync will get it again
DirIDLock dirLock(&store, getParentInfo()->getEntryID(), true);
ParentNameLock dentryLock(&store, getParentInfo()->getEntryID(), getNewFileName());
FileIDLock fileLock(&store, entryID);
return std::make_tuple(std::move(dirLock), std::move(dentryLock));
return std::make_tuple(std::move(dirLock), std::move(dentryLock), std::move(fileLock));
bool MkFileWithPatternMsgEx::processIncoming(ResponseContext& ctx)
......@@ -14,7 +14,7 @@
* or from ioctl calls.
class MkFileWithPatternMsgEx : public MirroredMessage<MkFileWithPatternMsg,
std::tuple<DirIDLock, ParentNameLock>>
std::tuple<DirIDLock, ParentNameLock, FileIDLock>>
typedef ErrorAndEntryResponseState<MkFileWithPatternRespMsg, NETMSGTYPE_MkFileWithPattern>
......@@ -22,7 +22,7 @@ class MkFileWithPatternMsgEx : public MirroredMessage<MkFileWithPatternMsg,
virtual bool processIncoming(ResponseContext& ctx) override;
std::tuple<DirIDLock, ParentNameLock> lock(EntryLockStore& store) override;
std::tuple<DirIDLock, ParentNameLock, FileIDLock> lock(EntryLockStore& store) override;
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