zap_micro.c (197172) | zap_micro.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 --- 1065 unchanged lines hidden (view full) --- 1074 zs->zs_num_entries = zap->zap_m.zap_num_entries; 1075 zs->zs_num_blocks = 1; 1076 } else { 1077 fzap_get_stats(zap, zs); 1078 } 1079 zap_unlockdir(zap); 1080 return (0); 1081} | 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 --- 1065 unchanged lines hidden (view full) --- 1074 zs->zs_num_entries = zap->zap_m.zap_num_entries; 1075 zs->zs_num_blocks = 1; 1076 } else { 1077 fzap_get_stats(zap, zs); 1078 } 1079 zap_unlockdir(zap); 1080 return (0); 1081} |
1082 1083int 1084zap_count_write(objset_t *os, uint64_t zapobj, const char *name, int add, 1085 uint64_t *towrite, uint64_t *tooverwrite) 1086{ 1087 zap_t *zap; 1088 int err = 0; 1089 1090 1091 /* 1092 * Since, we don't have a name, we cannot figure out which blocks will 1093 * be affected in this operation. So, account for the worst case : 1094 * - 3 blocks overwritten: target leaf, ptrtbl block, header block 1095 * - 4 new blocks written if adding: 1096 * - 2 blocks for possibly split leaves, 1097 * - 2 grown ptrtbl blocks 1098 * 1099 * This also accomodates the case where an add operation to a fairly 1100 * large microzap results in a promotion to fatzap. 1101 */ 1102 if (name == NULL) { 1103 *towrite += (3 + (add ? 4 : 0)) * SPA_MAXBLOCKSIZE; 1104 return (err); 1105 } 1106 1107 /* 1108 * We lock the zap with adding == FALSE. Because, if we pass 1109 * the actual value of add, it could trigger a mzap_upgrade(). 1110 * At present we are just evaluating the possibility of this operation 1111 * and hence we donot want to trigger an upgrade. 1112 */ 1113 err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap); 1114 if (err) 1115 return (err); 1116 1117 if (!zap->zap_ismicro) { 1118 zap_name_t *zn = zap_name_alloc(zap, name, MT_EXACT); 1119 if (zn) { 1120 err = fzap_count_write(zn, add, towrite, 1121 tooverwrite); 1122 zap_name_free(zn); 1123 } else { 1124 /* 1125 * We treat this case as similar to (name == NULL) 1126 */ 1127 *towrite += (3 + (add ? 4 : 0)) * SPA_MAXBLOCKSIZE; 1128 } 1129 } else { 1130 /* 1131 * We are here if (name != NULL) and this is a micro-zap. 1132 * We account for the header block depending on whether it 1133 * is freeable. 1134 * 1135 * Incase of an add-operation it is hard to find out 1136 * if this add will promote this microzap to fatzap. 1137 * Hence, we consider the worst case and account for the 1138 * blocks assuming this microzap would be promoted to a 1139 * fatzap. 1140 * 1141 * 1 block overwritten : header block 1142 * 4 new blocks written : 2 new split leaf, 2 grown 1143 * ptrtbl blocks 1144 */ 1145 if (dmu_buf_freeable(zap->zap_dbuf)) 1146 *tooverwrite += SPA_MAXBLOCKSIZE; 1147 else 1148 *towrite += SPA_MAXBLOCKSIZE; 1149 1150 if (add) { 1151 *towrite += 4 * SPA_MAXBLOCKSIZE; 1152 } 1153 } 1154 1155 zap_unlockdir(zap); 1156 return (err); 1157} |
|