Skip to content

Commit f0d6377

Browse files
committed
swap-like pagers: assert that writemapping decrease does not pass zero
(cherry picked from commit 6ada4e8)
1 parent 2ecfb14 commit f0d6377

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

sys/fs/tmpfs/tmpfs_subr.c

+3
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ tmpfs_pager_release_writecount(vm_object_t object, vm_offset_t start,
179179
KASSERT((object->flags & OBJ_ANON) == 0,
180180
("%s: object %p with OBJ_ANON", __func__, object));
181181
old = object->un_pager.swp.writemappings;
182+
KASSERT(old >= (vm_ooffset_t)end - start,
183+
("tmpfs obj %p writecount %jx dec %jx", object, (uintmax_t)old,
184+
(uintmax_t)((vm_ooffset_t)end - start)));
182185
object->un_pager.swp.writemappings -= (vm_ooffset_t)end - start;
183186
new = object->un_pager.swp.writemappings;
184187
tmpfs_pager_writecount_recalc(object, old, new);

sys/vm/swap_pager.c

+4
Original file line numberDiff line numberDiff line change
@@ -3161,6 +3161,10 @@ swap_pager_release_writecount(vm_object_t object, vm_offset_t start,
31613161
VM_OBJECT_WLOCK(object);
31623162
KASSERT((object->flags & OBJ_ANON) == 0,
31633163
("Splittable object with writecount"));
3164+
KASSERT(object->un_pager.swp.writemappings >= (vm_ooffset_t)end - start,
3165+
("swap obj %p writecount %jx dec %jx", object,
3166+
(uintmax_t)object->un_pager.swp.writemappings,
3167+
(uintmax_t)((vm_ooffset_t)end - start)));
31643168
object->un_pager.swp.writemappings -= (vm_ooffset_t)end - start;
31653169
VM_OBJECT_WUNLOCK(object);
31663170
}

0 commit comments

Comments
 (0)