Print this page
6537 Panic on zpool scrub with DEBUG kernel


   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
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2011, 2015 by Delphix. All rights reserved.

  24  */
  25 
  26 #include <sys/dsl_scan.h>
  27 #include <sys/dsl_pool.h>
  28 #include <sys/dsl_dataset.h>
  29 #include <sys/dsl_prop.h>
  30 #include <sys/dsl_dir.h>
  31 #include <sys/dsl_synctask.h>
  32 #include <sys/dnode.h>
  33 #include <sys/dmu_tx.h>
  34 #include <sys/dmu_objset.h>
  35 #include <sys/arc.h>
  36 #include <sys/zap.h>
  37 #include <sys/zio.h>
  38 #include <sys/zfs_context.h>
  39 #include <sys/fs/zfs.h>
  40 #include <sys/zfs_znode.h>
  41 #include <sys/spa_impl.h>
  42 #include <sys/vdev_impl.h>
  43 #include <sys/zil_impl.h>


1487                 }
1488         }
1489         if (scn->scn_visited_this_txg) {
1490                 zfs_dbgmsg("freed %llu blocks in %llums from "
1491                     "free_bpobj/bptree txg %llu; err=%u",
1492                     (longlong_t)scn->scn_visited_this_txg,
1493                     (longlong_t)
1494                     NSEC2MSEC(gethrtime() - scn->scn_sync_start_time),
1495                     (longlong_t)tx->tx_txg, err);
1496                 scn->scn_visited_this_txg = 0;
1497 
1498                 /*
1499                  * Write out changes to the DDT that may be required as a
1500                  * result of the blocks freed.  This ensures that the DDT
1501                  * is clean when a scrub/resilver runs.
1502                  */
1503                 ddt_sync(spa, tx->tx_txg);
1504         }
1505         if (err != 0)
1506                 return;
1507         if (!scn->scn_async_destroying && zfs_free_leak_on_eio &&

1508             (dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes != 0 ||
1509             dsl_dir_phys(dp->dp_free_dir)->dd_compressed_bytes != 0 ||
1510             dsl_dir_phys(dp->dp_free_dir)->dd_uncompressed_bytes != 0)) {
1511                 /*
1512                  * We have finished background destroying, but there is still
1513                  * some space left in the dp_free_dir. Transfer this leaked
1514                  * space to the dp_leak_dir.
1515                  */
1516                 if (dp->dp_leak_dir == NULL) {
1517                         rrw_enter(&dp->dp_config_rwlock, RW_WRITER, FTAG);
1518                         (void) dsl_dir_create_sync(dp, dp->dp_root_dir,
1519                             LEAK_DIR_NAME, tx);
1520                         VERIFY0(dsl_pool_open_special_dir(dp,
1521                             LEAK_DIR_NAME, &dp->dp_leak_dir));
1522                         rrw_exit(&dp->dp_config_rwlock, FTAG);
1523                 }
1524                 dsl_dir_diduse_space(dp->dp_leak_dir, DD_USED_HEAD,
1525                     dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes,
1526                     dsl_dir_phys(dp->dp_free_dir)->dd_compressed_bytes,
1527                     dsl_dir_phys(dp->dp_free_dir)->dd_uncompressed_bytes, tx);
1528                 dsl_dir_diduse_space(dp->dp_free_dir, DD_USED_HEAD,
1529                     -dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes,
1530                     -dsl_dir_phys(dp->dp_free_dir)->dd_compressed_bytes,
1531                     -dsl_dir_phys(dp->dp_free_dir)->dd_uncompressed_bytes, tx);
1532         }
1533         if (!scn->scn_async_destroying) {
1534                 /* finished; verify that space accounting went to zero */
1535                 ASSERT0(dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes);
1536                 ASSERT0(dsl_dir_phys(dp->dp_free_dir)->dd_compressed_bytes);
1537                 ASSERT0(dsl_dir_phys(dp->dp_free_dir)->dd_uncompressed_bytes);
1538         }
1539 
1540         if (scn->scn_phys.scn_state != DSS_SCANNING)
1541                 return;
1542 
1543         if (scn->scn_done_txg == tx->tx_txg) {
1544                 ASSERT(!scn->scn_pausing);
1545                 /* finished with scan. */
1546                 zfs_dbgmsg("txg %llu scan complete", tx->tx_txg);
1547                 dsl_scan_done(scn, B_TRUE, tx);
1548                 ASSERT3U(spa->spa_scrub_inflight, ==, 0);
1549                 dsl_scan_sync_state(scn, tx);
1550                 return;
1551         }
1552 
1553         if (scn->scn_phys.scn_ddt_bookmark.ddb_class <=




   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
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
  24  * Copyright 2016 Gary Mills
  25  */
  26 
  27 #include <sys/dsl_scan.h>
  28 #include <sys/dsl_pool.h>
  29 #include <sys/dsl_dataset.h>
  30 #include <sys/dsl_prop.h>
  31 #include <sys/dsl_dir.h>
  32 #include <sys/dsl_synctask.h>
  33 #include <sys/dnode.h>
  34 #include <sys/dmu_tx.h>
  35 #include <sys/dmu_objset.h>
  36 #include <sys/arc.h>
  37 #include <sys/zap.h>
  38 #include <sys/zio.h>
  39 #include <sys/zfs_context.h>
  40 #include <sys/fs/zfs.h>
  41 #include <sys/zfs_znode.h>
  42 #include <sys/spa_impl.h>
  43 #include <sys/vdev_impl.h>
  44 #include <sys/zil_impl.h>


1488                 }
1489         }
1490         if (scn->scn_visited_this_txg) {
1491                 zfs_dbgmsg("freed %llu blocks in %llums from "
1492                     "free_bpobj/bptree txg %llu; err=%u",
1493                     (longlong_t)scn->scn_visited_this_txg,
1494                     (longlong_t)
1495                     NSEC2MSEC(gethrtime() - scn->scn_sync_start_time),
1496                     (longlong_t)tx->tx_txg, err);
1497                 scn->scn_visited_this_txg = 0;
1498 
1499                 /*
1500                  * Write out changes to the DDT that may be required as a
1501                  * result of the blocks freed.  This ensures that the DDT
1502                  * is clean when a scrub/resilver runs.
1503                  */
1504                 ddt_sync(spa, tx->tx_txg);
1505         }
1506         if (err != 0)
1507                 return;
1508         if (dp->dp_free_dir != NULL && !scn->scn_async_destroying &&
1509             zfs_free_leak_on_eio && 
1510             (dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes != 0 ||
1511             dsl_dir_phys(dp->dp_free_dir)->dd_compressed_bytes != 0 ||
1512             dsl_dir_phys(dp->dp_free_dir)->dd_uncompressed_bytes != 0)) {
1513                 /*
1514                  * We have finished background destroying, but there is still
1515                  * some space left in the dp_free_dir. Transfer this leaked
1516                  * space to the dp_leak_dir.
1517                  */
1518                 if (dp->dp_leak_dir == NULL) {
1519                         rrw_enter(&dp->dp_config_rwlock, RW_WRITER, FTAG);
1520                         (void) dsl_dir_create_sync(dp, dp->dp_root_dir,
1521                             LEAK_DIR_NAME, tx);
1522                         VERIFY0(dsl_pool_open_special_dir(dp,
1523                             LEAK_DIR_NAME, &dp->dp_leak_dir));
1524                         rrw_exit(&dp->dp_config_rwlock, FTAG);
1525                 }
1526                 dsl_dir_diduse_space(dp->dp_leak_dir, DD_USED_HEAD,
1527                     dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes,
1528                     dsl_dir_phys(dp->dp_free_dir)->dd_compressed_bytes,
1529                     dsl_dir_phys(dp->dp_free_dir)->dd_uncompressed_bytes, tx);
1530                 dsl_dir_diduse_space(dp->dp_free_dir, DD_USED_HEAD,
1531                     -dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes,
1532                     -dsl_dir_phys(dp->dp_free_dir)->dd_compressed_bytes,
1533                     -dsl_dir_phys(dp->dp_free_dir)->dd_uncompressed_bytes, tx);
1534         }
1535         if (dp->dp_free_dir != NULL && !scn->scn_async_destroying) {
1536                 /* finished; verify that space accounting went to zero */
1537                 ASSERT0(dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes);
1538                 ASSERT0(dsl_dir_phys(dp->dp_free_dir)->dd_compressed_bytes);
1539                 ASSERT0(dsl_dir_phys(dp->dp_free_dir)->dd_uncompressed_bytes);
1540         }
1541 
1542         if (scn->scn_phys.scn_state != DSS_SCANNING)
1543                 return;
1544 
1545         if (scn->scn_done_txg == tx->tx_txg) {
1546                 ASSERT(!scn->scn_pausing);
1547                 /* finished with scan. */
1548                 zfs_dbgmsg("txg %llu scan complete", tx->tx_txg);
1549                 dsl_scan_done(scn, B_TRUE, tx);
1550                 ASSERT3U(spa->spa_scrub_inflight, ==, 0);
1551                 dsl_scan_sync_state(scn, tx);
1552                 return;
1553         }
1554 
1555         if (scn->scn_phys.scn_ddt_bookmark.ddb_class <=