zap.c (321527) | zap.c (321547) |
---|---|
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 --- 1342 unchanged lines hidden (view full) --- 1351 if (err == 0) { 1352 zap_stats_ptrtbl(zap, db->db_data, 1353 1<<(bs-3), zs); 1354 dmu_buf_rele(db, FTAG); 1355 } 1356 } 1357 } 1358} | 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 --- 1342 unchanged lines hidden (view full) --- 1351 if (err == 0) { 1352 zap_stats_ptrtbl(zap, db->db_data, 1353 1<<(bs-3), zs); 1354 dmu_buf_rele(db, FTAG); 1355 } 1356 } 1357 } 1358} |
1359 1360int 1361fzap_count_write(zap_name_t *zn, int add, refcount_t *towrite, 1362 refcount_t *tooverwrite) 1363{ 1364 zap_t *zap = zn->zn_zap; 1365 zap_leaf_t *l; 1366 int err; 1367 1368 /* 1369 * Account for the header block of the fatzap. 1370 */ 1371 if (!add && dmu_buf_freeable(zap->zap_dbuf)) { 1372 (void) refcount_add_many(tooverwrite, 1373 zap->zap_dbuf->db_size, FTAG); 1374 } else { 1375 (void) refcount_add_many(towrite, 1376 zap->zap_dbuf->db_size, FTAG); 1377 } 1378 1379 /* 1380 * Account for the pointer table blocks. 1381 * If we are adding we need to account for the following cases : 1382 * - If the pointer table is embedded, this operation could force an 1383 * external pointer table. 1384 * - If this already has an external pointer table this operation 1385 * could extend the table. 1386 */ 1387 if (add) { 1388 if (zap_f_phys(zap)->zap_ptrtbl.zt_blk == 0) { 1389 (void) refcount_add_many(towrite, 1390 zap->zap_dbuf->db_size, FTAG); 1391 } else { 1392 (void) refcount_add_many(towrite, 1393 zap->zap_dbuf->db_size * 3, FTAG); 1394 } 1395 } 1396 1397 /* 1398 * Now, check if the block containing leaf is freeable 1399 * and account accordingly. 1400 */ 1401 err = zap_deref_leaf(zap, zn->zn_hash, NULL, RW_READER, &l); 1402 if (err != 0) { 1403 return (err); 1404 } 1405 1406 if (!add && dmu_buf_freeable(l->l_dbuf)) { 1407 (void) refcount_add_many(tooverwrite, l->l_dbuf->db_size, FTAG); 1408 } else { 1409 /* 1410 * If this an add operation, the leaf block could split. 1411 * Hence, we need to account for an additional leaf block. 1412 */ 1413 (void) refcount_add_many(towrite, 1414 (add ? 2 : 1) * l->l_dbuf->db_size, FTAG); 1415 } 1416 1417 zap_put_leaf(l); 1418 return (0); 1419} | |