From patchwork Wed Nov 16 13:18:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13045205 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94DE8C433FE for ; Wed, 16 Nov 2022 13:19:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229463AbiKPNTJ (ORCPT ); Wed, 16 Nov 2022 08:19:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233463AbiKPNTI (ORCPT ); Wed, 16 Nov 2022 08:19:08 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ECA920F73 for ; Wed, 16 Nov 2022 05:18:57 -0800 (PST) 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=q/E3BqKCCjoCcCCbz9UnkL+Bsv6hDhREGM9RbKHDxDY=; b=QaL6DBkAN1mZckqOyGSH+rEmb8 uXsgxRsBSjEtyiC4ViKlRTlUgzuaPyqrJZ9spW5vE1VnjxGI5jMA4mg1BdKXFOP6Zj1TdG9VpJO9h bnZr7gWddbIUzz6d+JPTLOzUhiBlJSIxqZA4Yr60qtXiWjnD2FPGaQTdCQUYJWVcPR2IUJxXI0gXe UdKj2y8jj9Rty1uybE5NsZWCXAgJxgKsBeKTOUuxvf1VmWyy0CfdxAFVufDxF/oivdzqLW0+uX0Md LLSOs4vgPGF8IELH7P6tx4Jo/R/jop3pMhVLvN2BAGMZZERIbv2K9gLcUvvHUZwade5yz4+XZepi4 +wpZ2jKw==; Received: from [2001:4bb8:191:2606:427:bb47:a3d:e0b8] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovIJN-003ndw-2P; Wed, 16 Nov 2022 13:18:41 +0000 From: Christoph Hellwig To: Steve French Cc: Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org Subject: [PATCH 1/3] cifs: wire up >migrate_folio Date: Wed, 16 Nov 2022 14:18:33 +0100 Message-Id: <20221116131835.2192188-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221116131835.2192188-1-hch@lst.de> References: <20221116131835.2192188-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 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org CIFS does not use page private data that needs migration, so it can just wire up filemap_migrate_folio. This prepares for removing ->writepage, which is used as a fallback if no migrate_folio method is set. Signed-off-by: Christoph Hellwig --- fs/cifs/file.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index cd96982099309..6be924caed393 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -5240,10 +5240,10 @@ const struct address_space_operations cifs_addr_ops = { .direct_IO = cifs_direct_io, .invalidate_folio = cifs_invalidate_folio, .launder_folio = cifs_launder_folio, + .migrate_folio = filemap_migrate_folio, /* - * TODO: investigate and if useful we could add an cifs_migratePage - * helper (under an CONFIG_MIGRATION) in the future, and also - * investigate and add an is_dirty_writeback helper if needed + * TODO: investigate and if useful we could add an is_dirty_writeback + * helper if needed */ .swap_activate = cifs_swap_activate, .swap_deactivate = cifs_swap_deactivate, @@ -5264,4 +5264,5 @@ const struct address_space_operations cifs_addr_ops_smallbuf = { .release_folio = cifs_release_folio, .invalidate_folio = cifs_invalidate_folio, .launder_folio = cifs_launder_folio, + .migrate_folio = filemap_migrate_folio, }; From patchwork Wed Nov 16 13:18:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13045204 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C24CEC43219 for ; Wed, 16 Nov 2022 13:19:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231607AbiKPNTJ (ORCPT ); Wed, 16 Nov 2022 08:19:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233361AbiKPNTI (ORCPT ); Wed, 16 Nov 2022 08:19:08 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E2FA2126B for ; Wed, 16 Nov 2022 05:18:56 -0800 (PST) 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=u/oShJ302tmkGGvj0bjrcFQrXXwSX1/0HQi74xz16ks=; b=CsJttR4OYIVHr1DKyiIuJ2eBcC q7/VW5H3rN3iFmBQCuQlv0U0m/5/LutkdWfR5VseO92fXCT0R0oC7ZDMfTJGxh2RsoxwHo+mk6e3c vAarjyS7Br6mJBMxhLdGSgw8c8nJJw4d3ZCFOra74XL++TkJMlSGfI/wZwwOI96w1jvu/nHo5N8V3 g2CqF2GL0512Joai0mhps7p19cm+aAHBjEzUJJUv0F0aFm975kn7zY/HSaZvPUjSMSwTXQPsXi4/K K+HYB+esGRk4pOgTVumOm8NAmQtauCE0CCZaZeXx6U8IIRjXpI0ABQ7KXAYOH3JhVX/w9SHXuduO0 yjeSp8FA==; Received: from [2001:4bb8:191:2606:427:bb47:a3d:e0b8] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovIJQ-003nek-8Q; Wed, 16 Nov 2022 13:18:44 +0000 From: Christoph Hellwig To: Steve French Cc: Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org Subject: [PATCH 2/3] cifs: stop using generic_writepages Date: Wed, 16 Nov 2022 14:18:34 +0100 Message-Id: <20221116131835.2192188-3-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221116131835.2192188-1-hch@lst.de> References: <20221116131835.2192188-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 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org generic_writepages is just a wrapper that calls ->writepages on a range, and thus in the way of eventually removing ->writepage. Switch cifs to just open code it in preparation of removing ->writepage. [note: I suspect just integrating the small wsize case with the rest of the writeback code might be a better idea here, but that needs someone more familiar with the code] Signed-off-by: Christoph Hellwig --- fs/cifs/file.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 6be924caed393..ec14e38411a13 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2646,6 +2646,21 @@ wdata_send_pages(struct cifs_writedata *wdata, unsigned int nr_pages, return rc; } +static int +cifs_writepage_locked(struct page *page, struct writeback_control *wbc); + +static int cifs_write_one_page(struct page *page, struct writeback_control *wbc, + void *data) +{ + struct address_space *mapping = data; + int ret; + + ret = cifs_writepage_locked(page, wbc); + unlock_page(page); + mapping_set_error(mapping, ret); + return ret; +} + static int cifs_writepages(struct address_space *mapping, struct writeback_control *wbc) { @@ -2662,10 +2677,11 @@ static int cifs_writepages(struct address_space *mapping, /* * If wsize is smaller than the page cache size, default to writing - * one page at a time via cifs_writepage + * one page at a time. */ if (cifs_sb->ctx->wsize < PAGE_SIZE) - return generic_writepages(mapping, wbc); + return write_cache_pages(mapping, wbc, cifs_write_one_page, + mapping); xid = get_xid(); if (wbc->range_cyclic) { From patchwork Wed Nov 16 13:18:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13045203 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B364C4332F for ; Wed, 16 Nov 2022 13:19:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232097AbiKPNTI (ORCPT ); Wed, 16 Nov 2022 08:19:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232779AbiKPNTH (ORCPT ); Wed, 16 Nov 2022 08:19:07 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5694021835 for ; Wed, 16 Nov 2022 05:18:59 -0800 (PST) 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=Y0gJTkmVbdT+zvUmbKtXS4N5nKYSYLQ/A8m5DQX+czk=; b=qT5dZgbSnbEprtT3NlzhcnXQIH fPFLEH0nGF2xV8I28F6bvR2wLUu9WG101aIzfZychSkdLmJo/T8JFaGVDJbEYIeF2ydDbdDmCeeZS 5r47EgWK8bbdKbRnxvbpPGZko9WB2iKk+GBk12sPozQwHONFUdZKOwW1I7EoCeF6HS7BfXU5dwvO0 D25mw9alZtwsFSt6epf8pfizT5GzkHELsOqU2019CWegI+S4tmTG5AdbQWn5ZL0bfLKO0hrL9GU4b dvrG2rd8EtProdUd7vr2cnYGzcKttOkF+bVs7TuIorBuD4+XDKTDn5roAbOIUuDzacl9DK8W0bjkX n17kkyWA==; Received: from [2001:4bb8:191:2606:427:bb47:a3d:e0b8] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovIJT-003nfb-Ak; Wed, 16 Nov 2022 13:18:47 +0000 From: Christoph Hellwig To: Steve French Cc: Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org Subject: [PATCH 3/3] cifs: remove ->writepage Date: Wed, 16 Nov 2022 14:18:35 +0100 Message-Id: <20221116131835.2192188-4-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221116131835.2192188-1-hch@lst.de> References: <20221116131835.2192188-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 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org ->writepage is a very inefficient method to write back data, and only used through write_cache_pages or a a fallback when no ->migrate_folio method is present. Now that cifs implements ->migrate_folio and doesn't call generic_writepages, the writepage method can be removed. Signed-off-by: Christoph Hellwig --- fs/cifs/file.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index ec14e38411a13..6701257541ab2 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2868,13 +2868,6 @@ cifs_writepage_locked(struct page *page, struct writeback_control *wbc) return rc; } -static int cifs_writepage(struct page *page, struct writeback_control *wbc) -{ - int rc = cifs_writepage_locked(page, wbc); - unlock_page(page); - return rc; -} - static int cifs_write_end(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned copied, struct page *page, void *fsdata) @@ -5247,7 +5240,6 @@ static bool cifs_dirty_folio(struct address_space *mapping, struct folio *folio) const struct address_space_operations cifs_addr_ops = { .read_folio = cifs_read_folio, .readahead = cifs_readahead, - .writepage = cifs_writepage, .writepages = cifs_writepages, .write_begin = cifs_write_begin, .write_end = cifs_write_end, @@ -5272,7 +5264,6 @@ const struct address_space_operations cifs_addr_ops = { */ const struct address_space_operations cifs_addr_ops_smallbuf = { .read_folio = cifs_read_folio, - .writepage = cifs_writepage, .writepages = cifs_writepages, .write_begin = cifs_write_begin, .write_end = cifs_write_end,