git: 180bcaa46c5d - main - vm_pager: add pgo_set_writeable_dirty method
Konstantin Belousov
kib at FreeBSD.org
Fri May 7 14:08:20 UTC 2021
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=180bcaa46c5d297d137749258b23593d578d76a5
commit 180bcaa46c5d297d137749258b23593d578d76a5
Author: Konstantin Belousov <kib at FreeBSD.org>
AuthorDate: 2021-05-01 00:14:48 +0000
Commit: Konstantin Belousov <kib at FreeBSD.org>
CommitDate: 2021-05-07 14:08:03 +0000
vm_pager: add pgo_set_writeable_dirty method
specialized for swap and vnode pagers, and used to implement
vm_object_set_writeable_dirty().
Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30070
---
sys/vm/swap_pager.c | 9 +++++++++
sys/vm/vm_object.c | 7 +------
sys/vm/vm_object.h | 1 +
sys/vm/vm_pager.c | 11 +++++++++++
sys/vm/vm_pager.h | 3 ++-
sys/vm/vnode_pager.c | 1 +
6 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c
index c6ebfa0167f2..3f2a647b269d 100644
--- a/sys/vm/swap_pager.c
+++ b/sys/vm/swap_pager.c
@@ -433,6 +433,7 @@ static void swap_pager_update_writecount(vm_object_t object,
vm_offset_t start, vm_offset_t end);
static void swap_pager_release_writecount(vm_object_t object,
vm_offset_t start, vm_offset_t end);
+static void swap_pager_set_writeable_dirty(vm_object_t object);
struct pagerops swappagerops = {
.pgo_init = swap_pager_init, /* early system initialization of pager */
@@ -445,6 +446,7 @@ struct pagerops swappagerops = {
.pgo_pageunswapped = swap_pager_unswapped, /* remove swap related to page */
.pgo_update_writecount = swap_pager_update_writecount,
.pgo_release_writecount = swap_pager_release_writecount,
+ .pgo_set_writeable_dirty = swap_pager_set_writeable_dirty,
};
/*
@@ -3123,3 +3125,10 @@ swap_pager_release_writecount(vm_object_t object, vm_offset_t start,
object->un_pager.swp.writemappings -= (vm_ooffset_t)end - start;
VM_OBJECT_WUNLOCK(object);
}
+
+static void
+swap_pager_set_writeable_dirty(vm_object_t object)
+{
+ if ((object->flags & OBJ_TMPFS_NODE) != 0)
+ vm_object_set_writeable_dirty_(object);
+}
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index 1f5194464b69..46b43e8cee14 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -2332,13 +2332,8 @@ vm_object_coalesce(vm_object_t prev_object, vm_ooffset_t prev_offset,
}
void
-vm_object_set_writeable_dirty(vm_object_t object)
+vm_object_set_writeable_dirty_(vm_object_t object)
{
-
- /* Only set for vnodes & tmpfs */
- if (object->type != OBJT_VNODE &&
- (object->flags & OBJ_TMPFS_NODE) == 0)
- return;
atomic_add_int(&object->generation, 1);
}
diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h
index 3c589bd4b42e..93380d904526 100644
--- a/sys/vm/vm_object.h
+++ b/sys/vm/vm_object.h
@@ -378,6 +378,7 @@ void vm_object_deallocate (vm_object_t);
void vm_object_destroy (vm_object_t);
void vm_object_terminate (vm_object_t);
void vm_object_set_writeable_dirty (vm_object_t);
+void vm_object_set_writeable_dirty_(vm_object_t object);
void vm_object_init (void);
int vm_object_kvme_type(vm_object_t object, struct vnode **vpp);
void vm_object_madvise(vm_object_t, vm_pindex_t, vm_pindex_t, int);
diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c
index 2a30a2073b36..258c06fd3947 100644
--- a/sys/vm/vm_pager.c
+++ b/sys/vm/vm_pager.c
@@ -497,3 +497,14 @@ pbrelbo(struct buf *bp)
bp->b_bufobj = NULL;
bp->b_flags &= ~B_PAGING;
}
+
+void
+vm_object_set_writeable_dirty(vm_object_t object)
+{
+ pgo_set_writeable_dirty_t *method;
+
+ method = pagertab[object->type]->pgo_set_writeable_dirty;
+ if (method != NULL)
+ method(object);
+}
+
diff --git a/sys/vm/vm_pager.h b/sys/vm/vm_pager.h
index 2dfe374b9d4a..e17e29ea961f 100644
--- a/sys/vm/vm_pager.h
+++ b/sys/vm/vm_pager.h
@@ -62,6 +62,7 @@ typedef int pgo_populate_t(vm_object_t, vm_pindex_t, int, vm_prot_t,
vm_pindex_t *, vm_pindex_t *);
typedef void pgo_pageunswapped_t(vm_page_t);
typedef void pgo_writecount_t(vm_object_t, vm_offset_t, vm_offset_t);
+typedef void pgo_set_writeable_dirty_t(vm_object_t);
struct pagerops {
pgo_init_t *pgo_init; /* Initialize pager. */
@@ -73,9 +74,9 @@ struct pagerops {
pgo_haspage_t *pgo_haspage; /* Query page. */
pgo_populate_t *pgo_populate; /* Bulk spec pagein. */
pgo_pageunswapped_t *pgo_pageunswapped;
- /* Operations for specialized writecount handling */
pgo_writecount_t *pgo_update_writecount;
pgo_writecount_t *pgo_release_writecount;
+ pgo_set_writeable_dirty_t *pgo_set_writeable_dirty;
};
extern struct pagerops defaultpagerops;
diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c
index c33ffca4a700..bb0ec26ea35e 100644
--- a/sys/vm/vnode_pager.c
+++ b/sys/vm/vnode_pager.c
@@ -115,6 +115,7 @@ struct pagerops vnodepagerops = {
.pgo_haspage = vnode_pager_haspage,
.pgo_update_writecount = vnode_pager_update_writecount,
.pgo_release_writecount = vnode_pager_release_writecount,
+ .pgo_set_writeable_dirty = vm_object_set_writeable_dirty_,
};
static struct domainset *vnode_domainset = NULL;
More information about the dev-commits-src-main
mailing list