* [bug report] btrfs: mark block groups to copy for device-replace
@ 2021-02-03 8:54 Dan Carpenter
2021-02-03 14:26 ` Johannes Thumshirn
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-02-03 8:54 UTC (permalink / raw)
To: naohiro.aota; +Cc: linux-btrfs
Hello Naohiro Aota,
The patch 0d57e73ac5ae: "btrfs: mark block groups to copy for
device-replace" from Jan 26, 2021, leads to the following static
checker warning:
fs/btrfs/dev-replace.c:505 mark_block_group_to_copy()
error: double unlocked '&fs_info->trans_lock' (orig line 486)
fs/btrfs/dev-replace.c
463 static int mark_block_group_to_copy(struct btrfs_fs_info *fs_info,
464 struct btrfs_device *src_dev)
465 {
466 struct btrfs_path *path;
467 struct btrfs_key key;
468 struct btrfs_key found_key;
469 struct btrfs_root *root = fs_info->dev_root;
470 struct btrfs_dev_extent *dev_extent = NULL;
471 struct btrfs_block_group *cache;
472 struct btrfs_trans_handle *trans;
473 int ret = 0;
474 u64 chunk_offset;
475
476 /* Do not use "to_copy" on non-ZONED for now */
477 if (!btrfs_is_zoned(fs_info))
478 return 0;
479
480 mutex_lock(&fs_info->chunk_mutex);
481
482 /* Ensure we don't have pending new block group */
483 spin_lock(&fs_info->trans_lock);
484 while (fs_info->running_transaction &&
485 !list_empty(&fs_info->running_transaction->dev_update_list)) {
486 spin_unlock(&fs_info->trans_lock);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
487 mutex_unlock(&fs_info->chunk_mutex);
488 trans = btrfs_attach_transaction(root);
489 if (IS_ERR(trans)) {
490 ret = PTR_ERR(trans);
491 mutex_lock(&fs_info->chunk_mutex);
492 if (ret == -ENOENT)
493 continue;
We need to take the lock before the continue;
494 else
495 goto unlock;
496 }
497
498 ret = btrfs_commit_transaction(trans);
499 mutex_lock(&fs_info->chunk_mutex);
500 if (ret)
501 goto unlock;
502
503 spin_lock(&fs_info->trans_lock);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
504 }
505 spin_unlock(&fs_info->trans_lock);
Double unlock here.
506
507 path = btrfs_alloc_path();
508 if (!path) {
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] btrfs: mark block groups to copy for device-replace
2021-02-03 8:54 [bug report] btrfs: mark block groups to copy for device-replace Dan Carpenter
@ 2021-02-03 14:26 ` Johannes Thumshirn
0 siblings, 0 replies; 2+ messages in thread
From: Johannes Thumshirn @ 2021-02-03 14:26 UTC (permalink / raw)
To: Dan Carpenter, Naohiro Aota; +Cc: linux-btrfs
On 03/02/2021 09:57, Dan Carpenter wrote:
> Hello Naohiro Aota,
>
> The patch 0d57e73ac5ae: "btrfs: mark block groups to copy for
> device-replace" from Jan 26, 2021, leads to the following static
> checker warning:
>
> fs/btrfs/dev-replace.c:505 mark_block_group_to_copy()
> error: double unlocked '&fs_info->trans_lock' (orig line 486)
>
Fixed thanks for the report.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-03 14:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 8:54 [bug report] btrfs: mark block groups to copy for device-replace Dan Carpenter
2021-02-03 14:26 ` Johannes Thumshirn
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.