fellow_logs_rewrite: allocate pending logbuffer outside mtx

parent 9fdee0f7
......@@ -5387,13 +5387,32 @@ fellow_logs_rewrite(struct fellow_fd *ffd,
bfa->bitfs = bitfs_init(bfamem, sizeof bfamem);
bfa->mem = (struct buddy_ptr_extent[BITFMAXSEGS]){{0}};
bfa->lmem = BITFMAXSEGS;
//flexelint
memset(lbuf_pend, 0, sizeof lbuf_pend);
/*
* we put in place as the global buffer our temporary buffer
* backed by the pending region, which ultimately it is going to
* get appended to the rewritten global buffer.
*/
if (ffd->phase == FP_OPEN) {
logreg = &ffd->logreg[pend_region(log_info->region)];
logregion_reset(logreg);
logbuffer_init(ffd, lbuf_pend, logreg);
}
bfa_alloc(bfa);
AZ(pthread_mutex_lock(&ffd->logmtx));
if (fellow_logs_rewriting(ffd)) {
AZ(pthread_mutex_unlock(&ffd->logmtx));
ffd->diag("... (raced)\n");
bfa_free(bfa);
assert(lbuf_pend->state == LBUF_INIT);
lbuf_pend->state = LBUF_FINI;
logbuffer_fini(lbuf_pend);
return;
}
ffd->rewriting = 1;
......@@ -5428,15 +5447,6 @@ fellow_logs_rewrite(struct fellow_fd *ffd,
AZ(log_info->off.pendblk);
AZ(pendblk_off);
/*
* we put in place as the global buffer our temporary buffer
* backed by the pending region, which ultimately it is going to
* get appended to the rewritten global buffer.
*/
logreg = &ffd->logreg[pend_region(log_info->region)];
logregion_reset(logreg);
logbuffer_init(ffd, lbuf_pend, logreg);
assert(lbuf_pend->state == LBUF_INIT);
lbuf_pend->state = LBUF_PEND;
......
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