Skip to content

Instantly share code, notes, and snippets.

@coypoop
Last active May 7, 2016 18:20
Show Gist options
  • Save coypoop/b8bd5156b3ea11e3995ad9ce6c977d1a to your computer and use it in GitHub Desktop.
Save coypoop/b8bd5156b3ea11e3995ad9ce6c977d1a to your computer and use it in GitHub Desktop.
From 3faeec917d0777ae302c5119d62b26ff8a559fbc Mon Sep 17 00:00:00 2001
From: coypu <coypu@sdf.org>
Date: Sat, 7 May 2016 06:41:23 +0300
Subject: [PATCH 1/1] Rename wapbl truncate to wapbl journal trim
this name is too similar to ffs truncate, but only
trims the journal.
suggested by dholland.
---
sys/kern/vfs_wapbl.c | 38 +++++++++++++++++++-------------------
sys/sys/wapbl.h | 2 +-
sys/ufs/ufs/ufs_inode.c | 4 ++--
3 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/sys/kern/vfs_wapbl.c b/sys/kern/vfs_wapbl.c
index 19f8171..db7ea78 100644
--- a/sys/kern/vfs_wapbl.c
+++ b/sys/kern/vfs_wapbl.c
@@ -132,9 +132,9 @@ struct wapbl {
* head == tail == 0 means log is empty
* head == tail != 0 means log is full
* see assertions in wapbl_advance() for other boundary conditions.
- * only truncate moves the tail, except when flush sets it to
- * wl_header_size only flush moves the head, except when truncate
- * sets it to 0.
+ * only journal trim moves the tail, except when flush sets it to
+ * wl_header_size only flush moves the head, except when journal
+ * trim sets it to 0.
*/
struct wapbl_wc_header *wl_wc_header; /* l */
@@ -166,9 +166,9 @@ struct wapbl {
kcondvar_t wl_reclaimable_cv; /* m (obviously) */
size_t wl_reclaimable_bytes; /* m: Amount of space available for
- reclamation by truncate */
+ reclamation by trim */
int wl_error_count; /* m: # of wl_entries with errors */
- size_t wl_reserved_bytes; /* never truncate log smaller than this */
+ size_t wl_reserved_bytes; /* never trim log smaller than this */
#ifdef WAPBL_DEBUG_BUFBYTES
size_t wl_unsynced_bufbytes; /* Byte count of unsynced buffers */
@@ -243,9 +243,9 @@ static int wapbl_replay_isopen1(struct wapbl_replay *);
/*
* This is useful for debugging. If set, the log will
- * only be truncated when necessary.
+ * only be trimmed when necessary.
*/
-int wapbl_lazy_truncate = 0;
+int wapbl_lazy_journal_trim = 0;
struct wapbl_ops wapbl_ops = {
.wo_wapbl_discard = wapbl_discard,
@@ -407,7 +407,7 @@ wapbl_start(struct wapbl ** wlp, struct mount *mp, struct vnode *vp,
/*
* XXX check for minimum log size
* minimum is governed by minimum amount of space
- * to complete a transaction. (probably truncate)
+ * to complete a transaction. (probably trim)
*/
/* XXX for now pick something minimal */
if ((count * blksize) < MAXPHYS) {
@@ -438,7 +438,7 @@ wapbl_start(struct wapbl ** wlp, struct mount *mp, struct vnode *vp,
/* Reserve two log device blocks for the commit headers */
wl->wl_circ_off = 2<<wl->wl_log_dev_bshift;
wl->wl_circ_size = ((count * blksize) - wl->wl_circ_off);
- /* truncate the log usage to a multiple of log_dev_bshift */
+ /* trim the log usage to a multiple of log_dev_bshift */
wl->wl_circ_size >>= wl->wl_log_dev_bshift;
wl->wl_circ_size <<= wl->wl_log_dev_bshift;
@@ -1198,7 +1198,7 @@ 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 lazy_truncate)
+wapbl_journal_trim(struct wapbl *wl, size_t minfree, int lazy_journal_trim)
{
size_t delta;
size_t avail;
@@ -1223,8 +1223,8 @@ wapbl_truncate(struct wapbl *wl, size_t minfree, int lazy_truncate)
minfree -= avail;
while ((wl->wl_error_count == 0) &&
(wl->wl_reclaimable_bytes < minfree)) {
- WAPBL_PRINTF(WAPBL_PRINT_TRUNCATE,
- ("wapbl_truncate: sleeping on %p wl=%p bytes=%zd "
+ WAPBL_PRINTF(WAPBL_PRINT_JOURNAL_TRIM,
+ ("wapbl_journal_trim: sleeping on %p wl=%p bytes=%zd "
"minfree=%zd\n",
&wl->wl_reclaimable_bytes, wl, wl->wl_reclaimable_bytes,
minfree));
@@ -1258,7 +1258,7 @@ wapbl_truncate(struct wapbl *wl, size_t minfree, int lazy_truncate)
return error;
#ifdef WAPBL_DEBUG
- if (lazy_truncate)
+ if (lazy_journal_trim)
return 0;
#endif
@@ -1281,8 +1281,8 @@ wapbl_truncate(struct wapbl *wl, size_t minfree, int lazy_truncate)
KASSERT(wl->wl_reclaimable_bytes >= delta);
wl->wl_reclaimable_bytes -= delta;
mutex_exit(&wl->wl_mtx);
- WAPBL_PRINTF(WAPBL_PRINT_TRUNCATE,
- ("wapbl_truncate thread %d.%d truncating %zu bytes\n",
+ WAPBL_PRINTF(WAPBL_PRINT_JOURNAL_TRIM,
+ ("wapbl_journal_trim thread %d.%d trimming %zu bytes\n",
curproc->p_pid, curlwp->l_lid, delta));
return 0;
@@ -1504,7 +1504,7 @@ wapbl_flush(struct wapbl *wl, int waitfor)
panic("wapbl_flush: current transaction too big to flush");
}
- error = wapbl_truncate(wl, flushsize, 0);
+ error = wapbl_journal_trim(wl, flushsize, 0);
if (error)
goto abort;
@@ -1542,7 +1542,7 @@ wapbl_flush(struct wapbl *wl, int waitfor)
#endif
/* Opportunistically move the tail forward if we can */
- if (!wapbl_lazy_truncate) {
+ if (!wapbl_lazy_journal_trim) {
mutex_enter(&wl->wl_mtx);
delta = wl->wl_reclaimable_bytes;
mutex_exit(&wl->wl_mtx);
@@ -1637,8 +1637,8 @@ wapbl_flush(struct wapbl *wl, int waitfor)
* fully flushed and the on disk log is empty.
*/
if (waitfor) {
- error = wapbl_truncate(wl, wl->wl_circ_size -
- wl->wl_reserved_bytes, wapbl_lazy_truncate);
+ error = wapbl_journal_trim(wl, wl->wl_circ_size -
+ wl->wl_reserved_bytes, wapbl_lazy_journal_trim);
}
abort:
diff --git a/sys/sys/wapbl.h b/sys/sys/wapbl.h
index 87d608e..03f2048 100644
--- a/sys/sys/wapbl.h
+++ b/sys/sys/wapbl.h
@@ -62,7 +62,7 @@
enum {
WAPBL_PRINT_OPEN = 0x1,
WAPBL_PRINT_FLUSH = 0x2,
- WAPBL_PRINT_TRUNCATE = 0x4,
+ WAPBL_PRINT_JOURNAL_TRIM = 0x4,
WAPBL_PRINT_TRANSACTION = 0x8,
WAPBL_PRINT_BUFFER = 0x10,
WAPBL_PRINT_BUFFER2 = 0x20,
diff --git a/sys/ufs/ufs/ufs_inode.c b/sys/ufs/ufs/ufs_inode.c
index a1bf9a8..263e6d0 100644
--- a/sys/ufs/ufs/ufs_inode.c
+++ b/sys/ufs/ufs/ufs_inode.c
@@ -286,7 +286,7 @@ ufs_balloc_range(struct vnode *vp, off_t off, off_t len, kauth_cred_t cred,
}
static int
-ufs_wapbl_truncate(struct vnode *vp, uint64_t newsize, kauth_cred_t cred)
+ufs_wapbl_journal_trim(struct vnode *vp, uint64_t newsize, kauth_cred_t cred)
{
struct inode *ip = VTOI(vp);
int error = 0;
@@ -322,7 +322,7 @@ ufs_truncate(struct vnode *vp, uint64_t newsize, kauth_cred_t cred)
return error;
if (vp->v_mount->mnt_wapbl)
- error = ufs_wapbl_truncate(vp, newsize, cred);
+ error = ufs_wapbl_journal_trim(vp, newsize, cred);
if (error == 0)
error = UFS_TRUNCATE(vp, newsize, 0, cred);
--
2.8.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment