summaryrefslogtreecommitdiffstats
path: root/module/zfs/zfs_znode.c
diff options
context:
space:
mode:
Diffstat (limited to 'module/zfs/zfs_znode.c')
-rw-r--r--module/zfs/zfs_znode.c51
1 files changed, 46 insertions, 5 deletions
diff --git a/module/zfs/zfs_znode.c b/module/zfs/zfs_znode.c
index 79d8d2e7e..5e6bab81a 100644
--- a/module/zfs/zfs_znode.c
+++ b/module/zfs/zfs_znode.c
@@ -88,6 +88,7 @@
* (such as VFS logic) that will not compile easily in userland.
*/
#ifdef _KERNEL
+#ifdef HAVE_ZPL
/*
* Needed to close a small window in zfs_znode_move() that allows the zfsvfs to
* be freed before it can be safely accessed.
@@ -1737,22 +1738,29 @@ log:
dmu_tx_commit(tx);
return (0);
}
+#endif /* HAVE_ZPL */
void
zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx)
{
- zfsvfs_t zfsvfs;
uint64_t moid, obj, sa_obj, version;
uint64_t sense = ZFS_CASE_SENSITIVE;
uint64_t norm = 0;
nvpair_t *elem;
int error;
+#ifdef HAVE_ZPL
+ zfsvfs_t zfsvfs;
int i;
znode_t *rootzp = NULL;
vnode_t *vp;
vattr_t vattr;
znode_t *zp;
zfs_acl_ids_t acl_ids;
+#else
+ timestruc_t now;
+ dmu_buf_t *db;
+ znode_phys_t *pzp;
+#endif /* HAVE_ZPL */
/*
* First attempt to create master node.
@@ -1814,6 +1822,7 @@ zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx)
error = zap_add(os, moid, ZFS_UNLINKED_SET, 8, 1, &obj, tx);
ASSERT(error == 0);
+#ifdef HAVE_ZPL
/*
* Create root znode. Create minimal znode/vnode/zfsvfs
* to allow zfs_mknode to work.
@@ -1879,17 +1888,49 @@ zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx)
ZTOV(rootzp)->v_count = 0;
sa_handle_destroy(rootzp->z_sa_hdl);
kmem_cache_free(znode_cache, rootzp);
+ error = zfs_create_share_dir(&zfsvfs, tx);
+ for (i = 0; i != ZFS_OBJ_MTX_SZ; i++)
+ mutex_destroy(&zfsvfs.z_hold_mtx[i]);
+#else
/*
- * Create shares directory
+ * Create root znode with code free of VFS dependencies
*/
+ obj = zap_create_norm(os, norm, DMU_OT_DIRECTORY_CONTENTS,
+ DMU_OT_ZNODE, sizeof (znode_phys_t), tx);
- error = zfs_create_share_dir(&zfsvfs, tx);
+ VERIFY(0 == dmu_bonus_hold(os, obj, FTAG, &db));
+ dmu_buf_will_dirty(db, tx);
+ /*
+ * Initialize the znode physical data to zero.
+ */
+ ASSERT(db->db_size >= sizeof (znode_phys_t));
+ bzero(db->db_data, db->db_size);
+ pzp = db->db_data;
+
+ if (USE_FUIDS(version, os))
+ pzp->zp_flags = ZFS_ARCHIVE | ZFS_AV_MODIFIED;
+
+ pzp->zp_size = 2; /* "." and ".." */
+ pzp->zp_links = 2;
+ pzp->zp_parent = obj;
+ pzp->zp_gen = dmu_tx_get_txg(tx);
+ pzp->zp_mode = S_IFDIR | 0755;
+ pzp->zp_flags = ZFS_ACL_TRIVIAL;
+
+ gethrestime(&now);
+
+ ZFS_TIME_ENCODE(&now, pzp->zp_crtime);
+ ZFS_TIME_ENCODE(&now, pzp->zp_ctime);
+ ZFS_TIME_ENCODE(&now, pzp->zp_atime);
+ ZFS_TIME_ENCODE(&now, pzp->zp_mtime);
+
+ error = zap_add(os, moid, ZFS_ROOT_OBJ, 8, 1, &obj, tx);
ASSERT(error == 0);
- for (i = 0; i != ZFS_OBJ_MTX_SZ; i++)
- mutex_destroy(&zfsvfs.z_hold_mtx[i]);
+ dmu_buf_rele(db, FTAG);
+#endif /* HAVE_ZPL */
}
#endif /* _KERNEL */