Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ceph: adapt to breakup of struct file_lock

Most of the existing APIs have remained the same, but subsystems that
access file_lock fields directly need to reach into struct
file_lock_core now.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Link: https://lore.kernel.org/r/20240131-flsplit-v3-36-c6129007ee8d@kernel.org
Reviewed-by: NeilBrown <neilb@suse.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Jeff Layton and committed by
Christian Brauner
3956f35f 82a8cb96

+26 -25
+26 -25
fs/ceph/locks.c
··· 7 7 8 8 #include "super.h" 9 9 #include "mds_client.h" 10 - #define _NEED_FILE_LOCK_FIELD_MACROS 11 10 #include <linux/filelock.h> 12 11 #include <linux/ceph/pagelist.h> 13 12 ··· 33 34 34 35 static void ceph_fl_copy_lock(struct file_lock *dst, struct file_lock *src) 35 36 { 36 - struct inode *inode = file_inode(dst->fl_file); 37 + struct inode *inode = file_inode(dst->c.flc_file); 37 38 atomic_inc(&ceph_inode(inode)->i_filelock_ref); 38 39 dst->fl_u.ceph.inode = igrab(inode); 39 40 } ··· 110 111 else 111 112 length = fl->fl_end - fl->fl_start + 1; 112 113 113 - owner = secure_addr(fl->fl_owner); 114 + owner = secure_addr(fl->c.flc_owner); 114 115 115 116 doutc(cl, "rule: %d, op: %d, owner: %llx, pid: %llu, " 116 117 "start: %llu, length: %llu, wait: %d, type: %d\n", 117 - (int)lock_type, (int)operation, owner, (u64)fl->fl_pid, 118 - fl->fl_start, length, wait, fl->fl_type); 118 + (int)lock_type, (int)operation, owner, 119 + (u64) fl->c.flc_pid, 120 + fl->fl_start, length, wait, fl->c.flc_type); 119 121 120 122 req->r_args.filelock_change.rule = lock_type; 121 123 req->r_args.filelock_change.type = cmd; 122 124 req->r_args.filelock_change.owner = cpu_to_le64(owner); 123 - req->r_args.filelock_change.pid = cpu_to_le64((u64)fl->fl_pid); 125 + req->r_args.filelock_change.pid = cpu_to_le64((u64) fl->c.flc_pid); 124 126 req->r_args.filelock_change.start = cpu_to_le64(fl->fl_start); 125 127 req->r_args.filelock_change.length = cpu_to_le64(length); 126 128 req->r_args.filelock_change.wait = wait; ··· 131 131 err = ceph_mdsc_wait_request(mdsc, req, wait ? 132 132 ceph_lock_wait_for_completion : NULL); 133 133 if (!err && operation == CEPH_MDS_OP_GETFILELOCK) { 134 - fl->fl_pid = -le64_to_cpu(req->r_reply_info.filelock_reply->pid); 134 + fl->c.flc_pid = -le64_to_cpu(req->r_reply_info.filelock_reply->pid); 135 135 if (CEPH_LOCK_SHARED == req->r_reply_info.filelock_reply->type) 136 - fl->fl_type = F_RDLCK; 136 + fl->c.flc_type = F_RDLCK; 137 137 else if (CEPH_LOCK_EXCL == req->r_reply_info.filelock_reply->type) 138 - fl->fl_type = F_WRLCK; 138 + fl->c.flc_type = F_WRLCK; 139 139 else 140 - fl->fl_type = F_UNLCK; 140 + fl->c.flc_type = F_UNLCK; 141 141 142 142 fl->fl_start = le64_to_cpu(req->r_reply_info.filelock_reply->start); 143 143 length = le64_to_cpu(req->r_reply_info.filelock_reply->start) + ··· 151 151 ceph_mdsc_put_request(req); 152 152 doutc(cl, "rule: %d, op: %d, pid: %llu, start: %llu, " 153 153 "length: %llu, wait: %d, type: %d, err code %d\n", 154 - (int)lock_type, (int)operation, (u64)fl->fl_pid, 155 - fl->fl_start, length, wait, fl->fl_type, err); 154 + (int)lock_type, (int)operation, (u64) fl->c.flc_pid, 155 + fl->fl_start, length, wait, fl->c.flc_type, err); 156 156 return err; 157 157 } 158 158 ··· 228 228 static int try_unlock_file(struct file *file, struct file_lock *fl) 229 229 { 230 230 int err; 231 - unsigned int orig_flags = fl->fl_flags; 232 - fl->fl_flags |= FL_EXISTS; 231 + unsigned int orig_flags = fl->c.flc_flags; 232 + fl->c.flc_flags |= FL_EXISTS; 233 233 err = locks_lock_file_wait(file, fl); 234 - fl->fl_flags = orig_flags; 234 + fl->c.flc_flags = orig_flags; 235 235 if (err == -ENOENT) { 236 236 if (!(orig_flags & FL_EXISTS)) 237 237 err = 0; ··· 254 254 u8 wait = 0; 255 255 u8 lock_cmd; 256 256 257 - if (!(fl->fl_flags & FL_POSIX)) 257 + if (!(fl->c.flc_flags & FL_POSIX)) 258 258 return -ENOLCK; 259 259 260 260 if (ceph_inode_is_shutdown(inode)) 261 261 return -ESTALE; 262 262 263 - doutc(cl, "fl_owner: %p\n", fl->fl_owner); 263 + doutc(cl, "fl_owner: %p\n", fl->c.flc_owner); 264 264 265 265 /* set wait bit as appropriate, then make command as Ceph expects it*/ 266 266 if (IS_GETLK(cmd)) ··· 294 294 295 295 err = ceph_lock_message(CEPH_LOCK_FCNTL, op, inode, lock_cmd, wait, fl); 296 296 if (!err) { 297 - if (op == CEPH_MDS_OP_SETFILELOCK && F_UNLCK != fl->fl_type) { 297 + if (op == CEPH_MDS_OP_SETFILELOCK && F_UNLCK != fl->c.flc_type) { 298 298 doutc(cl, "locking locally\n"); 299 299 err = posix_lock_file(file, fl, NULL); 300 300 if (err) { ··· 320 320 u8 wait = 0; 321 321 u8 lock_cmd; 322 322 323 - if (!(fl->fl_flags & FL_FLOCK)) 323 + if (!(fl->c.flc_flags & FL_FLOCK)) 324 324 return -ENOLCK; 325 325 326 326 if (ceph_inode_is_shutdown(inode)) 327 327 return -ESTALE; 328 328 329 - doutc(cl, "fl_file: %p\n", fl->fl_file); 329 + doutc(cl, "fl_file: %p\n", fl->c.flc_file); 330 330 331 331 spin_lock(&ci->i_ceph_lock); 332 332 if (ci->i_ceph_flags & CEPH_I_ERROR_FILELOCK) { ··· 357 357 358 358 err = ceph_lock_message(CEPH_LOCK_FLOCK, CEPH_MDS_OP_SETFILELOCK, 359 359 inode, lock_cmd, wait, fl); 360 - if (!err && F_UNLCK != fl->fl_type) { 360 + if (!err && F_UNLCK != fl->c.flc_type) { 361 361 err = locks_lock_file_wait(file, fl); 362 362 if (err) { 363 363 ceph_lock_message(CEPH_LOCK_FLOCK, ··· 409 409 cephlock->start = cpu_to_le64(lock->fl_start); 410 410 cephlock->length = cpu_to_le64(lock->fl_end - lock->fl_start + 1); 411 411 cephlock->client = cpu_to_le64(0); 412 - cephlock->pid = cpu_to_le64((u64)lock->fl_pid); 413 - cephlock->owner = cpu_to_le64(secure_addr(lock->fl_owner)); 412 + cephlock->pid = cpu_to_le64((u64) lock->c.flc_pid); 413 + cephlock->owner = cpu_to_le64(secure_addr(lock->c.flc_owner)); 414 414 415 - switch (lock->fl_type) { 415 + switch (lock->c.flc_type) { 416 416 case F_RDLCK: 417 417 cephlock->type = CEPH_LOCK_SHARED; 418 418 break; ··· 423 423 cephlock->type = CEPH_LOCK_UNLOCK; 424 424 break; 425 425 default: 426 - doutc(cl, "Have unknown lock type %d\n", lock->fl_type); 426 + doutc(cl, "Have unknown lock type %d\n", 427 + lock->c.flc_type); 427 428 err = -EINVAL; 428 429 } 429 430