1ea8dc4b6Seschrock /* 2ea8dc4b6Seschrock * CDDL HEADER START 3ea8dc4b6Seschrock * 4ea8dc4b6Seschrock * The contents of this file are subject to the terms of the 5ea8dc4b6Seschrock * Common Development and Distribution License (the "License"). 6ea8dc4b6Seschrock * You may not use this file except in compliance with the License. 7ea8dc4b6Seschrock * 8ea8dc4b6Seschrock * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9ea8dc4b6Seschrock * or http://www.opensolaris.org/os/licensing. 10ea8dc4b6Seschrock * See the License for the specific language governing permissions 11ea8dc4b6Seschrock * and limitations under the License. 12ea8dc4b6Seschrock * 13ea8dc4b6Seschrock * When distributing Covered Code, include this CDDL HEADER in each 14ea8dc4b6Seschrock * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15ea8dc4b6Seschrock * If applicable, add the following below this CDDL HEADER, with the 16ea8dc4b6Seschrock * fields enclosed by brackets "[]" replaced with your own identifying 17ea8dc4b6Seschrock * information: Portions Copyright [yyyy] [name of copyright owner] 18ea8dc4b6Seschrock * 19ea8dc4b6Seschrock * CDDL HEADER END 20ea8dc4b6Seschrock */ 21ea8dc4b6Seschrock /* 223f9d6ad7SLin Ling * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 23*7802d7bfSMatthew Ahrens * Copyright (c) 2013, 2014 by Delphix. All rights reserved. 24ea8dc4b6Seschrock */ 25ea8dc4b6Seschrock 26ea8dc4b6Seschrock /* 27ea8dc4b6Seschrock * Routines to manage the on-disk persistent error log. 28ea8dc4b6Seschrock * 29ea8dc4b6Seschrock * Each pool stores a log of all logical data errors seen during normal 30ea8dc4b6Seschrock * operation. This is actually the union of two distinct logs: the last log, 31ea8dc4b6Seschrock * and the current log. All errors seen are logged to the current log. When a 32ea8dc4b6Seschrock * scrub completes, the current log becomes the last log, the last log is thrown 33ea8dc4b6Seschrock * out, and the current log is reinitialized. This way, if an error is somehow 34ea8dc4b6Seschrock * corrected, a new scrub will show that that it no longer exists, and will be 35ea8dc4b6Seschrock * deleted from the log when the scrub completes. 36ea8dc4b6Seschrock * 37ea8dc4b6Seschrock * The log is stored using a ZAP object whose key is a string form of the 38*7802d7bfSMatthew Ahrens * zbookmark_phys tuple (objset, object, level, blkid), and whose contents is an 39ea8dc4b6Seschrock * optional 'objset:object' human-readable string describing the data. When an 40ea8dc4b6Seschrock * error is first logged, this string will be empty, indicating that no name is 41ea8dc4b6Seschrock * known. This prevents us from having to issue a potentially large amount of 42ea8dc4b6Seschrock * I/O to discover the object name during an error path. Instead, we do the 43ea8dc4b6Seschrock * calculation when the data is requested, storing the result so future queries 44ea8dc4b6Seschrock * will be faster. 45ea8dc4b6Seschrock * 46ea8dc4b6Seschrock * This log is then shipped into an nvlist where the key is the dataset name and 47ea8dc4b6Seschrock * the value is the object name. Userland is then responsible for uniquifying 48ea8dc4b6Seschrock * this list and displaying it to the user. 49ea8dc4b6Seschrock */ 50ea8dc4b6Seschrock 51ea8dc4b6Seschrock #include <sys/dmu_tx.h> 52ea8dc4b6Seschrock #include <sys/spa.h> 53ea8dc4b6Seschrock #include <sys/spa_impl.h> 54ea8dc4b6Seschrock #include <sys/zap.h> 55ea8dc4b6Seschrock #include <sys/zio.h> 56ea8dc4b6Seschrock 57ea8dc4b6Seschrock 58ea8dc4b6Seschrock /* 59ea8dc4b6Seschrock * Convert a bookmark to a string. 60ea8dc4b6Seschrock */ 61ea8dc4b6Seschrock static void 62*7802d7bfSMatthew Ahrens bookmark_to_name(zbookmark_phys_t *zb, char *buf, size_t len) 63ea8dc4b6Seschrock { 64ea8dc4b6Seschrock (void) snprintf(buf, len, "%llx:%llx:%llx:%llx", 65ea8dc4b6Seschrock (u_longlong_t)zb->zb_objset, (u_longlong_t)zb->zb_object, 66ea8dc4b6Seschrock (u_longlong_t)zb->zb_level, (u_longlong_t)zb->zb_blkid); 67ea8dc4b6Seschrock } 68ea8dc4b6Seschrock 69ea8dc4b6Seschrock /* 70ea8dc4b6Seschrock * Convert a string to a bookmark 71ea8dc4b6Seschrock */ 725ad82045Snd150628 #ifdef _KERNEL 73ea8dc4b6Seschrock static void 74*7802d7bfSMatthew Ahrens name_to_bookmark(char *buf, zbookmark_phys_t *zb) 75ea8dc4b6Seschrock { 76ea8dc4b6Seschrock zb->zb_objset = strtonum(buf, &buf); 77ea8dc4b6Seschrock ASSERT(*buf == ':'); 78ea8dc4b6Seschrock zb->zb_object = strtonum(buf + 1, &buf); 79ea8dc4b6Seschrock ASSERT(*buf == ':'); 80ea8dc4b6Seschrock zb->zb_level = (int)strtonum(buf + 1, &buf); 81ea8dc4b6Seschrock ASSERT(*buf == ':'); 82ea8dc4b6Seschrock zb->zb_blkid = strtonum(buf + 1, &buf); 83ea8dc4b6Seschrock ASSERT(*buf == '\0'); 84ea8dc4b6Seschrock } 855ad82045Snd150628 #endif 86ea8dc4b6Seschrock 87ea8dc4b6Seschrock /* 88ea8dc4b6Seschrock * Log an uncorrectable error to the persistent error log. We add it to the 89ea8dc4b6Seschrock * spa's list of pending errors. The changes are actually synced out to disk 90ea8dc4b6Seschrock * during spa_errlog_sync(). 91ea8dc4b6Seschrock */ 92ea8dc4b6Seschrock void 93ea8dc4b6Seschrock spa_log_error(spa_t *spa, zio_t *zio) 94ea8dc4b6Seschrock { 95*7802d7bfSMatthew Ahrens zbookmark_phys_t *zb = &zio->io_logical->io_bookmark; 96ea8dc4b6Seschrock spa_error_entry_t search; 97ea8dc4b6Seschrock spa_error_entry_t *new; 98ea8dc4b6Seschrock avl_tree_t *tree; 99ea8dc4b6Seschrock avl_index_t where; 100ea8dc4b6Seschrock 101ea8dc4b6Seschrock /* 102ea8dc4b6Seschrock * If we are trying to import a pool, ignore any errors, as we won't be 103ea8dc4b6Seschrock * writing to the pool any time soon. 104ea8dc4b6Seschrock */ 105b16da2e2SGeorge Wilson if (spa_load_state(spa) == SPA_LOAD_TRYIMPORT) 106ea8dc4b6Seschrock return; 107ea8dc4b6Seschrock 108ea8dc4b6Seschrock mutex_enter(&spa->spa_errlist_lock); 109ea8dc4b6Seschrock 110ea8dc4b6Seschrock /* 111ea8dc4b6Seschrock * If we have had a request to rotate the log, log it to the next list 112ea8dc4b6Seschrock * instead of the current one. 113ea8dc4b6Seschrock */ 114ea8dc4b6Seschrock if (spa->spa_scrub_active || spa->spa_scrub_finished) 115ea8dc4b6Seschrock tree = &spa->spa_errlist_scrub; 116ea8dc4b6Seschrock else 117ea8dc4b6Seschrock tree = &spa->spa_errlist_last; 118ea8dc4b6Seschrock 119ea8dc4b6Seschrock search.se_bookmark = *zb; 120ea8dc4b6Seschrock if (avl_find(tree, &search, &where) != NULL) { 121ea8dc4b6Seschrock mutex_exit(&spa->spa_errlist_lock); 122ea8dc4b6Seschrock return; 123ea8dc4b6Seschrock } 124ea8dc4b6Seschrock 125ea8dc4b6Seschrock new = kmem_zalloc(sizeof (spa_error_entry_t), KM_SLEEP); 126ea8dc4b6Seschrock new->se_bookmark = *zb; 127ea8dc4b6Seschrock avl_insert(tree, new, where); 128ea8dc4b6Seschrock 129ea8dc4b6Seschrock mutex_exit(&spa->spa_errlist_lock); 130ea8dc4b6Seschrock } 131ea8dc4b6Seschrock 132ea8dc4b6Seschrock /* 133ea8dc4b6Seschrock * Return the number of errors currently in the error log. This is actually the 134ea8dc4b6Seschrock * sum of both the last log and the current log, since we don't know the union 135ea8dc4b6Seschrock * of these logs until we reach userland. 136ea8dc4b6Seschrock */ 137ea8dc4b6Seschrock uint64_t 138ea8dc4b6Seschrock spa_get_errlog_size(spa_t *spa) 139ea8dc4b6Seschrock { 140ea8dc4b6Seschrock uint64_t total = 0, count; 141ea8dc4b6Seschrock 142ea8dc4b6Seschrock mutex_enter(&spa->spa_errlog_lock); 143ea8dc4b6Seschrock if (spa->spa_errlog_scrub != 0 && 144ea8dc4b6Seschrock zap_count(spa->spa_meta_objset, spa->spa_errlog_scrub, 145ea8dc4b6Seschrock &count) == 0) 146ea8dc4b6Seschrock total += count; 147ea8dc4b6Seschrock 148ea8dc4b6Seschrock if (spa->spa_errlog_last != 0 && !spa->spa_scrub_finished && 149ea8dc4b6Seschrock zap_count(spa->spa_meta_objset, spa->spa_errlog_last, 150ea8dc4b6Seschrock &count) == 0) 151ea8dc4b6Seschrock total += count; 152ea8dc4b6Seschrock mutex_exit(&spa->spa_errlog_lock); 153ea8dc4b6Seschrock 154ea8dc4b6Seschrock mutex_enter(&spa->spa_errlist_lock); 155ea8dc4b6Seschrock total += avl_numnodes(&spa->spa_errlist_last); 156ea8dc4b6Seschrock total += avl_numnodes(&spa->spa_errlist_scrub); 157ea8dc4b6Seschrock mutex_exit(&spa->spa_errlist_lock); 158ea8dc4b6Seschrock 159ea8dc4b6Seschrock return (total); 160ea8dc4b6Seschrock } 161ea8dc4b6Seschrock 162ea8dc4b6Seschrock #ifdef _KERNEL 163ea8dc4b6Seschrock static int 164ea8dc4b6Seschrock process_error_log(spa_t *spa, uint64_t obj, void *addr, size_t *count) 165ea8dc4b6Seschrock { 166ea8dc4b6Seschrock zap_cursor_t zc; 167ea8dc4b6Seschrock zap_attribute_t za; 168*7802d7bfSMatthew Ahrens zbookmark_phys_t zb; 169ea8dc4b6Seschrock 170ea8dc4b6Seschrock if (obj == 0) 171ea8dc4b6Seschrock return (0); 172ea8dc4b6Seschrock 173ea8dc4b6Seschrock for (zap_cursor_init(&zc, spa->spa_meta_objset, obj); 174ea8dc4b6Seschrock zap_cursor_retrieve(&zc, &za) == 0; 175ea8dc4b6Seschrock zap_cursor_advance(&zc)) { 176ea8dc4b6Seschrock 177ea8dc4b6Seschrock if (*count == 0) { 178ea8dc4b6Seschrock zap_cursor_fini(&zc); 179be6fd75aSMatthew Ahrens return (SET_ERROR(ENOMEM)); 180ea8dc4b6Seschrock } 181ea8dc4b6Seschrock 182ea8dc4b6Seschrock name_to_bookmark(za.za_name, &zb); 183ea8dc4b6Seschrock 184ea8dc4b6Seschrock if (copyout(&zb, (char *)addr + 185*7802d7bfSMatthew Ahrens (*count - 1) * sizeof (zbookmark_phys_t), 186*7802d7bfSMatthew Ahrens sizeof (zbookmark_phys_t)) != 0) { 187b287be1bSWill Andrews zap_cursor_fini(&zc); 188be6fd75aSMatthew Ahrens return (SET_ERROR(EFAULT)); 189b287be1bSWill Andrews } 190ea8dc4b6Seschrock 191ea8dc4b6Seschrock *count -= 1; 192ea8dc4b6Seschrock } 193ea8dc4b6Seschrock 194ea8dc4b6Seschrock zap_cursor_fini(&zc); 195ea8dc4b6Seschrock 196ea8dc4b6Seschrock return (0); 197ea8dc4b6Seschrock } 198ea8dc4b6Seschrock 199ea8dc4b6Seschrock static int 200ea8dc4b6Seschrock process_error_list(avl_tree_t *list, void *addr, size_t *count) 201ea8dc4b6Seschrock { 202ea8dc4b6Seschrock spa_error_entry_t *se; 203ea8dc4b6Seschrock 204ea8dc4b6Seschrock for (se = avl_first(list); se != NULL; se = AVL_NEXT(list, se)) { 205ea8dc4b6Seschrock 206ea8dc4b6Seschrock if (*count == 0) 207be6fd75aSMatthew Ahrens return (SET_ERROR(ENOMEM)); 208ea8dc4b6Seschrock 209ea8dc4b6Seschrock if (copyout(&se->se_bookmark, (char *)addr + 210*7802d7bfSMatthew Ahrens (*count - 1) * sizeof (zbookmark_phys_t), 211*7802d7bfSMatthew Ahrens sizeof (zbookmark_phys_t)) != 0) 212be6fd75aSMatthew Ahrens return (SET_ERROR(EFAULT)); 213ea8dc4b6Seschrock 214ea8dc4b6Seschrock *count -= 1; 215ea8dc4b6Seschrock } 216ea8dc4b6Seschrock 217ea8dc4b6Seschrock return (0); 218ea8dc4b6Seschrock } 219ea8dc4b6Seschrock #endif 220ea8dc4b6Seschrock 221ea8dc4b6Seschrock /* 222ea8dc4b6Seschrock * Copy all known errors to userland as an array of bookmarks. This is 223ea8dc4b6Seschrock * actually a union of the on-disk last log and current log, as well as any 224ea8dc4b6Seschrock * pending error requests. 225ea8dc4b6Seschrock * 226ea8dc4b6Seschrock * Because the act of reading the on-disk log could cause errors to be 227ea8dc4b6Seschrock * generated, we have two separate locks: one for the error log and one for the 228ea8dc4b6Seschrock * in-core error lists. We only need the error list lock to log and error, so 229ea8dc4b6Seschrock * we grab the error log lock while we read the on-disk logs, and only pick up 230ea8dc4b6Seschrock * the error list lock when we are finished. 231ea8dc4b6Seschrock */ 232ea8dc4b6Seschrock int 233ea8dc4b6Seschrock spa_get_errlog(spa_t *spa, void *uaddr, size_t *count) 234ea8dc4b6Seschrock { 235ea8dc4b6Seschrock int ret = 0; 236ea8dc4b6Seschrock 237ea8dc4b6Seschrock #ifdef _KERNEL 238ea8dc4b6Seschrock mutex_enter(&spa->spa_errlog_lock); 239ea8dc4b6Seschrock 240ea8dc4b6Seschrock ret = process_error_log(spa, spa->spa_errlog_scrub, uaddr, count); 241ea8dc4b6Seschrock 242ea8dc4b6Seschrock if (!ret && !spa->spa_scrub_finished) 243ea8dc4b6Seschrock ret = process_error_log(spa, spa->spa_errlog_last, uaddr, 244ea8dc4b6Seschrock count); 245ea8dc4b6Seschrock 246ea8dc4b6Seschrock mutex_enter(&spa->spa_errlist_lock); 247ea8dc4b6Seschrock if (!ret) 248ea8dc4b6Seschrock ret = process_error_list(&spa->spa_errlist_scrub, uaddr, 249ea8dc4b6Seschrock count); 250ea8dc4b6Seschrock if (!ret) 251ea8dc4b6Seschrock ret = process_error_list(&spa->spa_errlist_last, uaddr, 252ea8dc4b6Seschrock count); 253ea8dc4b6Seschrock mutex_exit(&spa->spa_errlist_lock); 254ea8dc4b6Seschrock 255ea8dc4b6Seschrock mutex_exit(&spa->spa_errlog_lock); 256ea8dc4b6Seschrock #endif 257ea8dc4b6Seschrock 258ea8dc4b6Seschrock return (ret); 259ea8dc4b6Seschrock } 260ea8dc4b6Seschrock 261ea8dc4b6Seschrock /* 262ea8dc4b6Seschrock * Called when a scrub completes. This simply set a bit which tells which AVL 263ea8dc4b6Seschrock * tree to add new errors. spa_errlog_sync() is responsible for actually 264ea8dc4b6Seschrock * syncing the changes to the underlying objects. 265ea8dc4b6Seschrock */ 266ea8dc4b6Seschrock void 267ea8dc4b6Seschrock spa_errlog_rotate(spa_t *spa) 268ea8dc4b6Seschrock { 269ea8dc4b6Seschrock mutex_enter(&spa->spa_errlist_lock); 270ea8dc4b6Seschrock spa->spa_scrub_finished = B_TRUE; 271ea8dc4b6Seschrock mutex_exit(&spa->spa_errlist_lock); 272ea8dc4b6Seschrock } 273ea8dc4b6Seschrock 274ea8dc4b6Seschrock /* 275ea8dc4b6Seschrock * Discard any pending errors from the spa_t. Called when unloading a faulted 276ea8dc4b6Seschrock * pool, as the errors encountered during the open cannot be synced to disk. 277ea8dc4b6Seschrock */ 278ea8dc4b6Seschrock void 279ea8dc4b6Seschrock spa_errlog_drain(spa_t *spa) 280ea8dc4b6Seschrock { 281ea8dc4b6Seschrock spa_error_entry_t *se; 282ea8dc4b6Seschrock void *cookie; 283ea8dc4b6Seschrock 284ea8dc4b6Seschrock mutex_enter(&spa->spa_errlist_lock); 285ea8dc4b6Seschrock 286ea8dc4b6Seschrock cookie = NULL; 287ea8dc4b6Seschrock while ((se = avl_destroy_nodes(&spa->spa_errlist_last, 288ea8dc4b6Seschrock &cookie)) != NULL) 289ea8dc4b6Seschrock kmem_free(se, sizeof (spa_error_entry_t)); 290ea8dc4b6Seschrock cookie = NULL; 291ea8dc4b6Seschrock while ((se = avl_destroy_nodes(&spa->spa_errlist_scrub, 292ea8dc4b6Seschrock &cookie)) != NULL) 293ea8dc4b6Seschrock kmem_free(se, sizeof (spa_error_entry_t)); 294ea8dc4b6Seschrock 295ea8dc4b6Seschrock mutex_exit(&spa->spa_errlist_lock); 296ea8dc4b6Seschrock } 297ea8dc4b6Seschrock 298ea8dc4b6Seschrock /* 299ea8dc4b6Seschrock * Process a list of errors into the current on-disk log. 300ea8dc4b6Seschrock */ 301ea8dc4b6Seschrock static void 302ea8dc4b6Seschrock sync_error_list(spa_t *spa, avl_tree_t *t, uint64_t *obj, dmu_tx_t *tx) 303ea8dc4b6Seschrock { 304ea8dc4b6Seschrock spa_error_entry_t *se; 305ea8dc4b6Seschrock char buf[64]; 306ea8dc4b6Seschrock void *cookie; 307ea8dc4b6Seschrock 308ea8dc4b6Seschrock if (avl_numnodes(t) != 0) { 309ea8dc4b6Seschrock /* create log if necessary */ 310ea8dc4b6Seschrock if (*obj == 0) 311ea8dc4b6Seschrock *obj = zap_create(spa->spa_meta_objset, 312ea8dc4b6Seschrock DMU_OT_ERROR_LOG, DMU_OT_NONE, 313ea8dc4b6Seschrock 0, tx); 314ea8dc4b6Seschrock 315ea8dc4b6Seschrock /* add errors to the current log */ 316ea8dc4b6Seschrock for (se = avl_first(t); se != NULL; se = AVL_NEXT(t, se)) { 317ea8dc4b6Seschrock char *name = se->se_name ? se->se_name : ""; 318ea8dc4b6Seschrock 319ea8dc4b6Seschrock bookmark_to_name(&se->se_bookmark, buf, sizeof (buf)); 320ea8dc4b6Seschrock 321ea8dc4b6Seschrock (void) zap_update(spa->spa_meta_objset, 322ea8dc4b6Seschrock *obj, buf, 1, strlen(name) + 1, name, tx); 323ea8dc4b6Seschrock } 324ea8dc4b6Seschrock 325ea8dc4b6Seschrock /* purge the error list */ 326ea8dc4b6Seschrock cookie = NULL; 327ea8dc4b6Seschrock while ((se = avl_destroy_nodes(t, &cookie)) != NULL) 328ea8dc4b6Seschrock kmem_free(se, sizeof (spa_error_entry_t)); 329ea8dc4b6Seschrock } 330ea8dc4b6Seschrock } 331ea8dc4b6Seschrock 332ea8dc4b6Seschrock /* 333ea8dc4b6Seschrock * Sync the error log out to disk. This is a little tricky because the act of 334ea8dc4b6Seschrock * writing the error log requires the spa_errlist_lock. So, we need to lock the 335ea8dc4b6Seschrock * error lists, take a copy of the lists, and then reinitialize them. Then, we 336ea8dc4b6Seschrock * drop the error list lock and take the error log lock, at which point we 337ea8dc4b6Seschrock * do the errlog processing. Then, if we encounter an I/O error during this 338ea8dc4b6Seschrock * process, we can successfully add the error to the list. Note that this will 339ea8dc4b6Seschrock * result in the perpetual recycling of errors, but it is an unlikely situation 340ea8dc4b6Seschrock * and not a performance critical operation. 341ea8dc4b6Seschrock */ 342ea8dc4b6Seschrock void 343ea8dc4b6Seschrock spa_errlog_sync(spa_t *spa, uint64_t txg) 344ea8dc4b6Seschrock { 345ea8dc4b6Seschrock dmu_tx_t *tx; 346ea8dc4b6Seschrock avl_tree_t scrub, last; 347ea8dc4b6Seschrock int scrub_finished; 348ea8dc4b6Seschrock 349ea8dc4b6Seschrock mutex_enter(&spa->spa_errlist_lock); 350ea8dc4b6Seschrock 351ea8dc4b6Seschrock /* 352ea8dc4b6Seschrock * Bail out early under normal circumstances. 353ea8dc4b6Seschrock */ 354ea8dc4b6Seschrock if (avl_numnodes(&spa->spa_errlist_scrub) == 0 && 355ea8dc4b6Seschrock avl_numnodes(&spa->spa_errlist_last) == 0 && 356ea8dc4b6Seschrock !spa->spa_scrub_finished) { 357ea8dc4b6Seschrock mutex_exit(&spa->spa_errlist_lock); 358ea8dc4b6Seschrock return; 359ea8dc4b6Seschrock } 360ea8dc4b6Seschrock 361ea8dc4b6Seschrock spa_get_errlists(spa, &last, &scrub); 362ea8dc4b6Seschrock scrub_finished = spa->spa_scrub_finished; 363ea8dc4b6Seschrock spa->spa_scrub_finished = B_FALSE; 364ea8dc4b6Seschrock 365ea8dc4b6Seschrock mutex_exit(&spa->spa_errlist_lock); 366ea8dc4b6Seschrock mutex_enter(&spa->spa_errlog_lock); 367ea8dc4b6Seschrock 368ea8dc4b6Seschrock tx = dmu_tx_create_assigned(spa->spa_dsl_pool, txg); 369ea8dc4b6Seschrock 370ea8dc4b6Seschrock /* 371ea8dc4b6Seschrock * Sync out the current list of errors. 372ea8dc4b6Seschrock */ 373ea8dc4b6Seschrock sync_error_list(spa, &last, &spa->spa_errlog_last, tx); 374ea8dc4b6Seschrock 375ea8dc4b6Seschrock /* 376ea8dc4b6Seschrock * Rotate the log if necessary. 377ea8dc4b6Seschrock */ 378ea8dc4b6Seschrock if (scrub_finished) { 379ea8dc4b6Seschrock if (spa->spa_errlog_last != 0) 380ea8dc4b6Seschrock VERIFY(dmu_object_free(spa->spa_meta_objset, 381ea8dc4b6Seschrock spa->spa_errlog_last, tx) == 0); 382ea8dc4b6Seschrock spa->spa_errlog_last = spa->spa_errlog_scrub; 383ea8dc4b6Seschrock spa->spa_errlog_scrub = 0; 384ea8dc4b6Seschrock 385ea8dc4b6Seschrock sync_error_list(spa, &scrub, &spa->spa_errlog_last, tx); 386ea8dc4b6Seschrock } 387ea8dc4b6Seschrock 388ea8dc4b6Seschrock /* 389ea8dc4b6Seschrock * Sync out any pending scrub errors. 390ea8dc4b6Seschrock */ 391ea8dc4b6Seschrock sync_error_list(spa, &scrub, &spa->spa_errlog_scrub, tx); 392ea8dc4b6Seschrock 393ea8dc4b6Seschrock /* 394ea8dc4b6Seschrock * Update the MOS to reflect the new values. 395ea8dc4b6Seschrock */ 396ea8dc4b6Seschrock (void) zap_update(spa->spa_meta_objset, DMU_POOL_DIRECTORY_OBJECT, 397ea8dc4b6Seschrock DMU_POOL_ERRLOG_LAST, sizeof (uint64_t), 1, 398ea8dc4b6Seschrock &spa->spa_errlog_last, tx); 399ea8dc4b6Seschrock (void) zap_update(spa->spa_meta_objset, DMU_POOL_DIRECTORY_OBJECT, 400ea8dc4b6Seschrock DMU_POOL_ERRLOG_SCRUB, sizeof (uint64_t), 1, 401ea8dc4b6Seschrock &spa->spa_errlog_scrub, tx); 402ea8dc4b6Seschrock 403ea8dc4b6Seschrock dmu_tx_commit(tx); 404ea8dc4b6Seschrock 405ea8dc4b6Seschrock mutex_exit(&spa->spa_errlog_lock); 406ea8dc4b6Seschrock } 407