From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>, Song Liu <song@kernel.org>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>, Chao Yu <chao@kernel.org>,
Philipp Reisner <philipp.reisner@linbit.com>,
Lars Ellenberg <lars.ellenberg@linbit.com>,
Coly Li <colyli@suse.de>, Mike Snitzer <snitzer@redhat.com>,
Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>,
Damien Le Moal <damien.lemoal@wdc.com>,
Naohiro Aota <naohiro.aota@wdc.com>,
Andrew Morton <akpm@linux-foundation.org>,
Ryusuke Konishi <konishi.ryusuke@gmail.com>,
linux-nilfs@vger.kernel.org, dm-devel@redhat.com,
linux-f2fs-devel@lists.sourceforge.net,
linux-block@vger.kernel.org, drbd-dev@lists.linbit.com,
linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org,
linux-nfs@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH 17/17] mm: remove get_swap_bio
Date: Tue, 26 Jan 2021 15:52:47 +0100 [thread overview]
Message-ID: <20210126145247.1964410-18-hch@lst.de> (raw)
In-Reply-To: <20210126145247.1964410-1-hch@lst.de>
Just reuse the block_device and sector from the swap_info structure,
just as used by the SWP_SYNCHRONOUS path. Also remove the checks for
NULL returns from bio_alloc as that can't happen for sleeping
allocations.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
include/linux/swap.h | 1 -
mm/page_io.c | 45 +++++++++++++-------------------------------
mm/swapfile.c | 10 ----------
3 files changed, 13 insertions(+), 43 deletions(-)
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 596bc2f4d9b03e..3f1f7ae0fbe9e1 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -468,7 +468,6 @@ extern int free_swap_and_cache(swp_entry_t);
int swap_type_of(dev_t device, sector_t offset);
int find_first_swap(dev_t *device);
extern unsigned int count_swap_pages(int, int);
-extern sector_t map_swap_page(struct page *, struct block_device **);
extern sector_t swapdev_block(int, pgoff_t);
extern int page_swapcount(struct page *);
extern int __swap_count(swp_entry_t entry);
diff --git a/mm/page_io.c b/mm/page_io.c
index a75f35464a4e73..92f7941c6d018b 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -26,25 +26,6 @@
#include <linux/uio.h>
#include <linux/sched/task.h>
-static struct bio *get_swap_bio(gfp_t gfp_flags,
- struct page *page, bio_end_io_t end_io)
-{
- struct bio *bio;
-
- bio = bio_alloc(gfp_flags, 1);
- if (bio) {
- struct block_device *bdev;
-
- bio->bi_iter.bi_sector = map_swap_page(page, &bdev);
- bio_set_dev(bio, bdev);
- bio->bi_iter.bi_sector <<= PAGE_SHIFT - 9;
- bio->bi_end_io = end_io;
-
- bio_add_page(bio, page, thp_size(page), 0);
- }
- return bio;
-}
-
void end_swap_bio_write(struct bio *bio)
{
struct page *page = bio_first_page_all(bio);
@@ -361,13 +342,13 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
return 0;
}
- bio = get_swap_bio(GFP_NOIO, page, end_write_func);
- if (bio == NULL) {
- set_page_dirty(page);
- unlock_page(page);
- return -ENOMEM;
- }
+ bio = bio_alloc(GFP_NOIO, 1);
+ bio_set_dev(bio, sis->bdev);
+ bio->bi_iter.bi_sector = swap_page_sector(page);
bio->bi_opf = REQ_OP_WRITE | REQ_SWAP | wbc_to_write_flags(wbc);
+ bio->bi_end_io = end_write_func;
+ bio_add_page(bio, page, thp_size(page), 0);
+
bio_associate_blkg_from_page(bio, page);
count_swpout_vm_event(page);
set_page_writeback(page);
@@ -427,18 +408,18 @@ int swap_readpage(struct page *page, bool synchronous)
}
ret = 0;
- bio = get_swap_bio(GFP_KERNEL, page, end_swap_bio_read);
- if (bio == NULL) {
- unlock_page(page);
- ret = -ENOMEM;
- goto out;
- }
+ bio = bio_alloc(GFP_KERNEL, 1);
+ bio_set_dev(bio, sis->bdev);
+ bio->bi_opf = REQ_OP_READ;
+ bio->bi_iter.bi_sector = swap_page_sector(page);
+ bio->bi_end_io = end_swap_bio_read;
+ bio_add_page(bio, page, thp_size(page), 0);
+
disk = bio->bi_bdev->bd_disk;
/*
* Keep this task valid during swap readpage because the oom killer may
* attempt to access it in the page fault retry time check.
*/
- bio_set_op_attrs(bio, REQ_OP_READ, 0);
if (synchronous) {
bio->bi_opf |= REQ_HIPRI;
get_task_struct(current);
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 9fffc5af29d1b9..bfa9e8b0c2ef61 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2301,16 +2301,6 @@ static sector_t map_swap_entry(swp_entry_t entry, struct block_device **bdev)
return se->start_block + (offset - se->start_page);
}
-/*
- * Returns the page offset into bdev for the specified page's swap entry.
- */
-sector_t map_swap_page(struct page *page, struct block_device **bdev)
-{
- swp_entry_t entry;
- entry.val = page_private(page);
- return map_swap_entry(entry, bdev);
-}
-
/*
* Free all of a swapdev's extent information
*/
--
2.29.2
next prev parent reply other threads:[~2021-01-26 15:28 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-26 14:52 misc bio allocation cleanups Christoph Hellwig
2021-01-26 14:52 ` [PATCH 01/17] zonefs: use bio_alloc in zonefs_file_dio_append Christoph Hellwig
2021-01-26 15:08 ` Johannes Thumshirn
2021-01-26 19:09 ` Chaitanya Kulkarni
2021-01-26 23:23 ` [dm-devel] " Damien Le Moal
2021-01-26 14:52 ` [PATCH 02/17] btrfs: use bio_kmalloc in __alloc_device Christoph Hellwig
2021-01-26 15:01 ` Josef Bacik
2021-01-26 19:11 ` Chaitanya Kulkarni
2021-01-26 14:52 ` [PATCH 03/17] blk-crypto: use bio_kmalloc in blk_crypto_clone_bio Christoph Hellwig
2021-01-26 21:51 ` Eric Biggers
2021-01-26 14:52 ` [PATCH 04/17] block: split bio_kmalloc from bio_alloc_bioset Christoph Hellwig
2021-01-30 3:56 ` Matthew Wilcox
2021-02-01 12:22 ` Christoph Hellwig
2021-01-26 14:52 ` [PATCH 05/17] block: use an on-stack bio in blkdev_issue_flush Christoph Hellwig
2021-01-26 19:15 ` Chaitanya Kulkarni
2021-01-26 14:52 ` [PATCH 06/17] dm-clone: use blkdev_issue_flush in commit_metadata Christoph Hellwig
2021-01-26 14:52 ` [PATCH 07/17] f2fs: use blkdev_issue_flush in __submit_flush_wait Christoph Hellwig
2021-01-29 1:03 ` [f2fs-dev] " Chao Yu
2021-01-26 14:52 ` [PATCH 08/17] f2fs: remove FAULT_ALLOC_BIO Christoph Hellwig
2021-01-28 16:11 ` Jaegeuk Kim
2021-01-29 1:04 ` [f2fs-dev] " Chao Yu
2021-01-26 14:52 ` [PATCH 09/17] drbd: remove bio_alloc_drbd Christoph Hellwig
2021-01-26 14:52 ` [PATCH 10/17] drbd: remove drbd_req_make_private_bio Christoph Hellwig
2021-01-26 14:52 ` [PATCH 11/17] md: remove bio_alloc_mddev Christoph Hellwig
2021-01-27 7:21 ` Song Liu
2021-01-26 14:52 ` [PATCH 12/17] md: simplify sync_page_io Christoph Hellwig
2021-01-27 7:22 ` Song Liu
2021-01-26 14:52 ` [PATCH 13/17] md: remove md_bio_alloc_sync Christoph Hellwig
2021-01-27 7:22 ` Song Liu
2021-01-26 14:52 ` [PATCH 14/17] md/raid6: refactor raid5_read_one_chunk Christoph Hellwig
2021-01-27 7:15 ` Song Liu
2021-01-26 14:52 ` [PATCH 15/17] nfs/blocklayout: remove cruft in bl_alloc_init_bio Christoph Hellwig
2021-01-26 14:52 ` [PATCH 16/17] nilfs2: remove cruft in nilfs_alloc_seg_bio Christoph Hellwig
2021-01-26 19:17 ` Chaitanya Kulkarni
2021-01-26 14:52 ` Christoph Hellwig [this message]
2021-01-27 16:52 ` misc bio allocation cleanups Jens Axboe
2021-02-01 1:16 ` Guoqing Jiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210126145247.1964410-18-hch@lst.de \
--to=hch@lst.de \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=chao@kernel.org \
--cc=colyli@suse.de \
--cc=damien.lemoal@wdc.com \
--cc=dm-devel@redhat.com \
--cc=drbd-dev@lists.linbit.com \
--cc=dsterba@suse.com \
--cc=jaegeuk@kernel.org \
--cc=josef@toxicpanda.com \
--cc=konishi.ryusuke@gmail.com \
--cc=lars.ellenberg@linbit.com \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-nilfs@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=naohiro.aota@wdc.com \
--cc=philipp.reisner@linbit.com \
--cc=snitzer@redhat.com \
--cc=song@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).