From bac808fef6f98771014e7c348121ff8460a9f1d7 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 10 Dec 2008 15:42:40 -0800 Subject: [PATCH] Use per-mount kmalloc pools for bulk data structures, particularly inodes and records. --- sys/vfs/hammer/hammer.h | 8 ++++++-- sys/vfs/hammer/hammer_blockmap.c | 8 ++++---- sys/vfs/hammer/hammer_btree.c | 35 +++++++++++++++++++++-------------- sys/vfs/hammer/hammer_cursor.c | 8 ++++++-- sys/vfs/hammer/hammer_flusher.c | 6 +++--- sys/vfs/hammer/hammer_inode.c | 21 ++++++++++++--------- sys/vfs/hammer/hammer_object.c | 10 ++++++---- sys/vfs/hammer/hammer_ondisk.c | 28 +++++++++++++++++----------- sys/vfs/hammer/hammer_reblock.c | 2 +- sys/vfs/hammer/hammer_transaction.c | 7 ++++--- sys/vfs/hammer/hammer_vfsops.c | 37 ++++++++++++++++++------------------- 11 files changed, 98 insertions(+), 72 deletions(-) diff --git a/sys/vfs/hammer/hammer.h b/sys/vfs/hammer/hammer.h index 29e33a0e35..d1055c3456 100644 --- a/sys/vfs/hammer/hammer.h +++ b/sys/vfs/hammer/hammer.h @@ -66,7 +66,6 @@ #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) MALLOC_DECLARE(M_HAMMER); -MALLOC_DECLARE(M_HAMMER_INO); /* * Kernel trace @@ -691,6 +690,10 @@ struct hammer_mount { struct hammer_volume *rootvol; struct hammer_base_elm root_btree_beg; struct hammer_base_elm root_btree_end; + + struct malloc_type *m_misc; + struct malloc_type *m_inodes; + int flags; /* HAMMER_MOUNT_xxx flags */ int hflags; int ronly; @@ -957,7 +960,8 @@ int btree_set_parent(hammer_transaction_t trans, hammer_node_t node, hammer_btree_elm_t elm); int hammer_btree_lock_children(hammer_cursor_t cursor, struct hammer_node_locklist **locklistp); -void hammer_btree_unlock_children(struct hammer_node_locklist **locklistp); +void hammer_btree_unlock_children(hammer_cursor_t cursor, + struct hammer_node_locklist **locklistp); int hammer_btree_search_node(hammer_base_elm_t elm, hammer_node_ondisk_t node); hammer_node_t hammer_btree_get_parent(hammer_node_t node, int *parent_indexp, int *errorp, int try_exclusive); diff --git a/sys/vfs/hammer/hammer_blockmap.c b/sys/vfs/hammer/hammer_blockmap.c index a4656d90cb..bfbd81db3e 100644 --- a/sys/vfs/hammer/hammer_blockmap.c +++ b/sys/vfs/hammer/hammer_blockmap.c @@ -498,7 +498,7 @@ again: ++resv->refs; resx = NULL; } else { - resx = kmalloc(sizeof(*resv), M_HAMMER, + resx = kmalloc(sizeof(*resv), hmp->m_misc, M_WAITOK | M_ZERO | M_USE_RESERVE); resx->refs = 1; resx->zone = zone; @@ -588,7 +588,7 @@ hammer_blockmap_reserve_complete(hammer_mount_t hmp, hammer_reserve_t resv) if (--resv->refs == 0) { KKASSERT((resv->flags & HAMMER_RESF_ONDELAY) == 0); RB_REMOVE(hammer_res_rb_tree, &hmp->rb_resv_root, resv); - kfree(resv, M_HAMMER); + kfree(resv, hmp->m_misc); --hammer_count_reservations; } } @@ -613,7 +613,7 @@ hammer_reserve_setdelay(hammer_mount_t hmp, hammer_off_t base_offset, again: resv = RB_LOOKUP(hammer_res_rb_tree, &hmp->rb_resv_root, base_offset); if (resv == NULL) { - resv = kmalloc(sizeof(*resv), M_HAMMER, + resv = kmalloc(sizeof(*resv), hmp->m_misc, M_WAITOK | M_ZERO | M_USE_RESERVE); resv->zone_offset = base_offset; resv->refs = 0; @@ -621,7 +621,7 @@ again: if (layer2->bytes_free == HAMMER_LARGEBLOCK_SIZE) resv->flags |= HAMMER_RESF_LAYER2FREE; if (RB_INSERT(hammer_res_rb_tree, &hmp->rb_resv_root, resv)) { - kfree(resv, M_HAMMER); + kfree(resv, hmp->m_misc); goto again; } ++hammer_count_reservations; diff --git a/sys/vfs/hammer/hammer_btree.c b/sys/vfs/hammer/hammer_btree.c index c85b9c0f33..f3543fa303 100644 --- a/sys/vfs/hammer/hammer_btree.c +++ b/sys/vfs/hammer/hammer_btree.c @@ -661,10 +661,10 @@ hammer_btree_last(hammer_cursor_t cursor) int hammer_btree_extract(hammer_cursor_t cursor, int flags) { - hammer_mount_t hmp; hammer_node_ondisk_t node; hammer_btree_elm_t elm; hammer_off_t data_off; + hammer_mount_t hmp; int32_t data_len; int error; @@ -1611,7 +1611,7 @@ btree_split_internal(hammer_cursor_t cursor) &cursor->node->ondisk->elms[cursor->node->ondisk->count].internal.base) >= 0); done: - hammer_btree_unlock_children(&locklist); + hammer_btree_unlock_children(cursor, &locklist); hammer_cursor_downgrade(cursor); return (error); } @@ -1868,6 +1868,7 @@ TAILQ_HEAD(hammer_rhb_list, hammer_rhb); int hammer_btree_correct_rhb(hammer_cursor_t cursor, hammer_tid_t tid) { + struct hammer_mount *hmp; struct hammer_rhb_list rhb_list; hammer_base_elm_t elm; hammer_node_t orig_node; @@ -1876,6 +1877,7 @@ hammer_btree_correct_rhb(hammer_cursor_t cursor, hammer_tid_t tid) int error; TAILQ_INIT(&rhb_list); + hmp = cursor->trans->hmp; /* * Save our position so we can restore it on return. This also @@ -1908,7 +1910,7 @@ hammer_btree_correct_rhb(hammer_cursor_t cursor, hammer_tid_t tid) if (cursor->right_bound->create_tid >= tid) break; - rhb = kmalloc(sizeof(*rhb), M_HAMMER, M_WAITOK|M_ZERO); + rhb = kmalloc(sizeof(*rhb), hmp->m_misc, M_WAITOK|M_ZERO); rhb->node = cursor->parent; rhb->index = cursor->parent_index; hammer_ref_node(rhb->node); @@ -1931,7 +1933,7 @@ hammer_btree_correct_rhb(hammer_cursor_t cursor, hammer_tid_t tid) TAILQ_REMOVE(&rhb_list, rhb, entry); hammer_unlock(&rhb->node->lock); hammer_rel_node(rhb->node); - kfree(rhb, M_HAMMER); + kfree(rhb, hmp->m_misc); switch (cursor->node->ondisk->type) { case HAMMER_BTREE_TYPE_INTERNAL: @@ -1959,7 +1961,7 @@ hammer_btree_correct_rhb(hammer_cursor_t cursor, hammer_tid_t tid) TAILQ_REMOVE(&rhb_list, rhb, entry); hammer_unlock(&rhb->node->lock); hammer_rel_node(rhb->node); - kfree(rhb, M_HAMMER); + kfree(rhb, hmp->m_misc); } error = hammer_cursor_seek(cursor, orig_node, orig_index); hammer_unlock(&orig_node->lock); @@ -1980,9 +1982,11 @@ hammer_btree_correct_lhb(hammer_cursor_t cursor, hammer_tid_t tid) hammer_base_elm_t elm; hammer_base_elm_t cmp; struct hammer_rhb *rhb; + struct hammer_mount *hmp; int error; TAILQ_INIT(&rhb_list); + hmp = cursor->trans->hmp; cmp = &cursor->node->ondisk->elms[cursor->index].base; @@ -1992,7 +1996,7 @@ hammer_btree_correct_lhb(hammer_cursor_t cursor, hammer_tid_t tid) */ error = 0; for (;;) { - rhb = kmalloc(sizeof(*rhb), M_HAMMER, M_WAITOK|M_ZERO); + rhb = kmalloc(sizeof(*rhb), hmp->m_misc, M_WAITOK|M_ZERO); rhb->node = cursor->node; rhb->index = cursor->index; hammer_ref_node(rhb->node); @@ -2039,7 +2043,7 @@ hammer_btree_correct_lhb(hammer_cursor_t cursor, hammer_tid_t tid) TAILQ_REMOVE(&rhb_list, rhb, entry); hammer_unlock(&rhb->node->lock); hammer_rel_node(rhb->node); - kfree(rhb, M_HAMMER); + kfree(rhb, hmp->m_misc); elm = &cursor->node->ondisk->elms[cursor->index].base; if (cursor->node->ondisk->type == HAMMER_BTREE_TYPE_INTERNAL) { @@ -2060,7 +2064,7 @@ hammer_btree_correct_lhb(hammer_cursor_t cursor, hammer_tid_t tid) TAILQ_REMOVE(&rhb_list, rhb, entry); hammer_unlock(&rhb->node->lock); hammer_rel_node(rhb->node); - kfree(rhb, M_HAMMER); + kfree(rhb, hmp->m_misc); } return (error); } @@ -2437,12 +2441,14 @@ hammer_btree_lock_children(hammer_cursor_t cursor, hammer_node_ondisk_t ondisk; hammer_btree_elm_t elm; hammer_node_t child; + struct hammer_mount *hmp; int error; int i; node = cursor->node; ondisk = node->ondisk; error = 0; + hmp = cursor->trans->hmp; /* * We really do not want to block on I/O with exclusive locks held, @@ -2455,7 +2461,7 @@ hammer_btree_lock_children(hammer_cursor_t cursor, elm->base.btype != HAMMER_BTREE_TYPE_INTERNAL) { continue; } - child = hammer_get_node(node->hmp, + child = hammer_get_node(hmp, elm->internal.subtree_offset, 0, &error); if (child) @@ -2473,7 +2479,7 @@ hammer_btree_lock_children(hammer_cursor_t cursor, case HAMMER_BTREE_TYPE_INTERNAL: case HAMMER_BTREE_TYPE_LEAF: KKASSERT(elm->internal.subtree_offset != 0); - child = hammer_get_node(node->hmp, + child = hammer_get_node(hmp, elm->internal.subtree_offset, 0, &error); break; @@ -2491,7 +2497,7 @@ hammer_btree_lock_children(hammer_cursor_t cursor, hammer_rel_node(child); } else { item = kmalloc(sizeof(*item), - M_HAMMER, M_WAITOK); + hmp->m_misc, M_WAITOK); item->next = *locklistp; item->node = child; *locklistp = item; @@ -2499,7 +2505,7 @@ hammer_btree_lock_children(hammer_cursor_t cursor, } } if (error) - hammer_btree_unlock_children(locklistp); + hammer_btree_unlock_children(cursor, locklistp); return(error); } @@ -2508,7 +2514,8 @@ hammer_btree_lock_children(hammer_cursor_t cursor, * Release previously obtained node locks. */ void -hammer_btree_unlock_children(struct hammer_node_locklist **locklistp) +hammer_btree_unlock_children(hammer_cursor_t cursor, + struct hammer_node_locklist **locklistp) { hammer_node_locklist_t item; @@ -2516,7 +2523,7 @@ hammer_btree_unlock_children(struct hammer_node_locklist **locklistp) *locklistp = item->next; hammer_unlock(&item->node->lock); hammer_rel_node(item->node); - kfree(item, M_HAMMER); + kfree(item, cursor->trans->hmp->m_misc); } } diff --git a/sys/vfs/hammer/hammer_cursor.c b/sys/vfs/hammer/hammer_cursor.c index 214d36927c..72b12401b2 100644 --- a/sys/vfs/hammer/hammer_cursor.c +++ b/sys/vfs/hammer/hammer_cursor.c @@ -624,8 +624,10 @@ hammer_push_cursor(hammer_cursor_t ocursor) hammer_cursor_t ncursor; hammer_inode_t ip; hammer_node_t node; + hammer_mount_t hmp; - ncursor = kmalloc(sizeof(*ncursor), M_HAMMER, M_WAITOK | M_ZERO); + hmp = ocursor->trans->hmp; + ncursor = kmalloc(sizeof(*ncursor), hmp->m_misc, M_WAITOK | M_ZERO); bcopy(ocursor, ncursor, sizeof(*ocursor)); node = ocursor->node; @@ -659,14 +661,16 @@ hammer_push_cursor(hammer_cursor_t ocursor) void hammer_pop_cursor(hammer_cursor_t ocursor, hammer_cursor_t ncursor) { + hammer_mount_t hmp; hammer_inode_t ip; + hmp = ncursor->trans->hmp; ip = ncursor->ip; ncursor->ip = NULL; if (ip) --ip->cursor_ip_refs; hammer_done_cursor(ncursor); - kfree(ncursor, M_HAMMER); + kfree(ncursor, hmp->m_misc); KKASSERT(ocursor->ip == ip); hammer_lock_cursor(ocursor, 0); } diff --git a/sys/vfs/hammer/hammer_flusher.c b/sys/vfs/hammer/hammer_flusher.c index c7fdfcf470..b167c5187f 100644 --- a/sys/vfs/hammer/hammer_flusher.c +++ b/sys/vfs/hammer/hammer_flusher.c @@ -153,7 +153,7 @@ hammer_flusher_create(hammer_mount_t hmp) lwkt_create(hammer_flusher_master_thread, hmp, &hmp->flusher.td, NULL, 0, -1, "hammer-M"); for (i = 0; i < HAMMER_MAX_FLUSHERS; ++i) { - info = kmalloc(sizeof(*info), M_HAMMER, M_WAITOK|M_ZERO); + info = kmalloc(sizeof(*info), hmp->m_misc, M_WAITOK|M_ZERO); info->hmp = hmp; TAILQ_INSERT_TAIL(&hmp->flusher.ready_list, info, entry); lwkt_create(hammer_flusher_slave_thread, info, @@ -187,7 +187,7 @@ hammer_flusher_destroy(hammer_mount_t hmp) while (info->td) tsleep(&info->td, 0, "hmrwwc", 0); TAILQ_REMOVE(&hmp->flusher.ready_list, info, entry); - kfree(info, M_HAMMER); + kfree(info, hmp->m_misc); } } @@ -370,7 +370,7 @@ hammer_flusher_flush(hammer_mount_t hmp) KKASSERT(TAILQ_EMPTY(&flg->flush_list)); KKASSERT(flg->refs == 0); TAILQ_REMOVE(&hmp->flush_group_list, flg, flush_entry); - kfree(flg, M_HAMMER); + kfree(flg, hmp->m_misc); break; } } diff --git a/sys/vfs/hammer/hammer_inode.c b/sys/vfs/hammer/hammer_inode.c index a909f28271..18abae7418 100644 --- a/sys/vfs/hammer/hammer_inode.c +++ b/sys/vfs/hammer/hammer_inode.c @@ -373,7 +373,7 @@ loop: /* * Allocate a new inode structure and deal with races later. */ - ip = kmalloc(sizeof(*ip), M_HAMMER_INO, M_WAITOK|M_ZERO); + ip = kmalloc(sizeof(*ip), hmp->m_inodes, M_WAITOK|M_ZERO); ++hammer_count_inodes; ++hmp->count_inodes; ip->obj_id = obj_id; @@ -507,7 +507,7 @@ hammer_create_inode(hammer_transaction_t trans, struct vattr *vap, hmp = trans->hmp; - ip = kmalloc(sizeof(*ip), M_HAMMER_INO, M_WAITOK|M_ZERO); + ip = kmalloc(sizeof(*ip), hmp->m_inodes, M_WAITOK|M_ZERO); ++hammer_count_inodes; ++hmp->count_inodes; @@ -666,6 +666,9 @@ hammer_create_inode(hammer_transaction_t trans, struct vattr *vap, static void hammer_free_inode(hammer_inode_t ip) { + struct hammer_mount *hmp; + + hmp = ip->hmp; KKASSERT(ip->lock.refs == 1); hammer_uncache_node(&ip->cache[0]); hammer_uncache_node(&ip->cache[1]); @@ -673,12 +676,12 @@ hammer_free_inode(hammer_inode_t ip) if (ip->objid_cache) hammer_clear_objid(ip); --hammer_count_inodes; - --ip->hmp->count_inodes; + --hmp->count_inodes; if (ip->pfsm) { - hammer_rel_pseudofs(ip->hmp, ip->pfsm); + hammer_rel_pseudofs(hmp, ip->pfsm); ip->pfsm = NULL; } - kfree(ip, M_HAMMER_INO); + kfree(ip, hmp->m_inodes); ip = NULL; } @@ -720,7 +723,7 @@ retry: ip = NULL; } - pfsm = kmalloc(sizeof(*pfsm), M_HAMMER, M_WAITOK | M_ZERO); + pfsm = kmalloc(sizeof(*pfsm), hmp->m_misc, M_WAITOK | M_ZERO); pfsm->localization = localization; pfsm->pfsd.unique_uuid = trans->rootvol->ondisk->vol_fsid; pfsm->pfsd.shared_uuid = pfsm->pfsd.unique_uuid; @@ -762,7 +765,7 @@ retry: if (ip) hammer_rel_inode(ip, 0); if (RB_INSERT(hammer_pfs_rb_tree, &hmp->rb_pfsm_root, pfsm)) { - kfree(pfsm, M_HAMMER); + kfree(pfsm, hmp->m_misc); goto retry; } return(pfsm); @@ -910,7 +913,7 @@ hammer_rel_pseudofs(hammer_mount_t hmp, hammer_pseudofs_inmem_t pfsm) hammer_unref(&pfsm->lock); if (pfsm->lock.refs == 0) { RB_REMOVE(hammer_pfs_rb_tree, &hmp->rb_pfsm_root, pfsm); - kfree(pfsm, M_HAMMER); + kfree(pfsm, hmp->m_misc); } } @@ -1386,7 +1389,7 @@ hammer_flush_inode(hammer_inode_t ip, int flags) hammer_flusher_async(ip->hmp, flg); } if (flg == NULL) { - flg = kmalloc(sizeof(*flg), M_HAMMER, M_WAITOK|M_ZERO); + flg = kmalloc(sizeof(*flg), hmp->m_misc, M_WAITOK|M_ZERO); hmp->next_flush_group = flg; TAILQ_INIT(&flg->flush_list); TAILQ_INSERT_TAIL(&hmp->flush_group_list, flg, flush_entry); diff --git a/sys/vfs/hammer/hammer_object.c b/sys/vfs/hammer/hammer_object.c index 461f80a666..aca7a2929e 100644 --- a/sys/vfs/hammer/hammer_object.c +++ b/sys/vfs/hammer/hammer_object.c @@ -249,9 +249,11 @@ hammer_record_t hammer_alloc_mem_record(hammer_inode_t ip, int data_len) { hammer_record_t record; + hammer_mount_t hmp; + hmp = ip->hmp; ++hammer_count_records; - record = kmalloc(sizeof(*record), M_HAMMER, + record = kmalloc(sizeof(*record), hmp->m_misc, M_WAITOK | M_ZERO | M_USE_RESERVE); record->flush_state = HAMMER_FST_IDLE; record->ip = ip; @@ -260,7 +262,7 @@ hammer_alloc_mem_record(hammer_inode_t ip, int data_len) hammer_ref(&record->lock); if (data_len) { - record->data = kmalloc(data_len, M_HAMMER, M_WAITOK | M_ZERO); + record->data = kmalloc(data_len, hmp->m_misc, M_WAITOK | M_ZERO); record->flags |= HAMMER_RECF_ALLOCDATA; ++hammer_count_record_datas; } @@ -415,7 +417,7 @@ hammer_rel_mem_record(struct hammer_record *record) if (record->flags & HAMMER_RECF_ALLOCDATA) { --hammer_count_record_datas; - kfree(record->data, M_HAMMER); + kfree(record->data, hmp->m_misc); record->flags &= ~HAMMER_RECF_ALLOCDATA; } @@ -438,7 +440,7 @@ hammer_rel_mem_record(struct hammer_record *record) } record->data = NULL; --hammer_count_records; - kfree(record, M_HAMMER); + kfree(record, hmp->m_misc); } } } diff --git a/sys/vfs/hammer/hammer_ondisk.c b/sys/vfs/hammer/hammer_ondisk.c index b6873d24d6..9bf7872c94 100644 --- a/sys/vfs/hammer/hammer_ondisk.c +++ b/sys/vfs/hammer/hammer_ondisk.c @@ -117,8 +117,8 @@ hammer_install_volume(struct hammer_mount *hmp, const char *volname, * Allocate a volume structure */ ++hammer_count_volumes; - volume = kmalloc(sizeof(*volume), M_HAMMER, M_WAITOK|M_ZERO); - volume->vol_name = kstrdup(volname, M_HAMMER); + volume = kmalloc(sizeof(*volume), hmp->m_misc, M_WAITOK|M_ZERO); + volume->vol_name = kstrdup(volname, hmp->m_misc); volume->io.hmp = hmp; /* bootstrap */ hammer_io_init(&volume->io, volume, HAMMER_STRUCTURE_VOLUME); volume->io.offset = 0LL; @@ -265,7 +265,7 @@ hammer_adjust_volume_mode(hammer_volume_t volume, void *data __unused) int hammer_unload_volume(hammer_volume_t volume, void *data __unused) { - struct hammer_mount *hmp = volume->io.hmp; + hammer_mount_t hmp = volume->io.hmp; int ronly = ((hmp->mp->mnt_flag & MNT_RDONLY) ? 1 : 0); struct buf *bp; @@ -338,8 +338,10 @@ static void hammer_free_volume(hammer_volume_t volume) { + hammer_mount_t hmp = volume->io.hmp; + if (volume->vol_name) { - kfree(volume->vol_name, M_HAMMER); + kfree(volume->vol_name, hmp->m_misc); volume->vol_name = NULL; } if (volume->devvp) { @@ -347,7 +349,7 @@ hammer_free_volume(hammer_volume_t volume) volume->devvp = NULL; } --hammer_count_volumes; - kfree(volume, M_HAMMER); + kfree(volume, hmp->m_misc); } /* @@ -611,7 +613,7 @@ again: * Allocate a new buffer structure. We will check for races later. */ ++hammer_count_buffers; - buffer = kmalloc(sizeof(*buffer), M_HAMMER, + buffer = kmalloc(sizeof(*buffer), hmp->m_misc, M_WAITOK|M_ZERO|M_USE_RESERVE); buffer->zone2_offset = zone2_offset; buffer->zoneX_offset = buf_offset; @@ -629,7 +631,7 @@ again: if (RB_INSERT(hammer_buf_rb_tree, &hmp->rb_bufs_root, buffer)) { hammer_unref(&buffer->io.lock); --hammer_count_buffers; - kfree(buffer, M_HAMMER); + kfree(buffer, hmp->m_misc); goto again; } ++hammer_count_refedbufs; @@ -860,9 +862,12 @@ void hammer_rel_buffer(hammer_buffer_t buffer, int flush) { hammer_volume_t volume; + hammer_mount_t hmp; struct buf *bp = NULL; int freeme = 0; + hmp = buffer->io.hmp; + crit_enter(); if (buffer->io.lock.refs == 1) { ++buffer->io.loading; /* force interlock check */ @@ -903,7 +908,7 @@ hammer_rel_buffer(hammer_buffer_t buffer, int flush) brelse(bp); if (freeme) { --hammer_count_buffers; - kfree(buffer, M_HAMMER); + kfree(buffer, hmp->m_misc); } } @@ -1057,14 +1062,14 @@ again: node = RB_LOOKUP(hammer_nod_rb_tree, &hmp->rb_nods_root, node_offset); if (node == NULL) { ++hammer_count_nodes; - node = kmalloc(sizeof(*node), M_HAMMER, M_WAITOK|M_ZERO|M_USE_RESERVE); + node = kmalloc(sizeof(*node), hmp->m_misc, M_WAITOK|M_ZERO|M_USE_RESERVE); node->node_offset = node_offset; node->hmp = hmp; TAILQ_INIT(&node->cursor_list); TAILQ_INIT(&node->cache_list); if (RB_INSERT(hammer_nod_rb_tree, &hmp->rb_nods_root, node)) { --hammer_count_nodes; - kfree(node, M_HAMMER); + kfree(node, hmp->m_misc); goto again; } } @@ -1290,6 +1295,7 @@ hammer_flush_node(hammer_node_t node) { hammer_node_cache_t cache; hammer_buffer_t buffer; + hammer_mount_t hmp = node->hmp; while ((cache = TAILQ_FIRST(&node->cache_list)) != NULL) { TAILQ_REMOVE(&node->cache_list, cache, entry); @@ -1304,7 +1310,7 @@ hammer_flush_node(hammer_node_t node) /* buffer is unreferenced because ondisk is NULL */ } --hammer_count_nodes; - kfree(node, M_HAMMER); + kfree(node, hmp->m_misc); } } diff --git a/sys/vfs/hammer/hammer_reblock.c b/sys/vfs/hammer/hammer_reblock.c index 30527984fb..d000e669e9 100644 --- a/sys/vfs/hammer/hammer_reblock.c +++ b/sys/vfs/hammer/hammer_reblock.c @@ -554,7 +554,7 @@ hammer_reblock_int_node(struct hammer_ioc_reblock *reblock, hammer_rel_node(onode); done: - hammer_btree_unlock_children(&locklist); + hammer_btree_unlock_children(cursor, &locklist); return (error); } diff --git a/sys/vfs/hammer/hammer_transaction.c b/sys/vfs/hammer/hammer_transaction.c index 1f888fc778..01ff37c3a8 100644 --- a/sys/vfs/hammer/hammer_transaction.c +++ b/sys/vfs/hammer/hammer_transaction.c @@ -174,7 +174,8 @@ hammer_alloc_objid(hammer_mount_t hmp, hammer_inode_t dip) while ((ocp = dip->objid_cache) == NULL) { if (hmp->objid_cache_count < OBJID_CACHE_SIZE) { - ocp = kmalloc(sizeof(*ocp), M_HAMMER, M_WAITOK|M_ZERO); + ocp = kmalloc(sizeof(*ocp), hmp->m_misc, + M_WAITOK|M_ZERO); ocp->next_tid = hammer_alloc_tid(hmp, OBJID_CACHE_BULK); ocp->count = OBJID_CACHE_BULK; TAILQ_INSERT_HEAD(&hmp->objid_cache_list, ocp, entry); @@ -205,7 +206,7 @@ hammer_alloc_objid(hammer_mount_t hmp, hammer_inode_t dip) dip->objid_cache = NULL; --hmp->objid_cache_count; ocp->dip = NULL; - kfree(ocp, M_HAMMER); + kfree(ocp, hmp->m_misc); } else { TAILQ_INSERT_TAIL(&hmp->objid_cache_list, ocp, entry); } @@ -234,7 +235,7 @@ hammer_destroy_objid_cache(hammer_mount_t hmp) TAILQ_REMOVE(&hmp->objid_cache_list, ocp, entry); if (ocp->dip) ocp->dip->objid_cache = NULL; - kfree(ocp, M_HAMMER); + kfree(ocp, hmp->m_misc); } } diff --git a/sys/vfs/hammer/hammer_vfsops.c b/sys/vfs/hammer/hammer_vfsops.c index a625c3b2bb..46f9ca8f2c 100644 --- a/sys/vfs/hammer/hammer_vfsops.c +++ b/sys/vfs/hammer/hammer_vfsops.c @@ -251,8 +251,7 @@ static struct vfsops hammer_vfsops = { .vfs_checkexp = hammer_vfs_checkexp }; -MALLOC_DEFINE(M_HAMMER, "hammer-general", "hammer general"); -MALLOC_DEFINE(M_HAMMER_INO, "hammer-inodes", "hammer inodes"); +MALLOC_DEFINE(M_HAMMER, "HAMMER-mount", ""); VFS_SET(hammer_vfsops, hammer, 0); MODULE_VERSION(hammer, 1); @@ -292,22 +291,7 @@ hammer_vfs_mount(struct mount *mp, char *mntpt, caddr_t data, int error; int i; int master_id; - - /* - * Make sure kmalloc type limits are set appropriately. If root - * increases the vnode limit you may have to do a dummy remount - * to adjust the HAMMER inode limit. - */ - { - int maxinodes; - - maxinodes = desiredvnodes + desiredvnodes / 5 + - HAMMER_RECLAIM_WAIT; - - kmalloc_raise_limit(M_HAMMER_INO, - maxinodes * sizeof(struct hammer_inode)); - } - + int maxinodes; /* * Accept hammer_mount_info. mntpt is NULL for root mounts at boot. @@ -368,6 +352,19 @@ hammer_vfs_mount(struct mount *mp, char *mntpt, caddr_t data, hmp->mp = mp; /*TAILQ_INIT(&hmp->recycle_list);*/ + /* + * Make sure kmalloc type limits are set appropriately. If root + * increases the vnode limit you may have to do a dummy remount + * to adjust the HAMMER inode limit. + */ + kmalloc_create(&hmp->m_misc, "HAMMER-others"); + kmalloc_create(&hmp->m_inodes, "HAMMER-inodes"); + + maxinodes = desiredvnodes + desiredvnodes / 5 + + HAMMER_RECLAIM_WAIT; + kmalloc_raise_limit(hmp->m_inodes, + maxinodes * sizeof(struct hammer_inode)); + hmp->root_btree_beg.localization = 0x00000000U; hmp->root_btree_beg.obj_id = -0x8000000000000000LL; hmp->root_btree_beg.key = -0x8000000000000000LL; @@ -727,7 +724,7 @@ hammer_free_hmp(struct mount *mp) kprintf("HAMMER: Warning, flush_group %p was " "not empty on umount!\n", flg); } - kfree(flg, M_HAMMER); + kfree(flg, hmp->m_misc); } /* @@ -754,6 +751,8 @@ hammer_free_hmp(struct mount *mp) mp->mnt_flag &= ~MNT_LOCAL; hmp->mp = NULL; hammer_destroy_objid_cache(hmp); + kmalloc_destroy(&hmp->m_misc); + kmalloc_destroy(&hmp->m_inodes); kfree(hmp, M_HAMMER); } -- 2.11.4.GIT