btrfs: add lockdep annotations for num_extwriters wait event
Similarly to the num_writers wait event in fs/btrfs/transaction.c add a lockdep annotation for the num_extwriters wait event. Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Ioannis Angelakopoulos <iangelak@fb.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
e1489b4fe6
commit
5a9ba6709f
|
@ -1097,6 +1097,7 @@ struct btrfs_fs_info {
|
|||
* compiled without lockdep).
|
||||
*/
|
||||
struct lockdep_map btrfs_trans_num_writers_map;
|
||||
struct lockdep_map btrfs_trans_num_extwriters_map;
|
||||
|
||||
#ifdef CONFIG_BTRFS_FS_REF_VERIFY
|
||||
spinlock_t ref_verify_lock;
|
||||
|
|
|
@ -2991,6 +2991,7 @@ void btrfs_init_fs_info(struct btrfs_fs_info *fs_info)
|
|||
seqlock_init(&fs_info->profiles_lock);
|
||||
|
||||
btrfs_lockdep_init_map(fs_info, btrfs_trans_num_writers);
|
||||
btrfs_lockdep_init_map(fs_info, btrfs_trans_num_extwriters);
|
||||
|
||||
INIT_LIST_HEAD(&fs_info->dirty_cowonly_roots);
|
||||
INIT_LIST_HEAD(&fs_info->space_info);
|
||||
|
|
|
@ -314,6 +314,7 @@ loop:
|
|||
extwriter_counter_inc(cur_trans, type);
|
||||
spin_unlock(&fs_info->trans_lock);
|
||||
btrfs_lockdep_acquire(fs_info, btrfs_trans_num_writers);
|
||||
btrfs_lockdep_acquire(fs_info, btrfs_trans_num_extwriters);
|
||||
return 0;
|
||||
}
|
||||
spin_unlock(&fs_info->trans_lock);
|
||||
|
@ -336,6 +337,7 @@ loop:
|
|||
return -ENOMEM;
|
||||
|
||||
btrfs_lockdep_acquire(fs_info, btrfs_trans_num_writers);
|
||||
btrfs_lockdep_acquire(fs_info, btrfs_trans_num_extwriters);
|
||||
|
||||
spin_lock(&fs_info->trans_lock);
|
||||
if (fs_info->running_transaction) {
|
||||
|
@ -343,11 +345,13 @@ loop:
|
|||
* someone started a transaction after we unlocked. Make sure
|
||||
* to redo the checks above
|
||||
*/
|
||||
btrfs_lockdep_release(fs_info, btrfs_trans_num_extwriters);
|
||||
btrfs_lockdep_release(fs_info, btrfs_trans_num_writers);
|
||||
kfree(cur_trans);
|
||||
goto loop;
|
||||
} else if (BTRFS_FS_ERROR(fs_info)) {
|
||||
spin_unlock(&fs_info->trans_lock);
|
||||
btrfs_lockdep_release(fs_info, btrfs_trans_num_extwriters);
|
||||
btrfs_lockdep_release(fs_info, btrfs_trans_num_writers);
|
||||
kfree(cur_trans);
|
||||
return -EROFS;
|
||||
|
@ -1028,6 +1032,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
|
|||
|
||||
cond_wake_up(&cur_trans->writer_wait);
|
||||
|
||||
btrfs_lockdep_release(info, btrfs_trans_num_extwriters);
|
||||
btrfs_lockdep_release(info, btrfs_trans_num_writers);
|
||||
|
||||
btrfs_put_transaction(cur_trans);
|
||||
|
@ -2270,6 +2275,13 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
|
|||
if (ret)
|
||||
goto lockdep_release;
|
||||
|
||||
/*
|
||||
* The thread has started/joined the transaction thus it holds the
|
||||
* lockdep map as a reader. It has to release it before acquiring the
|
||||
* lockdep map as a writer.
|
||||
*/
|
||||
btrfs_lockdep_release(fs_info, btrfs_trans_num_extwriters);
|
||||
btrfs_might_wait_for_event(fs_info, btrfs_trans_num_extwriters);
|
||||
wait_event(cur_trans->writer_wait,
|
||||
extwriter_counter_read(cur_trans) == 0);
|
||||
|
||||
|
@ -2541,6 +2553,7 @@ cleanup_transaction:
|
|||
return ret;
|
||||
|
||||
lockdep_release:
|
||||
btrfs_lockdep_release(fs_info, btrfs_trans_num_extwriters);
|
||||
btrfs_lockdep_release(fs_info, btrfs_trans_num_writers);
|
||||
goto cleanup_transaction;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue