Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp696411rwe; Thu, 1 Sep 2022 06:25:23 -0700 (PDT) X-Google-Smtp-Source: AA6agR6imwCxksVdqCHBGjiBbqlpV3XdCpViZC/TDM9a+abw9oJyUtV3Nyxk/vr1sMrQDV3KZjJz X-Received: by 2002:a05:6402:3714:b0:445:d91b:b0aa with SMTP id ek20-20020a056402371400b00445d91bb0aamr27901011edb.313.1662038723044; Thu, 01 Sep 2022 06:25:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662038723; cv=none; d=google.com; s=arc-20160816; b=pSFJuVp0se/bvqECzrF6YqsGTTYRmVYwTBajR4310sVqiQ0Nu4gmySqvUrjRkQQyK9 4xRNmTqabHq4JZxa+g2kQKmUx1B2bDyPqOZK+FLXspR+Njkl9LQ9EhmBZg0LrHcYC1TD V/0yuYkB9ewATfHaXILf7IyYhegfMJoHMyfnbN3Xro0CMzggyelZkAIKnpITArPKqqbm xpMLabH3rm3w6bAPc5fj3JAEwnszEprHaoMsJyrEGovU4EXwSmaxfELRACMDDfJy7hnA sBFXSa8dUFX9cEFBXoln9by2ISn8HRj9KgzfW1EWWppqDsF4JGNRLNf75TPD1lmy2tIP /GOQ== 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=ZEbq4ciByGMTGCq3QrHYR+l4zo6+fvg8Lz+6eF6fwuE=; b=C7lEAIQbTJ6KgsVR+pPbJZG3fpTbdsR07AFH1zgb/I38WKDNq3E/3UpBOLyIRK105K DG+hEpTUdOlJJG0R8hMrQwOh3CW6ANrPLNRqV/t6+ARMVGTmz5hPhmIh67TYRqtLWHdo 7bzB1Qb+pa/J5VegcHfvW6O44ihJ5puUU0S1vhVDDNcB8QnaGTyv4OI7EU+g2uWf0thp /ZGNxMfcJffGqP/pkr07ehLzhqI1g44/QPeNlJbmWXVqQyA9m/fxtH+jVH25V/Vk25B8 5wgftgfSJAZ18ehPsS3UJUIM42WKSD4ulnLbA41pl13xbSh6UhSv6m8MPKs92S7r+0se Nbyw== 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 d30-20020a056402401e00b00443e3fe60a0si1797205eda.622.2022.09.01.06.24.57; Thu, 01 Sep 2022 06:25:23 -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 S234425AbiIANYh (ORCPT + 99 others); Thu, 1 Sep 2022 09:24:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234336AbiIANYM (ORCPT ); Thu, 1 Sep 2022 09:24:12 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B1A4201A4; Thu, 1 Sep 2022 06:24:03 -0700 (PDT) Received: from canpemm500005.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MJM9Z0SyCzlWYC; Thu, 1 Sep 2022 21:20:34 +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; Thu, 1 Sep 2022 21:23:59 +0800 From: Zhang Yi To: , , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v2 03/14] fs/buffer: replace ll_rw_block() Date: Thu, 1 Sep 2022 21:34:54 +0800 Message-ID: <20220901133505.2510834-4-yi.zhang@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220901133505.2510834-1-yi.zhang@huawei.com> References: <20220901133505.2510834-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 | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index a6bc769e665d..aec568b3ae52 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,7 @@ 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); + bh_readahead(bh, REQ_RAHEAD); brelse(bh); } } @@ -2022,7 +2022,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 +2582,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 < 0) goto unlock; } -- 2.31.1