]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
smb/server: convert to using new filelock helpers
authorJeff Layton <jlayton@kernel.org>
Wed, 31 Jan 2024 23:01:56 +0000 (18:01 -0500)
committerChristian Brauner <brauner@kernel.org>
Mon, 5 Feb 2024 12:11:37 +0000 (13:11 +0100)
Convert to using the new file locking helper functions.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Link: https://lore.kernel.org/r/20240131-flsplit-v3-15-c6129007ee8d@kernel.org
Reviewed-by: NeilBrown <neilb@suse.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/smb/server/smb2pdu.c
fs/smb/server/vfs.c

index ba7a72a6a4f45f6b756768c4a3a48e19d74e3683..e170b96d5ac045fd9793a7904111adae335d450a 100644 (file)
@@ -6841,7 +6841,7 @@ static void smb2_remove_blocked_lock(void **argv)
        struct file_lock *flock = (struct file_lock *)argv[0];
 
        ksmbd_vfs_posix_lock_unblock(flock);
-       wake_up(&flock->fl_wait);
+       locks_wake_up(flock);
 }
 
 static inline bool lock_defer_pending(struct file_lock *fl)
@@ -6991,7 +6991,7 @@ int smb2_lock(struct ksmbd_work *work)
                                    file_inode(smb_lock->fl->fl_file))
                                        continue;
 
-                               if (smb_lock->fl->fl_type == F_UNLCK) {
+                               if (lock_is_unlock(smb_lock->fl)) {
                                        if (cmp_lock->fl->fl_file == smb_lock->fl->fl_file &&
                                            cmp_lock->start == smb_lock->start &&
                                            cmp_lock->end == smb_lock->end &&
@@ -7051,7 +7051,7 @@ int smb2_lock(struct ksmbd_work *work)
                }
                up_read(&conn_list_lock);
 out_check_cl:
-               if (smb_lock->fl->fl_type == F_UNLCK && nolock) {
+               if (lock_is_unlock(smb_lock->fl) && nolock) {
                        pr_err("Try to unlock nolocked range\n");
                        rsp->hdr.Status = STATUS_RANGE_NOT_LOCKED;
                        goto out;
index a6961bfe3e139467296cf55798fe8f943aae9432..449cfa9ed31caba09243473a6de313a1c5c0d4b2 100644 (file)
@@ -337,16 +337,16 @@ static int check_lock_range(struct file *filp, loff_t start, loff_t end,
                return 0;
 
        spin_lock(&ctx->flc_lock);
-       list_for_each_entry(flock, &ctx->flc_posix, fl_list) {
+       for_each_file_lock(flock, &ctx->flc_posix) {
                /* check conflict locks */
                if (flock->fl_end >= start && end >= flock->fl_start) {
-                       if (flock->fl_type == F_RDLCK) {
+                       if (lock_is_read(flock)) {
                                if (type == WRITE) {
                                        pr_err("not allow write by shared lock\n");
                                        error = 1;
                                        goto out;
                                }
-                       } else if (flock->fl_type == F_WRLCK) {
+                       } else if (lock_is_write(flock)) {
                                /* check owner in lock */
                                if (flock->fl_file != filp) {
                                        error = 1;