ceph: pass lock information by struct file_lock instead of as individual params.

Signed-off-by: Herb Shiu <herb_shiu@tcloudcomputing.com>
Acked-by: Greg Farnum <gregf@hq.newdream.net>
Signed-off-by: Sage Weil <sage@newdream.net>

authored by Herb Shiu and committed by Sage Weil 637ae8d5 25933abd

+21 -37
+21 -37
fs/ceph/locks.c
··· 11 11 * Implement fcntl and flock locking functions. 12 12 */ 13 13 static int ceph_lock_message(u8 lock_type, u16 operation, struct file *file, 14 - u64 pid, u64 pid_ns, 15 - int cmd, u64 start, u64 length, u8 wait) 14 + int cmd, u8 wait, struct file_lock *fl) 16 15 { 17 16 struct inode *inode = file->f_dentry->d_inode; 18 17 struct ceph_mds_client *mdsc = 19 18 ceph_sb_to_client(inode->i_sb)->mdsc; 20 19 struct ceph_mds_request *req; 21 20 int err; 21 + u64 length = 0; 22 22 23 23 req = ceph_mdsc_create_request(mdsc, operation, USE_AUTH_MDS); 24 24 if (IS_ERR(req)) 25 25 return PTR_ERR(req); 26 26 req->r_inode = igrab(inode); 27 27 28 + /* mds requires start and length rather than start and end */ 29 + if (LLONG_MAX == fl->fl_end) 30 + length = 0; 31 + else 32 + length = fl->fl_end - fl->fl_start + 1; 33 + 28 34 dout("ceph_lock_message: rule: %d, op: %d, pid: %llu, start: %llu, " 29 35 "length: %llu, wait: %d, type`: %d", (int)lock_type, 30 - (int)operation, pid, start, length, wait, cmd); 36 + (int)operation, (u64)fl->fl_pid, fl->fl_start, 37 + length, wait, fl->fl_type); 38 + 31 39 32 40 req->r_args.filelock_change.rule = lock_type; 33 41 req->r_args.filelock_change.type = cmd; 34 - req->r_args.filelock_change.pid = cpu_to_le64(pid); 42 + req->r_args.filelock_change.pid = cpu_to_le64((u64)fl->fl_pid); 35 43 /* This should be adjusted, but I'm not sure if 36 44 namespaces actually get id numbers*/ 37 45 req->r_args.filelock_change.pid_namespace = 38 - cpu_to_le64((u64)pid_ns); 39 - req->r_args.filelock_change.start = cpu_to_le64(start); 46 + cpu_to_le64((u64)(unsigned long)fl->fl_nspid); 47 + req->r_args.filelock_change.start = cpu_to_le64(fl->fl_start); 40 48 req->r_args.filelock_change.length = cpu_to_le64(length); 41 49 req->r_args.filelock_change.wait = wait; 42 50 43 51 err = ceph_mdsc_do_request(mdsc, inode, req); 44 52 ceph_mdsc_put_request(req); 45 53 dout("ceph_lock_message: rule: %d, op: %d, pid: %llu, start: %llu, " 46 - "length: %llu, wait: %d, type`: %d err code %d", (int)lock_type, 47 - (int)operation, pid, start, length, wait, cmd, err); 54 + "length: %llu, wait: %d, type`: %d, err code %d", (int)lock_type, 55 + (int)operation, (u64)fl->fl_pid, fl->fl_start, 56 + length, wait, fl->fl_type, err); 48 57 return err; 49 58 } 50 59 ··· 63 54 */ 64 55 int ceph_lock(struct file *file, int cmd, struct file_lock *fl) 65 56 { 66 - u64 length; 67 57 u8 lock_cmd; 68 58 int err; 69 59 u8 wait = 0; ··· 84 76 else 85 77 lock_cmd = CEPH_LOCK_UNLOCK; 86 78 87 - if (LLONG_MAX == fl->fl_end) 88 - length = 0; 89 - else 90 - length = fl->fl_end - fl->fl_start + 1; 91 - 92 - err = ceph_lock_message(CEPH_LOCK_FCNTL, op, file, 93 - (u64)fl->fl_pid, 94 - (u64)(unsigned long)fl->fl_nspid, 95 - lock_cmd, fl->fl_start, 96 - length, wait); 79 + err = ceph_lock_message(CEPH_LOCK_FCNTL, op, file, lock_cmd, wait, fl); 97 80 if (!err) { 98 81 dout("mds locked, locking locally"); 99 82 err = posix_lock_file(file, fl, NULL); ··· 92 93 /* undo! This should only happen if the kernel detects 93 94 * local deadlock. */ 94 95 ceph_lock_message(CEPH_LOCK_FCNTL, op, file, 95 - (u64)fl->fl_pid, 96 - (u64)(unsigned long)fl->fl_nspid, 97 - CEPH_LOCK_UNLOCK, fl->fl_start, 98 - length, 0); 96 + CEPH_LOCK_UNLOCK, 0, fl); 99 97 dout("got %d on posix_lock_file, undid lock", err); 100 98 } 101 99 } else { ··· 103 107 104 108 int ceph_flock(struct file *file, int cmd, struct file_lock *fl) 105 109 { 106 - u64 length; 107 110 u8 lock_cmd; 108 111 int err; 109 112 u8 wait = 1; ··· 122 127 lock_cmd = CEPH_LOCK_EXCL; 123 128 else 124 129 lock_cmd = CEPH_LOCK_UNLOCK; 125 - /* mds requires start and length rather than start and end */ 126 - if (LLONG_MAX == fl->fl_end) 127 - length = 0; 128 - else 129 - length = fl->fl_end - fl->fl_start + 1; 130 130 131 131 err = ceph_lock_message(CEPH_LOCK_FLOCK, CEPH_MDS_OP_SETFILELOCK, 132 - file, (u64)fl->fl_pid, 133 - (u64)(unsigned long)fl->fl_nspid, 134 - lock_cmd, fl->fl_start, 135 - length, wait); 132 + file, lock_cmd, wait, fl); 136 133 if (!err) { 137 134 err = flock_lock_file_wait(file, fl); 138 135 if (err) { 139 136 ceph_lock_message(CEPH_LOCK_FLOCK, 140 137 CEPH_MDS_OP_SETFILELOCK, 141 - file, (u64)fl->fl_pid, 142 - (u64)(unsigned long)fl->fl_nspid, 143 - CEPH_LOCK_UNLOCK, fl->fl_start, 144 - length, 0); 138 + file, CEPH_LOCK_UNLOCK, 0, fl); 145 139 dout("got %d on flock_lock_file_wait, undid lock", err); 146 140 } 147 141 } else {