FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c
/*
 * Clean up any znodes that had no links when we either crashed or
 * (force) umounted the file system.
 */
Clean up any znodes that had no links when we either crashed or
(force) umounted the file system.
Clean up any znodes that had no links when we either crashed or ( force ) umounted the file system .
void
zfs_unlinked_drain(zfsvfs_t *zfsvfs)
{
	zap_cursor_t	zc;
	zap_attribute_t zap;
	dmu_object_info_t doi;
	znode_t		*zp;
	int		error;
	for (zap_cursor_init(&zc, zfsvfs->z_os, zfsvfs->z_unlinkedobj);
	    zap_cursor_retrieve(&zc, &zap) == 0;
	    zap_cursor_advance(&zc)) {
		error = dmu_object_info(zfsvfs->z_os,
		    zap.za_first_integer, &doi);
		if (error != 0)
			continue;
		ASSERT((doi.doi_type == DMU_OT_PLAIN_FILE_CONTENTS) ||
		    (doi.doi_type == DMU_OT_DIRECTORY_CONTENTS));
		error = zfs_zget(zfsvfs, zap.za_first_integer, &zp);
		if (error != 0)
			continue;
		vn_lock(ZTOV(zp), LK_EXCLUSIVE | LK_RETRY);
		zp->z_unlinked = B_TRUE;
		vput(ZTOV(zp));
	}
	zap_cursor_fini(&zc);
}
void zfs_unlinked_drain ( zfsvfs_t * zfsvfs ) { zap_cursor_t zc ; zap_attribute_t zap ; dmu_object_info_t doi ; znode_t * zp ; int error ; for ( zap_cursor_init ( & zc , zfsvfs -> z_os , zfsvfs -> z_unlinkedobj ) ; zap_cursor_retrieve ( & zc , & zap ) == 0 ; zap_cursor_advance ( & zc ) ) { error = dmu_object_info ( zfsvfs -> z_os , zap . za_first_integer , & doi ) ; if ( error != 0 ) continue ; ASSERT ( ( doi . doi_type == DMU_OT_PLAIN_FILE_CONTENTS ) || ( doi . doi_type == DMU_OT_DIRECTORY_CONTENTS ) ) ; error = zfs_zget ( zfsvfs , zap . za_first_integer , & zp ) ; if ( error != 0 ) continue ; vn_lock ( ZTOV ( zp ) , LK_EXCLUSIVE | LK_RETRY ) ; zp -> z_unlinked = B_TRUE ; vput ( ZTOV ( zp ) ) ; } zap_cursor_fini ( & zc ) ; }
Clean up any znodes that had no links when we either crashed or
 (force) umounted the file system.
Clean up any znodes that had no links when we either crashed or ( force ) umounted the file system .
/*
	 * Interate over the contents of the unlinked set.
	 */ /*
		 * See what kind of object we have in list
		 */ /*
		 * We need to re-mark these list entries for deletion,
		 * so we pull them back into core and set zp->z_unlinked.
		 */ /*
		 * We may pick up znodes that are already marked for deletion.
		 * This could happen during the purge of an extended attribute
		 * directory.  All we need to do is skip over them, since they
		 * are already in the system marked z_unlinked.
		 */