git: c6213beff4f5 - main - Add flag BIO_SWAP to mark IOs that are associated with swap.

Gleb Smirnoff glebius at FreeBSD.org
Tue Sep 28 18:24:06 UTC 2021


The branch main has been updated by glebius:

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

commit c6213beff4f51d6c9cc4e41682538d203249359e
Author:     Gleb Smirnoff <glebius at FreeBSD.org>
AuthorDate: 2021-09-28 18:11:50 +0000
Commit:     Gleb Smirnoff <glebius at FreeBSD.org>
CommitDate: 2021-09-28 18:23:51 +0000

    Add flag BIO_SWAP to mark IOs that are associated with swap.
    
    Submitted by:           jtl
    Reviewed by:            kib
    Differential Revision:  https://reviews.freebsd.org/D24400
---
 sys/geom/geom_io.c  | 8 ++++----
 sys/sys/bio.h       | 3 ++-
 sys/vm/swap_pager.c | 1 +
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c
index 31213f0f2b22..c4e9be02bf44 100644
--- a/sys/geom/geom_io.c
+++ b/sys/geom/geom_io.c
@@ -199,12 +199,12 @@ g_clone_bio(struct bio *bp)
 		/*
 		 *  BIO_ORDERED flag may be used by disk drivers to enforce
 		 *  ordering restrictions, so this flag needs to be cloned.
-		 *  BIO_UNMAPPED and BIO_VLIST should be inherited, to properly
-		 *  indicate which way the buffer is passed.
+		 *  BIO_UNMAPPED, BIO_VLIST, and BIO_SWAP should be inherited,
+		 *  to properly indicate which way the buffer is passed.
 		 *  Other bio flags are not suitable for cloning.
 		 */
 		bp2->bio_flags = bp->bio_flags &
-		    (BIO_ORDERED | BIO_UNMAPPED | BIO_VLIST);
+		    (BIO_ORDERED | BIO_UNMAPPED | BIO_VLIST | BIO_SWAP);
 		bp2->bio_length = bp->bio_length;
 		bp2->bio_offset = bp->bio_offset;
 		bp2->bio_data = bp->bio_data;
@@ -238,7 +238,7 @@ g_duplicate_bio(struct bio *bp)
 	struct bio *bp2;
 
 	bp2 = uma_zalloc(biozone, M_WAITOK | M_ZERO);
-	bp2->bio_flags = bp->bio_flags & (BIO_UNMAPPED | BIO_VLIST);
+	bp2->bio_flags = bp->bio_flags & (BIO_UNMAPPED | BIO_VLIST | BIO_SWAP);
 	bp2->bio_parent = bp;
 	bp2->bio_cmd = bp->bio_cmd;
 	bp2->bio_length = bp->bio_length;
diff --git a/sys/sys/bio.h b/sys/sys/bio.h
index 5fdf0ecbb917..fba1b9dce68f 100644
--- a/sys/sys/bio.h
+++ b/sys/sys/bio.h
@@ -67,8 +67,9 @@
 #define	BIO_UNMAPPED	0x10
 #define	BIO_TRANSIENT_MAPPING	0x20
 #define	BIO_VLIST	0x40
+#define	BIO_SWAP	0x200	/* Swap-related I/O */
 
-#define	PRINT_BIO_FLAGS "\20\7vlist\6transient_mapping\5unmapped" \
+#define	PRINT_BIO_FLAGS "\20\12swap\7vlist\6transient_mapping\5unmapped" \
 	"\4ordered\3onqueue\2done\1error"
 
 #define BIO_SPEEDUP_WRITE	0x4000	/* Resource shortage at upper layers */
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c
index 6d64ff883966..08a5ead438ba 100644
--- a/sys/vm/swap_pager.c
+++ b/sys/vm/swap_pager.c
@@ -2893,6 +2893,7 @@ swapgeom_strategy(struct buf *bp, struct swdevt *sp)
 	bio->bio_offset = (bp->b_blkno - sp->sw_first) * PAGE_SIZE;
 	bio->bio_length = bp->b_bcount;
 	bio->bio_done = swapgeom_done;
+	bio->bio_flags |= BIO_SWAP;
 	if (!buf_mapped(bp)) {
 		bio->bio_ma = bp->b_pages;
 		bio->bio_data = unmapped_buf;


More information about the dev-commits-src-all mailing list