scrub.c (2473d24f2b77da0ffabcbb916793e58e7f57440b) scrub.c (6b7304af62d02d77d740defd4cfddf2ef3188067)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2011, 2012 STRATO. All rights reserved.
4 */
5
6#include <linux/blkdev.h>
7#include <linux/ratelimit.h>
8#include <linux/sched/mm.h>

--- 3569 unchanged lines hidden (view full) ---

3578 * repair extents.
3579 */
3580 spin_lock(&cache->lock);
3581 if (cache->removed) {
3582 spin_unlock(&cache->lock);
3583 btrfs_put_block_group(cache);
3584 goto skip;
3585 }
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2011, 2012 STRATO. All rights reserved.
4 */
5
6#include <linux/blkdev.h>
7#include <linux/ratelimit.h>
8#include <linux/sched/mm.h>

--- 3569 unchanged lines hidden (view full) ---

3578 * repair extents.
3579 */
3580 spin_lock(&cache->lock);
3581 if (cache->removed) {
3582 spin_unlock(&cache->lock);
3583 btrfs_put_block_group(cache);
3584 goto skip;
3585 }
3586 btrfs_get_block_group_trimming(cache);
3586 btrfs_freeze_block_group(cache);
3587 spin_unlock(&cache->lock);
3588
3589 /*
3590 * we need call btrfs_inc_block_group_ro() with scrubs_paused,
3591 * to avoid deadlock caused by:
3592 * btrfs_inc_block_group_ro()
3593 * -> btrfs_wait_for_commit()
3594 * -> btrfs_commit_transaction()

--- 41 unchanged lines hidden (view full) ---

3636 * It is not a problem for scrub, because
3637 * metadata are always cowed, and our scrub paused
3638 * commit_transactions.
3639 */
3640 ro_set = 0;
3641 } else {
3642 btrfs_warn(fs_info,
3643 "failed setting block group ro: %d", ret);
3587 spin_unlock(&cache->lock);
3588
3589 /*
3590 * we need call btrfs_inc_block_group_ro() with scrubs_paused,
3591 * to avoid deadlock caused by:
3592 * btrfs_inc_block_group_ro()
3593 * -> btrfs_wait_for_commit()
3594 * -> btrfs_commit_transaction()

--- 41 unchanged lines hidden (view full) ---

3636 * It is not a problem for scrub, because
3637 * metadata are always cowed, and our scrub paused
3638 * commit_transactions.
3639 */
3640 ro_set = 0;
3641 } else {
3642 btrfs_warn(fs_info,
3643 "failed setting block group ro: %d", ret);
3644 btrfs_put_block_group_trimming(cache);
3644 btrfs_unfreeze_block_group(cache);
3645 btrfs_put_block_group(cache);
3646 scrub_pause_off(fs_info);
3647 break;
3648 }
3649
3650 /*
3651 * Now the target block is marked RO, wait for nocow writes to
3652 * finish before dev-replace.

--- 70 unchanged lines hidden (view full) ---

3723 btrfs_discard_queue_work(&fs_info->discard_ctl,
3724 cache);
3725 else
3726 btrfs_mark_bg_unused(cache);
3727 } else {
3728 spin_unlock(&cache->lock);
3729 }
3730
3645 btrfs_put_block_group(cache);
3646 scrub_pause_off(fs_info);
3647 break;
3648 }
3649
3650 /*
3651 * Now the target block is marked RO, wait for nocow writes to
3652 * finish before dev-replace.

--- 70 unchanged lines hidden (view full) ---

3723 btrfs_discard_queue_work(&fs_info->discard_ctl,
3724 cache);
3725 else
3726 btrfs_mark_bg_unused(cache);
3727 } else {
3728 spin_unlock(&cache->lock);
3729 }
3730
3731 btrfs_put_block_group_trimming(cache);
3731 btrfs_unfreeze_block_group(cache);
3732 btrfs_put_block_group(cache);
3733 if (ret)
3734 break;
3735 if (sctx->is_dev_replace &&
3736 atomic64_read(&dev_replace->num_write_errors) > 0) {
3737 ret = -EIO;
3738 break;
3739 }

--- 380 unchanged lines hidden ---
3732 btrfs_put_block_group(cache);
3733 if (ret)
3734 break;
3735 if (sctx->is_dev_replace &&
3736 atomic64_read(&dev_replace->num_write_errors) > 0) {
3737 ret = -EIO;
3738 break;
3739 }

--- 380 unchanged lines hidden ---