From patchwork Mon Jun 27 13:23:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12896643 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 31ED4C43334 for ; Mon, 27 Jun 2022 13:24:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 981BE6B0071; Mon, 27 Jun 2022 09:24:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 90B3E6B0072; Mon, 27 Jun 2022 09:24:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7AB758E0001; Mon, 27 Jun 2022 09:24:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 67B0D6B0071 for ; Mon, 27 Jun 2022 09:24:01 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 253DB120830 for ; Mon, 27 Jun 2022 13:24:01 +0000 (UTC) X-FDA: 79624083882.02.9040816 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf07.hostedemail.com (Postfix) with ESMTP id F06E64003D for ; Mon, 27 Jun 2022 13:23:59 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4LWpM65sQ4z9srP; Mon, 27 Jun 2022 21:23:14 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 27 Jun 2022 21:23:53 +0800 From: Miaohe Lin To: , CC: , , , Subject: [PATCH] filemap: minor cleanup for filemap_write_and_wait_range Date: Mon, 27 Jun 2022 21:23:51 +0800 Message-ID: <20220627132351.55680-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656336240; a=rsa-sha256; cv=none; b=pv6mhjyAu26l5ytjFRDTIlrms+qVKSAAVTA4eWtbLnE9h4rB5J2uyJYHCISpLN5/vGs8v7 yhef4T+nCs4ax9dYWoQ0Uq+/O2Oi9egqcrtThEHuWaz9dWQngSljDxJgFys1iUvb3S1gut 8S9nmL4+iudOHPbDZbSrF3WwYC55hLg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656336240; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=mae6CpNhDieIa2C6tunc8o6evNIepDQ1R1KJp6Daj98=; b=5dzzKo2LfOwFd/Q2tnDvPFwTS7D/F4O8wIfmOhS975GKX1LvUD0LFbwK69OTP3BC9zh9HW ePFiLNwCi7zO7m6+Z7KxjiJZYM2WtMhx3qvpi3cAGl7rJ/me8WsV/RbBx+RkYVodX1+5HB UU1cKO80xYuT+b4Ped/4dDoHvqs6Ht4= X-Stat-Signature: c6nzy3y4ywnaexctkhfxp3k5czws5g7i X-Rspamd-Server: rspam08 X-Rspam-User: X-Rspamd-Queue-Id: F06E64003D Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-HE-Tag: 1656336239-153800 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: Restructure the logic in filemap_write_and_wait_range to simplify the code and make it more consistent with file_write_and_wait_range. No functional change intended. Signed-off-by: Miaohe Lin Reviewed-by: Muchun Song --- mm/filemap.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 8ccb868c3d95..b561619cfafe 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -667,7 +667,7 @@ EXPORT_SYMBOL_GPL(filemap_range_has_writeback); int filemap_write_and_wait_range(struct address_space *mapping, loff_t lstart, loff_t lend) { - int err = 0; + int err = 0, err2; if (mapping_needs_writeback(mapping)) { err = __filemap_fdatawrite_range(mapping, lstart, lend, @@ -678,18 +678,12 @@ int filemap_write_and_wait_range(struct address_space *mapping, * But the -EIO is special case, it may indicate the worst * thing (e.g. bug) happened, so we avoid waiting for it. */ - if (err != -EIO) { - int err2 = filemap_fdatawait_range(mapping, - lstart, lend); - if (!err) - err = err2; - } else { - /* Clear any previously stored errors */ - filemap_check_errors(mapping); - } - } else { - err = filemap_check_errors(mapping); + if (err != -EIO) + __filemap_fdatawait_range(mapping, lstart, lend); } + err2 = filemap_check_errors(mapping); + if (!err) + err = err2; return err; } EXPORT_SYMBOL(filemap_write_and_wait_range);