Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp175575rwe; Wed, 31 Aug 2022 00:13:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR7JGRAbPQDNVLaobNUGm7ed5hhRkSthgsyp1cFj1BXA6pnKIKyQW5xGi5Iw0y1spywR2DRc X-Received: by 2002:a17:907:7678:b0:730:e1ad:b128 with SMTP id kk24-20020a170907767800b00730e1adb128mr20090062ejc.67.1661929993465; Wed, 31 Aug 2022 00:13:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661929993; cv=none; d=google.com; s=arc-20160816; b=YtK81qyGHu/1Ej7OHAdOeJ3epVLut38YT7KJXYQ+l7AK0KV3hkP0bE1c4O4W9MVTjl j2/BYj2FwOXWQ2SRI735ksxPzBjTFeiFYu7PV14efZ1QRlJCiyqP9jOVch3+Bk30FfUj l5U4elr9NxsiXYkC334bQcBBDDq88I4HNcSmwPIRstBB3505pN0Z2Sx3d6DGONDH0QLA 5tIyWabd8dtg17VUqx8+yW6wGoZkFHkMmm/13Xq7E5OVGa/ownW8kef7AC4t59SOyLR6 erby2Hbp0O3thefkeyzhTBmXXpYUMN9zfJnTAe2Nq43EFdtmQZd0WglYPTRXEwcIM+QP Sj5g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=WjgmEcxWedtyRrzCb4Tgp5aZKXjU5cK6AQrEouthsPU=; b=eFMScdAMeA8BZyfOG91EGoial358vuAxn0FcdRkOMEFu/ayhx9wSbMrg2VRDyCgSor zTRM6t29DJ94hc8j7VRvtNH0+vvakh45nymp+FqxhFf/776GMwZNJs0bsH9+0vKIVJNj 6+F3DD41TBbCnwOPspVrXwAkrPXYR/gxltNls6mAWnWvhqzlkUbAitUxPNMRRXk3l/IY N3NptOBl/waYV6H/PqgOQcozDSt52Vd7QIUnKfY7BpkKL+Lt98fERWlyI4hfiJJntl/R 2ngEQb2Nf1tLdH7cHqGoF8OY0NwOeSRBbbVRxArtzGYVPSXnFNYWZk0TzjLjIV0PZ14o Foqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n14-20020a170906688e00b0073d63d9946asi8481943ejr.109.2022.08.31.00.12.47; Wed, 31 Aug 2022 00:13:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230455AbiHaHKL (ORCPT + 99 others); Wed, 31 Aug 2022 03:10:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230413AbiHaHKH (ORCPT ); Wed, 31 Aug 2022 03:10:07 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A60BE0AA; Wed, 31 Aug 2022 00:10:06 -0700 (PDT) Received: from canpemm500005.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MHZwb6y9SzlWfp; Wed, 31 Aug 2022 15:06:39 +0800 (CST) Received: from huawei.com (10.175.127.227) by canpemm500005.china.huawei.com (7.192.104.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 31 Aug 2022 15:10:03 +0800 From: Zhang Yi To: , , , , , , CC: , , , , , , , , , , , , , Subject: [PATCH 03/14] fs/buffer: replace ll_rw_block() Date: Wed, 31 Aug 2022 15:21:00 +0800 Message-ID: <20220831072111.3569680-4-yi.zhang@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220831072111.3569680-1-yi.zhang@huawei.com> References: <20220831072111.3569680-1-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500005.china.huawei.com (7.192.104.229) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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-ext4@vger.kernel.org ll_rw_block() is not safe for the sync IO path because it skip buffers which has been locked by others, it could lead to false positive EIO when submitting read IO. So stop using ll_rw_block(), switch to use new helpers which could guarantee buffer locked and submit IO if needed. Signed-off-by: Zhang Yi --- fs/buffer.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index a663191903ed..e14adc638bfe 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -562,7 +562,7 @@ void write_boundary_block(struct block_device *bdev, struct buffer_head *bh = __find_get_block(bdev, bblock + 1, blocksize); if (bh) { if (buffer_dirty(bh)) - ll_rw_block(REQ_OP_WRITE, 1, &bh); + write_dirty_buffer(bh, 0); put_bh(bh); } } @@ -1342,7 +1342,8 @@ void __breadahead(struct block_device *bdev, sector_t block, unsigned size) { struct buffer_head *bh = __getblk(bdev, block, size); if (likely(bh)) { - ll_rw_block(REQ_OP_READ | REQ_RAHEAD, 1, &bh); + if (trylock_buffer(bh)) + __bh_read(bh, REQ_RAHEAD, false); brelse(bh); } } @@ -2022,7 +2023,7 @@ int __block_write_begin_int(struct folio *folio, loff_t pos, unsigned len, if (!buffer_uptodate(bh) && !buffer_delay(bh) && !buffer_unwritten(bh) && (block_start < from || block_end > to)) { - ll_rw_block(REQ_OP_READ, 1, &bh); + bh_read_nowait(bh, 0); *wait_bh++=bh; } } @@ -2582,11 +2583,9 @@ int block_truncate_page(struct address_space *mapping, set_buffer_uptodate(bh); if (!buffer_uptodate(bh) && !buffer_delay(bh) && !buffer_unwritten(bh)) { - err = -EIO; - ll_rw_block(REQ_OP_READ, 1, &bh); - wait_on_buffer(bh); + err = bh_read(bh, 0); /* Uhhuh. Read error. Complain and punt. */ - if (!buffer_uptodate(bh)) + if (err) goto unlock; } -- 2.31.1