Author: avg
Date: Fri May 26 11:32:05 2017
New Revision: 318929
URL: https://svnweb.freebsd.org/changeset/base/318929

Log:
  7786 zfs`vdev_online() needs better notification about state changes
  
  illumos/illumos-gate@5f368aef86387d6ef4eda84030ae9b402313ee4c
  
https://github.com/illumos/illumos-gate/commit/5f368aef86387d6ef4eda84030ae9b402313ee4c
  
  https://www.illumos.org/issues/7786
    Currently, vdev_online() will only post sysevent if previous state was
    "offline". It should also post the event when the state changes from 
"removed"
    or "faulted" to "healthy" or "degraded".
    This will fix the following scenario:
    - pull disk from slot A
    - check that hotspare has taken its place (if available)
    - insert disk into slot B
    - check that hotspare moved back to "avail" state (if spare was used)
    The problem here is that we don't get any ESC_ZFS_VDEV_* notification and 
fail
    to update the vdev FRU.
  
  Reviewed by: Matthew Ahrens [email protected]
  Reviewed by: George Wilson [email protected]
  Approved by: Albert Lee <[email protected]>
  Author: Yuri Pankov <[email protected]>

Modified:
  vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.c

Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.c
==============================================================================
--- vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.c    Fri May 26 11:30:55 
2017        (r318928)
+++ vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.c    Fri May 26 11:32:05 
2017        (r318929)
@@ -22,7 +22,7 @@
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
- * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2017 Nexenta Systems, Inc.
  * Copyright (c) 2014 Integros [integros.com]
  * Copyright 2016 Toomas Soome <[email protected]>
  */
@@ -2449,7 +2449,8 @@ int
 vdev_online(spa_t *spa, uint64_t guid, uint64_t flags, vdev_state_t *newstate)
 {
        vdev_t *vd, *tvd, *pvd, *rvd = spa->spa_root_vdev;
-       boolean_t postevent = B_FALSE;
+       boolean_t wasoffline;
+       vdev_state_t oldstate;
 
        spa_vdev_state_enter(spa, SCL_NONE);
 
@@ -2459,9 +2460,8 @@ vdev_online(spa_t *spa, uint64_t guid, u
        if (!vd->vdev_ops->vdev_op_leaf)
                return (spa_vdev_state_exit(spa, NULL, ENOTSUP));
 
-       postevent =
-           (vd->vdev_offline == B_TRUE || vd->vdev_tmpoffline == B_TRUE) ?
-           B_TRUE : B_FALSE;
+       wasoffline = (vd->vdev_offline || vd->vdev_tmpoffline);
+       oldstate = vd->vdev_state;
 
        tvd = vd->vdev_top;
        vd->vdev_offline = B_FALSE;
@@ -2499,7 +2499,9 @@ vdev_online(spa_t *spa, uint64_t guid, u
                spa_async_request(spa, SPA_ASYNC_CONFIG_UPDATE);
        }
 
-       if (postevent)
+       if (wasoffline ||
+           (oldstate < VDEV_STATE_DEGRADED &&
+           vd->vdev_state >= VDEV_STATE_DEGRADED))
                spa_event_notify(spa, vd, ESC_ZFS_VDEV_ONLINE);
 
        return (spa_vdev_state_exit(spa, vd, 0));
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to