tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: WAPBL not locking enough?



How about this change instead?
Still going over the rest of the function calls of wapbl_flush.

From d51a64a5e9a15169949b8f1442c79060c157536d Mon Sep 17 00:00:00 2001
From: coypu <coypu%sdf.org@localhost>
Date: Wed, 11 May 2016 13:08:06 +0300
Subject: [PATCH 1/2] assert wl_mtx held in wapbl_transaction_len

---
 sys/kern/vfs_wapbl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sys/kern/vfs_wapbl.c b/sys/kern/vfs_wapbl.c
index e63f228..e317daf 100644
--- a/sys/kern/vfs_wapbl.c
+++ b/sys/kern/vfs_wapbl.c
@@ -2098,6 +2098,9 @@ wapbl_transaction_len(struct wapbl *wl)
            sizeof(((struct wapbl_wc_blocklist *)0)->wc_blocks[0]);
 
        KASSERT(bph > 0);
+#ifdef WAPBL_DEBUG /* XXX: get rid of this eventually */
+       KASSERT(mutex_owned(&wl->wl_mtx));
+#endif
 
        len = wl->wl_bcount;
        len += howmany(wl->wl_bufcount, bph) * blocklen;
-- 
2.8.1

From fa8f55b0373747697f81c4fedc36deb93ad2e51d Mon Sep 17 00:00:00 2001
From: coypu <coypu%sdf.org@localhost>
Date: Wed, 11 May 2016 14:27:46 +0300
Subject: [PATCH 2/2] hold wl_mtx for wapbl_truncate and wl_bufcount

---
 sys/kern/vfs_wapbl.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sys/kern/vfs_wapbl.c b/sys/kern/vfs_wapbl.c
index e317daf..3d2fd4c 100644
--- a/sys/kern/vfs_wapbl.c
+++ b/sys/kern/vfs_wapbl.c
@@ -1592,6 +1592,9 @@ wapbl_flush(struct wapbl *wl, int waitfor)
         * file system didn't produce any blocks as a consequence of
         * it, but the same does not seem to be so of wl_inohashcnt.
         */
+
+       mutex_enter(&wl->wl_mtx); /* protect bufcount, truncate call */
+
        if (wl->wl_bufcount == 0) {
                goto wait_out;
        }
@@ -1624,6 +1627,9 @@ wapbl_flush(struct wapbl *wl, int waitfor)
        }
 
        error = wapbl_truncate(wl, flushsize);
+
+       mutex_exit(&wl->wl_mtx);
+
        if (error)
                goto out;
 
@@ -1753,6 +1759,7 @@ wapbl_flush(struct wapbl *wl, int waitfor)
                error = wapbl_truncate(wl, wl->wl_circ_size - 
                        wl->wl_reserved_bytes);
        }
+       mutex_exit(&wl->wl_mtx);
 
  out:
        if (error) {
-- 
2.8.1



Home | Main Index | Thread Index | Old Index