zap.c (185029) | zap.c (209962) |
---|---|
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 --- 1121 unchanged lines hidden (view full) --- 1130 if (err == 0) { 1131 zap_stats_ptrtbl(zap, db->db_data, 1132 1<<(bs-3), zs); 1133 dmu_buf_rele(db, FTAG); 1134 } 1135 } 1136 } 1137} | 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 --- 1121 unchanged lines hidden (view full) --- 1130 if (err == 0) { 1131 zap_stats_ptrtbl(zap, db->db_data, 1132 1<<(bs-3), zs); 1133 dmu_buf_rele(db, FTAG); 1134 } 1135 } 1136 } 1137} |
1138 1139int 1140fzap_count_write(zap_name_t *zn, int add, uint64_t *towrite, 1141 uint64_t *tooverwrite) 1142{ 1143 zap_t *zap = zn->zn_zap; 1144 zap_leaf_t *l; 1145 int err; 1146 1147 /* 1148 * Account for the header block of the fatzap. 1149 */ 1150 if (!add && dmu_buf_freeable(zap->zap_dbuf)) { 1151 *tooverwrite += zap->zap_dbuf->db_size; 1152 } else { 1153 *towrite += zap->zap_dbuf->db_size; 1154 } 1155 1156 /* 1157 * Account for the pointer table blocks. 1158 * If we are adding we need to account for the following cases : 1159 * - If the pointer table is embedded, this operation could force an 1160 * external pointer table. 1161 * - If this already has an external pointer table this operation 1162 * could extend the table. 1163 */ 1164 if (add) { 1165 if (zap->zap_f.zap_phys->zap_ptrtbl.zt_blk == 0) 1166 *towrite += zap->zap_dbuf->db_size; 1167 else 1168 *towrite += (zap->zap_dbuf->db_size * 3); 1169 } 1170 1171 /* 1172 * Now, check if the block containing leaf is freeable 1173 * and account accordingly. 1174 */ 1175 err = zap_deref_leaf(zap, zn->zn_hash, NULL, RW_READER, &l); 1176 if (err != 0) { 1177 return (err); 1178 } 1179 1180 if (!add && dmu_buf_freeable(l->l_dbuf)) { 1181 *tooverwrite += l->l_dbuf->db_size; 1182 } else { 1183 /* 1184 * If this an add operation, the leaf block could split. 1185 * Hence, we need to account for an additional leaf block. 1186 */ 1187 *towrite += (add ? 2 : 1) * l->l_dbuf->db_size; 1188 } 1189 1190 zap_put_leaf(l); 1191 return (0); 1192} |
|