lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <163250395192.2330363.9101664122191208351.stgit@warthog.procyon.org.uk>
Date:   Fri, 24 Sep 2021 18:19:11 +0100
From:   David Howells <dhowells@...hat.com>
To:     willy@...radead.org, hch@....de, trond.myklebust@...marydata.com
Cc:     Jens Axboe <axboe@...nel.dk>, Chris Mason <clm@...com>,
        Josef Bacik <josef@...icpanda.com>,
        David Sterba <dsterba@...e.com>, Theodore Ts'o <tytso@....edu>,
        Andreas Dilger <adilger.kernel@...ger.ca>,
        "Darrick J. Wong" <djwong@...nel.org>, linux-block@...r.kernel.org,
        linux-btrfs@...r.kernel.org, linux-ext4@...r.kernel.org,
        linux-xfs@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        linux-mm@...ck.org, dhowells@...hat.com, dhowells@...hat.com,
        darrick.wong@...cle.com, viro@...iv.linux.org.uk,
        jlayton@...nel.org, torvalds@...ux-foundation.org,
        linux-nfs@...r.kernel.org, linux-mm@...ck.org,
        linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH v3 8/9] block, btrfs, ext4, xfs: Implement swap_rw

Implement swap_rw for block devices, btrfs, ext4 and xfs.  This allows the
the page swapping code to use direct-IO rather than direct bio submission,
whilst skipping the checks going via read/write_iter would entail.

Signed-off-by: David Howells <dhowells@...hat.com>
cc: Matthew Wilcox <willy@...radead.org>
cc: Christoph Hellwig <hch@....de>
cc: Jens Axboe <axboe@...nel.dk>
cc: Chris Mason <clm@...com>
cc: Josef Bacik <josef@...icpanda.com>
cc: David Sterba <dsterba@...e.com>
cc: "Theodore Ts'o" <tytso@....edu>
cc: Andreas Dilger <adilger.kernel@...ger.ca>
cc: Darrick J. Wong <djwong@...nel.org>
cc: linux-block@...r.kernel.org
cc: linux-btrfs@...r.kernel.org
cc: linux-ext4@...r.kernel.org
cc: linux-xfs@...r.kernel.org
cc: linux-fsdevel@...r.kernel.org
cc: linux-mm@...ck.org
---

 block/fops.c      |    1 +
 fs/btrfs/inode.c  |   12 +++++-------
 fs/ext4/inode.c   |    9 +++++++++
 fs/xfs/xfs_aops.c |    9 +++++++++
 4 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/block/fops.c b/block/fops.c
index 84c64d814d0d..7ba37dfafae2 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -382,6 +382,7 @@ const struct address_space_operations def_blk_aops = {
 	.write_end	= blkdev_write_end,
 	.writepages	= blkdev_writepages,
 	.direct_IO	= blkdev_direct_IO,
+	.swap_rw	= blkdev_direct_IO,
 	.migratepage	= buffer_migrate_page_norefs,
 	.is_dirty_writeback = buffer_check_dirty_writeback,
 	.supports	= AS_SUPPORTS_DIRECT_IO,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b479c97e42fc..9ffcefecb3bb 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -10852,15 +10852,10 @@ static int btrfs_swap_activate(struct swap_info_struct *sis, struct file *file,
 	sis->highest_bit = bsi.nr_pages - 1;
 	return bsi.nr_extents;
 }
-#else
-static void btrfs_swap_deactivate(struct file *file)
-{
-}
 
-static int btrfs_swap_activate(struct swap_info_struct *sis, struct file *file,
-			       sector_t *span)
+static ssize_t btrfs_swap_rw(struct kiocb *iocb, struct iov_iter *iter)
 {
-	return -EOPNOTSUPP;
+	return iomap_dio_rw(iocb, iter, &btrfs_dio_iomap_ops, NULL, 0);
 }
 #endif
 
@@ -10944,8 +10939,11 @@ static const struct address_space_operations btrfs_aops = {
 #endif
 	.set_page_dirty	= btrfs_set_page_dirty,
 	.error_remove_page = generic_error_remove_page,
+#ifdef CONFIG_SWAP
 	.swap_activate	= btrfs_swap_activate,
 	.swap_deactivate = btrfs_swap_deactivate,
+	.swap_rw	= btrfs_swap_rw,
+#endif
 	.supports	= AS_SUPPORTS_DIRECT_IO,
 };
 
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 08d3541d8daa..3c14724d58a8 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3651,6 +3651,11 @@ static int ext4_iomap_swap_activate(struct swap_info_struct *sis,
 				       &ext4_iomap_report_ops);
 }
 
+static ssize_t ext4_swap_rw(struct kiocb *iocb, struct iov_iter *iter)
+{
+	return iomap_dio_rw(iocb, iter, &ext4_iomap_ops, NULL, 0);
+}
+
 static const struct address_space_operations ext4_aops = {
 	.readpage		= ext4_readpage,
 	.readahead		= ext4_readahead,
@@ -3666,6 +3671,7 @@ static const struct address_space_operations ext4_aops = {
 	.is_partially_uptodate  = block_is_partially_uptodate,
 	.error_remove_page	= generic_error_remove_page,
 	.swap_activate		= ext4_iomap_swap_activate,
+	.swap_rw		= ext4_swap_rw,
 	.supports		= AS_SUPPORTS_DIRECT_IO,
 };
 
@@ -3683,6 +3689,7 @@ static const struct address_space_operations ext4_journalled_aops = {
 	.is_partially_uptodate  = block_is_partially_uptodate,
 	.error_remove_page	= generic_error_remove_page,
 	.swap_activate		= ext4_iomap_swap_activate,
+	.swap_rw		= ext4_swap_rw,
 	.supports		= AS_SUPPORTS_DIRECT_IO,
 };
 
@@ -3701,6 +3708,7 @@ static const struct address_space_operations ext4_da_aops = {
 	.is_partially_uptodate  = block_is_partially_uptodate,
 	.error_remove_page	= generic_error_remove_page,
 	.swap_activate		= ext4_iomap_swap_activate,
+	.swap_rw		= ext4_swap_rw,
 	.supports		= AS_SUPPORTS_DIRECT_IO,
 };
 
@@ -3710,6 +3718,7 @@ static const struct address_space_operations ext4_dax_aops = {
 	.bmap			= ext4_bmap,
 	.invalidatepage		= noop_invalidatepage,
 	.swap_activate		= ext4_iomap_swap_activate,
+	.swap_rw		= ext4_swap_rw,
 	.supports		= AS_SUPPORTS_DIRECT_IO,
 };
 
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 2a4570516591..23ade2cc8241 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -540,6 +540,13 @@ xfs_iomap_swapfile_activate(
 			&xfs_read_iomap_ops);
 }
 
+static ssize_t xfs_swap_rw(struct kiocb *iocb, struct iov_iter *iter)
+{
+	if (iocb->ki_flags & IOCB_WRITE)
+		return iomap_dio_rw(iocb, iter, &xfs_direct_write_iomap_ops, NULL, 0);
+	return iomap_dio_rw(iocb, iter, &xfs_read_iomap_ops, NULL, 0);
+}
+
 const struct address_space_operations xfs_address_space_operations = {
 	.readpage		= xfs_vm_readpage,
 	.readahead		= xfs_vm_readahead,
@@ -552,6 +559,7 @@ const struct address_space_operations xfs_address_space_operations = {
 	.is_partially_uptodate  = iomap_is_partially_uptodate,
 	.error_remove_page	= generic_error_remove_page,
 	.swap_activate		= xfs_iomap_swapfile_activate,
+	.swap_rw		= xfs_swap_rw,
 	.supports		= AS_SUPPORTS_DIRECT_IO,
 };
 
@@ -560,5 +568,6 @@ const struct address_space_operations xfs_dax_aops = {
 	.set_page_dirty		= __set_page_dirty_no_writeback,
 	.invalidatepage		= noop_invalidatepage,
 	.swap_activate		= xfs_iomap_swapfile_activate,
+	.swap_rw		= xfs_swap_rw,
 	.supports		= AS_SUPPORTS_DIRECT_IO,
 };


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ