dbuf.c (208373) | dbuf.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 --- 313 unchanged lines hidden (view full) --- 322 ASSERT(dr == NULL || dr->dt.dl.dr_data == db->db_buf); 323 } 324 325 /* verify db->db_blkptr */ 326 if (db->db_blkptr) { 327 if (db->db_parent == dn->dn_dbuf) { 328 /* db is pointed to by the dnode */ 329 /* ASSERT3U(db->db_blkid, <, dn->dn_nblkptr); */ | 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 --- 313 unchanged lines hidden (view full) --- 322 ASSERT(dr == NULL || dr->dt.dl.dr_data == db->db_buf); 323 } 324 325 /* verify db->db_blkptr */ 326 if (db->db_blkptr) { 327 if (db->db_parent == dn->dn_dbuf) { 328 /* db is pointed to by the dnode */ 329 /* ASSERT3U(db->db_blkid, <, dn->dn_nblkptr); */ |
330 if (db->db.db_object == DMU_META_DNODE_OBJECT) | 330 if (DMU_OBJECT_IS_SPECIAL(db->db.db_object)) |
331 ASSERT(db->db_parent == NULL); 332 else 333 ASSERT(db->db_parent != NULL); 334 ASSERT3P(db->db_blkptr, ==, 335 &dn->dn_phys->dn_blkptr[db->db_blkid]); 336 } else { 337 /* db is pointed to by an indirect block */ 338 int epb = db->db_parent->db.db_size >> SPA_BLKPTRSHIFT; --- 555 unchanged lines hidden (view full) --- 894 ASSERT(tx->tx_txg != 0); 895 ASSERT(!refcount_is_zero(&db->db_holds)); 896 DMU_TX_DIRTY_BUF(tx, db); 897 898 /* 899 * Shouldn't dirty a regular buffer in syncing context. Private 900 * objects may be dirtied in syncing context, but only if they 901 * were already pre-dirtied in open context. | 331 ASSERT(db->db_parent == NULL); 332 else 333 ASSERT(db->db_parent != NULL); 334 ASSERT3P(db->db_blkptr, ==, 335 &dn->dn_phys->dn_blkptr[db->db_blkid]); 336 } else { 337 /* db is pointed to by an indirect block */ 338 int epb = db->db_parent->db.db_size >> SPA_BLKPTRSHIFT; --- 555 unchanged lines hidden (view full) --- 894 ASSERT(tx->tx_txg != 0); 895 ASSERT(!refcount_is_zero(&db->db_holds)); 896 DMU_TX_DIRTY_BUF(tx, db); 897 898 /* 899 * Shouldn't dirty a regular buffer in syncing context. Private 900 * objects may be dirtied in syncing context, but only if they 901 * were already pre-dirtied in open context. |
902 * XXX We may want to prohibit dirtying in syncing context even 903 * if they did pre-dirty. | |
904 */ 905 ASSERT(!dmu_tx_is_syncing(tx) || 906 BP_IS_HOLE(dn->dn_objset->os_rootbp) || | 902 */ 903 ASSERT(!dmu_tx_is_syncing(tx) || 904 BP_IS_HOLE(dn->dn_objset->os_rootbp) || |
907 dn->dn_object == DMU_META_DNODE_OBJECT || 908 dn->dn_objset->os_dsl_dataset == NULL || 909 dsl_dir_is_private(dn->dn_objset->os_dsl_dataset->ds_dir)); 910 | 905 DMU_OBJECT_IS_SPECIAL(dn->dn_object) || 906 dn->dn_objset->os_dsl_dataset == NULL); |
911 /* 912 * We make this assert for private objects as well, but after we 913 * check if we're already dirty. They are allowed to re-dirty 914 * in syncing context. 915 */ 916 ASSERT(dn->dn_object == DMU_META_DNODE_OBJECT || 917 dn->dn_dirtyctx == DN_UNDIRTIED || dn->dn_dirtyctx == 918 (dmu_tx_is_syncing(tx) ? DN_DIRTY_SYNC : DN_DIRTY_OPEN)); --- 41 unchanged lines hidden (view full) --- 960 } 961 mutex_exit(&db->db_mtx); 962 return (dr); 963 } 964 965 /* 966 * Only valid if not already dirty. 967 */ | 907 /* 908 * We make this assert for private objects as well, but after we 909 * check if we're already dirty. They are allowed to re-dirty 910 * in syncing context. 911 */ 912 ASSERT(dn->dn_object == DMU_META_DNODE_OBJECT || 913 dn->dn_dirtyctx == DN_UNDIRTIED || dn->dn_dirtyctx == 914 (dmu_tx_is_syncing(tx) ? DN_DIRTY_SYNC : DN_DIRTY_OPEN)); --- 41 unchanged lines hidden (view full) --- 956 } 957 mutex_exit(&db->db_mtx); 958 return (dr); 959 } 960 961 /* 962 * Only valid if not already dirty. 963 */ |
968 ASSERT(dn->dn_dirtyctx == DN_UNDIRTIED || dn->dn_dirtyctx == | 964 ASSERT(dn->dn_object == 0 || 965 dn->dn_dirtyctx == DN_UNDIRTIED || dn->dn_dirtyctx == |
969 (dmu_tx_is_syncing(tx) ? DN_DIRTY_SYNC : DN_DIRTY_OPEN)); 970 971 ASSERT3U(dn->dn_nlevels, >, db->db_level); 972 ASSERT((dn->dn_phys->dn_nlevels == 0 && db->db_level == 0) || 973 dn->dn_phys->dn_nlevels > db->db_level || 974 dn->dn_next_nlevels[txgoff] > db->db_level || 975 dn->dn_next_nlevels[(tx->tx_txg-1) & TXG_MASK] > db->db_level || 976 dn->dn_next_nlevels[(tx->tx_txg-2) & TXG_MASK] > db->db_level); 977 978 /* 979 * We should only be dirtying in syncing context if it's the | 966 (dmu_tx_is_syncing(tx) ? DN_DIRTY_SYNC : DN_DIRTY_OPEN)); 967 968 ASSERT3U(dn->dn_nlevels, >, db->db_level); 969 ASSERT((dn->dn_phys->dn_nlevels == 0 && db->db_level == 0) || 970 dn->dn_phys->dn_nlevels > db->db_level || 971 dn->dn_next_nlevels[txgoff] > db->db_level || 972 dn->dn_next_nlevels[(tx->tx_txg-1) & TXG_MASK] > db->db_level || 973 dn->dn_next_nlevels[(tx->tx_txg-2) & TXG_MASK] > db->db_level); 974 975 /* 976 * We should only be dirtying in syncing context if it's the |
980 * mos, a spa os, or we're initializing the os. However, we are 981 * allowed to dirty in syncing context provided we already 982 * dirtied it in open context. Hence we must make this 983 * assertion only if we're not already dirty. | 977 * mos or we're initializing the os or it's a special object. 978 * However, we are allowed to dirty in syncing context provided 979 * we already dirtied it in open context. Hence we must make 980 * this assertion only if we're not already dirty. |
984 */ | 981 */ |
985 ASSERT(!dmu_tx_is_syncing(tx) || 986 os->os_dsl_dataset == NULL || 987 !dsl_dir_is_private(os->os_dsl_dataset->ds_dir) || 988 !BP_IS_HOLE(os->os_rootbp)); | 982 ASSERT(!dmu_tx_is_syncing(tx) || DMU_OBJECT_IS_SPECIAL(dn->dn_object) || 983 os->os_dsl_dataset == NULL || BP_IS_HOLE(os->os_rootbp)); |
989 ASSERT(db->db.db_size != 0); 990 991 dprintf_dbuf(db, "size=%llx\n", (u_longlong_t)db->db.db_size); 992 993 if (db->db_blkid != DB_BONUS_BLKID) { 994 /* 995 * Update the accounting. 996 * Note: we delay "free accounting" until after we drop --- 283 unchanged lines hidden (view full) --- 1280 } 1281 db->db_state = DB_CACHED; 1282 cv_broadcast(&db->db_changed); 1283 } 1284 mutex_exit(&db->db_mtx); 1285} 1286 1287/* | 984 ASSERT(db->db.db_size != 0); 985 986 dprintf_dbuf(db, "size=%llx\n", (u_longlong_t)db->db.db_size); 987 988 if (db->db_blkid != DB_BONUS_BLKID) { 989 /* 990 * Update the accounting. 991 * Note: we delay "free accounting" until after we drop --- 283 unchanged lines hidden (view full) --- 1275 } 1276 db->db_state = DB_CACHED; 1277 cv_broadcast(&db->db_changed); 1278 } 1279 mutex_exit(&db->db_mtx); 1280} 1281 1282/* |
1283 * Directly assign a provided arc buf to a given dbuf if it's not referenced 1284 * by anybody except our caller. Otherwise copy arcbuf's contents to dbuf. 1285 */ 1286void 1287dbuf_assign_arcbuf(dmu_buf_impl_t *db, arc_buf_t *buf, dmu_tx_t *tx) 1288{ 1289 ASSERT(!refcount_is_zero(&db->db_holds)); 1290 ASSERT(db->db_dnode->dn_object != DMU_META_DNODE_OBJECT); 1291 ASSERT(db->db_blkid != DB_BONUS_BLKID); 1292 ASSERT(db->db_level == 0); 1293 ASSERT(DBUF_GET_BUFC_TYPE(db) == ARC_BUFC_DATA); 1294 ASSERT(buf != NULL); 1295 ASSERT(arc_buf_size(buf) == db->db.db_size); 1296 ASSERT(tx->tx_txg != 0); 1297 1298 arc_return_buf(buf, db); 1299 ASSERT(arc_released(buf)); 1300 1301 mutex_enter(&db->db_mtx); 1302 1303 while (db->db_state == DB_READ || db->db_state == DB_FILL) 1304 cv_wait(&db->db_changed, &db->db_mtx); 1305 1306 ASSERT(db->db_state == DB_CACHED || db->db_state == DB_UNCACHED); 1307 1308 if (db->db_state == DB_CACHED && 1309 refcount_count(&db->db_holds) - 1 > db->db_dirtycnt) { 1310 mutex_exit(&db->db_mtx); 1311 (void) dbuf_dirty(db, tx); 1312 bcopy(buf->b_data, db->db.db_data, db->db.db_size); 1313 VERIFY(arc_buf_remove_ref(buf, db) == 1); 1314 return; 1315 } 1316 1317 if (db->db_state == DB_CACHED) { 1318 dbuf_dirty_record_t *dr = db->db_last_dirty; 1319 1320 ASSERT(db->db_buf != NULL); 1321 if (dr != NULL && dr->dr_txg == tx->tx_txg) { 1322 ASSERT(dr->dt.dl.dr_data == db->db_buf); 1323 if (!arc_released(db->db_buf)) { 1324 ASSERT(dr->dt.dl.dr_override_state == 1325 DR_OVERRIDDEN); 1326 arc_release(db->db_buf, db); 1327 } 1328 dr->dt.dl.dr_data = buf; 1329 VERIFY(arc_buf_remove_ref(db->db_buf, db) == 1); 1330 } else if (dr == NULL || dr->dt.dl.dr_data != db->db_buf) { 1331 arc_release(db->db_buf, db); 1332 VERIFY(arc_buf_remove_ref(db->db_buf, db) == 1); 1333 } 1334 db->db_buf = NULL; 1335 } 1336 ASSERT(db->db_buf == NULL); 1337 dbuf_set_data(db, buf); 1338 db->db_state = DB_FILL; 1339 mutex_exit(&db->db_mtx); 1340 (void) dbuf_dirty(db, tx); 1341 dbuf_fill_done(db, tx); 1342} 1343 1344/* |
|
1288 * "Clear" the contents of this dbuf. This will mark the dbuf 1289 * EVICTING and clear *most* of its references. Unfortunetely, 1290 * when we are not holding the dn_dbufs_mtx, we can't clear the 1291 * entry in the dn_dbufs list. We have to wait until dbuf_destroy() 1292 * in this case. For callers from the DMU we will usually see: 1293 * dbuf_clear()->arc_buf_evict()->dbuf_do_evict()->dbuf_destroy() 1294 * For the arc callback, we will usually see: 1295 * dbuf_do_evict()->dbuf_clear();dbuf_destroy() --- 526 unchanged lines hidden (view full) --- 1822dmu_buf_get_user(dmu_buf_t *db_fake) 1823{ 1824 dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake; 1825 ASSERT(!refcount_is_zero(&db->db_holds)); 1826 1827 return (db->db_user_ptr); 1828} 1829 | 1345 * "Clear" the contents of this dbuf. This will mark the dbuf 1346 * EVICTING and clear *most* of its references. Unfortunetely, 1347 * when we are not holding the dn_dbufs_mtx, we can't clear the 1348 * entry in the dn_dbufs list. We have to wait until dbuf_destroy() 1349 * in this case. For callers from the DMU we will usually see: 1350 * dbuf_clear()->arc_buf_evict()->dbuf_do_evict()->dbuf_destroy() 1351 * For the arc callback, we will usually see: 1352 * dbuf_do_evict()->dbuf_clear();dbuf_destroy() --- 526 unchanged lines hidden (view full) --- 1879dmu_buf_get_user(dmu_buf_t *db_fake) 1880{ 1881 dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake; 1882 ASSERT(!refcount_is_zero(&db->db_holds)); 1883 1884 return (db->db_user_ptr); 1885} 1886 |
1887boolean_t 1888dmu_buf_freeable(dmu_buf_t *dbuf) 1889{ 1890 boolean_t res = B_FALSE; 1891 dmu_buf_impl_t *db = (dmu_buf_impl_t *)dbuf; 1892 1893 if (db->db_blkptr) 1894 res = dsl_dataset_block_freeable(db->db_objset->os_dsl_dataset, 1895 db->db_blkptr->blk_birth); 1896 1897 return (res); 1898} 1899 |
|
1830static void 1831dbuf_check_blkptr(dnode_t *dn, dmu_buf_impl_t *db) 1832{ 1833 /* ASSERT(dmu_tx_is_syncing(tx) */ 1834 ASSERT(MUTEX_HELD(&db->db_mtx)); 1835 1836 if (db->db_blkptr != NULL) 1837 return; --- 452 unchanged lines hidden --- | 1900static void 1901dbuf_check_blkptr(dnode_t *dn, dmu_buf_impl_t *db) 1902{ 1903 /* ASSERT(dmu_tx_is_syncing(tx) */ 1904 ASSERT(MUTEX_HELD(&db->db_mtx)); 1905 1906 if (db->db_blkptr != NULL) 1907 return; --- 452 unchanged lines hidden --- |