Module Name:    src
Committed By:   riastradh
Date:           Mon Feb 29 16:18:37 UTC 2016

Modified Files:
        src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_rlock.c

Log Message:
Sprinkle some more zfs range lock reference count kasserts.

>From a debugging session months ago, might as well share them.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
    src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_rlock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_rlock.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_rlock.c:1.4 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_rlock.c:1.5
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_rlock.c:1.4	Sat Apr 11 04:35:39 2015
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_rlock.c	Mon Feb 29 16:18:37 2016
@@ -98,6 +98,8 @@ static int
 zfs_range_lock_hold(rl_t *rl)
 {
 
+	KASSERT(rl->r_zp != NULL);
+	KASSERT(0 < rl->r_refcnt);
 	KASSERT(mutex_owned(&rl->r_zp->z_range_lock));
 
 	if (rl->r_refcnt >= ULONG_MAX)
@@ -111,8 +113,9 @@ static void
 zfs_range_lock_rele(rl_t *rl)
 {
 
+	KASSERT(rl->r_zp != NULL);
+	KASSERT(0 < rl->r_refcnt);
 	KASSERT(mutex_owned(&rl->r_zp->z_range_lock));
-	KASSERT(rl->r_refcnt > 0);
 
 	if (--rl->r_refcnt == 0) {
 		cv_destroy(&rl->r_wr_cv);
@@ -184,10 +187,12 @@ zfs_range_lock_writer(znode_t *zp, rl_t 
 			goto wait; /* already locked at same offset */
 
 		rl = (rl_t *)avl_nearest(tree, where, AVL_AFTER);
+		KASSERT(0 < rl->r_refcnt);
 		if (rl && (rl->r_off < new->r_off + new->r_len))
 			goto wait;
 
 		rl = (rl_t *)avl_nearest(tree, where, AVL_BEFORE);
+		KASSERT(0 < rl->r_refcnt);
 		if (rl && rl->r_off + rl->r_len > new->r_off)
 			goto wait;
 
@@ -345,6 +350,7 @@ zfs_range_add_reader(avl_tree_t *tree, r
 		return;
 	}
 
+	KASSERT(0 < next->r_refcnt);
 	if (off < next->r_off) {
 		/* Add a proxy for initial range before the overlap */
 		zfs_range_new_proxy(tree, off, next->r_off - off, zp);
@@ -369,17 +375,20 @@ zfs_range_add_reader(avl_tree_t *tree, r
 		if (off + len == next->r_off + next->r_len) {
 			/* exact overlap with end */
 			next = zfs_range_proxify(tree, next);
+			KASSERT(0 < next->r_refcnt);
 			next->r_cnt++;
 			return;
 		}
 		if (off + len < next->r_off + next->r_len) {
 			/* new range ends in the middle of this block */
 			next = zfs_range_split(tree, next, off + len);
+			KASSERT(0 < next->r_refcnt);
 			next->r_cnt++;
 			return;
 		}
 		ASSERT3U(off + len, >, next->r_off + next->r_len);
 		next = zfs_range_proxify(tree, next);
+		KASSERT(0 < next->r_refcnt);
 		next->r_cnt++;
 	}
 

Reply via email to