Commit 75e9570c authored by Jeff Layton's avatar Jeff Layton Committed by Christian Brauner

ceph: convert to using new filelock helpers

Convert to using the new file locking helper functions.
Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
Link: https://lore.kernel.org/r/20240131-flsplit-v3-7-c6129007ee8d@kernel.orgReviewed-by: default avatarNeilBrown <neilb@suse.de>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 76698510
...@@ -273,19 +273,19 @@ int ceph_lock(struct file *file, int cmd, struct file_lock *fl) ...@@ -273,19 +273,19 @@ int ceph_lock(struct file *file, int cmd, struct file_lock *fl)
} }
spin_unlock(&ci->i_ceph_lock); spin_unlock(&ci->i_ceph_lock);
if (err < 0) { if (err < 0) {
if (op == CEPH_MDS_OP_SETFILELOCK && F_UNLCK == fl->fl_type) if (op == CEPH_MDS_OP_SETFILELOCK && lock_is_unlock(fl))
posix_lock_file(file, fl, NULL); posix_lock_file(file, fl, NULL);
return err; return err;
} }
if (F_RDLCK == fl->fl_type) if (lock_is_read(fl))
lock_cmd = CEPH_LOCK_SHARED; lock_cmd = CEPH_LOCK_SHARED;
else if (F_WRLCK == fl->fl_type) else if (lock_is_write(fl))
lock_cmd = CEPH_LOCK_EXCL; lock_cmd = CEPH_LOCK_EXCL;
else else
lock_cmd = CEPH_LOCK_UNLOCK; lock_cmd = CEPH_LOCK_UNLOCK;
if (op == CEPH_MDS_OP_SETFILELOCK && F_UNLCK == fl->fl_type) { if (op == CEPH_MDS_OP_SETFILELOCK && lock_is_unlock(fl)) {
err = try_unlock_file(file, fl); err = try_unlock_file(file, fl);
if (err <= 0) if (err <= 0)
return err; return err;
...@@ -333,7 +333,7 @@ int ceph_flock(struct file *file, int cmd, struct file_lock *fl) ...@@ -333,7 +333,7 @@ int ceph_flock(struct file *file, int cmd, struct file_lock *fl)
} }
spin_unlock(&ci->i_ceph_lock); spin_unlock(&ci->i_ceph_lock);
if (err < 0) { if (err < 0) {
if (F_UNLCK == fl->fl_type) if (lock_is_unlock(fl))
locks_lock_file_wait(file, fl); locks_lock_file_wait(file, fl);
return err; return err;
} }
...@@ -341,14 +341,14 @@ int ceph_flock(struct file *file, int cmd, struct file_lock *fl) ...@@ -341,14 +341,14 @@ int ceph_flock(struct file *file, int cmd, struct file_lock *fl)
if (IS_SETLKW(cmd)) if (IS_SETLKW(cmd))
wait = 1; wait = 1;
if (F_RDLCK == fl->fl_type) if (lock_is_read(fl))
lock_cmd = CEPH_LOCK_SHARED; lock_cmd = CEPH_LOCK_SHARED;
else if (F_WRLCK == fl->fl_type) else if (lock_is_write(fl))
lock_cmd = CEPH_LOCK_EXCL; lock_cmd = CEPH_LOCK_EXCL;
else else
lock_cmd = CEPH_LOCK_UNLOCK; lock_cmd = CEPH_LOCK_UNLOCK;
if (F_UNLCK == fl->fl_type) { if (lock_is_unlock(fl)) {
err = try_unlock_file(file, fl); err = try_unlock_file(file, fl);
if (err <= 0) if (err <= 0)
return err; return err;
...@@ -385,9 +385,9 @@ void ceph_count_locks(struct inode *inode, int *fcntl_count, int *flock_count) ...@@ -385,9 +385,9 @@ void ceph_count_locks(struct inode *inode, int *fcntl_count, int *flock_count)
ctx = locks_inode_context(inode); ctx = locks_inode_context(inode);
if (ctx) { if (ctx) {
spin_lock(&ctx->flc_lock); spin_lock(&ctx->flc_lock);
list_for_each_entry(lock, &ctx->flc_posix, fl_list) for_each_file_lock(lock, &ctx->flc_posix)
++(*fcntl_count); ++(*fcntl_count);
list_for_each_entry(lock, &ctx->flc_flock, fl_list) for_each_file_lock(lock, &ctx->flc_flock)
++(*flock_count); ++(*flock_count);
spin_unlock(&ctx->flc_lock); spin_unlock(&ctx->flc_lock);
} }
...@@ -453,7 +453,7 @@ int ceph_encode_locks_to_buffer(struct inode *inode, ...@@ -453,7 +453,7 @@ int ceph_encode_locks_to_buffer(struct inode *inode,
return 0; return 0;
spin_lock(&ctx->flc_lock); spin_lock(&ctx->flc_lock);
list_for_each_entry(lock, &ctx->flc_posix, fl_list) { for_each_file_lock(lock, &ctx->flc_posix) {
++seen_fcntl; ++seen_fcntl;
if (seen_fcntl > num_fcntl_locks) { if (seen_fcntl > num_fcntl_locks) {
err = -ENOSPC; err = -ENOSPC;
...@@ -464,7 +464,7 @@ int ceph_encode_locks_to_buffer(struct inode *inode, ...@@ -464,7 +464,7 @@ int ceph_encode_locks_to_buffer(struct inode *inode,
goto fail; goto fail;
++l; ++l;
} }
list_for_each_entry(lock, &ctx->flc_flock, fl_list) { for_each_file_lock(lock, &ctx->flc_flock) {
++seen_flock; ++seen_flock;
if (seen_flock > num_flock_locks) { if (seen_flock > num_flock_locks) {
err = -ENOSPC; err = -ENOSPC;
......
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