Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_subr.c
Show First 20 Lines • Show All 228 Lines • ▼ Show 20 Lines | |||||
* freevnodes | * freevnodes | ||||
*/ | */ | ||||
static struct mtx __exclusive_cache_line vnode_list_mtx; | static struct mtx __exclusive_cache_line vnode_list_mtx; | ||||
/* Publicly exported FS */ | /* Publicly exported FS */ | ||||
struct nfs_public nfs_pub; | struct nfs_public nfs_pub; | ||||
static uma_zone_t buf_trie_zone; | static uma_zone_t buf_trie_zone; | ||||
static smr_t buf_trie_smr; | |||||
/* Zone for allocation of new vnodes - used exclusively by getnewvnode() */ | /* Zone for allocation of new vnodes - used exclusively by getnewvnode() */ | ||||
static uma_zone_t vnode_zone; | static uma_zone_t vnode_zone; | ||||
static uma_zone_t vnodepoll_zone; | static uma_zone_t vnodepoll_zone; | ||||
__read_frequently smr_t vfs_smr; | __read_frequently smr_t vfs_smr; | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 241 Lines • ▼ Show 20 Lines | |||||
static int vnsz2log; | static int vnsz2log; | ||||
/* | /* | ||||
* Support for the bufobj clean & dirty pctrie. | * Support for the bufobj clean & dirty pctrie. | ||||
*/ | */ | ||||
static void * | static void * | ||||
buf_trie_alloc(struct pctrie *ptree) | buf_trie_alloc(struct pctrie *ptree) | ||||
{ | { | ||||
return uma_zalloc_smr(buf_trie_zone, M_NOWAIT); | |||||
markj: Missing parens. | |||||
return uma_zalloc(buf_trie_zone, M_NOWAIT); | |||||
} | } | ||||
static void | static void | ||||
buf_trie_free(struct pctrie *ptree, void *node) | buf_trie_free(struct pctrie *ptree, void *node) | ||||
{ | { | ||||
uma_zfree_smr(buf_trie_zone, node); | |||||
uma_zfree(buf_trie_zone, node); | |||||
} | } | ||||
PCTRIE_DEFINE(BUF, buf, b_lblkno, buf_trie_alloc, buf_trie_free); | PCTRIE_DEFINE_SMR(BUF, buf, b_lblkno, buf_trie_alloc, buf_trie_free, | ||||
buf_trie_smr); | |||||
/* | /* | ||||
* Initialize the vnode management data structures. | * Initialize the vnode management data structures. | ||||
* | * | ||||
* Reevaluate the following cap on the number of vnodes after the physical | * Reevaluate the following cap on the number of vnodes after the physical | ||||
* memory size exceeds 512GB. In the limit, as the physical memory size | * memory size exceeds 512GB. In the limit, as the physical memory size | ||||
* grows, the ratio of the memory size in KB to vnodes approaches 64:1. | * grows, the ratio of the memory size in KB to vnodes approaches 64:1. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | vnodepoll_zone = uma_zcreate("VNODEPOLL", sizeof (struct vpollinfo), | ||||
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); | NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); | ||||
/* | /* | ||||
* Preallocate enough nodes to support one-per buf so that | * Preallocate enough nodes to support one-per buf so that | ||||
* we can not fail an insert. reassignbuf() callers can not | * we can not fail an insert. reassignbuf() callers can not | ||||
* tolerate the insertion failure. | * tolerate the insertion failure. | ||||
*/ | */ | ||||
buf_trie_zone = uma_zcreate("BUF TRIE", pctrie_node_size(), | buf_trie_zone = uma_zcreate("BUF TRIE", pctrie_node_size(), | ||||
NULL, NULL, pctrie_zone_init, NULL, UMA_ALIGN_PTR, | NULL, NULL, pctrie_zone_init, NULL, UMA_ALIGN_PTR, | ||||
UMA_ZONE_NOFREE); | UMA_ZONE_NOFREE | UMA_ZONE_SMR); | ||||
buf_trie_smr = uma_zone_get_smr(buf_trie_zone); | |||||
uma_prealloc(buf_trie_zone, nbuf); | uma_prealloc(buf_trie_zone, nbuf); | ||||
vnodes_created = counter_u64_alloc(M_WAITOK); | vnodes_created = counter_u64_alloc(M_WAITOK); | ||||
recycles_count = counter_u64_alloc(M_WAITOK); | recycles_count = counter_u64_alloc(M_WAITOK); | ||||
recycles_free_count = counter_u64_alloc(M_WAITOK); | recycles_free_count = counter_u64_alloc(M_WAITOK); | ||||
deferred_inact = counter_u64_alloc(M_WAITOK); | deferred_inact = counter_u64_alloc(M_WAITOK); | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 1,638 Lines • ▼ Show 20 Lines | |||||
gbincore(struct bufobj *bo, daddr_t lblkno) | gbincore(struct bufobj *bo, daddr_t lblkno) | ||||
{ | { | ||||
struct buf *bp; | struct buf *bp; | ||||
ASSERT_BO_LOCKED(bo); | ASSERT_BO_LOCKED(bo); | ||||
bp = BUF_PCTRIE_LOOKUP(&bo->bo_clean.bv_root, lblkno); | bp = BUF_PCTRIE_LOOKUP(&bo->bo_clean.bv_root, lblkno); | ||||
if (bp != NULL) | if (bp != NULL) | ||||
return (bp); | return (bp); | ||||
return BUF_PCTRIE_LOOKUP(&bo->bo_dirty.bv_root, lblkno); | return (BUF_PCTRIE_LOOKUP(&bo->bo_dirty.bv_root, lblkno)); | ||||
} | |||||
/* | |||||
* Look up a buf using the buffer tries, without the bufobj lock. This relies | |||||
* on SMR for safe lookup, and bufs being in a no-free zone to provide type | |||||
* stability of the result. Like other lockless lookups, the found buf may | |||||
* already be invalid by the time this function returns. | |||||
*/ | |||||
struct buf * | |||||
gbincore_unlocked(struct bufobj *bo, daddr_t lblkno) | |||||
{ | |||||
struct buf *bp; | |||||
ASSERT_BO_UNLOCKED(bo); | |||||
bp = BUF_PCTRIE_LOOKUP_UNLOCKED(&bo->bo_clean.bv_root, lblkno); | |||||
if (bp != NULL) | |||||
return (bp); | |||||
return (BUF_PCTRIE_LOOKUP_UNLOCKED(&bo->bo_dirty.bv_root, lblkno)); | |||||
} | } | ||||
/* | /* | ||||
* Associate a buffer with a vnode. | * Associate a buffer with a vnode. | ||||
*/ | */ | ||||
void | void | ||||
bgetvp(struct vnode *vp, struct buf *bp) | bgetvp(struct vnode *vp, struct buf *bp) | ||||
{ | { | ||||
struct bufobj *bo; | struct bufobj *bo; | ||||
bo = &vp->v_bufobj; | bo = &vp->v_bufobj; | ||||
ASSERT_BO_WLOCKED(bo); | ASSERT_BO_WLOCKED(bo); | ||||
VNASSERT(bp->b_vp == NULL, bp->b_vp, ("bgetvp: not free")); | VNASSERT(bp->b_vp == NULL, bp->b_vp, ("bgetvp: not free")); | ||||
CTR3(KTR_BUF, "bgetvp(%p) vp %p flags %X", bp, vp, bp->b_flags); | CTR3(KTR_BUF, "bgetvp(%p) vp %p flags %X", bp, vp, bp->b_flags); | ||||
VNASSERT((bp->b_xflags & (BX_VNDIRTY|BX_VNCLEAN)) == 0, vp, | VNASSERT((bp->b_xflags & (BX_VNDIRTY|BX_VNCLEAN)) == 0, vp, | ||||
("bgetvp: bp already attached! %p", bp)); | ("bgetvp: bp already attached! %p", bp)); | ||||
Done Inline Actionsreturn () kib: return () | |||||
Done Inline Actionswill fix cem: will fix | |||||
vhold(vp); | vhold(vp); | ||||
bp->b_vp = vp; | bp->b_vp = vp; | ||||
bp->b_bufobj = bo; | bp->b_bufobj = bo; | ||||
/* | /* | ||||
* Insert onto list for new vnode. | * Insert onto list for new vnode. | ||||
*/ | */ | ||||
buf_vlist_add(bp, bo, BX_VNCLEAN); | buf_vlist_add(bp, bo, BX_VNCLEAN); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 4,201 Lines • Show Last 20 Lines |
Missing parens.