Skip to content

Instantly share code, notes, and snippets.

@coypoop
Last active May 27, 2016 19:17
Show Gist options
  • Save coypoop/29730578b31715fe7fed0815464832ab to your computer and use it in GitHub Desktop.
Save coypoop/29730578b31715fe7fed0815464832ab to your computer and use it in GitHub Desktop.
clean up wapbl_flush debugging code, feel free to rename the new function
From 2cdce88c4544c23e47a562b803f2583d3b1c949f Mon Sep 17 00:00:00 2001
From: coypu <coypu@sdf.org>
Date: Fri, 27 May 2016 22:16:35 +0300
Subject: [PATCH 1/1] Move wapbl_flush debugging code to separate function
Improves readability.
---
sys/kern/vfs_wapbl.c | 103 ++++++++++++++++++++++++++++-----------------------
1 file changed, 56 insertions(+), 47 deletions(-)
diff --git a/sys/kern/vfs_wapbl.c b/sys/kern/vfs_wapbl.c
index 49c3107..5b9c1d6 100644
--- a/sys/kern/vfs_wapbl.c
+++ b/sys/kern/vfs_wapbl.c
@@ -223,6 +223,7 @@ struct wapbl {
#ifdef WAPBL_DEBUG_PRINT
int wapbl_debug_print = WAPBL_DEBUG_PRINT;
+void wapbl_flush_debug_error(struct wapbl *wl, int error);
#endif
/****************************************************************/
@@ -1733,62 +1734,70 @@ wapbl_flush(struct wapbl *wl, int waitfor)
wl->wl_flush_abort(wl->wl_mount, wl->wl_deallocblks,
wl->wl_dealloclens, wl->wl_dealloccnt);
}
-
#ifdef WAPBL_DEBUG_PRINT
if (error) {
- pid_t pid = -1;
- lwpid_t lid = -1;
- if (curproc)
- pid = curproc->p_pid;
- if (curlwp)
- lid = curlwp->l_lid;
- mutex_enter(&wl->wl_mtx);
+ wapbl_flush_debug_error(wl, error);
+ }
+#endif
+ rw_exit(&wl->wl_rwlock);
+ return error;
+}
+
+#ifdef WAPBL_DEBUG_PRINT
+void
+wapbl_flush_debug_error(struct wapbl *wl, int error)
+{
+ struct wapbl_entry *we;
+ pid_t pid = -1;
+ lwpid_t lid = -1;
+ if (curproc)
+ pid = curproc->p_pid;
+ if (curlwp)
+ lid = curlwp->l_lid;
+ mutex_enter(&wl->wl_mtx);
#ifdef WAPBL_DEBUG_BUFBYTES
+ WAPBL_PRINTF(WAPBL_PRINT_ERROR,
+ ("wapbl_flush: thread %d.%d aborted flush: "
+ "error = %d\n"
+ "\tbufcount=%zu bufbytes=%zu bcount=%zu "
+ "deallocs=%d inodes=%d\n"
+ "\terrcnt = %d, reclaimable=%zu reserved=%zu "
+ "unsynced=%zu\n",
+ pid, lid, error, wl->wl_bufcount,
+ wl->wl_bufbytes, wl->wl_bcount,
+ wl->wl_dealloccnt, wl->wl_inohashcnt,
+ wl->wl_error_count, wl->wl_reclaimable_bytes,
+ wl->wl_reserved_bytes, wl->wl_unsynced_bufbytes));
+ SIMPLEQ_FOREACH(we, &wl->wl_entries, we_entries) {
WAPBL_PRINTF(WAPBL_PRINT_ERROR,
- ("wapbl_flush: thread %d.%d aborted flush: "
- "error = %d\n"
- "\tbufcount=%zu bufbytes=%zu bcount=%zu "
- "deallocs=%d inodes=%d\n"
- "\terrcnt = %d, reclaimable=%zu reserved=%zu "
- "unsynced=%zu\n",
- pid, lid, error, wl->wl_bufcount,
- wl->wl_bufbytes, wl->wl_bcount,
- wl->wl_dealloccnt, wl->wl_inohashcnt,
- wl->wl_error_count, wl->wl_reclaimable_bytes,
- wl->wl_reserved_bytes, wl->wl_unsynced_bufbytes));
- SIMPLEQ_FOREACH(we, &wl->wl_entries, we_entries) {
- WAPBL_PRINTF(WAPBL_PRINT_ERROR,
- ("\tentry: bufcount = %zu, reclaimable = %zu, "
- "error = %d, unsynced = %zu\n",
- we->we_bufcount, we->we_reclaimable_bytes,
- we->we_error, we->we_unsynced_bufbytes));
- }
+ ("\tentry: bufcount = %zu, reclaimable = %zu, "
+ "error = %d, unsynced = %zu\n",
+ we->we_bufcount, we->we_reclaimable_bytes,
+ we->we_error, we->we_unsynced_bufbytes));
+ }
#else
+ WAPBL_PRINTF(WAPBL_PRINT_ERROR,
+ ("wapbl_flush: thread %d.%d aborted flush: "
+ "error = %d\n"
+ "\tbufcount=%zu bufbytes=%zu bcount=%zu "
+ "deallocs=%d inodes=%d\n"
+ "\terrcnt = %d, reclaimable=%zu reserved=%zu\n",
+ pid, lid, error, wl->wl_bufcount,
+ wl->wl_bufbytes, wl->wl_bcount,
+ wl->wl_dealloccnt, wl->wl_inohashcnt,
+ wl->wl_error_count, wl->wl_reclaimable_bytes,
+ wl->wl_reserved_bytes));
+ SIMPLEQ_FOREACH(we, &wl->wl_entries, we_entries) {
WAPBL_PRINTF(WAPBL_PRINT_ERROR,
- ("wapbl_flush: thread %d.%d aborted flush: "
- "error = %d\n"
- "\tbufcount=%zu bufbytes=%zu bcount=%zu "
- "deallocs=%d inodes=%d\n"
- "\terrcnt = %d, reclaimable=%zu reserved=%zu\n",
- pid, lid, error, wl->wl_bufcount,
- wl->wl_bufbytes, wl->wl_bcount,
- wl->wl_dealloccnt, wl->wl_inohashcnt,
- wl->wl_error_count, wl->wl_reclaimable_bytes,
- wl->wl_reserved_bytes));
- SIMPLEQ_FOREACH(we, &wl->wl_entries, we_entries) {
- WAPBL_PRINTF(WAPBL_PRINT_ERROR,
- ("\tentry: bufcount = %zu, reclaimable = %zu, "
- "error = %d\n", we->we_bufcount,
- we->we_reclaimable_bytes, we->we_error));
- }
-#endif
- mutex_exit(&wl->wl_mtx);
+ ("\tentry: bufcount = %zu, reclaimable = %zu, "
+ "error = %d\n", we->we_bufcount,
+ we->we_reclaimable_bytes, we->we_error));
}
#endif
-
- rw_exit(&wl->wl_rwlock);
- return error;
+ mutex_exit(&wl->wl_mtx);
}
+#endif
+
/****************************************************************/
--
2.8.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment