Deleted Added
full compact
spa.c (251636) spa.c (253990)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

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

5758{
5759 spa_t *spa = arg;
5760 int tasks;
5761
5762 ASSERT(spa->spa_sync_on);
5763
5764 mutex_enter(&spa->spa_async_lock);
5765 tasks = spa->spa_async_tasks;
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

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

5758{
5759 spa_t *spa = arg;
5760 int tasks;
5761
5762 ASSERT(spa->spa_sync_on);
5763
5764 mutex_enter(&spa->spa_async_lock);
5765 tasks = spa->spa_async_tasks;
5766 spa->spa_async_tasks = 0;
5766 spa->spa_async_tasks &= SPA_ASYNC_REMOVE;
5767 mutex_exit(&spa->spa_async_lock);
5768
5769 /*
5770 * See if the config needs to be updated.
5771 */
5772 if (tasks & SPA_ASYNC_CONFIG_UPDATE) {
5773 uint64_t old_space, new_space;
5774

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

5784 */
5785 if (new_space != old_space) {
5786 spa_history_log_internal(spa, "vdev online", NULL,
5787 "pool '%s' size: %llu(+%llu)",
5788 spa_name(spa), new_space, new_space - old_space);
5789 }
5790 }
5791
5767 mutex_exit(&spa->spa_async_lock);
5768
5769 /*
5770 * See if the config needs to be updated.
5771 */
5772 if (tasks & SPA_ASYNC_CONFIG_UPDATE) {
5773 uint64_t old_space, new_space;
5774

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

5784 */
5785 if (new_space != old_space) {
5786 spa_history_log_internal(spa, "vdev online", NULL,
5787 "pool '%s' size: %llu(+%llu)",
5788 spa_name(spa), new_space, new_space - old_space);
5789 }
5790 }
5791
5792 /*
5793 * See if any devices need to be marked REMOVED.
5794 */
5795 if (tasks & SPA_ASYNC_REMOVE) {
5796 spa_vdev_state_enter(spa, SCL_NONE);
5797 spa_async_remove(spa, spa->spa_root_vdev);
5798 for (int i = 0; i < spa->spa_l2cache.sav_count; i++)
5799 spa_async_remove(spa, spa->spa_l2cache.sav_vdevs[i]);
5800 for (int i = 0; i < spa->spa_spares.sav_count; i++)
5801 spa_async_remove(spa, spa->spa_spares.sav_vdevs[i]);
5802 (void) spa_vdev_state_exit(spa, NULL, 0);
5803 }
5804
5805 if ((tasks & SPA_ASYNC_AUTOEXPAND) && !spa_suspended(spa)) {
5806 spa_config_enter(spa, SCL_CONFIG, FTAG, RW_READER);
5807 spa_async_autoexpand(spa, spa->spa_root_vdev);
5808 spa_config_exit(spa, SCL_CONFIG, FTAG);
5809 }
5810
5811 /*
5812 * See if any devices need to be probed.

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

5834 */
5835 mutex_enter(&spa->spa_async_lock);
5836 spa->spa_async_thread = NULL;
5837 cv_broadcast(&spa->spa_async_cv);
5838 mutex_exit(&spa->spa_async_lock);
5839 thread_exit();
5840}
5841
5792 if ((tasks & SPA_ASYNC_AUTOEXPAND) && !spa_suspended(spa)) {
5793 spa_config_enter(spa, SCL_CONFIG, FTAG, RW_READER);
5794 spa_async_autoexpand(spa, spa->spa_root_vdev);
5795 spa_config_exit(spa, SCL_CONFIG, FTAG);
5796 }
5797
5798 /*
5799 * See if any devices need to be probed.

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

5821 */
5822 mutex_enter(&spa->spa_async_lock);
5823 spa->spa_async_thread = NULL;
5824 cv_broadcast(&spa->spa_async_cv);
5825 mutex_exit(&spa->spa_async_lock);
5826 thread_exit();
5827}
5828
5829static void
5830spa_async_thread_vd(void *arg)
5831{
5832 spa_t *spa = arg;
5833 int tasks;
5834
5835 ASSERT(spa->spa_sync_on);
5836
5837 mutex_enter(&spa->spa_async_lock);
5838 tasks = spa->spa_async_tasks;
5839retry:
5840 spa->spa_async_tasks &= ~SPA_ASYNC_REMOVE;
5841 mutex_exit(&spa->spa_async_lock);
5842
5843 /*
5844 * See if any devices need to be marked REMOVED.
5845 */
5846 if (tasks & SPA_ASYNC_REMOVE) {
5847 spa_vdev_state_enter(spa, SCL_NONE);
5848 spa_async_remove(spa, spa->spa_root_vdev);
5849 for (int i = 0; i < spa->spa_l2cache.sav_count; i++)
5850 spa_async_remove(spa, spa->spa_l2cache.sav_vdevs[i]);
5851 for (int i = 0; i < spa->spa_spares.sav_count; i++)
5852 spa_async_remove(spa, spa->spa_spares.sav_vdevs[i]);
5853 (void) spa_vdev_state_exit(spa, NULL, 0);
5854 }
5855
5856 /*
5857 * Let the world know that we're done.
5858 */
5859 mutex_enter(&spa->spa_async_lock);
5860 tasks = spa->spa_async_tasks;
5861 if ((tasks & SPA_ASYNC_REMOVE) != 0)
5862 goto retry;
5863 spa->spa_async_thread_vd = NULL;
5864 cv_broadcast(&spa->spa_async_cv);
5865 mutex_exit(&spa->spa_async_lock);
5866 thread_exit();
5867}
5868
5842void
5843spa_async_suspend(spa_t *spa)
5844{
5845 mutex_enter(&spa->spa_async_lock);
5846 spa->spa_async_suspended++;
5869void
5870spa_async_suspend(spa_t *spa)
5871{
5872 mutex_enter(&spa->spa_async_lock);
5873 spa->spa_async_suspended++;
5847 while (spa->spa_async_thread != NULL)
5874 while (spa->spa_async_thread != NULL &&
5875 spa->spa_async_thread_vd != NULL)
5848 cv_wait(&spa->spa_async_cv, &spa->spa_async_lock);
5849 mutex_exit(&spa->spa_async_lock);
5850}
5851
5852void
5853spa_async_resume(spa_t *spa)
5854{
5855 mutex_enter(&spa->spa_async_lock);

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

5860
5861static boolean_t
5862spa_async_tasks_pending(spa_t *spa)
5863{
5864 uint_t non_config_tasks;
5865 uint_t config_task;
5866 boolean_t config_task_suspended;
5867
5876 cv_wait(&spa->spa_async_cv, &spa->spa_async_lock);
5877 mutex_exit(&spa->spa_async_lock);
5878}
5879
5880void
5881spa_async_resume(spa_t *spa)
5882{
5883 mutex_enter(&spa->spa_async_lock);

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

5888
5889static boolean_t
5890spa_async_tasks_pending(spa_t *spa)
5891{
5892 uint_t non_config_tasks;
5893 uint_t config_task;
5894 boolean_t config_task_suspended;
5895
5868 non_config_tasks = spa->spa_async_tasks & ~SPA_ASYNC_CONFIG_UPDATE;
5896 non_config_tasks = spa->spa_async_tasks & ~(SPA_ASYNC_CONFIG_UPDATE |
5897 SPA_ASYNC_REMOVE);
5869 config_task = spa->spa_async_tasks & SPA_ASYNC_CONFIG_UPDATE;
5870 if (spa->spa_ccw_fail_time == 0) {
5871 config_task_suspended = B_FALSE;
5872 } else {
5873 config_task_suspended =
5874 (gethrtime() - spa->spa_ccw_fail_time) <
5875 (zfs_ccw_retry_interval * NANOSEC);
5876 }

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

5886 !spa->spa_async_suspended &&
5887 spa->spa_async_thread == NULL &&
5888 rootdir != NULL)
5889 spa->spa_async_thread = thread_create(NULL, 0,
5890 spa_async_thread, spa, 0, &p0, TS_RUN, maxclsyspri);
5891 mutex_exit(&spa->spa_async_lock);
5892}
5893
5898 config_task = spa->spa_async_tasks & SPA_ASYNC_CONFIG_UPDATE;
5899 if (spa->spa_ccw_fail_time == 0) {
5900 config_task_suspended = B_FALSE;
5901 } else {
5902 config_task_suspended =
5903 (gethrtime() - spa->spa_ccw_fail_time) <
5904 (zfs_ccw_retry_interval * NANOSEC);
5905 }

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

5915 !spa->spa_async_suspended &&
5916 spa->spa_async_thread == NULL &&
5917 rootdir != NULL)
5918 spa->spa_async_thread = thread_create(NULL, 0,
5919 spa_async_thread, spa, 0, &p0, TS_RUN, maxclsyspri);
5920 mutex_exit(&spa->spa_async_lock);
5921}
5922
5923static void
5924spa_async_dispatch_vd(spa_t *spa)
5925{
5926 mutex_enter(&spa->spa_async_lock);
5927 if ((spa->spa_async_tasks & SPA_ASYNC_REMOVE) != 0 &&
5928 !spa->spa_async_suspended &&
5929 spa->spa_async_thread_vd == NULL &&
5930 rootdir != NULL)
5931 spa->spa_async_thread_vd = thread_create(NULL, 0,
5932 spa_async_thread_vd, spa, 0, &p0, TS_RUN, maxclsyspri);
5933 mutex_exit(&spa->spa_async_lock);
5934}
5935
5894void
5895spa_async_request(spa_t *spa, int task)
5896{
5897 zfs_dbgmsg("spa=%s async request task=%u", spa->spa_name, task);
5898 mutex_enter(&spa->spa_async_lock);
5899 spa->spa_async_tasks |= task;
5900 mutex_exit(&spa->spa_async_lock);
5936void
5937spa_async_request(spa_t *spa, int task)
5938{
5939 zfs_dbgmsg("spa=%s async request task=%u", spa->spa_name, task);
5940 mutex_enter(&spa->spa_async_lock);
5941 spa->spa_async_tasks |= task;
5942 mutex_exit(&spa->spa_async_lock);
5943 spa_async_dispatch_vd(spa);
5901}
5902
5903/*
5904 * ==========================================================================
5905 * SPA syncing routines
5906 * ==========================================================================
5907 */
5908

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

6481 spa_config_exit(spa, SCL_CONFIG, FTAG);
6482
6483 spa_handle_ignored_writes(spa);
6484
6485 /*
6486 * If any async tasks have been requested, kick them off.
6487 */
6488 spa_async_dispatch(spa);
5944}
5945
5946/*
5947 * ==========================================================================
5948 * SPA syncing routines
5949 * ==========================================================================
5950 */
5951

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

6524 spa_config_exit(spa, SCL_CONFIG, FTAG);
6525
6526 spa_handle_ignored_writes(spa);
6527
6528 /*
6529 * If any async tasks have been requested, kick them off.
6530 */
6531 spa_async_dispatch(spa);
6532 spa_async_dispatch_vd(spa);
6489}
6490
6491/*
6492 * Sync all pools. We don't want to hold the namespace lock across these
6493 * operations, so we take a reference on the spa_t and drop the lock during the
6494 * sync.
6495 */
6496void

--- 204 unchanged lines hidden ---
6533}
6534
6535/*
6536 * Sync all pools. We don't want to hold the namespace lock across these
6537 * operations, so we take a reference on the spa_t and drop the lock during the
6538 * sync.
6539 */
6540void

--- 204 unchanged lines hidden ---