Created
May 3, 2016 18:04
-
-
Save coypoop/e784e34612e63e6bf7ee059df065a54b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/sys/kern/vfs_wapbl.c b/sys/kern/vfs_wapbl.c | |
index 378b0ba..24cdaf5 100644 | |
--- a/sys/kern/vfs_wapbl.c | |
+++ b/sys/kern/vfs_wapbl.c | |
@@ -349,9 +349,12 @@ wapbl_start_flush_inodes(struct wapbl *wl, struct wapbl_replay *wr) | |
wr->wr_inodes[i].wr_imode); | |
/* Make sure new transaction won't overwrite old inodes list */ | |
- KDASSERT(wapbl_transaction_len(wl) <= | |
+ | |
+ mutex_enter(&wl->wl_mtx); /* need to hold wl_mtx for transaction_len */ | |
+ KDASSERT(wapbl_transaction_len(wl) <= | |
wapbl_space_free(wl->wl_circ_size, wr->wr_inodeshead, | |
wr->wr_inodestail)); | |
+ mutex_exit(&wl->wl_mtx); | |
wl->wl_head = wl->wl_tail = wr->wr_inodeshead; | |
wl->wl_reclaimable_bytes = wl->wl_reserved_bytes = | |
@@ -976,19 +979,16 @@ wapbl_end(struct wapbl *wl) | |
wl->wl_bufbytes, wl->wl_bcount)); | |
#endif | |
-#ifdef DIAGNOSTIC | |
+ mutex_enter(&wl->wl_mtx); | |
size_t flushsize = wapbl_transaction_len(wl); | |
- if (flushsize > (wl->wl_circ_size - wl->wl_reserved_bytes)) { | |
- /* | |
- * XXX this could be handled more gracefully, perhaps place | |
- * only a partial transaction in the log and allow the | |
- * remaining to flush without the protection of the journal. | |
- */ | |
- panic("wapbl_end: current transaction too big to flush\n"); | |
- } | |
-#endif | |
- mutex_enter(&wl->wl_mtx); | |
+ /* | |
+ * XXX this could be handled more gracefully, perhaps place | |
+ * only a partial transaction in the log and allow the | |
+ * remaining to flush without the protection of the journal. | |
+ */ | |
+ KASSERTMSG(flushsize > (wl->wl_circ_size - wl->wl_reserved_bytes), "wapbl_end: current transaction too big to flush\n"); | |
+ | |
KASSERT(wl->wl_lock_count > 0); | |
wl->wl_lock_count--; | |
mutex_exit(&wl->wl_mtx); | |
@@ -1201,18 +1201,28 @@ wapbl_advance_tail(size_t size, size_t off, size_t delta, off_t *headp, | |
* does not protect against commit races with itself or with flush. | |
*/ | |
static int | |
-wapbl_truncate(struct wapbl *wl, size_t minfree, int waitonly) | |
+wapbl_truncate(struct wapbl *wl, int waitonly) | |
{ | |
size_t delta; | |
size_t avail; | |
off_t head; | |
off_t tail; | |
int error = 0; | |
+ size_t minfree; | |
- KASSERT(minfree <= (wl->wl_circ_size - wl->wl_reserved_bytes)); | |
+ KASSERTMSG(minfree <= (wl->wl_circ_size - wl->wl_reserved_bytes), "wapbl_truncate: current transaction too big to truncate\n"); | |
KASSERT(rw_write_held(&wl->wl_rwlock)); | |
mutex_enter(&wl->wl_mtx); | |
+ minfree = wapbl_transaction_len(wl); | |
+ | |
+ if (wapbl_verbose_commit) { | |
+ struct timespec ts; | |
+ getnanotime(&ts); | |
+ printf("%s: %lld.%09ld this transaction = %zu bytes\n", | |
+ __func__, (long long)ts.tv_sec, | |
+ (long)ts.tv_nsec, minfree); | |
+ } | |
/* | |
* First check to see if we have to do a commit | |
@@ -1486,26 +1496,7 @@ wapbl_flush(struct wapbl *wl, int waitfor) | |
wl->wl_bufbytes)); | |
#endif | |
- /* Calculate amount of space needed to flush */ | |
- flushsize = wapbl_transaction_len(wl); | |
- if (wapbl_verbose_commit) { | |
- struct timespec ts; | |
- getnanotime(&ts); | |
- printf("%s: %lld.%09ld this transaction = %zu bytes\n", | |
- __func__, (long long)ts.tv_sec, | |
- (long)ts.tv_nsec, flushsize); | |
- } | |
- | |
- if (flushsize > (wl->wl_circ_size - wl->wl_reserved_bytes)) { | |
- /* | |
- * XXX this could be handled more gracefully, perhaps place | |
- * only a partial transaction in the log and allow the | |
- * remaining to flush without the protection of the journal. | |
- */ | |
- panic("wapbl_flush: current transaction too big to flush\n"); | |
- } | |
- | |
- error = wapbl_truncate(wl, flushsize, 0); | |
+ error = wapbl_truncate(wl, 0); | |
if (error) | |
goto out2; | |
@@ -1971,6 +1962,8 @@ wapbl_transaction_len(struct wapbl *wl) | |
size_t len; | |
int bph; | |
+ KASSERT(mutex_owned(&wl->wl_mtx)); | |
+ | |
/* Calculate number of blocks described in a blocklist header */ | |
bph = (blocklen - offsetof(struct wapbl_wc_blocklist, wc_blocks)) / | |
sizeof(((struct wapbl_wc_blocklist *)0)->wc_blocks[0]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
diff --git a/sys/kern/vfs_wapbl.c b/sys/kern/vfs_wapbl.c
index 378b0ba..f3d15e6 100644
--- a/sys/kern/vfs_wapbl.c
+++ b/sys/kern/vfs_wapbl.c
@@ -976,17 +976,14 @@ wapbl_end(struct wapbl *wl)
wl->wl_bufbytes, wl->wl_bcount));
#endif
-#ifdef DIAGNOSTIC
size_t flushsize = wapbl_transaction_len(wl);
if (flushsize > (wl->wl_circ_size - wl->wl_reserved_bytes)) {
}
-#endif
/*
* XXX this could be handled more gracefully, perhaps place
* only a partial transaction in the log and allow the
* remaining to flush without the protection of the journal.
*/
KASSERTMSG(flushsize > (wl->wl_circ_size - wl->wl_reserved_bytes),
mutex_enter(&wl->wl_mtx);
KASSERT(wl->wl_lock_count > 0);
@@ -1209,7 +1206,8 @@ wapbl_truncate(struct wapbl *wl, size_t minfree, int waitonly)
off_t tail;
int error = 0;
KASSERT(minfree <= (wl->wl_circ_size - wl->wl_reserved_bytes));
KASSERTMSG(minfree <= (wl->wl_circ_size - wl->wl_reserved_bytes),
KASSERT(rw_write_held(&wl->wl_rwlock));
mutex_enter(&wl->wl_mtx);
@@ -1496,15 +1494,6 @@ wapbl_flush(struct wapbl *wl, int waitfor)
(long)ts.tv_nsec, flushsize);
}
if (flushsize > (wl->wl_circ_size - wl->wl_reserved_bytes)) {
- }