Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2286385iof; Wed, 8 Jun 2022 01:27:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwphB4EJBHN8qsheP2X7NfKI5s0OSr4uYkDw0O6rpERmVgSKgoxXoUzOxpbuqH+Et4+A8Fj X-Received: by 2002:a63:135b:0:b0:3fd:876c:975a with SMTP id 27-20020a63135b000000b003fd876c975amr16136729pgt.538.1654676866484; Wed, 08 Jun 2022 01:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654676866; cv=none; d=google.com; s=arc-20160816; b=hdOtH8W6yqWrStYM4ORryyt1Cg7OGndZmxynGjF8G57gwr7f/zC0LqTUCm2VfQgS5I 0HjSWPHFjZUy/aNGcJFBn4WHnxPDP6k1+26JeOuXIeqYk1UeqHCGjeAkEb/dT0OXM19o RmuIVF8ow26M0hLXZ8TXy2nq4Pf1S17kqrCtF3aK4svj/WbCiqfKbhj29iwsDnmE3WHy LKZfLOA26ZjMsqNPEhtfgLvrsgjJhExQy/lEdw7DdxOB3QKx5faj3ws6Im8pGjIYWaHS Ug5H0tn7SK+r6hoi2HYyDeRpzQ7MMXoIu33ODjyOSomBVIT7gD+zi2Cn7wkL5HkDFUh+ yxcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=S+6LojNcBMDCyexi0RbDUmv35gQSo2fjW/Y45Hh7LpY=; b=Zj5HVGphuvISpBtHd4UkTnfofaUoweN9xoz0hJUtEjjrYXHVrN7yyNPC+5uLi/mfFl 1CdZ4oIcUZAgVwUfzQXV6XTLejNMBPinUokLhZISvKNIM8IAOrZSOk4Nr2JTPhdhp2P6 waq0CHoFDdPMQVMOMA2QwhWfAZsmRdiX4sAkMKV1sMO71z21wbw42hGtQaCPTEmpRc7W kzVDizt67dEmlZ5uYiXTdOx47H6MNC1ofUxDnmDBLtq2n9Y9OI1UdsM9bC7sOPCI6Ws2 9Pj6w7ozKW/Gc5SRgR2nkJavRXc2FbgTFfBoP36fvbqZN3j8cZRnPyoZ/X49F0BPCm9e x4sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v0e0BV3z; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i5-20020a170902c28500b00163f8c2dec7si25071283pld.347.2022.06.08.01.27.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:27:46 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v0e0BV3z; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 771AC10EA73; Wed, 8 Jun 2022 00:57:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388853AbiFHB1y (ORCPT + 99 others); Tue, 7 Jun 2022 21:27:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383924AbiFGWIy (ORCPT ); Tue, 7 Jun 2022 18:08:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF8E625873C; Tue, 7 Jun 2022 12:18:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 96295617DA; Tue, 7 Jun 2022 19:18:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A493CC385A2; Tue, 7 Jun 2022 19:18:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629527; bh=dQGT3VlrKxcHxBouEadgO5wi9SVWHYVnGFN9n4WJfvY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v0e0BV3zzotDL1ppxjj6j07We1M6l1EBd+7coiWyxarIk4MTLlvo2iyxRWFRU21ug Ct1QF3EFLMPAI5rusNhnv2dCufRYSOqtF11/nxjisiVeYUW270Ih3undR77v73KJOC NCxd6ZwzWKoOcBHiagF3oQnupwNZ3BXk1UIzvLpI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Olga Kornievskaia , Trond Myklebust , Anna Schumaker , Sasha Levin Subject: [PATCH 5.18 682/879] NFS: Further fixes to the writeback error handling Date: Tue, 7 Jun 2022 19:03:20 +0200 Message-Id: <20220607165022.642130557@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust [ Upstream commit c6fd3511c3397dd9cbc6dc5d105bbedb69bf4061 ] When we handle an error by redirtying the page, we're not corrupting the mapping, so we don't want the error to be recorded in the mapping. If the caller has specified a sync_mode of WB_SYNC_NONE, we can just return AOP_WRITEPAGE_ACTIVATE. However if we're dealing with WB_SYNC_ALL, we need to ensure that retries happen when the errors are non-fatal. Reported-by: Olga Kornievskaia Fixes: 8fc75bed96bb ("NFS: Fix up return value on fatal errors in nfs_page_async_flush()") Signed-off-by: Trond Myklebust Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- fs/nfs/write.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 4925d11849cd..2f41659e232e 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -603,8 +603,9 @@ static void nfs_write_error(struct nfs_page *req, int error) * Find an associated nfs write request, and prepare to flush it out * May return an error if the user signalled nfs_wait_on_request(). */ -static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio, - struct page *page) +static int nfs_page_async_flush(struct page *page, + struct writeback_control *wbc, + struct nfs_pageio_descriptor *pgio) { struct nfs_page *req; int ret = 0; @@ -630,11 +631,11 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio, /* * Remove the problematic req upon fatal errors on the server */ - if (nfs_error_is_fatal(ret)) { - if (nfs_error_is_fatal_on_server(ret)) - goto out_launder; - } else - ret = -EAGAIN; + if (nfs_error_is_fatal_on_server(ret)) + goto out_launder; + if (wbc->sync_mode == WB_SYNC_NONE) + ret = AOP_WRITEPAGE_ACTIVATE; + redirty_page_for_writepage(wbc, page); nfs_redirty_request(req); pgio->pg_error = 0; } else @@ -650,15 +651,8 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio, static int nfs_do_writepage(struct page *page, struct writeback_control *wbc, struct nfs_pageio_descriptor *pgio) { - int ret; - nfs_pageio_cond_complete(pgio, page_index(page)); - ret = nfs_page_async_flush(pgio, page); - if (ret == -EAGAIN) { - redirty_page_for_writepage(wbc, page); - ret = AOP_WRITEPAGE_ACTIVATE; - } - return ret; + return nfs_page_async_flush(page, wbc, pgio); } /* @@ -733,12 +727,15 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc) priority = wb_priority(wbc); } - nfs_pageio_init_write(&pgio, inode, priority, false, - &nfs_async_write_completion_ops); - pgio.pg_io_completion = ioc; - err = write_cache_pages(mapping, wbc, nfs_writepages_callback, &pgio); - pgio.pg_error = 0; - nfs_pageio_complete(&pgio); + do { + nfs_pageio_init_write(&pgio, inode, priority, false, + &nfs_async_write_completion_ops); + pgio.pg_io_completion = ioc; + err = write_cache_pages(mapping, wbc, nfs_writepages_callback, + &pgio); + pgio.pg_error = 0; + nfs_pageio_complete(&pgio); + } while (err < 0 && !nfs_error_is_fatal(err)); nfs_io_completion_put(ioc); if (err < 0) -- 2.35.1