FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
/*
 * Loan out an arc_buf for read.  Return the loaned arc_buf.
 */
Loan out an arc_buf for read.  Return the loaned arc_buf.
Loan out an arc_buf for read . Return the loaned arc_buf .
arc_buf_t *
dbuf_loan_arcbuf(dmu_buf_impl_t *db)
{
	arc_buf_t *abuf;
	mutex_enter(&db->db_mtx);
	if (arc_released(db->db_buf) || refcount_count(&db->db_holds) > 1) {
		int blksz = db->db.db_size;
		spa_t *spa = db->db_objset->os_spa;
		mutex_exit(&db->db_mtx);
		abuf = arc_loan_buf(spa, blksz);
		bcopy(db->db.db_data, abuf->b_data, blksz);
	} else {
		abuf = db->db_buf;
		arc_loan_inuse_buf(abuf, db);
		dbuf_clear_data(db);
		mutex_exit(&db->db_mtx);
	}
	return (abuf);
}
arc_buf_t * dbuf_loan_arcbuf ( dmu_buf_impl_t * db ) { arc_buf_t * abuf ; mutex_enter ( & db -> db_mtx ) ; if ( arc_released ( db -> db_buf ) || refcount_count ( & db -> db_holds ) > 1 ) { int blksz = db -> db . db_size ; spa_t * spa = db -> db_objset -> os_spa ; mutex_exit ( & db -> db_mtx ) ; abuf = arc_loan_buf ( spa , blksz ) ; bcopy ( db -> db . db_data , abuf -> b_data , blksz ) ; } else { abuf = db -> db_buf ; arc_loan_inuse_buf ( abuf , db ) ; dbuf_clear_data ( db ) ; mutex_exit ( & db -> db_mtx ) ; } return ( abuf ) ; }
Loan out an arc_buf for read.
Loan out an arc_buf for read .