aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph/locks.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@poochiereds.net>2014-05-09 14:13:04 -0400
committerJeff Layton <jlayton@poochiereds.net>2014-06-02 08:09:29 -0400
commit130d1f956ab367bab855336279afa3b19acdc9a1 (patch)
tree8372682ec959aa89df1d280e93c3ab8119801dea /fs/ceph/locks.c
parentcf01f4eef9fe367ec0d85b38dd7214e29e376cdb (diff)
locks: ensure that fl_owner is always initialized properly in flock and lease codepaths
Currently, the fl_owner isn't set for flock locks. Some filesystems use byte-range locks to simulate flock locks and there is a common idiom in those that does: fl->fl_owner = (fl_owner_t)filp; fl->fl_start = 0; fl->fl_end = OFFSET_MAX; Since flock locks are generally "owned" by the open file description, move this into the common flock lock setup code. The fl_start and fl_end fields are already set appropriately, so remove the unneeded setting of that in flock ops in those filesystems as well. Finally, the lease code also sets the fl_owner as if they were owned by the process and not the open file description. This is incorrect as leases have the same ownership semantics as flock locks. Set them the same way. The lease code doesn't actually use the fl_owner value for anything, so this is more for consistency's sake than a bugfix. Reported-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: Jeff Layton <jlayton@poochiereds.net> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (Staging portion) Acked-by: J. Bruce Fields <bfields@fieldses.org>
Diffstat (limited to 'fs/ceph/locks.c')
-rw-r--r--fs/ceph/locks.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c
index 191398852a2e..fbc39c47bacd 100644
--- a/fs/ceph/locks.c
+++ b/fs/ceph/locks.c
@@ -53,10 +53,7 @@ static int ceph_lock_message(u8 lock_type, u16 operation, struct file *file,
53 else 53 else
54 length = fl->fl_end - fl->fl_start + 1; 54 length = fl->fl_end - fl->fl_start + 1;
55 55
56 if (lock_type == CEPH_LOCK_FCNTL) 56 owner = secure_addr(fl->fl_owner);
57 owner = secure_addr(fl->fl_owner);
58 else
59 owner = secure_addr(fl->fl_file);
60 57
61 dout("ceph_lock_message: rule: %d, op: %d, owner: %llx, pid: %llu, " 58 dout("ceph_lock_message: rule: %d, op: %d, owner: %llx, pid: %llu, "
62 "start: %llu, length: %llu, wait: %d, type: %d", (int)lock_type, 59 "start: %llu, length: %llu, wait: %d, type: %d", (int)lock_type,
@@ -314,10 +311,7 @@ int lock_to_ceph_filelock(struct file_lock *lock,
314 cephlock->length = cpu_to_le64(lock->fl_end - lock->fl_start + 1); 311 cephlock->length = cpu_to_le64(lock->fl_end - lock->fl_start + 1);
315 cephlock->client = cpu_to_le64(0); 312 cephlock->client = cpu_to_le64(0);
316 cephlock->pid = cpu_to_le64((u64)lock->fl_pid); 313 cephlock->pid = cpu_to_le64((u64)lock->fl_pid);
317 if (lock->fl_flags & FL_POSIX) 314 cephlock->owner = cpu_to_le64(secure_addr(lock->fl_owner));
318 cephlock->owner = cpu_to_le64(secure_addr(lock->fl_owner));
319 else
320 cephlock->owner = cpu_to_le64(secure_addr(lock->fl_file));
321 315
322 switch (lock->fl_type) { 316 switch (lock->fl_type) {
323 case F_RDLCK: 317 case F_RDLCK: