aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2025-07-24 10:47:52 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2025-09-14 19:12:58 +0000
commit3f05bbdbd80f2eefb647e595dc73e80d6186d6a5 (patch)
tree49ca22eaa34bb27f8c741437f2bd0553b2624603
parent5bd4c04a4e7f7bda657e6027e64675d0caf50715 (diff)
vm_fault: add helper vm_fault_can_cow_rename()
Reviewed by: alc, markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D51474
-rw-r--r--sys/vm/vm_fault.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c
index 226cf34b3ca4..27b5f72ec945 100644
--- a/sys/vm/vm_fault.c
+++ b/sys/vm/vm_fault.c
@@ -1006,6 +1006,16 @@ vm_fault_relookup(struct faultstate *fs)
return (KERN_SUCCESS);
}
+static bool
+vm_fault_can_cow_rename(struct faultstate *fs)
+{
+ return (
+ /* Only one shadow object and no other refs. */
+ fs->object->shadow_count == 1 && fs->object->ref_count == 1 &&
+ /* No other ways to look the object up. */
+ fs->object->handle == NULL && (fs->object->flags & OBJ_ANON) != 0);
+}
+
static void
vm_fault_cow(struct faultstate *fs)
{
@@ -1023,15 +1033,7 @@ vm_fault_cow(struct faultstate *fs)
* object so that it will go out to swap when needed.
*/
is_first_object_locked = false;
- if (
- /*
- * Only one shadow object and no other refs.
- */
- fs->object->shadow_count == 1 && fs->object->ref_count == 1 &&
- /*
- * No other ways to look the object up
- */
- fs->object->handle == NULL && (fs->object->flags & OBJ_ANON) != 0 &&
+ if (vm_fault_can_cow_rename(fs) &&
/*
* We don't chase down the shadow chain and we can acquire locks.
*/