fellow_log: Rename lbuf_mempool -> logblk_mempool

parent 6f575650
...@@ -413,8 +413,7 @@ assert_seq_macros(void) ...@@ -413,8 +413,7 @@ assert_seq_macros(void)
#define LBUF_DSKPOOL_SIZE \ #define LBUF_DSKPOOL_SIZE \
((((1<<13) - 16) - 2 * sizeof(struct buddy_reqs)) / \ ((((1<<13) - 16) - 2 * sizeof(struct buddy_reqs)) / \
(2 * sizeof(struct i_reqalloc))) (2 * sizeof(struct i_reqalloc)))
// XXX is 4 a good number? #define LOGBLK_MEMPOOL_SIZE 4
#define LBUF_MEMPOOL_SIZE 4
//lint -e{506, 527} //lint -e{506, 527}
static void __attribute__((constructor)) static void __attribute__((constructor))
assert_lbuf_dsk_resv(void) assert_lbuf_dsk_resv(void)
...@@ -427,14 +426,25 @@ BUDDY_POOL(lbuf_dskpool, LBUF_DSKPOOL_SIZE); ...@@ -427,14 +426,25 @@ BUDDY_POOL(lbuf_dskpool, LBUF_DSKPOOL_SIZE);
// this is the memory request for dskpool // this is the memory request for dskpool
BUDDY_REQS(lbuf_dskpool_mem_s, 1); BUDDY_REQS(lbuf_dskpool_mem_s, 1);
// mem block pool // mem block pool
BUDDY_POOL(lbuf_mempool, LBUF_MEMPOOL_SIZE); BUDDY_POOL(logblk_mempool, LOGBLK_MEMPOOL_SIZE);
BUDDY_POOL_GET_FUNC(lbuf_mempool, static) BUDDY_POOL_GET_FUNC(logblk_mempool, static)
BUDDY_POOL_AVAIL_FUNC(lbuf_mempool, static) BUDDY_POOL_AVAIL_FUNC(logblk_mempool, static)
// memory for flush_finish // memory for flush_finish
BUDDY_POOL(lbuf_ffpool, 4); BUDDY_POOL(lbuf_ffpool, 4);
BUDDY_POOL_GET_FUNC(lbuf_ffpool, static) BUDDY_POOL_GET_FUNC(lbuf_ffpool, static)
BUDDY_POOL_AVAIL_FUNC(lbuf_ffpool, static) BUDDY_POOL_AVAIL_FUNC(lbuf_ffpool, static)
static void
logblk_mempool_fill(struct buddy_reqs *reqs, const void *priv)
{
unsigned u;
(void) priv;
for (u = 0; u < reqs->space; u++)
AN(buddy_req_page(reqs, MIN_FELLOW_BITS, 0));
}
struct fellow_logbuffer { struct fellow_logbuffer {
unsigned magic; unsigned magic;
#define FELLOW_LOGBUFFER_MAGIC 0xe8454b5a #define FELLOW_LOGBUFFER_MAGIC 0xe8454b5a
...@@ -474,7 +484,7 @@ struct fellow_logbuffer { ...@@ -474,7 +484,7 @@ struct fellow_logbuffer {
off_t tail_off; off_t tail_off;
struct fellow_logbuffer_ff *ff; struct fellow_logbuffer_ff *ff;
struct lbuf_ffpool ffpool[1]; struct lbuf_ffpool ffpool[1];
struct lbuf_mempool mempool[1]; struct logblk_mempool mempool[1];
struct lbuf_dskpool_mem_s dskpool_mem; struct lbuf_dskpool_mem_s dskpool_mem;
struct lbuf_dskpool *dskpool; struct lbuf_dskpool *dskpool;
}; };
...@@ -1077,11 +1087,6 @@ struct fellow_logcache_entry { ...@@ -1077,11 +1087,6 @@ struct fellow_logcache_entry {
off_t off; off_t off;
}; };
#define FLC_MEMPOOL_SIZE 2
BUDDY_POOL(flc_mempool, FLC_MEMPOOL_SIZE);
BUDDY_POOL_GET_FUNC(flc_mempool, static)
BUDDY_POOL_AVAIL_FUNC(flc_mempool, static)
VTAILQ_HEAD(flehead, fellow_logcache_entry); VTAILQ_HEAD(flehead, fellow_logcache_entry);
struct fellow_logcache { struct fellow_logcache {
...@@ -1096,7 +1101,7 @@ struct fellow_logcache { ...@@ -1096,7 +1101,7 @@ struct fellow_logcache {
struct fellow_fd_ioctx_lease fdil; struct fellow_fd_ioctx_lease fdil;
const struct buddy_off_extent *region; const struct buddy_off_extent *region;
struct buddy_ptr_page alloc_entry; struct buddy_ptr_page alloc_entry;
struct flc_mempool mempool[1]; struct logblk_mempool mempool[1];
struct fellow_logcache_entry *current; struct fellow_logcache_entry *current;
struct flehead free; struct flehead free;
struct flehead used; struct flehead used;
...@@ -1178,18 +1183,6 @@ fellow_logcache_fini(struct fellow_logcache *flc) ...@@ -1178,18 +1183,6 @@ fellow_logcache_fini(struct fellow_logcache *flc)
buddy_return(rets); buddy_return(rets);
} }
// dup logbuffer_fill_mempool
static void
flc_mempool_fill(struct buddy_reqs *reqs, const void *priv)
{
unsigned u;
(void) priv;
for (u = 0; u < reqs->space; u++)
AN(buddy_req_page(reqs, MIN_FELLOW_BITS, 0));
}
static void static void
fellow_logcache_init(struct fellow_logcache *flc, struct fellow_fd *ffd, fellow_logcache_init(struct fellow_logcache *flc, struct fellow_fd *ffd,
uint8_t id, const struct buddy_off_extent *region) uint8_t id, const struct buddy_off_extent *region)
...@@ -1233,7 +1226,7 @@ fellow_logcache_init(struct fellow_logcache *flc, struct fellow_fd *ffd, ...@@ -1233,7 +1226,7 @@ fellow_logcache_init(struct fellow_logcache *flc, struct fellow_fd *ffd,
sz /= sizeof *fle; sz /= sizeof *fle;
BUDDY_POOL_INIT(flc->mempool, ffd->membuddy, FEP_MEM_FLC, BUDDY_POOL_INIT(flc->mempool, ffd->membuddy, FEP_MEM_FLC,
flc_mempool_fill, NULL); logblk_mempool_fill, NULL);
assert(sz < UINT_MAX); assert(sz < UINT_MAX);
flc->n = (unsigned)sz; flc->n = (unsigned)sz;
...@@ -1331,14 +1324,14 @@ fellow_logcache_take(struct fellow_logcache *flc, int direction, int need) ...@@ -1331,14 +1324,14 @@ fellow_logcache_take(struct fellow_logcache *flc, int direction, int need)
if (fle == NULL) if (fle == NULL)
return (fellow_logcache_steal(flc, direction)); return (fellow_logcache_steal(flc, direction));
if (need == 0 && ! flc_mempool_avail(flc->mempool)) if (need == 0 && ! logblk_mempool_avail(flc->mempool))
return (NULL); return (NULL);
VTAILQ_REMOVE(&flc->free, fle, list); VTAILQ_REMOVE(&flc->free, fle, list);
AZ(fle->alloc.ptr); AZ(fle->alloc.ptr);
fle->alloc = buddy_get_next_ptr_page( fle->alloc = buddy_get_next_ptr_page(
flc_mempool_get(flc->mempool, NULL)); logblk_mempool_get(flc->mempool, NULL));
return (fle); return (fle);
} }
...@@ -2200,17 +2193,6 @@ logbuffer_recycle(struct fellow_fd *ffd, struct fellow_logbuffer *lbuf, ...@@ -2200,17 +2193,6 @@ logbuffer_recycle(struct fellow_fd *ffd, struct fellow_logbuffer *lbuf,
lbuf->head_seq[1] = 0; lbuf->head_seq[1] = 0;
} }
static void
logbuffer_fill_mempool(struct buddy_reqs *reqs, const void *priv)
{
unsigned u;
(void) priv;
for (u = 0; u < reqs->space; u++)
AN(buddy_req_page(reqs, MIN_FELLOW_BITS, 0));
}
static void static void
logbuffer_init(struct fellow_fd *ffd, struct fellow_logbuffer *lbuf, logbuffer_init(struct fellow_fd *ffd, struct fellow_logbuffer *lbuf,
struct fellow_log_region *logreg) struct fellow_log_region *logreg)
...@@ -2234,7 +2216,7 @@ logbuffer_init(struct fellow_fd *ffd, struct fellow_logbuffer *lbuf, ...@@ -2234,7 +2216,7 @@ logbuffer_init(struct fellow_fd *ffd, struct fellow_logbuffer *lbuf,
logbuffer_grow(lbuf, (uint8_t)b); logbuffer_grow(lbuf, (uint8_t)b);
BUDDY_POOL_INIT(lbuf->mempool, lbuf->membuddy, FEP_MEM_LOG, BUDDY_POOL_INIT(lbuf->mempool, lbuf->membuddy, FEP_MEM_LOG,
logbuffer_fill_mempool, lbuf); logblk_mempool_fill, lbuf);
BUDDY_POOL_INIT(lbuf->ffpool, lbuf->membuddy, FEP_MEM_LOG, BUDDY_POOL_INIT(lbuf->ffpool, lbuf->membuddy, FEP_MEM_LOG,
logbuffer_fill_ffpool, lbuf); logbuffer_fill_ffpool, lbuf);
...@@ -2251,7 +2233,7 @@ logbuffer_take(struct fellow_logbuffer *to, struct fellow_logbuffer *from) ...@@ -2251,7 +2233,7 @@ logbuffer_take(struct fellow_logbuffer *to, struct fellow_logbuffer *from)
logbuffer_wait_flush_fini(from); logbuffer_wait_flush_fini(from);
*to = *from; *to = *from;
BUDDY_POOL_INIT(to->mempool, from->membuddy, FEP_MEM_LOG, BUDDY_POOL_INIT(to->mempool, from->membuddy, FEP_MEM_LOG,
logbuffer_fill_mempool, to); logblk_mempool_fill, to);
BUDDY_POOL_INIT(to->ffpool, from->membuddy, FEP_MEM_LOG, BUDDY_POOL_INIT(to->ffpool, from->membuddy, FEP_MEM_LOG,
logbuffer_fill_ffpool, to); logbuffer_fill_ffpool, to);
...@@ -2270,10 +2252,10 @@ fellow_logblk_new( ...@@ -2270,10 +2252,10 @@ fellow_logblk_new(
struct fellow_disk_log_block *logblk; struct fellow_disk_log_block *logblk;
struct buddy_ptr_page e; struct buddy_ptr_page e;
if (wait == 0 && lbuf_mempool_avail(lbuf->mempool) == 0) if (wait == 0 && logblk_mempool_avail(lbuf->mempool) == 0)
return (NULL); return (NULL);
e = buddy_get_next_ptr_page(lbuf_mempool_get(lbuf->mempool, lbuf)); e = buddy_get_next_ptr_page(logblk_mempool_get(lbuf->mempool, lbuf));
AN(e.ptr); AN(e.ptr);
//lint -e{587} false positive, definitely -- assertion is true //lint -e{587} false positive, definitely -- assertion is true
...@@ -2646,10 +2628,10 @@ logbuffer_need_regions_to_free(struct fellow_logbuffer *lbuf) ...@@ -2646,10 +2628,10 @@ logbuffer_need_regions_to_free(struct fellow_logbuffer *lbuf)
if (lbuf->regions_to_free != NULL) if (lbuf->regions_to_free != NULL)
return; return;
if (lbuf_mempool_avail(lbuf->mempool)) { if (logblk_mempool_avail(lbuf->mempool)) {
lbuf->regions_to_free = regionlist_init( lbuf->regions_to_free = regionlist_init(
buddy_get_next_ptr_page( buddy_get_next_ptr_page(
lbuf_mempool_get(lbuf->mempool, lbuf)), logblk_mempool_get(lbuf->mempool, lbuf)),
lbuf->membuddy); lbuf->membuddy);
} }
else else
...@@ -3311,7 +3293,7 @@ logbuffer_addblks(struct fellow_fd *ffd, ...@@ -3311,7 +3293,7 @@ logbuffer_addblks(struct fellow_fd *ffd,
/* low water in mempool? /* low water in mempool?
*/ */
if (canflush && if (canflush &&
lbuf_mempool_avail(lbuf->mempool) < LBUF_MEMPOOL_SIZE) logblk_mempool_avail(lbuf->mempool) < LOGBLK_MEMPOOL_SIZE)
kick = 1; kick = 1;
/* if we run short of disk blocks (25%), we want to /* if we run short of disk blocks (25%), we want to
...@@ -6021,7 +6003,7 @@ fellow_logwatcher_need(struct fellow_fd *ffd, struct flw_need_why *why) ...@@ -6021,7 +6003,7 @@ fellow_logwatcher_need(struct fellow_fd *ffd, struct flw_need_why *why)
if (lbuf->space == 0 || lbuf->n == 0) if (lbuf->space == 0 || lbuf->n == 0)
return (FLW_NEED_NONE); return (FLW_NEED_NONE);
if (lbuf_mempool_avail(lbuf->mempool) < LBUF_MEMPOOL_SIZE) if (logblk_mempool_avail(lbuf->mempool) < LOGBLK_MEMPOOL_SIZE)
return (FLW_NEED_FLUSH); return (FLW_NEED_FLUSH);
if (lbuf->space - lbuf->n <= thr_logbuffer_minfree) if (lbuf->space - lbuf->n <= thr_logbuffer_minfree)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment