Lines Matching +full:sync +full:- +full:active

1 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 Copyright (C) 1996-98 Ingo Molnar, Gadi Oxman
12 #include <linux/backing-dev.h>
22 #include "md-cluster.h"
37 /* Status of sync thread. */
41 * 1) after assemble, sync data from first rdev to other copies, this
42 * must be done first before other sync actions and will only execute
44 * 2) resize the array(notice that this is not reshape), sync data for
50 * 1) for new replacement, sync data based on the replace rdev or
52 * 2) for new member disk while the array is degraded, sync data from
54 * 3) reassemble after power failure or re-add a hot removed rdev, sync
81 * or internal usage like setting the array read-only, will forbid above
112 * If meta_bdev is non-NULL, it means that a separate device is
135 * in sync with array
148 * the array after a level-change completes.
201 * bitmap-based recovery to get fully in sync.
203 * has been passed to pers->hot_add_disk.
206 AutoDetected, /* added by auto-detect */
215 * Blocked. The Fault is/will-be
221 * found an unacknowledged bad-block.
223 * time, and the writer will re-check.
226 * re-check. So setting it as
231 * hot-replaced, either because it has
244 * raid-5/6.
266 Nonrot, /* non-rotational device (SSD) */
272 if (unlikely(rdev->badblocks.count)) { in is_badblock()
273 int rv = badblocks_check(&rdev->badblocks, rdev->data_offset + s, in is_badblock()
277 *first_bad -= rdev->data_offset; in is_badblock()
299 * enum mddev_flags - md device flags.
311 * @MD_NOT_READY: do_md_run() is active, so 'array_state', ust not report that
335 MD_SB_CHANGE_PENDING, /* switch from 'clean' to 'active' in progress */
349 * mddev->curr_resync stores the current sector of the resync but
357 /* Delayed to check that there is no conflict with another sync */
359 /* Any value greater than or equal to this is in an active resync */
407 /* If the last 'event' was simply a clean->dirty transition, and
409 * to just decrement the event count on a dirty->clean transition.
430 * Set when a sync operation is started. It holds this value even
431 * when the sync thread is "frozen" (interrupted) or "idle" (stopped
432 * or finished). It is overwritten when a new sync operation is begun.
453 /* allow user-space to request suspension of IO to regions of the array */
456 /* if zero, use the system-wide default */
460 /* resync even though the same disks are shared among md-devices */
478 * with disk->open_mutex.
480 * reconfig_mutex -> disk->open_mutex
481 * disk->open_mutex -> open_mutex: e.g. __blkdev_get -> md_open
485 atomic_t active; /* general refcount */ member
486 atomic_t openers; /* number of active opens */
497 sector_t resync_min; /* user requested sync
512 /* used for register new sync thread */
519 * in_sync - and related safemode and MD_CHANGE changes
521 * clearing ->bitmap
522 * clearing ->bitmap_info.file
523 * changing ->resync_{min,max}
528 atomic_t pending_writes; /* number of active superblock writes */
550 * hot-adding a bitmap. It should
558 unsigned long max_write_behind; /* write-behind mode */
570 struct bio_set sync_set; /* for sync operations like
588 /* The sequence number for sync thread */
597 /* flags for sync thread running status */
600 * set when one of sync action is set and new sync thread need to be
604 /* sync thread is running, or about to be started */
606 /* sync thread needs to be aborted for some reason */
608 /* sync thread is done and is waiting to be unregistered */
610 /* running sync thread must abort immediately, and not restart */
612 /* waiting for pers->start() to finish */
614 /* interrupted because io-error */
617 /* flags determines sync action, see details in enum sync_action */
648 return (mddev->ro == MD_RDWR); in md_is_rdwr()
654 if (mddev->reshape_position == MaxSector) in reshape_interrupted()
658 if (!test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) in reshape_interrupted()
662 if (test_bit(MD_RECOVERY_WAIT, &mddev->recovery) || in reshape_interrupted()
663 test_bit(MD_RECOVERY_INTR, &mddev->recovery) || in reshape_interrupted()
664 test_bit(MD_RECOVERY_FROZEN, &mddev->recovery)) in reshape_interrupted()
672 return mutex_lock_interruptible(&mddev->reconfig_mutex); in mddev_lock()
680 mutex_lock(&mddev->reconfig_mutex); in mddev_lock_nointr()
685 return mutex_trylock(&mddev->reconfig_mutex); in mddev_trylock()
691 if (blk_queue_io_stat(bdev->bd_disk->queue)) in md_sync_acct()
692 atomic_add(nr_sectors, &bdev->bd_disk->sync_io); in md_sync_acct()
697 md_sync_acct(bio->bi_bdev, nr_sectors); in md_sync_acct_bio()
716 /* error_handler must set ->faulty and clear ->in_sync
733 * 1 - stop new actions and wait for action io to complete
734 * 0 - return to normal behaviour
740 * e.g. 2drive raid1 -> 2drive raid5
741 * ndrive raid5 -> degraded n+1drive raid6 with special layout
743 * This needs to be installed and then ->run used to activate the
747 /* Changes the consistency policy of an active array. */
772 return mddev->gendisk ? mddev->gendisk->disk_name : "mdX"; in mdname()
778 if (!test_bit(Replacement, &rdev->flags) && in sysfs_link_rdev()
779 !test_bit(Journal, &rdev->flags) && in sysfs_link_rdev()
780 mddev->kobj.sd) { in sysfs_link_rdev()
781 sprintf(nm, "rd%d", rdev->raid_disk); in sysfs_link_rdev()
782 return sysfs_create_link(&mddev->kobj, &rdev->kobj, nm); in sysfs_link_rdev()
790 if (!test_bit(Replacement, &rdev->flags) && in sysfs_unlink_rdev()
791 !test_bit(Journal, &rdev->flags) && in sysfs_unlink_rdev()
792 mddev->kobj.sd) { in sysfs_unlink_rdev()
793 sprintf(nm, "rd%d", rdev->raid_disk); in sysfs_unlink_rdev()
794 sysfs_remove_link(&mddev->kobj, nm); in sysfs_unlink_rdev()
809 list_for_each_entry(rdev, &((mddev)->disks), same_set)
812 list_for_each_entry_safe(rdev, tmp, &((mddev)->disks), same_set)
815 list_for_each_entry_rcu(rdev, &((mddev)->disks), same_set)
914 return !disk_live(rdev->bdev->bd_disk); in is_rdev_broken()
919 int faulty = test_bit(Faulty, &rdev->flags); in rdev_dec_pending()
920 if (atomic_dec_and_test(&rdev->nr_pending) && faulty) { in rdev_dec_pending()
921 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); in rdev_dec_pending()
922 md_wakeup_thread(mddev->thread); in rdev_dec_pending()
929 return mddev->cluster_info && mddev->bitmap_info.nodes > 1; in mddev_is_clustered()
936 mddev->flags &= ~unsupported_flags; in mddev_clear_unsupported_flags()
942 !bio->bi_bdev->bd_disk->queue->limits.max_write_zeroes_sectors) in mddev_check_write_zeroes()
943 mddev->gendisk->queue->limits.max_write_zeroes_sectors = 0; in mddev_check_write_zeroes()
964 mutex_lock(&mddev->reconfig_mutex); in mddev_suspend_and_lock_nointr()
991 * MD devices can be used undeneath by DM, in which case ->gendisk is NULL.
995 return !mddev->gendisk; in mddev_is_dm()
1002 trace_block_bio_remap(bio, disk_devt(mddev->gendisk), sector); in mddev_trace_remap()
1008 blk_add_trace_msg((mddev)->gendisk->queue, fmt, ##args); \