MCPcopy Create free account
hub / github.com/F-Stack/f-stack / dnode_diduse_space

Function dnode_diduse_space

freebsd/contrib/openzfs/module/zfs/dnode.c:2317–2343  ·  view source on GitHub ↗

call from syncing context when we actually write/free space for this dnode */

Source from the content-addressed store, hash-verified

2315
2316/* call from syncing context when we actually write/free space for this dnode */
2317void
2318dnode_diduse_space(dnode_t *dn, int64_t delta)
2319{
2320 uint64_t space;
2321 dprintf_dnode(dn, "dn=%p dnp=%p used=%llu delta=%lld\n",
2322 dn, dn->dn_phys,
2323 (u_longlong_t)dn->dn_phys->dn_used,
2324 (longlong_t)delta);
2325
2326 mutex_enter(&dn->dn_mtx);
2327 space = DN_USED_BYTES(dn->dn_phys);
2328 if (delta > 0) {
2329 ASSERT3U(space + delta, >=, space); /* no overflow */
2330 } else {
2331 ASSERT3U(space, >=, -delta); /* no underflow */
2332 }
2333 space += delta;
2334 if (spa_version(dn->dn_objset->os_spa) < SPA_VERSION_DNODE_BYTES) {
2335 ASSERT((dn->dn_phys->dn_flags & DNODE_FLAG_USED_BYTES) == 0);
2336 ASSERT0(P2PHASE(space, 1<<DEV_BSHIFT));
2337 dn->dn_phys->dn_used = space >> DEV_BSHIFT;
2338 } else {
2339 dn->dn_phys->dn_used = space;
2340 dn->dn_phys->dn_flags |= DNODE_FLAG_USED_BYTES;
2341 }
2342 mutex_exit(&dn->dn_mtx);
2343}
2344
2345/*
2346 * Scans a block at the indicated "level" looking for a hole or data,

Callers 3

dbuf_lightweight_readyFunction · 0.85
dbuf_write_readyFunction · 0.85
free_blocksFunction · 0.85

Calls 3

mutex_enterFunction · 0.85
spa_versionFunction · 0.85
mutex_exitFunction · 0.85

Tested by

no test coverage detected