Skip to content

Instantly share code, notes, and snippets.

@coypoop
Last active May 19, 2016 01:47
Show Gist options
  • Save coypoop/9bb83a306c8164fbae252ec75313efd4 to your computer and use it in GitHub Desktop.
Save coypoop/9bb83a306c8164fbae252ec75313efd4 to your computer and use it in GitHub Desktop.
From 6a6fc08c59d07446c7133941a2b28593f02f48cc Mon Sep 17 00:00:00 2001
From: coypu <coypu@sdf.org>
Date: Thu, 19 May 2016 03:01:28 +0300
Subject: [PATCH 1/1] Simplify buffer error handling case.
Don't bother advancing the log when errors occur.
---
sys/kern/vfs_wapbl.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/sys/kern/vfs_wapbl.c b/sys/kern/vfs_wapbl.c
index 41797f0..e983fb6 100644
--- a/sys/kern/vfs_wapbl.c
+++ b/sys/kern/vfs_wapbl.c
@@ -1323,9 +1323,10 @@ wapbl_truncate(struct wapbl *wl, size_t minfree)
return 0;
}
minfree -= avail;
- while ((wl->wl_error_count == 0) &&
- (wl->wl_reclaimable_bytes < minfree)) {
- WAPBL_PRINTF(WAPBL_PRINT_TRUNCATE,
+ while (wl->wl_reclaimable_bytes < minfree) {
+ if (wl->wl_error_count != 0)
+ break;
+ WAPBL_PRINTF(WAPBL_PRINT_TRUNCATE,
("wapbl_truncate: sleeping on %p wl=%p bytes=%zd "
"minfree=%zd\n",
&wl->wl_reclaimable_bytes, wl, wl->wl_reclaimable_bytes,
@@ -1333,11 +1334,12 @@ wapbl_truncate(struct wapbl *wl, size_t minfree)
cv_wait(&wl->wl_reclaimable_cv, &wl->wl_mtx);
}
- if (wl->wl_reclaimable_bytes < minfree) {
+ if (wl->wl_error_count != 0) {
KASSERT(wl->wl_error_count);
/* XXX maybe get actual error from buffer instead someday? */
- error = EIO;
+ return EIO;
}
+
head = wl->wl_head;
tail = wl->wl_tail;
delta = wl->wl_reclaimable_bytes;
@@ -1356,9 +1358,6 @@ wapbl_truncate(struct wapbl *wl, size_t minfree)
wapbl_space_used(wl->wl_circ_size, head, tail));
mutex_exit(&wl->wl_mtx);
- if (error)
- return error;
-
/*
* This is where head, tail and delta are unprotected
* from races against itself or flush. This is ok since
--
2.8.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment