usr/src/uts/common/fs/zfs/zfs_vfsops.c
changeset 6083 23e77aa611b1
parent 5648 161f8007cab9
child 6404 6377536e1718
equal deleted inserted replaced
6082:30337f24796b 6083:23e77aa611b1
    17  * information: Portions Copyright [yyyy] [name of copyright owner]
    17  * information: Portions Copyright [yyyy] [name of copyright owner]
    18  *
    18  *
    19  * CDDL HEADER END
    19  * CDDL HEADER END
    20  */
    20  */
    21 /*
    21 /*
    22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
    22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
    23  * Use is subject to license terms.
    23  * Use is subject to license terms.
    24  */
    24  */
    25 
    25 
    26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
    26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
    27 
    27 
   622 		zfsvfs->z_log = zil_open(zfsvfs->z_os, zfs_get_data);
   622 		zfsvfs->z_log = zil_open(zfsvfs->z_os, zfs_get_data);
   623 
   623 
   624 	return (0);
   624 	return (0);
   625 }
   625 }
   626 
   626 
       
   627 static void
       
   628 zfs_freezfsvfs(zfsvfs_t *zfsvfs)
       
   629 {
       
   630 	mutex_destroy(&zfsvfs->z_znodes_lock);
       
   631 	mutex_destroy(&zfsvfs->z_online_recv_lock);
       
   632 	list_destroy(&zfsvfs->z_all_znodes);
       
   633 	rrw_destroy(&zfsvfs->z_teardown_lock);
       
   634 	rw_destroy(&zfsvfs->z_teardown_inactive_lock);
       
   635 	rw_destroy(&zfsvfs->z_fuid_lock);
       
   636 	kmem_free(zfsvfs, sizeof (zfsvfs_t));
       
   637 }
       
   638 
   627 static int
   639 static int
   628 zfs_domount(vfs_t *vfsp, char *osname, cred_t *cr)
   640 zfs_domount(vfs_t *vfsp, char *osname, cred_t *cr)
   629 {
   641 {
   630 	dev_t mount_dev;
   642 	dev_t mount_dev;
   631 	uint64_t recordsize, readonly;
   643 	uint64_t recordsize, readonly;
   648 	zfsvfs->z_assign = TXG_NOWAIT;
   660 	zfsvfs->z_assign = TXG_NOWAIT;
   649 	zfsvfs->z_max_blksz = SPA_MAXBLOCKSIZE;
   661 	zfsvfs->z_max_blksz = SPA_MAXBLOCKSIZE;
   650 	zfsvfs->z_show_ctldir = ZFS_SNAPDIR_VISIBLE;
   662 	zfsvfs->z_show_ctldir = ZFS_SNAPDIR_VISIBLE;
   651 
   663 
   652 	mutex_init(&zfsvfs->z_znodes_lock, NULL, MUTEX_DEFAULT, NULL);
   664 	mutex_init(&zfsvfs->z_znodes_lock, NULL, MUTEX_DEFAULT, NULL);
       
   665 	mutex_init(&zfsvfs->z_online_recv_lock, NULL, MUTEX_DEFAULT, NULL);
   653 	list_create(&zfsvfs->z_all_znodes, sizeof (znode_t),
   666 	list_create(&zfsvfs->z_all_znodes, sizeof (znode_t),
   654 	    offsetof(znode_t, z_link_node));
   667 	    offsetof(znode_t, z_link_node));
   655 	rrw_init(&zfsvfs->z_teardown_lock);
   668 	rrw_init(&zfsvfs->z_teardown_lock);
   656 	rw_init(&zfsvfs->z_teardown_inactive_lock, NULL, RW_DEFAULT, NULL);
   669 	rw_init(&zfsvfs->z_teardown_inactive_lock, NULL, RW_DEFAULT, NULL);
   657 	rw_init(&zfsvfs->z_fuid_lock, NULL, RW_DEFAULT, NULL);
   670 	rw_init(&zfsvfs->z_fuid_lock, NULL, RW_DEFAULT, NULL);
   736 		zfsctl_create(zfsvfs);
   749 		zfsctl_create(zfsvfs);
   737 out:
   750 out:
   738 	if (error) {
   751 	if (error) {
   739 		if (zfsvfs->z_os)
   752 		if (zfsvfs->z_os)
   740 			dmu_objset_close(zfsvfs->z_os);
   753 			dmu_objset_close(zfsvfs->z_os);
   741 		mutex_destroy(&zfsvfs->z_znodes_lock);
   754 		zfs_freezfsvfs(zfsvfs);
   742 		list_destroy(&zfsvfs->z_all_znodes);
       
   743 		rrw_destroy(&zfsvfs->z_teardown_lock);
       
   744 		rw_destroy(&zfsvfs->z_teardown_inactive_lock);
       
   745 		rw_destroy(&zfsvfs->z_fuid_lock);
       
   746 		kmem_free(zfsvfs, sizeof (zfsvfs_t));
       
   747 	} else {
   755 	} else {
   748 		atomic_add_32(&zfs_active_fs_count, 1);
   756 		atomic_add_32(&zfs_active_fs_count, 1);
   749 	}
   757 	}
   750 
   758 
   751 	return (error);
   759 	return (error);
  1143  * and 'z_teardown_inactive_lock' held.
  1151  * and 'z_teardown_inactive_lock' held.
  1144  */
  1152  */
  1145 static int
  1153 static int
  1146 zfsvfs_teardown(zfsvfs_t *zfsvfs, boolean_t unmounting)
  1154 zfsvfs_teardown(zfsvfs_t *zfsvfs, boolean_t unmounting)
  1147 {
  1155 {
  1148 	objset_t *os = zfsvfs->z_os;
       
  1149 	znode_t	*zp;
  1156 	znode_t	*zp;
  1150 
  1157 
  1151 	rrw_enter(&zfsvfs->z_teardown_lock, RW_WRITER, FTAG);
  1158 	rrw_enter(&zfsvfs->z_teardown_lock, RW_WRITER, FTAG);
  1152 
  1159 
  1153 	if (!unmounting) {
  1160 	if (!unmounting) {
  1223 	zfs_unregister_callbacks(zfsvfs);
  1230 	zfs_unregister_callbacks(zfsvfs);
  1224 
  1231 
  1225 	/*
  1232 	/*
  1226 	 * Evict cached data
  1233 	 * Evict cached data
  1227 	 */
  1234 	 */
  1228 	if (dmu_objset_evict_dbufs(os)) {
  1235 	if (dmu_objset_evict_dbufs(zfsvfs->z_os)) {
  1229 		txg_wait_synced(dmu_objset_pool(zfsvfs->z_os), 0);
  1236 		txg_wait_synced(dmu_objset_pool(zfsvfs->z_os), 0);
  1230 		(void) dmu_objset_evict_dbufs(os);
  1237 		(void) dmu_objset_evict_dbufs(zfsvfs->z_os);
  1231 	}
  1238 	}
  1232 
  1239 
  1233 	return (0);
  1240 	return (0);
  1234 }
  1241 }
  1235 
  1242 
  1480 	int i;
  1487 	int i;
  1481 
  1488 
  1482 	for (i = 0; i != ZFS_OBJ_MTX_SZ; i++)
  1489 	for (i = 0; i != ZFS_OBJ_MTX_SZ; i++)
  1483 		mutex_destroy(&zfsvfs->z_hold_mtx[i]);
  1490 		mutex_destroy(&zfsvfs->z_hold_mtx[i]);
  1484 
  1491 
  1485 	mutex_destroy(&zfsvfs->z_znodes_lock);
       
  1486 	list_destroy(&zfsvfs->z_all_znodes);
       
  1487 	rrw_destroy(&zfsvfs->z_teardown_lock);
       
  1488 	rw_destroy(&zfsvfs->z_teardown_inactive_lock);
       
  1489 	zfs_fuid_destroy(zfsvfs);
  1492 	zfs_fuid_destroy(zfsvfs);
  1490 	rw_destroy(&zfsvfs->z_fuid_lock);
  1493 	zfs_freezfsvfs(zfsvfs);
  1491 	kmem_free(zfsvfs, sizeof (zfsvfs_t));
       
  1492 
  1494 
  1493 	atomic_add_32(&zfs_active_fs_count, -1);
  1495 	atomic_add_32(&zfs_active_fs_count, -1);
  1494 }
  1496 }
  1495 
  1497 
  1496 /*
  1498 /*