Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 May 2021 09:46:25 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: f3b6b7de3cc0 - stable/13 - vm_pager: add pgo_set_writeable_dirty method
Message-ID:  <202105220946.14M9kPJn012362@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=f3b6b7de3cc0b3379b9ed991cc3d4980eedf17b1

commit f3b6b7de3cc0b3379b9ed991cc3d4980eedf17b1
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-05-01 00:14:48 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-05-22 09:38:28 +0000

    vm_pager: add pgo_set_writeable_dirty method
    
    (cherry picked from commit 180bcaa46c5d297d137749258b23593d578d76a5)
---
 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 fa0aa0c41925..8ccc3a6710e0 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,
 };
 
 /*
@@ -3127,3 +3129,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 e75c6fb6b5d7..619121b672eb 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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105220946.14M9kPJn012362>