Add linux kernel disk support

Native Linux vdev disk interfaces

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
This commit is contained in:
Brian Behlendorf
2010-08-26 11:45:02 -07:00
parent 325f023544
commit 60101509ee
27 changed files with 2575 additions and 116 deletions
+49 -8
View File
@@ -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);
/*
* Create shares directory
*/
error = zfs_create_share_dir(&zfsvfs, tx);
ASSERT(error == 0);
for (i = 0; i != ZFS_OBJ_MTX_SZ; i++)
mutex_destroy(&zfsvfs.z_hold_mtx[i]);
#else
/*
* 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);
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);
dmu_buf_rele(db, FTAG);
#endif /* HAVE_ZPL */
}
#endif /* _KERNEL */