From patchwork Wed Jan 25 13:34:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13115640 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D18AAC54EAA for ; Wed, 25 Jan 2023 13:35:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B7196B0080; Wed, 25 Jan 2023 08:35:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6682E6B0081; Wed, 25 Jan 2023 08:35:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E19A6B0082; Wed, 25 Jan 2023 08:35:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3DF546B0080 for ; Wed, 25 Jan 2023 08:35:10 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 11379A0B99 for ; Wed, 25 Jan 2023 13:35:10 +0000 (UTC) X-FDA: 80393417580.07.8514FFF Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf27.hostedemail.com (Postfix) with ESMTP id 428A840009 for ; Wed, 25 Jan 2023 13:35:08 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=FZLS7LER; spf=none (imf27.hostedemail.com: domain of BATV+926f35216cf1e93e6ac9+7094+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+926f35216cf1e93e6ac9+7094+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674653708; a=rsa-sha256; cv=none; b=D8X9D2M/0NltbU1/51MBGE0idXZm2XP3xO4Qo6nmazYZp2rVy7Mevaeu0glMxm0EWYWpWv johiyIL9a9HndzAGpIpL/2KtchbCw9gmu1dwcq+bdDGgB3y1GHqZnNEsw2VfVM43L6tqdb cYa63ETu1c03VgU+m7VqoyEGv+WIvpo= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=FZLS7LER; spf=none (imf27.hostedemail.com: domain of BATV+926f35216cf1e93e6ac9+7094+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+926f35216cf1e93e6ac9+7094+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674653708; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=O8RUMOLSrBkE/AeLTaJ5NRi7CBbI3GgiJS4cpgVv33A=; b=0MqpFXm+kf2tGQfRTHAOofbNLTGlLI6bx8ikYVzLzo7WD3cmN0HCP79GizpWrTY1jzlrjU pW7Qr1DTMlz8awYbSd711S4sj1MaQn+ktgrW1fwG852JCs2BWbf+F5HDXylhdpgXjyp2jL vaA+IwmKAD1VATRf0MZ3D6upgfBUkqA= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=O8RUMOLSrBkE/AeLTaJ5NRi7CBbI3GgiJS4cpgVv33A=; b=FZLS7LERrZSdq80qX1+1MvYfm+ tHSMY9a2OAXiuep3YUjzxChyTd7mWMpjgGGK1IWSZCHOrsBc4mYr9O0fcAuBRVeVf/HygYJyfUxBK 6zaLL47c+sAcntjQ0kgrkDmgJ5LiUUvvcUQ8ROLe5lvCOY66Gmlpi0BFWsebpRD9KlaIh5wQ2fCMA jTDLpbWC61h8bEnaKdenCM22qooLGyurBJsPxnpvIj3NMRRDkq7+3Sqyzxa3wXqlXJiM1niLjZMZQ pM7HXBQ9xd74o4URQAYlOsC7tXJS0grlmJQts2LwPMdvETtcJh13rKH47OPAJQn7JzpP5EkFPeOgJ r5n6fmsg==; Received: from [2001:4bb8:19a:27af:c78f:9b0d:b95c:d248] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKfvZ-007P6r-P0; Wed, 25 Jan 2023 13:35:02 +0000 From: Christoph Hellwig To: Jens Axboe , Minchan Kim , Sergey Senozhatsky , Dan Williams , Vishal Verma , Dave Jiang , Ira Weiny Cc: Andrew Morton , linux-block@vger.kernel.org, nvdimm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 6/7] mm: factor out a swap_writepage_bdev helper Date: Wed, 25 Jan 2023 14:34:35 +0100 Message-Id: <20230125133436.447864-7-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125133436.447864-1-hch@lst.de> References: <20230125133436.447864-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: X-Rspamd-Queue-Id: 428A840009 X-Rspamd-Server: rspam01 X-Stat-Signature: mqa5tkmmd6us1sjkh97hj1u43b9zaues X-HE-Tag: 1674653708-87602 X-HE-Meta: U2FsdGVkX1+Jqf97t1OsgHejakiWC6ihz1cbGVr1p0uzPeM2MnUMX4YfSSvsChq6ZHoYEn3MUdG64wOSQtwQm5y24OITUq62QbXmn/xEt2Gogj/l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f/zlO0HCsdSWI/jWzcap6HTWXKLzEibwc8kzQNNtG8lDf7IElkdg6Y2E9V+TsNNdhzItG3WOU8w8dH8J7f+gdYdHBU5pFu6uf2kuyWI4Z+MPxGls/kseGtK/pX/UowNeVqfEGeT8G5bAxeyyHd34qPWwJ1Bg9kmJ8nTFUjepNYvMe8bxyPFGwkPNrKjWUzpknSKp+0OBNnrY6G7TnAjONpg7pOoD+65eFwaMmu2705zIdyXaiMNnmdqSYk+w3VgfZbYEcG9iIN30n+zthtYD4nNcYYy/Gp6Ujz7f X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Split the block device case from swap_readpage into a separate helper, following the abstraction for file based swap. Signed-off-by: Christoph Hellwig --- mm/page_io.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/mm/page_io.c b/mm/page_io.c index c373d5694cdffd..2ee2bfe5de0386 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -327,23 +327,12 @@ static void swap_writepage_fs(struct page *page, struct writeback_control *wbc) *wbc->swap_plug = sio; } -void __swap_writepage(struct page *page, struct writeback_control *wbc) +static void swap_writepage_bdev(struct page *page, + struct writeback_control *wbc, struct swap_info_struct *sis) { struct bio *bio; - int ret; - struct swap_info_struct *sis = page_swap_info(page); - - VM_BUG_ON_PAGE(!PageSwapCache(page), page); - /* - * ->flags can be updated non-atomicially (scan_swap_map_slots), - * but that will never affect SWP_FS_OPS, so the data_race - * is safe. - */ - if (data_race(sis->flags & SWP_FS_OPS)) - return swap_writepage_fs(page, wbc); - ret = bdev_write_page(sis->bdev, swap_page_sector(page), page, wbc); - if (!ret) { + if (!bdev_write_page(sis->bdev, swap_page_sector(page), page, wbc)) { count_swpout_vm_event(page); return; } @@ -362,6 +351,22 @@ void __swap_writepage(struct page *page, struct writeback_control *wbc) submit_bio(bio); } +void __swap_writepage(struct page *page, struct writeback_control *wbc) +{ + struct swap_info_struct *sis = page_swap_info(page); + + VM_BUG_ON_PAGE(!PageSwapCache(page), page); + /* + * ->flags can be updated non-atomicially (scan_swap_map_slots), + * but that will never affect SWP_FS_OPS, so the data_race + * is safe. + */ + if (data_race(sis->flags & SWP_FS_OPS)) + swap_writepage_fs(page, wbc); + else + swap_writepage_bdev(page, wbc, sis); +} + void swap_write_unplug(struct swap_iocb *sio) { struct iov_iter from;