dnode_sync.c revision 347a31bcb38b51837caee115d3979d3a981cc099
0N/A * The contents of this file are subject to the terms of the 0N/A * Common Development and Distribution License (the "License"). 0N/A * You may not use this file except in compliance with the License. 0N/A * See the License for the specific language governing permissions 0N/A * and limitations under the License. 0N/A * When distributing Covered Code, include this CDDL HEADER in each 0N/A * If applicable, add the following below this CDDL HEADER, with the 0N/A * fields enclosed by brackets "[]" replaced with your own identifying 0N/A * information: Portions Copyright [yyyy] [name of copyright owner] 0N/A * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 0N/A * Use is subject to license terms. 1879N/A#
pragma ident "%Z%%M% %I% %E% SMI" 0N/A /* this dnode can't be paged out because it's dirty */ 0N/A /* copy dnode's block pointers to new indirect block */ 0N/A /* set dbuf's parent pointers to new indirect buf */ 0N/A "changing db_blkptr to new indirect %s",
"");
0N/A "changed db_blkptr to new indirect %s",
"");
0N/A /* db_data_old better be zeroed */ 0N/A "child=%p i=%d off=%d num=%d\n",
64N/A * db_data better be zeroed unless it's dirty in a 64N/A "child=%p i=%d off=%d num=%d\n",
0N/A * free_range: Traverse the indicated range of the provided file 0N/A * and "free" all the blocks contained there. 0N/A /* There are no indirect blocks in the object */ 0N/A /* this range was never made persistent */ 0N/A * Try to kick all the dnodes dbufs out of the cache... 0N/A /* dbuf_clear() may remove db from this list */ 0N/A * NB: we need to drop dn_dbufs_mtx between passes so 0N/A * that any DB_EVICTING dbufs can make progress. 0N/A * Ideally, we would have some cv we could wait on, but 0N/A * since we don't, just wait a bit to give the other 0N/A * thread a chance to run. 0N/A * This function works fine even if it can't evict everything, 0N/A * but all of our callers need this assertion, so let's put it 0N/A * here (for now). Perhaps in the future there will be a try vs 0N/A panic(
"dangling dbufs (dn=%p, dbuf=%p)\n",
0N/A /* Undirty all buffers */ 0N/A /* XXX - use dbuf_undirty()? */ 0N/A * XXX - It would be nice to assert this, but we may still 0N/A * have residual holds from async evictions from the arc... 0N/A * ASSERT3U(refcount_count(&dn->dn_holds), ==, 1); 0N/A /* Undirty next bits */ 0N/A /* free up all the blocks in the file. */ 0N/A /* ASSERT(blkptrs are zero); */ 0N/A * Now that we've released our hold, the dnode may 0N/A * be evicted, so we musn't access it. 0N/A * Write out the dnode's dirty buffers at the specified level. 0N/A * This may create more dirty buffers at the next level up. 0N/A * NOTE: The dnode is kept in memory by being dirty. Once the 0N/A * dirty bit is cleared, it may be evicted. Beware of this! 0N/A * Make sure the dbuf for the dn_phys is released before we modify it. 0N/A /* The dnode is newly allocated or reallocated */ 0N/A /* this is a first alloc, not a realloc */ 0N/A /* XXX shouldn't the phys already be zeroed? */ 0N/A /* zero the new blkptrs we are gaining */ * Just take the live (open-context) values for checksum and compress. * Strictly speaking it's a future leak, but nothing bad happens if we * start using the new checksum or compress algorithm a little early. /* process all the "freed" ranges in the file */ /* we've already synced out all data and indirect blocks */ /* there are no more dirty dbufs under this dnode */ /* XXX this is expensive. remove once 6343073 is closed. */ /* NB: the "off < maxblkid" is to catch overflow */ * NB: if blocksize is changing, we could get confused, * so only bother if there are multiple blocks and thus * Now that we've dropped the reference, the dnode may * be evicted, so we musn't access it. * Iterate over the list, removing and sync'ing dbufs * which are on the level we want, and leaving others.