summaryrefslogtreecommitdiffstats
path: root/src/mds/flock.cc
diff options
context:
space:
mode:
authorYan, Zheng <zheng.z.yan@intel.com>2014-03-10 00:36:14 +0100
committerYan, Zheng <zheng.z.yan@intel.com>2014-03-11 02:45:43 +0100
commitd3e3df7ad792c55e73d481dd31f5a85070c603ac (patch)
tree1efde2d42396cd5dc439b26fd17120d9175bb3bc /src/mds/flock.cc
parentReplicatedPG::finish_ctx: clear object_info if !obs.exists (diff)
downloadceph-d3e3df7ad792c55e73d481dd31f5a85070c603ac.tar.xz
ceph-d3e3df7ad792c55e73d481dd31f5a85070c603ac.zip
mds: fix owner check of file lock
flock and posix lock do not use process ID as owner identifier. The process ID of who holds the lock is just for F_GETLK fcntl(2). For linux kernel, File lock's owner identifier is the file pointer through which the lock is requested. The fix is do not take the 'pid_namespace' into consideration when checking conflict locks. Also rename the 'pid' fields of struct ceph_mds_request_args and struct ceph_filelock to 'owner', rename 'pid_namespace' fields to 'pid'. The kclient counterpart of this patch modifies the flock code to assign the file pointer to the 'owner' field of lock message. It also set the most significant bit of the 'owner' field. We can use that bit to distinguish between old and new clients. Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Diffstat (limited to 'src/mds/flock.cc')
-rw-r--r--src/mds/flock.cc16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/mds/flock.cc b/src/mds/flock.cc
index 5e329afafb7..4e825c9df27 100644
--- a/src/mds/flock.cc
+++ b/src/mds/flock.cc
@@ -15,9 +15,7 @@ bool ceph_lock_state_t::is_waiting(ceph_filelock &fl)
if (p->second.start > fl.start)
return false;
if (p->second.length == fl.length &&
- p->second.client == fl.client &&
- p->second.pid == fl.pid &&
- p->second.pid_namespace == fl.pid_namespace)
+ ceph_filelock_owner_equal(p->second, fl))
return true;
++p;
}
@@ -31,9 +29,7 @@ void ceph_lock_state_t::remove_waiting(ceph_filelock& fl)
if (p->second.start > fl.start)
return;
if (p->second.length == fl.length &&
- p->second.client == fl.client &&
- p->second.pid == fl.pid &&
- p->second.pid_namespace == fl.pid_namespace) {
+ ceph_filelock_owner_equal(p->second, fl)) {
waiting_locks.erase(p);
--client_waiting_lock_counts[(client_t)fl.client];
if (!client_waiting_lock_counts[(client_t)fl.client]) {
@@ -466,17 +462,15 @@ void ceph_lock_state_t::split_by_owner(ceph_filelock& owner,
dout(15) << "owner lock: " << owner << dendl;
while (iter != locks.end()) {
dout(15) << "comparing to " << (*iter)->second << dendl;
- if ((*iter)->second.client == owner.client &&
- (*iter)->second.pid_namespace == owner.pid_namespace &&
- (*iter)->second.pid == owner.pid) {
+ if (ceph_filelock_owner_equal((*iter)->second, owner)) {
dout(15) << "success, pushing to owned_locks" << dendl;
owned_locks.push_back(*iter);
iter = locks.erase(iter);
} else {
dout(15) << "failure, something not equal in this group "
<< (*iter)->second.client << ":" << owner.client << ","
- << (*iter)->second.pid_namespace << ":" << owner.pid_namespace
- << "," << (*iter)->second.pid << ":" << owner.pid << dendl;
+ << (*iter)->second.owner << ":" << owner.owner << ","
+ << (*iter)->second.pid << ":" << owner.pid << dendl;
++iter;
}
}