Print this page
3749 zfs event processing should work on R/O root filesystems
Submitted by:   Justin Gibbs <justing@spectralogic.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/spa.c
          +++ new/usr/src/uts/common/fs/zfs/spa.c
↓ open down ↓ 69 lines elided ↑ open up ↑
  70   70  #include <sys/callb.h>
  71   71  #include <sys/cpupart.h>
  72   72  #include <sys/pool.h>
  73   73  #include <sys/sysdc.h>
  74   74  #include <sys/zone.h>
  75   75  #endif  /* _KERNEL */
  76   76  
  77   77  #include "zfs_prop.h"
  78   78  #include "zfs_comutil.h"
  79   79  
       80 +/*
       81 + * The interval at which failed configuration cache file writes
       82 + * should be retried.
       83 + */
       84 +static int zfs_ccw_retry_interval = 300;
       85 +
  80   86  typedef enum zti_modes {
  81   87          ZTI_MODE_FIXED,                 /* value is # of threads (min 1) */
  82   88          ZTI_MODE_ONLINE_PERCENT,        /* value is % of online CPUs */
  83   89          ZTI_MODE_BATCH,                 /* cpu-intensive; value is ignored */
  84   90          ZTI_MODE_NULL,                  /* don't create a taskq */
  85   91          ZTI_NMODES
  86   92  } zti_modes_t;
  87   93  
  88   94  #define ZTI_P(n, q)     { ZTI_MODE_FIXED, (n), (q) }
  89   95  #define ZTI_PCT(n)      { ZTI_MODE_ONLINE_PERCENT, (n), 1 }
↓ open down ↓ 5564 lines elided ↑ open up ↑
5654 5660  
5655 5661  void
5656 5662  spa_async_resume(spa_t *spa)
5657 5663  {
5658 5664          mutex_enter(&spa->spa_async_lock);
5659 5665          ASSERT(spa->spa_async_suspended != 0);
5660 5666          spa->spa_async_suspended--;
5661 5667          mutex_exit(&spa->spa_async_lock);
5662 5668  }
5663 5669  
     5670 +static int
     5671 +spa_async_tasks_pending(spa_t *spa)
     5672 +{
     5673 +        u_int non_config_tasks;
     5674 +        u_int config_task;
     5675 +        boolean_t config_task_suspended;
     5676 +
     5677 +        non_config_tasks = spa->spa_async_tasks & ~SPA_ASYNC_CONFIG_UPDATE;
     5678 +        config_task = spa->spa_async_tasks & SPA_ASYNC_CONFIG_UPDATE;
     5679 +        if (spa->spa_ccw_fail_time == 0)
     5680 +                config_task_suspended = B_FALSE;
     5681 +        else
     5682 +                config_task_suspended =
     5683 +                    (ddi_get_lbolt64() - spa->spa_ccw_fail_time)
     5684 +                  < (zfs_ccw_retry_interval * hz);
     5685 +
     5686 +        return (non_config_tasks || (config_task && !config_task_suspended));
     5687 +}
     5688 +
5664 5689  static void
5665 5690  spa_async_dispatch(spa_t *spa)
5666 5691  {
5667 5692          mutex_enter(&spa->spa_async_lock);
5668      -        if (spa->spa_async_tasks && !spa->spa_async_suspended &&
     5693 +        if (spa_async_tasks_pending(spa) &&
     5694 +            !spa->spa_async_suspended &&
5669 5695              spa->spa_async_thread == NULL &&
5670      -            rootdir != NULL && !vn_is_readonly(rootdir))
     5696 +            rootdir != NULL)
5671 5697                  spa->spa_async_thread = thread_create(NULL, 0,
5672 5698                      spa_async_thread, spa, 0, &p0, TS_RUN, maxclsyspri);
5673 5699          mutex_exit(&spa->spa_async_lock);
5674 5700  }
5675 5701  
5676 5702  void
5677 5703  spa_async_request(spa_t *spa, int task)
5678 5704  {
5679 5705          zfs_dbgmsg("spa=%s async request task=%u", spa->spa_name, task);
5680 5706          mutex_enter(&spa->spa_async_lock);
↓ open down ↓ 789 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX