]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/miscfs/nullfs/null_subr.c
xnu-7195.101.1.tar.gz
[apple/xnu.git] / bsd / miscfs / nullfs / null_subr.c
index caffb546ae3eee8e0bdc121468e343b53773064b..4561bec50a4e787ab7fcadf6575b8cd535b4cd93 100644 (file)
 #define NULL_NHASH(vp) (&null_node_hashtbl[((((uintptr_t)vp) >> vnsz2log) + (uintptr_t)vnode_mount(vp)) & null_hash_mask])
 
 static LIST_HEAD(null_node_hashhead, null_node) * null_node_hashtbl;
-static lck_mtx_t null_hashmtx;
-static lck_attr_t * null_hashlck_attr;
-static lck_grp_t * null_hashlck_grp;
-static lck_grp_attr_t * null_hashlck_grp_attr;
+static LCK_GRP_DECLARE(null_hashlck_grp, "com.apple.filesystems.nullfs");
+static LCK_MTX_DECLARE(null_hashmtx, &null_hashlck_grp);
 static u_long null_hash_mask;
 
 /* os x doesn't have hashes built into vnode. gonna try doing what freebsd does
@@ -97,26 +95,16 @@ static int vnsz2log = 9;
 
 static int null_hashins(struct mount *, struct null_node *, struct vnode **);
 
-int
+void
 nullfs_init_lck(lck_mtx_t * lck)
 {
-       int error = 1;
-       if (lck && null_hashlck_grp && null_hashlck_attr) {
-               lck_mtx_init(lck, null_hashlck_grp, null_hashlck_attr);
-               error = 0;
-       }
-       return error;
+       lck_mtx_init(lck, &null_hashlck_grp, LCK_ATTR_NULL);
 }
 
-int
+void
 nullfs_destroy_lck(lck_mtx_t * lck)
 {
-       int error = 1;
-       if (lck && null_hashlck_grp) {
-               lck_mtx_destroy(lck, null_hashlck_grp);
-               error = 0;
-       }
-       return error;
+       lck_mtx_destroy(lck, &null_hashlck_grp);
 }
 
 /*
@@ -126,62 +114,17 @@ int
 nullfs_init(__unused struct vfsconf * vfsp)
 {
        NULLFSDEBUG("%s\n", __FUNCTION__);
-
-       /* assuming for now that this happens immediately and by default after fs
-        * installation */
-       null_hashlck_grp_attr = lck_grp_attr_alloc_init();
-       if (null_hashlck_grp_attr == NULL) {
-               goto error;
-       }
-       null_hashlck_grp = lck_grp_alloc_init("com.apple.filesystems.nullfs", null_hashlck_grp_attr);
-       if (null_hashlck_grp == NULL) {
-               goto error;
-       }
-       null_hashlck_attr = lck_attr_alloc_init();
-       if (null_hashlck_attr == NULL) {
-               goto error;
-       }
-
-       lck_mtx_init(&null_hashmtx, null_hashlck_grp, null_hashlck_attr);
        null_node_hashtbl = hashinit(NULL_HASH_SIZE, M_TEMP, &null_hash_mask);
        NULLFSDEBUG("%s finished\n", __FUNCTION__);
        return 0;
-error:
-       printf("NULLFS: failed to get lock element\n");
-       if (null_hashlck_grp_attr) {
-               lck_grp_attr_free(null_hashlck_grp_attr);
-               null_hashlck_grp_attr = NULL;
-       }
-       if (null_hashlck_grp) {
-               lck_grp_free(null_hashlck_grp);
-               null_hashlck_grp = NULL;
-       }
-       if (null_hashlck_attr) {
-               lck_attr_free(null_hashlck_attr);
-               null_hashlck_attr = NULL;
-       }
-       return KERN_FAILURE;
 }
 
 int
-nullfs_uninit()
+nullfs_uninit(void)
 {
        /* This gets called when the fs is uninstalled, there wasn't an exact
         * equivalent in vfsops */
-       lck_mtx_destroy(&null_hashmtx, null_hashlck_grp);
        hashdestroy(null_node_hashtbl, M_TEMP, null_hash_mask);
-       if (null_hashlck_grp_attr) {
-               lck_grp_attr_free(null_hashlck_grp_attr);
-               null_hashlck_grp_attr = NULL;
-       }
-       if (null_hashlck_grp) {
-               lck_grp_free(null_hashlck_grp);
-               null_hashlck_grp = NULL;
-       }
-       if (null_hashlck_attr) {
-               lck_attr_free(null_hashlck_attr);
-               null_hashlck_attr = NULL;
-       }
        return 0;
 }