bptree.c (256281) | bptree.c (262120) |
---|---|
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 --- 166 unchanged lines hidden (view full) --- 175 ba.ba_free = free; 176 ba.ba_func = func; 177 ba.ba_arg = arg; 178 ba.ba_tx = tx; 179 180 err = 0; 181 for (i = ba.ba_phys->bt_begin; i < ba.ba_phys->bt_end; i++) { 182 bptree_entry_phys_t bte; | 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 --- 166 unchanged lines hidden (view full) --- 175 ba.ba_free = free; 176 ba.ba_func = func; 177 ba.ba_arg = arg; 178 ba.ba_tx = tx; 179 180 err = 0; 181 for (i = ba.ba_phys->bt_begin; i < ba.ba_phys->bt_end; i++) { 182 bptree_entry_phys_t bte; |
183 int flags = TRAVERSE_PREFETCH_METADATA | TRAVERSE_POST; |
|
183 184 ASSERT(!free || i == ba.ba_phys->bt_begin); 185 186 err = dmu_read(os, obj, i * sizeof (bte), sizeof (bte), 187 &bte, DMU_READ_NO_PREFETCH); 188 if (err != 0) 189 break; 190 | 184 185 ASSERT(!free || i == ba.ba_phys->bt_begin); 186 187 err = dmu_read(os, obj, i * sizeof (bte), sizeof (bte), 188 &bte, DMU_READ_NO_PREFETCH); 189 if (err != 0) 190 break; 191 |
192 if (zfs_recover) 193 flags |= TRAVERSE_HARD; |
|
191 err = traverse_dataset_destroyed(os->os_spa, &bte.be_bp, | 194 err = traverse_dataset_destroyed(os->os_spa, &bte.be_bp, |
192 bte.be_birth_txg, &bte.be_zb, 193 TRAVERSE_PREFETCH_METADATA | TRAVERSE_POST, | 195 bte.be_birth_txg, &bte.be_zb, flags, |
194 bptree_visit_cb, &ba); 195 if (free) { | 196 bptree_visit_cb, &ba); 197 if (free) { |
196 ASSERT(err == 0 || err == ERESTART); 197 if (err != 0) { | 198 if (err == ERESTART) { |
198 /* save bookmark for future resume */ 199 ASSERT3U(bte.be_zb.zb_objset, ==, 200 ZB_DESTROYED_OBJSET); 201 ASSERT0(bte.be_zb.zb_level); 202 dmu_write(os, obj, i * sizeof (bte), 203 sizeof (bte), &bte, tx); 204 break; | 199 /* save bookmark for future resume */ 200 ASSERT3U(bte.be_zb.zb_objset, ==, 201 ZB_DESTROYED_OBJSET); 202 ASSERT0(bte.be_zb.zb_level); 203 dmu_write(os, obj, i * sizeof (bte), 204 sizeof (bte), &bte, tx); 205 break; |
205 } else { 206 ba.ba_phys->bt_begin++; 207 (void) dmu_free_range(os, obj, 208 i * sizeof (bte), sizeof (bte), tx); | |
209 } | 206 } |
207 if (err != 0) { 208 /* 209 * We can not properly handle an i/o 210 * error, because the traversal code 211 * does not know how to resume from an 212 * arbitrary bookmark. 213 */ 214 zfs_panic_recover("error %u from " 215 "traverse_dataset_destroyed()", err); 216 } 217 218 ba.ba_phys->bt_begin++; 219 (void) dmu_free_range(os, obj, 220 i * sizeof (bte), sizeof (bte), tx); |
|
210 } 211 } 212 213 ASSERT(!free || err != 0 || ba.ba_phys->bt_begin == ba.ba_phys->bt_end); 214 215 /* if all blocks are free there should be no used space */ 216 if (ba.ba_phys->bt_begin == ba.ba_phys->bt_end) { 217 ASSERT0(ba.ba_phys->bt_bytes); 218 ASSERT0(ba.ba_phys->bt_comp); 219 ASSERT0(ba.ba_phys->bt_uncomp); 220 } 221 222 dmu_buf_rele(db, FTAG); 223 224 return (err); 225} | 221 } 222 } 223 224 ASSERT(!free || err != 0 || ba.ba_phys->bt_begin == ba.ba_phys->bt_end); 225 226 /* if all blocks are free there should be no used space */ 227 if (ba.ba_phys->bt_begin == ba.ba_phys->bt_end) { 228 ASSERT0(ba.ba_phys->bt_bytes); 229 ASSERT0(ba.ba_phys->bt_comp); 230 ASSERT0(ba.ba_phys->bt_uncomp); 231 } 232 233 dmu_buf_rele(db, FTAG); 234 235 return (err); 236} |