From patchwork Fri Nov 3 05:09:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Dongyang X-Patchwork-Id: 13444306 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 5F5CEC4332F for ; Fri, 3 Nov 2023 05:10:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229497AbjKCFKO (ORCPT ); Fri, 3 Nov 2023 01:10:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjKCFKN (ORCPT ); Fri, 3 Nov 2023 01:10:13 -0400 Received: from outbound-ip191a.ess.barracuda.com (outbound-ip191a.ess.barracuda.com [209.222.82.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBC0A1A7 for ; Thu, 2 Nov 2023 22:10:07 -0700 (PDT) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by mx-outbound8-226.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 03 Nov 2023 05:09:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fFfLVCJofEv6tNFWB6WP+tj10783++XYkOnCUCnnrd1y8B89uZNmOBLn8XgZLzuTEyQN/ardgKLyB4654qgzYF6c5ElOSW+9RTHOTNc4YZi4UBVrSNi4PJRz/qhaXiTPsu7nV2+XwodwoQQ2Q9ovVcl/0cxxHweAFgP7ObHSrbJYfKXvUEihzGU/5J6GYae6M/cCUBMoRjZrkvE1DG5oQvqVO4UkUb9yMYyD55bXF8RSO2RRoU5N/+dUpBVYiTnnhynTwdJAacrTMg11IK+gqdPgCndfcn9r/OEkC4UW6YYmBCB0bZaEH/t62+hSE+hAxc8lApwKF73sPsqH5IvyMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EhyhobByy3czDRChRUdmXoPp3UaAxTOpm3dJHErmyag=; b=ZWwp3iA2hh/OvEFqTfMkrta8Fg8j1RypsViS0tZwU+kNki0pbf5MT2Zia++Vq8q3O6K7sUYtJ7soLNA3ryYymJq+rZcK3trmvzc0VNNNRq+dcjPafijBCtGyYjIBwWqw0o+ExwT8iGSqsjD8WBcZvX5iSv6mkSsRFnp6DDjRbbsiosRt0mZK+mcqHOovJEHphfsJuFweFs0oaUCeY8hbM8FgPsIatRjGKqUUxA2NpC+fv9cKCPLu7dm8kXue/9a1REnmq0EqqHGT+YMcJlyRPjDgAxOMXAtLAQ+OQa1eOKwgfJKnzKzCk4YNRbQ9pLraIVtkvIIMImXeXYh6GBI7UA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ddn.com; dmarc=pass action=none header.from=ddn.com; dkim=pass header.d=ddn.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ddn.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EhyhobByy3czDRChRUdmXoPp3UaAxTOpm3dJHErmyag=; b=dxLm70s4D3f9vXwWYpEwj9y4fuLsZIKnebqzPAJb9EczrgTddNER+UHMlpD9eq14dM0qtecDg4jDG+u/c55wsrrm5Q1gXlA8SdYO9v3EpaAgNN5kxnavIKkvaDGTfIbhzBbWPbYQMhs6TlCF69Kx5K+4wkDXCLMuB4t0NVf+Tjs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=ddn.com; Received: from DS7PR19MB5711.namprd19.prod.outlook.com (2603:10b6:8:72::19) by DS7PR19MB5901.namprd19.prod.outlook.com (2603:10b6:8:7c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.21; Fri, 3 Nov 2023 05:09:56 +0000 Received: from DS7PR19MB5711.namprd19.prod.outlook.com ([fe80::d7a0:ac28:9211:7962]) by DS7PR19MB5711.namprd19.prod.outlook.com ([fe80::d7a0:ac28:9211:7962%7]) with mapi id 15.20.6954.019; Fri, 3 Nov 2023 05:09:55 +0000 From: Li Dongyang To: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: hch@lst.de, adilger.kernel@dilger.ca Subject: [PATCH] mm: folio_wait_stable() should check for bdev Date: Fri, 3 Nov 2023 16:09:49 +1100 Message-ID: <20231103050949.480892-1-dongyangli@ddn.com> X-Mailer: git-send-email 2.42.0 X-ClientProxiedBy: SY4P282CA0007.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:a0::17) To DS7PR19MB5711.namprd19.prod.outlook.com (2603:10b6:8:72::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR19MB5711:EE_|DS7PR19MB5901:EE_ X-MS-Office365-Filtering-Correlation-Id: fad7d9c9-8e43-4c58-03e0-08dbdc2b1df1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tRew/5Q6lmUoVGLBWmUM8mJw47Q+7g9o5N+RVc7taVhXOtGdefNjHcH77YnA61qYSXLW6ek3wyVD8dCfTwkPxO4lubayXzmbwokGd70HoFaoeeVU2Dj8degUtF/YctRYE7s8HTjYsFUd7YCpGy2XbRyQ0XoW0RoFQ+WRU3WcLrxWlHJCrCWmLY17HWWZvq32I/TJQLEmdBgNDKqQEEyLweR6Ku0QMIGJPaCXH8nONGn/CdJllqawQrkccd4z+VcuSGlNoo/L1MY8ZXUnd7epweHOAevi0Y7Epr+XEGX87VIA6+talqJtgejghDSL51/nZK6Grp5UP8gX4Lhn4cIxf/V0pJXAL34d5F3/4mP51cT3S3gm2mKYvvVL9L1vUDQ9RQi2SkXxOL8FfOxbv1O/jIaEG779hBo/jGIo/UdP3gMTZMtzvpa2PZKGogfMjgJrirUVm88CiCKOqNrk8m4/OrNPq/MaElFuNclQyO6NFAUzdDz59pgmUEvr8FjEg+5HbAkK0jD+B8WX14L5XTFzA5r9mdEokBA4HhhChC6B9dTKTv86KszhjCqm3SehId3j X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR19MB5711.namprd19.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(346002)(376002)(136003)(39850400004)(396003)(230922051799003)(451199024)(64100799003)(186009)(1800799009)(6512007)(26005)(2616005)(55236004)(478600001)(6666004)(2906002)(83380400001)(5660300002)(6506007)(41300700001)(66946007)(6486002)(66556008)(66476007)(4326008)(8676002)(316002)(8936002)(1076003)(36756003)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XiI2nZaRFQ6QiDs0k1pfRKGIE6StlLboBrjNNXY29eZ4O36ec2BjczXR61abIl5xJLqsHC96A9iIBCvXfLZnnSqaPF8nqFZyLwVFPzK0z9TfNyezjv055KKdy3szj5eKnjW+BS9NBZ4xww+nvTPUcdRwMK3/vAj6MW4TxZI1+VYKSEyXNcxFaLF8KTh2ZfdTNsMFzDx/pWQDX2znjW56Xyx4Ns0TUn8JimQ/bAdbbDS6AGoSTr/fn4r2ErYdAAyDjeESxPazmUYPdI1VLW7zCfAViPRqThomUxNhPkT4mNsvWvs1ff7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yztxYztrXx98tepqHUNngGnMMRHGDN/wYCtCjsSukmrCrKYajYxgQ== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-Network-Message-Id: fad7d9c9-8e43-4c58-03e0-08dbdc2b1df1 X-MS-Exchange-CrossTenant-AuthSource: DS7PR19MB5711.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2023 05:09:55.2457 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 753b6e26-6fd3-43e6-8248-3f1735d59bb4 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: twyMsQv5yM9JbDXGWavqaiGPpHxO5vYjPTLM+U0z4lp1XwRSTVrs4xgx0snp56Ge X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR19MB5901 X-BESS-ID: 1698988199-102274-12492-105637-1 X-BESS-VER: 2019.1_20231024.1900 X-BESS-Apparent-Source-IP: 104.47.58.100 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVobGRsZAVgZQ0NzEPDnRLDUl2c jQOC01NSnNzNzcMsUiNcksNc3cwDBFqTYWAI8ofQhBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.251874 [from cloudscan10-148.us-east-2a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org folio_wait_stable() now checks SB_I_STABLE_WRITES flag on the superblock instead of backing_dev_info, this could trigger a false block integrity error when doing buffered write directly to the block device, as folio_wait_stable() is a noop for bdev and the content could be modified during writeback. Check if the folio's superblock is bdev and wait for writeback if the backing device requires stables_writes. Fixes: 1cb039f3dc16 ("bdi: replace BDI_CAP_STABLE_WRITES with a queue and a sb flag") Signed-off-by: Li Dongyang --- This patch supersedes the previous block: add SB_I_STABLE_WRITES to bdev sb flag --- --- mm/page-writeback.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index b8d3d7040a50..a236f93347a1 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -3110,7 +3110,11 @@ EXPORT_SYMBOL_GPL(folio_wait_writeback_killable); */ void folio_wait_stable(struct folio *folio) { - if (folio_inode(folio)->i_sb->s_iflags & SB_I_STABLE_WRITES) + struct inode *inode = folio_inode(folio); + + if (inode->i_sb->s_iflags & SB_I_STABLE_WRITES || + (sb_is_blkdev_sb(inode->i_sb) && + bdev_stable_writes(I_BDEV(inode)))) folio_wait_writeback(folio); } EXPORT_SYMBOL_GPL(folio_wait_stable);