1293 break;
1294 case ARC_SPACE_OTHER:
1295 ARCSTAT_INCR(arcstat_other_size, -space);
1296 break;
1297 case ARC_SPACE_HDRS:
1298 ARCSTAT_INCR(arcstat_hdr_size, -space);
1299 break;
1300 case ARC_SPACE_L2HDRS:
1301 ARCSTAT_INCR(arcstat_l2_hdr_size, -space);
1302 break;
1303 }
1304
1305 ASSERT(arc_meta_used >= space);
1306 if (arc_meta_max < arc_meta_used)
1307 arc_meta_max = arc_meta_used;
1308 ARCSTAT_INCR(arcstat_meta_used, -space);
1309 ASSERT(arc_size >= space);
1310 atomic_add_64(&arc_size, -space);
1311 }
1312
1313 void *
1314 arc_data_buf_alloc(uint64_t size)
1315 {
1316 if (arc_evict_needed(ARC_BUFC_DATA))
1317 cv_signal(&arc_reclaim_thr_cv);
1318 atomic_add_64(&arc_size, size);
1319 return (zio_data_buf_alloc(size));
1320 }
1321
1322 void
1323 arc_data_buf_free(void *buf, uint64_t size)
1324 {
1325 zio_data_buf_free(buf, size);
1326 ASSERT(arc_size >= size);
1327 atomic_add_64(&arc_size, -size);
1328 }
1329
1330 arc_buf_t *
1331 arc_buf_alloc(spa_t *spa, int size, void *tag, arc_buf_contents_t type)
1332 {
1333 arc_buf_hdr_t *hdr;
1334 arc_buf_t *buf;
1335
1336 ASSERT3U(size, >, 0);
1337 hdr = kmem_cache_alloc(hdr_cache, KM_PUSHPAGE);
1338 ASSERT(BUF_EMPTY(hdr));
1339 hdr->b_size = size;
1340 hdr->b_type = type;
1341 hdr->b_spa = spa_load_guid(spa);
1342 hdr->b_state = arc_anon;
1343 hdr->b_arc_access = 0;
1344 buf = kmem_cache_alloc(buf_cache, KM_PUSHPAGE);
1345 buf->b_hdr = hdr;
1346 buf->b_data = NULL;
1347 buf->b_efunc = NULL;
1348 buf->b_private = NULL;
1349 buf->b_next = NULL;
|
1293 break;
1294 case ARC_SPACE_OTHER:
1295 ARCSTAT_INCR(arcstat_other_size, -space);
1296 break;
1297 case ARC_SPACE_HDRS:
1298 ARCSTAT_INCR(arcstat_hdr_size, -space);
1299 break;
1300 case ARC_SPACE_L2HDRS:
1301 ARCSTAT_INCR(arcstat_l2_hdr_size, -space);
1302 break;
1303 }
1304
1305 ASSERT(arc_meta_used >= space);
1306 if (arc_meta_max < arc_meta_used)
1307 arc_meta_max = arc_meta_used;
1308 ARCSTAT_INCR(arcstat_meta_used, -space);
1309 ASSERT(arc_size >= space);
1310 atomic_add_64(&arc_size, -space);
1311 }
1312
1313 arc_buf_t *
1314 arc_buf_alloc(spa_t *spa, int size, void *tag, arc_buf_contents_t type)
1315 {
1316 arc_buf_hdr_t *hdr;
1317 arc_buf_t *buf;
1318
1319 ASSERT3U(size, >, 0);
1320 hdr = kmem_cache_alloc(hdr_cache, KM_PUSHPAGE);
1321 ASSERT(BUF_EMPTY(hdr));
1322 hdr->b_size = size;
1323 hdr->b_type = type;
1324 hdr->b_spa = spa_load_guid(spa);
1325 hdr->b_state = arc_anon;
1326 hdr->b_arc_access = 0;
1327 buf = kmem_cache_alloc(buf_cache, KM_PUSHPAGE);
1328 buf->b_hdr = hdr;
1329 buf->b_data = NULL;
1330 buf->b_efunc = NULL;
1331 buf->b_private = NULL;
1332 buf->b_next = NULL;
|