btrfs: merge btrfs_set_lock_blocking_rw with it's caller
authorDavid Sterba <dsterba@suse.com>
Wed, 23 Jan 2019 17:07:14 +0000 (18:07 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 25 Feb 2019 13:13:28 +0000 (14:13 +0100)
The last caller that does not have a fixed value of lock is
btrfs_set_path_blocking, that actually does the same conditional swtich
by the lock type so we can merge the branches together and remove the
helper.

Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.c
fs/btrfs/locking.h

index 3940d707fcf3de825302358c48696cd605cfa1c4..4fac5cc2e648b0e057ad719097f393b704f941a4 100644 (file)
@@ -46,11 +46,18 @@ noinline void btrfs_set_path_blocking(struct btrfs_path *p)
        for (i = 0; i < BTRFS_MAX_LEVEL; i++) {
                if (!p->nodes[i] || !p->locks[i])
                        continue;
        for (i = 0; i < BTRFS_MAX_LEVEL; i++) {
                if (!p->nodes[i] || !p->locks[i])
                        continue;
-               btrfs_set_lock_blocking_rw(p->nodes[i], p->locks[i]);
-               if (p->locks[i] == BTRFS_READ_LOCK)
+               /*
+                * If we currently have a spinning reader or writer lock this
+                * will bump the count of blocking holders and drop the
+                * spinlock.
+                */
+               if (p->locks[i] == BTRFS_READ_LOCK) {
+                       btrfs_set_lock_blocking_read(p->nodes[i]);
                        p->locks[i] = BTRFS_READ_LOCK_BLOCKING;
                        p->locks[i] = BTRFS_READ_LOCK_BLOCKING;
-               else if (p->locks[i] == BTRFS_WRITE_LOCK)
+               } else if (p->locks[i] == BTRFS_WRITE_LOCK) {
+                       btrfs_set_lock_blocking_write(p->nodes[i]);
                        p->locks[i] = BTRFS_WRITE_LOCK_BLOCKING;
                        p->locks[i] = BTRFS_WRITE_LOCK_BLOCKING;
+               }
        }
 }
 
        }
 }
 
index 84ea6ed60047b10b0d01f6b1922887e041d6b844..595014f64830f822d6d9135641e528353fdfe4f3 100644 (file)
@@ -39,16 +39,4 @@ static inline void btrfs_tree_unlock_rw(struct extent_buffer *eb, int rw)
                BUG();
 }
 
                BUG();
 }
 
-/*
- * If we currently have a spinning reader or writer lock (indicated by the rw
- * flag) this will bump the count of blocking holders and drop the spinlock.
- */
-static inline void btrfs_set_lock_blocking_rw(struct extent_buffer *eb, int rw)
-{
-       if (rw == BTRFS_WRITE_LOCK)
-               btrfs_set_lock_blocking_write(eb);
-       else if (rw == BTRFS_READ_LOCK)
-               btrfs_set_lock_blocking_read(eb);
-}
-
 #endif
 #endif