From patchwork Thu Sep 1 13:34:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 12962610 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 aib29ajc254.phx1.oracleemaildelivery.com (aib29ajc254.phx1.oracleemaildelivery.com [192.29.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8B448ECAAD1 for ; Thu, 1 Sep 2022 13:24:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=fIWFzd+4OSG7kctJW4DehgCpmIgIGWpb//91BgzJMJI=; b=X6GioFrcCLaa9oH9wDLankgD16/kZbgMr0i0rA5qTK+gSFaEInRD9ww5NahdNkAZ8aEZOmi37NK0 jq6bGahSiBYLCCJAEBOetDyH+NnBO1T02eFjcRE8EprtSlrSavtvfqLzg01NObnFWAJNRLDu7sbk rE8qm7lfLUevKggJymAfERxBxEFt9z0b7mpiqDZZC4huGhn+1mg44dXx2ffcMWe0Gtj/j2Zn3Lau NEdG9dyTj5jtdJA/AtbCwFGjMZyE2PPsTxuVtXfH3QGO5zm6SaUuMUJ8h2eTRMhDaEvxjtUTVopS WqfyfzeqAIafqZB0eMsMtccOhLMBp9WxC24Z3Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=fIWFzd+4OSG7kctJW4DehgCpmIgIGWpb//91BgzJMJI=; b=uicyLbBWvbE0TsuoLEtjrwb0gQS4GEWdEizZ46sl9CjGBAc9lfmOfAmRlHQ/6xuRXqmrizbjCSOd jhZAmMF4OgPat3o6v4V50QwySvTAVNCJQIX/BuRxMlLOb3BSlmxlBXvPmm4fie60njIzFHr1AwRP XiPr6KYhfF+I7if9I5OS6MOcRgobNq5/i7vyBpA3b5G0EDP0qViM6hpEoL8mXKCm7MSoi/kwIfMP nDEyKoKJxpasGQjidb82vDmsqqvPqoxs1Fhm2KWT2MKVG0X90uBZrAY/pWenzhet4EIrPOghfqUu dNIcz5ElotKYLek9LGvfmUbIqvEt9zCzsvDtMQ== Received: by omta-ad3-fd3-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220817 64bit (built Aug 17 2022)) with ESMTPS id <0RHJ00B7H98FAQB0@omta-ad3-fd3-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Thu, 01 Sep 2022 13:24:15 +0000 (GMT) To: , , , , , , , Date: Thu, 1 Sep 2022 21:34:52 +0800 Message-id: <20220901133505.2510834-2-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 X-Originating-IP: [10.175.127.227] X-Source-IP: 45.249.212.187 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10457 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 impostorscore=0 mlxscore=0 phishscore=0 adultscore=0 clxscore=119 bulkscore=0 suspectscore=0 malwarescore=0 priorityscore=207 mlxlogscore=799 spamscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209010060 domainage_hfrom=8269 Cc: axboe@kernel.dk, hch@infradead.org, tytso@mit.edu, agruenba@redhat.com, yi.zhang@huawei.com, almaz.alexandrovich@paragon-software.com, viro@zeniv.linux.org.uk, yukuai3@huawei.com, rpeterso@redhat.com, dushistov@mail.ru, chengzhihao1@huawei.com Subject: [Ocfs2-devel] [PATCH v2 01/14] fs/buffer: remove __breadahead_gfp() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Zhang Yi via Ocfs2-devel Reply-to: Zhang Yi Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com 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-ServerName: szxga01-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-ORIG-GUID: e58GfGUoQlk6icVLEJ6Amjk9640-i4Z6 X-Proofpoint-GUID: e58GfGUoQlk6icVLEJ6Amjk9640-i4Z6 Reporting-Meta: AAF55idWRfbxPozgKQ8TMIUHlDoYw8FeqJaVSOKzo6F8/PWC3EIgXdDEuV1xrAIb WQiHDn7HizP8/T/XB6z8jR7C43Runt2Zy2XxpvmbQcAPlopG+ppwVKabFVCXxMAA cmsN14gGmMzS3uLr8RPHo/ltMTGfnqwwwMLEZ8Vt8xBCCrYoUWku3BLe98sNYivD G7SQ1lV4ifO/oHW0JNRED1PulFTv26ZIqVgl6KB6PTxTWhhKEl8nizDcbXoXbavz 5xd6DNFxDI67yT0x/6XLHEsLfMRMPG7oEvNJHUS1ZRKPQIm4RnJ+8vRY3xjt9+Xb lsKePt8hZobX1vkceAkyEdO5R4Sciig4/9WD2hkufebMa2F4QKwUaSg7h6myNZcO XHP8waiPHxECIbGQT1FSMQZxUg+U8OJtOtjQpMBV3bAibe3ZLmGj7uC23eLhBsJz 2uda2QguuMLxihV5nGIlugOEJgfh0nuFPdAE7Jkrsxw3X8kOL6gg/+uRoLZHFlGD UABlz60Tqq5ZpF8NyirW7r/CYoeBLIg5aoTFI/QV3MVk No one use __breadahead_gfp() and sb_breadahead_unmovable() any more, remove them. Signed-off-by: Zhang Yi Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig --- fs/buffer.c | 11 ----------- include/linux/buffer_head.h | 8 -------- 2 files changed, 19 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 55e762a58eb6..a0b70b3239f3 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1348,17 +1348,6 @@ void __breadahead(struct block_device *bdev, sector_t block, unsigned size) } EXPORT_SYMBOL(__breadahead); -void __breadahead_gfp(struct block_device *bdev, sector_t block, unsigned size, - gfp_t gfp) -{ - struct buffer_head *bh = __getblk_gfp(bdev, block, size, gfp); - if (likely(bh)) { - ll_rw_block(REQ_OP_READ | REQ_RAHEAD, 1, &bh); - brelse(bh); - } -} -EXPORT_SYMBOL(__breadahead_gfp); - /** * __bread_gfp() - reads a specified block and returns the bh * @bdev: the block_device to read from diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 089c9ade4325..c3863c417b00 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -214,8 +214,6 @@ struct buffer_head *__getblk_gfp(struct block_device *bdev, sector_t block, void __brelse(struct buffer_head *); void __bforget(struct buffer_head *); void __breadahead(struct block_device *, sector_t block, unsigned int size); -void __breadahead_gfp(struct block_device *, sector_t block, unsigned int size, - gfp_t gfp); struct buffer_head *__bread_gfp(struct block_device *, sector_t block, unsigned size, gfp_t gfp); void invalidate_bh_lrus(void); @@ -340,12 +338,6 @@ sb_breadahead(struct super_block *sb, sector_t block) __breadahead(sb->s_bdev, block, sb->s_blocksize); } -static inline void -sb_breadahead_unmovable(struct super_block *sb, sector_t block) -{ - __breadahead_gfp(sb->s_bdev, block, sb->s_blocksize, 0); -} - static inline struct buffer_head * sb_getblk(struct super_block *sb, sector_t block) { From patchwork Thu Sep 1 13:34:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 12962612 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 aib29ajc248.phx1.oracleemaildelivery.com (aib29ajc248.phx1.oracleemaildelivery.com [192.29.103.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A42C1C64991 for ; Thu, 1 Sep 2022 13:24:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=Iz8niT28R/j0Gma1iAmexQqXcxmu0auXr57hWc5mNSg=; b=mN7JqHDpwY60tVWawhgRf5jHsXdxPUhi++UNsSvg6m5CEeDnGmTNzB6E4L5ogxzw947sCSFA2t3E Dab+1ko7S5VwdvbvOWkEWL4S0K878XBIJyBp4O60h3xcJVpugvJAEbtZ+etcU6nczxtfIE5mJopq Tg7ng87SpcCo7Lnz3apenVozE/iV6h6VIf9ACSZiOPdC6h2wUf/H8Y6N1RqmYWosDqOOoZto/JLz kQ5lBektN1a7FR1CKOrsSrtzeV9TQtOASCR9lForxkvxqvLKAtGewzTEPD+/hw4ZT2zovr7iHlFg fttp6FurOrmiG9n6Uj6l5RQ48zz8BtGgfXzvRQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=Iz8niT28R/j0Gma1iAmexQqXcxmu0auXr57hWc5mNSg=; b=JN1xu2Eak79f69RZwtgp2I7wEQ1QbZ807nBNJdB0S32pqcZnws3FSybAX2xCnFmfU7EMZPxnAqH3 iS41i4JbgUeRCy9nJ7LKt9zlhKVNvXFFJen9WDCdM5kavlEPmnKtTbn2AcOdM/YS90l3y8IwXXAu RzG265/7Q0VKp4ILcFkMxe7fsPgy5G9X0I1ejzHNlI+Aq20nL6/Mk5PRK0cQngHobh3DMSG1eMvq mKhhxeqcsk3XycFb/4IdJzRkqUtzz9bKzz0UV5Y7wOzalPNWMC2zO9lOksb9iaRfnqFiVNwJiM0W jKAnAd5CSQT5wwedh0vS1hDvAz6BaLVrDItVoA== Received: by omta-ad2-fd1-201-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220817 64bit (built Aug 17 2022)) with ESMTPS id <0RHJ007EX98J8X10@omta-ad2-fd1-201-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Thu, 01 Sep 2022 13:24:19 +0000 (GMT) To: , , , , , , , Date: Thu, 1 Sep 2022 21:34:53 +0800 Message-id: <20220901133505.2510834-3-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 X-Originating-IP: [10.175.127.227] X-Source-IP: 45.249.212.187 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10457 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 mlxscore=0 phishscore=0 suspectscore=0 adultscore=0 priorityscore=207 mlxlogscore=770 clxscore=119 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209010060 domainage_hfrom=8269 Cc: axboe@kernel.dk, hch@infradead.org, tytso@mit.edu, agruenba@redhat.com, yi.zhang@huawei.com, almaz.alexandrovich@paragon-software.com, viro@zeniv.linux.org.uk, yukuai3@huawei.com, rpeterso@redhat.com, dushistov@mail.ru, chengzhihao1@huawei.com Subject: [Ocfs2-devel] [PATCH v2 02/14] fs/buffer: add some new buffer read helpers X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Zhang Yi via Ocfs2-devel Reply-to: Zhang Yi Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com 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-ServerName: szxga01-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-GUID: WBkEPgVXZYA8ZpzJz7ZXnby9AbFgF3qo X-Proofpoint-ORIG-GUID: WBkEPgVXZYA8ZpzJz7ZXnby9AbFgF3qo Reporting-Meta: AAF2x+q1GWvWJCW6ocMuMEwXSi4KbqRgdGigNhBvvQFU6Q66mcluShaj09qrQ4sX DDE78Q1JU37zeJuck4yQNxAF6pxnzBtdTP+fSsHsSfDXuNVMkuINlsirURYZs+u4 H02p0TMSWzKi/A33LB507zm/7ST/+ne8jnxJRtHmf0O0dWzcGBdhlnE3FevnXRVp HeA1AiZz63+tBUhiNEYzz2Uq8AgIeX5u1RyOTZK8Lc6Dnk+aVH1qKqYk/X7i4n0Z Boi5EuMOSSYQv5aizA+0icBwZBXUkQfkARBWBLlkay5eI0df0+6lQjH17XQZraqE lVfPxfuIyHjfvJpgliW+Pqts5z8jZy+5/XJmq6zzd6VjNke/sUnIRLlny33DgOwo OKWIy0VWNIDV3BWPf0ywblMOzi0b5585YbSgJX6XQsqLhwA/Zg7pkgb/muuWv2zV 8pC74BB8sOoZI85x2gkpMmf8ZvmdTS234aRCXjNoob1FNK1Ob1g1hS8+NHoNlhW3 RILosnPz+N2fdeu46zgG2bOCO/s+ZqbhTA9cbVbIt2XSKA== Current ll_rw_block() helper is fragile because it assumes that locked buffer means it's under IO which is submitted by some other who holds the lock, it skip buffer if it failed to get the lock, so it's only safe on the readahead path. Unfortunately, now that most filesystems still use this helper mistakenly on the sync metadata read path. There is no guarantee that the one who holds the buffer lock always submit IO (e.g. buffer_migrate_folio_norefs() after commit 88dbcbb3a484 ("blkdev: avoid migration stalls for blkdev pages"), it could lead to false positive -EIO when submitting reading IO. This patch add some friendly buffer read helpers to prepare replacing ll_rw_block() and similar calls. We can only call bh_readahead_[] helpers for the readahead paths. Signed-off-by: Zhang Yi Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig --- fs/buffer.c | 65 +++++++++++++++++++++++++++++++++++++ include/linux/buffer_head.h | 38 ++++++++++++++++++++++ 2 files changed, 103 insertions(+) diff --git a/fs/buffer.c b/fs/buffer.c index a0b70b3239f3..a6bc769e665d 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3017,6 +3017,71 @@ int bh_uptodate_or_lock(struct buffer_head *bh) } EXPORT_SYMBOL(bh_uptodate_or_lock); +/** + * __bh_read - Submit read for a locked buffer + * @bh: struct buffer_head + * @op_flags: appending REQ_OP_* flags besides REQ_OP_READ + * @wait: wait until reading finish + * + * Returns zero on success or don't wait, and -EIO on error. + */ +int __bh_read(struct buffer_head *bh, blk_opf_t op_flags, bool wait) +{ + int ret = 0; + + BUG_ON(!buffer_locked(bh)); + + get_bh(bh); + bh->b_end_io = end_buffer_read_sync; + submit_bh(REQ_OP_READ | op_flags, bh); + if (wait) { + wait_on_buffer(bh); + if (!buffer_uptodate(bh)) + ret = -EIO; + } + return ret; +} +EXPORT_SYMBOL(__bh_read); + +/** + * __bh_read_batch - Submit read for a batch of unlocked buffers + * @nr: entry number of the buffer batch + * @bhs: a batch of struct buffer_head + * @op_flags: appending REQ_OP_* flags besides REQ_OP_READ + * @force_lock: force to get a lock on the buffer if set, otherwise drops any + * buffer that cannot lock. + * + * Returns zero on success or don't wait, and -EIO on error. + */ +void __bh_read_batch(int nr, struct buffer_head *bhs[], + blk_opf_t op_flags, bool force_lock) +{ + int i; + + for (i = 0; i < nr; i++) { + struct buffer_head *bh = bhs[i]; + + if (buffer_uptodate(bh)) + continue; + + if (force_lock) + lock_buffer(bh); + else + if (!trylock_buffer(bh)) + continue; + + if (buffer_uptodate(bh)) { + unlock_buffer(bh); + continue; + } + + bh->b_end_io = end_buffer_read_sync; + get_bh(bh); + submit_bh(REQ_OP_READ | op_flags, bh); + } +} +EXPORT_SYMBOL(__bh_read_batch); + /** * bh_submit_read - Submit a locked buffer for reading * @bh: struct buffer_head diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index c3863c417b00..6d09785bed9f 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -232,6 +232,9 @@ void write_boundary_block(struct block_device *bdev, sector_t bblock, unsigned blocksize); int bh_uptodate_or_lock(struct buffer_head *bh); int bh_submit_read(struct buffer_head *bh); +int __bh_read(struct buffer_head *bh, blk_opf_t op_flags, bool wait); +void __bh_read_batch(int nr, struct buffer_head *bhs[], + blk_opf_t op_flags, bool force_lock); extern int buffer_heads_over_limit; @@ -399,6 +402,41 @@ static inline struct buffer_head *__getblk(struct block_device *bdev, return __getblk_gfp(bdev, block, size, __GFP_MOVABLE); } +static inline void bh_readahead(struct buffer_head *bh, blk_opf_t op_flags) +{ + if (!buffer_uptodate(bh) && trylock_buffer(bh)) { + if (!buffer_uptodate(bh)) + __bh_read(bh, op_flags, false); + else + unlock_buffer(bh); + } +} + +static inline void bh_read_nowait(struct buffer_head *bh, blk_opf_t op_flags) +{ + if (!bh_uptodate_or_lock(bh)) + __bh_read(bh, op_flags, false); +} + +/* Returns 1 if buffer uptodated, 0 on success, and -EIO on error. */ +static inline int bh_read(struct buffer_head *bh, blk_opf_t op_flags) +{ + if (bh_uptodate_or_lock(bh)) + return 1; + return __bh_read(bh, op_flags, true); +} + +static inline void bh_read_batch(int nr, struct buffer_head *bhs[]) +{ + __bh_read_batch(nr, bhs, 0, true); +} + +static inline void bh_readahead_batch(int nr, struct buffer_head *bhs[], + blk_opf_t op_flags) +{ + __bh_read_batch(nr, bhs, op_flags, false); +} + /** * __bread() - reads a specified block and returns the bh * @bdev: the block_device to read from From patchwork Thu Sep 1 13:34:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 12962613 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 aib29ajc247.phx1.oracleemaildelivery.com (aib29ajc247.phx1.oracleemaildelivery.com [192.29.103.247]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BAE31ECAAD3 for ; Thu, 1 Sep 2022 13:24:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=ddz0UmqMESkJLPVy3XJ+Im5L/sUFKtn+KiweUl3b3Dc=; b=1rpeox+um+vM1WiLTo0HL8dgp8WsZ0B2jpmPUkoxr0LViJEkPJyT1GU1L6mzVKfBb7qWYomut8Qg JDi+lB4QlH41h29WJn2V1GhfoNJZQij9wdKoq0dC1GuweMlzFCZUkhHiqWJZsFIeev2O65alQJAK F9gPttxB4xaVUR76G/b/cIgpeQLcOJtkHwoCE2POVCh/IFOxW2zc9xN29MEl0gnR2qgXhD/4/j7v jMuD2DyFeihfFkJhr/Re931jUFXe7sY2/0ffG8nkmkJaihVjsmYztaJTENqJmbcZSlbpv/Kq+Rad p/lCMQ7c8WbCGTEipXzoGyRymWeZeqYmIJsVfg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=ddz0UmqMESkJLPVy3XJ+Im5L/sUFKtn+KiweUl3b3Dc=; b=e4hrjjGyLX5qGBklsf8dd5aejCX6XRx5fOM8+3Fr8BVHTjhYsyPQYDoexdqCyb9k+GjhNDm6cr6P wyhURs5WUTadjf+ZmnKJxsAcLk6eUY9MrHYOQY04mj1ZBgo2Ue1wJkaPJqHFYJoqaIzMP0MuCSU1 M2PE/2sSGwzlWXJsLA9FfCbsrarLuHiy3UzLCmHamFCvg6jk0oWtCkGJFsoTckU68EOkVvvu5W6b /1Wz5vm4QZUmEN9WxvQdj0sSD2w+G/KdnMqU+P2GNN+1xlsQ2BFXcbFG4aADxQ87T/BNLO0vtsn8 IxzfT1oHs7YdfbFIW7B2t/mjg85Gjk1PCB3CXA== Received: by omta-ad1-fd3-102-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220817 64bit (built Aug 17 2022)) with ESMTPS id <0RHJ00L2Z98K6S90@omta-ad1-fd3-102-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Thu, 01 Sep 2022 13:24:20 +0000 (GMT) To: , , , , , , , 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 X-Originating-IP: [10.175.127.227] X-Source-IP: 45.249.212.188 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10457 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 malwarescore=0 priorityscore=207 phishscore=0 impostorscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 adultscore=0 clxscore=123 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209010060 domainage_hfrom=8269 Cc: axboe@kernel.dk, hch@infradead.org, tytso@mit.edu, agruenba@redhat.com, yi.zhang@huawei.com, almaz.alexandrovich@paragon-software.com, viro@zeniv.linux.org.uk, yukuai3@huawei.com, rpeterso@redhat.com, dushistov@mail.ru, chengzhihao1@huawei.com Subject: [Ocfs2-devel] [PATCH v2 03/14] fs/buffer: replace ll_rw_block() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Zhang Yi via Ocfs2-devel Reply-to: Zhang Yi Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com 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-ServerName: szxga02-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-ORIG-GUID: DRZYMPa5B7fhwEp21EGCY5rvTkv38s5d X-Proofpoint-GUID: DRZYMPa5B7fhwEp21EGCY5rvTkv38s5d Reporting-Meta: AAGJMB0kxE5tPjUshQcwVapkM6uX6X841baEh8Qht4rsUlFIp2cmwa3AmWbO13k1 2eMvuM17ffTZGFql+u8FkKNU4/bFBPl5HDK3ckRK3qrGUcD+RS5ZERgkDNOGqNko y2b/vrPziiRCWicxWHf9cC3f3Xl9SW+NlmLat/B94s2V2Er4cLlnr3Uf1PrZpMhc 4U33p3CSyeS3Bo6NFI69g95DYCRwjfzpebzqIUO7o/V/+12Om6wsqZZcNVC2i+D/ QI0Aolnxng1mOBJiBqzc2sbqSdJ3Qal7/K0Z2B+9tfpos0d8Gesdd+x/A7rD1pW2 UM0uT6y26fmH3zmpz+SIdvg+V2mYvYnLEBwqKPla9CyJryNzTJmQXzQxEaw8460Z jQyhBVknq88we2wCTVESKsfwqrjkoiirWm1uqNU7hHliQdc60c++zEIFowUXi9CG xJVSvtv001Dq+be/FBhAXmcGugMK99zgmnEMDRhHSSp5smwgxJ93zydI32nY27Mn Op+zisHVnFAbNRzqu7VB6Yx8tP9nllI9Nm7tvYg9bo35 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 Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig --- 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; } From patchwork Thu Sep 1 13:34:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 12962614 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 aib29ajc252.phx1.oracleemaildelivery.com (aib29ajc252.phx1.oracleemaildelivery.com [192.29.103.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3F096C0502C for ; Thu, 1 Sep 2022 13:24:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=4OrNcWlsxYANafIEeCZveKQuj0/uSOzs1nxT23ieFfk=; b=HHtbgFoJj6NSivRhfj7oNsjOcvwz7888mVh98lJmHDAiuRGjPyO9dQeW+w1fHWAejFSFMjwb+Tvy pntx/HPSoNrGUnLEqwoEXyiWOkIoZLn6dvyZR2Y3dFghsC2fw2ANKF1ZDnN6yPII0I/9dCkzUB3J I48Va5O/z31w55uxzSIezBdKH9Mm2iog3vc9+bp1PlnqscqSZGON5xe383wY0pvEHfWPlVyDa1r/ xZW7ERSWwVCsCR56TSs1qkLZX06s6rIy6k6vdEniEq6ND3V94IliUAtjVHYhbIiZ3glmEgGkdSwS kxRJzHQ2OLSPBbm897AGtMFUIiDuMN8S2v8Vcw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=4OrNcWlsxYANafIEeCZveKQuj0/uSOzs1nxT23ieFfk=; b=cilmLdv80/ZTm49FLnhCH22w6Et8ejxyMuAzFatQHcBVt1AVZ0oQaLstyWBe4CO524q7M4JQUDcM 3ZRnggGNZxdSVjk4eIPgaMNIVJ46InkFrCsl2P48bb6JvN0LIDZySlHkI/AFEyn/HuVQyyr2JdR1 QXyu+6HzbStadJqwsLrKuICoK1vFdM/cvmVTXc1DAzScyeK9G0k8a7YDiMdSFqnRQunh5DLHMFOL b+f9VyBbRgMUpDhcyBUmSRsm3P+2krooG2ZPBWBYKyoewB2Mk7ZtVze39avlldsOSzlpXmiWWxVG dMzr7bHbBCPvdm1WwpTeBGUMKLD3QwMyY3LYPw== Received: by omta-ad3-fd1-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220817 64bit (built Aug 17 2022)) with ESMTPS id <0RHJ00AKZ98LN6C0@omta-ad3-fd1-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Thu, 01 Sep 2022 13:24:21 +0000 (GMT) To: , , , , , , , Date: Thu, 1 Sep 2022 21:34:55 +0800 Message-id: <20220901133505.2510834-5-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 X-Originating-IP: [10.175.127.227] X-Source-IP: 45.249.212.188 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10457 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 clxscore=137 bulkscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=244 impostorscore=0 adultscore=0 phishscore=0 malwarescore=0 mlxlogscore=961 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209010060 domainage_hfrom=8269 Cc: axboe@kernel.dk, hch@infradead.org, tytso@mit.edu, agruenba@redhat.com, yi.zhang@huawei.com, almaz.alexandrovich@paragon-software.com, viro@zeniv.linux.org.uk, yukuai3@huawei.com, rpeterso@redhat.com, dushistov@mail.ru, chengzhihao1@huawei.com Subject: [Ocfs2-devel] [PATCH v2 04/14] gfs2: replace ll_rw_block() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Zhang Yi via Ocfs2-devel Reply-to: Zhang Yi Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com 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-ServerName: szxga02-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-ORIG-GUID: wQtFhPLHEn05jvm0ZdJB79DMm2X9V3HE X-Proofpoint-GUID: wQtFhPLHEn05jvm0ZdJB79DMm2X9V3HE Reporting-Meta: AAGNOSAbBHZAfrdVvHQmh19FHgXLyXfOQazCGCzNZCDQwDECEq8NvBJCnWnhi7ZS GToP8AVllXFQbklZ3JkQ6+PIAzCDrERl/cyP7oceslkS/O/qckn82R2/rbv3WVcw itloj5YGItKqvv3ORURKH7YtVQKXXBprGDoMWfX/A0Wc2ezINqKJa/W+GKe0J+wk NBRNUe0w0/TlvcieNx3aXG59HD6L8KTHA3y1LpkoSWdIt/QHeEoJ4l4Pezzeg6nh 8mdxYJu5D5m2LlAAf1ItvbPEWUs7TJVfTS/SatvtFtfzEeExmu9wY4Z2YbBgyDeN F1zY79O+0Sd/puLbQGxGeUwUYtrt09FPxtAmpqlkVCwh6i9ivPfE62N6ON96tmpP tYaFjhLzZVvxXghl7ONd6RyHFyWea0yr1Z2cCBAQ1j4e5TCdseqvMu2pE22pHDMS 9I/oRnoFPrRAgthqLpbNFVMhBSZAzqxdl5TsmYoHaOzImlsOIsmLy7DfJVH5NldX r+JYswYQaeby2IOYUepsuQlks0jE2JxZGaom4z/ZTow= ll_rw_block() is not safe for the sync read path because it cannot guarantee that always submitting read IO if the buffer has been locked, so stop using it. We also switch to new bh_readahead() helper for the readahead path. Signed-off-by: Zhang Yi Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig Reviewed-by: Andreas Gruenbacher --- fs/gfs2/meta_io.c | 7 ++----- fs/gfs2/quota.c | 8 ++------ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index 7e70e0ba5a6c..6ed728aae9a5 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c @@ -525,8 +525,7 @@ struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen) if (buffer_uptodate(first_bh)) goto out; - if (!buffer_locked(first_bh)) - ll_rw_block(REQ_OP_READ | REQ_META | REQ_PRIO, 1, &first_bh); + bh_read_nowait(first_bh, REQ_META | REQ_PRIO); dblock++; extlen--; @@ -534,9 +533,7 @@ struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen) while (extlen) { bh = gfs2_getbuf(gl, dblock, CREATE); - if (!buffer_uptodate(bh) && !buffer_locked(bh)) - ll_rw_block(REQ_OP_READ | REQ_RAHEAD | REQ_META | - REQ_PRIO, 1, &bh); + bh_readahead(bh, REQ_RAHEAD | REQ_META | REQ_PRIO); brelse(bh); dblock++; extlen--; diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index f201eaf59d0d..1ed17226d9ed 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -745,12 +745,8 @@ static int gfs2_write_buf_to_page(struct gfs2_inode *ip, unsigned long index, } if (PageUptodate(page)) set_buffer_uptodate(bh); - if (!buffer_uptodate(bh)) { - ll_rw_block(REQ_OP_READ | REQ_META | REQ_PRIO, 1, &bh); - wait_on_buffer(bh); - if (!buffer_uptodate(bh)) - goto unlock_out; - } + if (bh_read(bh, REQ_META | REQ_PRIO) < 0) + goto unlock_out; if (gfs2_is_jdata(ip)) gfs2_trans_add_data(ip->i_gl, bh); else From patchwork Thu Sep 1 13:34:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 12962622 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 aib29ajc253.phx1.oracleemaildelivery.com (aib29ajc253.phx1.oracleemaildelivery.com [192.29.103.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A14A4ECAAD3 for ; Thu, 1 Sep 2022 13:24:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=tcJVcqexIZzCWdE36q125JxESm575mrJsDGQZ7GzZZ8=; b=PFBAu/QuZkEtjBgoUkSoT3iHkPQJh9wBgesK1xbqJRYurm6ibnX9S+eVRgGcLpt7PeMEYxWeo69k dr/znZt9humwZv/xs/ItmF42ua/IukN+9Baem0x1A0pm9ld5YHjmMI0t56D5HBycLKOa3H82TSiV idiuWc5DVUdrVwYk4GSc2JCFkElxRKeP14egR5bwM7l6HoEHjngmDdwE705YTHKD737MWeRwh4b2 HSD/QnuNvo9a9VmOnGIz77/gQ42bqpQdzMtnbQM8q9wpYlF799GL3DqoNvJdeLUGYyCmh0IMhE+n zovh/oogCpBw6d3dvW70j0l879Lz7+xnWKwQbA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=tcJVcqexIZzCWdE36q125JxESm575mrJsDGQZ7GzZZ8=; b=PTDOqnavFMjV5aNXRH2hHTIcMHoyR8qcQzM+oTE/LQ7SZeDJSeKD1RV27AyD13cH7G1zb5RxIX89 LJN1fmnBOONkvfmFyJniu7DL5t6SdhB5xWOT3NyZDg2Exmm47Y3K1wS5Zs/aA8afgr/pf25++7rE H2Aq0NEzMOFHUK8/5nEPfMUHyjLPg9ku5yGPhG9q4w3rNLqBbYJtfSHIVLHtJh0BBEkAldxFXqxe A89ord15EOZxp4n5ibccU4uEy9fsJXUfrpSMfSeFq+P6v1N6xRBGHaJVilJqAuizvTY8zzecfgrv kXV3RnTtKfusgAXyvn/qzS+u2fGZK2oowLxWDQ== Received: by omta-ad3-fd1-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220817 64bit (built Aug 17 2022)) with ESMTPS id <0RHJ00O0C98WJP10@omta-ad3-fd1-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Thu, 01 Sep 2022 13:24:33 +0000 (GMT) To: , , , , , , , Date: Thu, 1 Sep 2022 21:34:56 +0800 Message-id: <20220901133505.2510834-6-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 X-Originating-IP: [10.175.127.227] X-Source-IP: 45.249.212.188 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10457 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 mlxscore=0 phishscore=0 suspectscore=0 adultscore=0 priorityscore=207 mlxlogscore=817 clxscore=119 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209010060 domainage_hfrom=8269 Cc: axboe@kernel.dk, hch@infradead.org, tytso@mit.edu, agruenba@redhat.com, yi.zhang@huawei.com, almaz.alexandrovich@paragon-software.com, viro@zeniv.linux.org.uk, yukuai3@huawei.com, rpeterso@redhat.com, dushistov@mail.ru, chengzhihao1@huawei.com Subject: [Ocfs2-devel] [PATCH v2 05/14] isofs: replace ll_rw_block() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Zhang Yi via Ocfs2-devel Reply-to: Zhang Yi Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com 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-ServerName: szxga02-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-ORIG-GUID: UVenWuULLmmDmmqCfUo8lPD14fcsyLGJ X-Proofpoint-GUID: UVenWuULLmmDmmqCfUo8lPD14fcsyLGJ Reporting-Meta: AAGw5akX3++AC8S/4x4G4JFq52NkczWkyM2QN5lIGaIce9rHt67ivD6eUaZ/FnhU VRzPISvzrlKP5eVShon9boQPmgEV8LTdGAtIsEYLRWFYjLZoVzH9OYE3LJU4LYmt DNt+LGVhR21XkNX+sLYJJvXOO3chiCYn7N8ar/8DVPofroRpW7WJIdmk6PRdmIt3 HIrP6ol3m2bXcOoUiy/eIdGyfwJ7jzWyzrj+O38sQ1Ob8G1wSK09BdJJ72qa+8Jd juY8dAIaP3tsETljmH31LwlX0IoKc8nVewa7Ubh+9JJvgu9K792m8LLnNC0v/72C yLxO2uL7XVDmBzun4NTY0XeoJfcNiAFQtRs+N0cYa4eOmkGmrQfnxsj6CXv3FxgK sQcoO90CMmvGbE48bGm5syojpasjVl+LhycslXAzlBqYSxIeSwHdrfDrvvOvEnpC TY+WcLc7OMo4zX9gqQ0lFhPQwv6/HQZs+Z/XD+CwMUuCXOOxc95X9J5r/wNv+21I C/XgpcGLUuTVB0TV4Mo4SNraPT9uSQZjC51CJLxUCa3h ll_rw_block() is not safe for the sync read path because it cannot guarantee that submitting read IO if the buffer has been locked. We could get false positive EIO return from zisofs_uncompress_block() if he buffer has been locked by others. So stop using ll_rw_block(), switch to sync helper instead. Signed-off-by: Zhang Yi Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig --- fs/isofs/compress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/isofs/compress.c b/fs/isofs/compress.c index b466172eec25..59b03d74ecbe 100644 --- a/fs/isofs/compress.c +++ b/fs/isofs/compress.c @@ -82,7 +82,7 @@ static loff_t zisofs_uncompress_block(struct inode *inode, loff_t block_start, return 0; } haveblocks = isofs_get_blocks(inode, blocknum, bhs, needblocks); - ll_rw_block(REQ_OP_READ, haveblocks, bhs); + bh_read_batch(haveblocks, bhs); curbh = 0; curpage = 0; From patchwork Thu Sep 1 13:34:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 12962616 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 aib29ajc255.phx1.oracleemaildelivery.com (aib29ajc255.phx1.oracleemaildelivery.com [192.29.103.255]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CAC8FC64991 for ; Thu, 1 Sep 2022 13:24:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=YLkcqhbGajkU2sUy67PK9wpiTtQ+y+2FHnU88DuUAaY=; b=J9jlC4sPmmi55GevqL/iiKPJIG6Tu4+nR3Jnvi01gDABgy1GxYQq2Vpo69psF4Erfzrk4Z6fpObm Fa/fzhdW0Wte2EW02LqgmZQrcIxEHlUgfrecQJ3ldBWTa9l2ibMINO5iq0csJ8rWfV3d29TAHUAr A6t/UU1KW8RHk9J7dCWXFVXk1ufNhRKmm2auACs57G0KD2+tvmTlIHaTC/AitjJHrZwiSWZc9A2U sGk/CrTyMVghxHe9uIbT3Yqox5wWX03QLWcjVa5vH1rL/Mo6e2FLPr+iFYXMybOF90wEBi58mmW0 W/G11z5aHNO5Uk8B6MZas90PkIyk+hnYxGx1+w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=YLkcqhbGajkU2sUy67PK9wpiTtQ+y+2FHnU88DuUAaY=; b=VuuOVzYOP84j+DH/hO/Jk6n+LzHJp5dtRuHvIjXAXRtePPmNj8+mgYg7iWX524o7cFQLKigHeQ+Y m3pb3Bjr9YPodTR4mR99q9BG0s2PdyEArLb6TmpjB6nvGnkD82zaU41mCLh7fI6DqHqd4L3RDTnu RepSWlaLwbd7Xd3LzE4YhEUQKzpAZgD06c6uZkJ8gMCddbdr0MuZWoSOfBac0WSkjHAul74K/D/D HjQiKdgdub6tsj4DDWs6csBu4t1VE5VatDODYZssGVqoI+cbS6Z3domcbDcuGsSj8iB+z8uIbP+R bQUANBmMRYANTRk7iTK+Z9gmGW5GQURqHPaC7g== Received: by omta-ad3-fd3-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220817 64bit (built Aug 17 2022)) with ESMTPS id <0RHJ00D5098MQ6C0@omta-ad3-fd3-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Thu, 01 Sep 2022 13:24:22 +0000 (GMT) To: , , , , , , , Date: Thu, 1 Sep 2022 21:34:57 +0800 Message-id: <20220901133505.2510834-7-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 X-Originating-IP: [10.175.127.227] X-Source-IP: 45.249.212.188 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10457 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 clxscore=142 priorityscore=237 lowpriorityscore=0 adultscore=0 spamscore=0 impostorscore=0 mlxscore=0 phishscore=0 mlxlogscore=942 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209010060 domainage_hfrom=8269 Cc: axboe@kernel.dk, hch@infradead.org, tytso@mit.edu, agruenba@redhat.com, yi.zhang@huawei.com, almaz.alexandrovich@paragon-software.com, viro@zeniv.linux.org.uk, yukuai3@huawei.com, rpeterso@redhat.com, dushistov@mail.ru, chengzhihao1@huawei.com Subject: [Ocfs2-devel] [PATCH v2 06/14] jbd2: replace ll_rw_block() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Zhang Yi via Ocfs2-devel Reply-to: Zhang Yi Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com 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-ServerName: szxga02-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-ORIG-GUID: 1msWMPqh4PUAGmcfTcs-htwM5aqdHZek X-Proofpoint-GUID: 1msWMPqh4PUAGmcfTcs-htwM5aqdHZek Reporting-Meta: AAG4az+Z18ZmH0WISyIDBIf5Y2IQW+3ERFdDT8St+4QfD1855s2tKoJA6pTjbnJt JdOJfcGPzhrF7TR7/0PvfjoBWMXPEVnL5Imdi8FedVVYvh8gIIsZZ/fyvgSXbdtE AmCRpEdZr0WIt8UHpZmWl+1949luHE2546NxxXBg2jdeGh+33yb09jkPtBymKeeT 4ExVYCT4Ata+xTHVo/RHbj9j4KkNIOCNJStqqEhyOBGitksExsPVQIhQfSURMtNH QcnnzzW//E9xr8qvHpjzkhkXe6Ox/7NZRLtZv3tXR/Ed5cgL+sY5GKkOhO/MbnRp IR7c+N5w/BqAbKJRUI5FPlammu7mav0HnGyo5PtOrZWzUE09pRJsMFV5dl45ZSAl IAai9NCwUOX+KABXjfkr+/40/ej32elNS6UtWpB3bGyrm1TtiivEEW8Ru+t1kI0H Yo2TP/w+m94W+TkndEFJ08kyoEVlUUGlXq2nDRyfpTWXCvWb/Fs6joCX31jVBX/1 zj47z4rwXa2CShUFWq1dzrRBzPvt4JYsrZZt2k0a8ltN ll_rw_block() is not safe for the sync read path because it cannot guarantee that submitting read IO if the buffer has been locked. We could get false positive EIO after wait_on_buffer() if the buffer has been locked by others. So stop using ll_rw_block() in journal_get_superblock(). We also switch to new bh_readahead_batch() for the buffer array readahead path. Signed-off-by: Zhang Yi Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig Reviewed-by: Theodore Ts'o --- fs/jbd2/journal.c | 15 ++++++--------- fs/jbd2/recovery.c | 16 ++++++++++------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 6350d3857c89..140b070471c0 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -1893,19 +1893,16 @@ static int journal_get_superblock(journal_t *journal) { struct buffer_head *bh; journal_superblock_t *sb; - int err = -EIO; + int err; bh = journal->j_sb_buffer; J_ASSERT(bh != NULL); - if (!buffer_uptodate(bh)) { - ll_rw_block(REQ_OP_READ, 1, &bh); - wait_on_buffer(bh); - if (!buffer_uptodate(bh)) { - printk(KERN_ERR - "JBD2: IO error reading journal superblock\n"); - goto out; - } + err = bh_read(bh, 0); + if (err < 0) { + printk(KERN_ERR + "JBD2: IO error reading journal superblock\n"); + goto out; } if (buffer_verified(bh)) diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c index f548479615c6..1f878c315b03 100644 --- a/fs/jbd2/recovery.c +++ b/fs/jbd2/recovery.c @@ -100,7 +100,7 @@ static int do_readahead(journal_t *journal, unsigned int start) if (!buffer_uptodate(bh) && !buffer_locked(bh)) { bufs[nbufs++] = bh; if (nbufs == MAXBUF) { - ll_rw_block(REQ_OP_READ, nbufs, bufs); + bh_readahead_batch(nbufs, bufs, 0); journal_brelse_array(bufs, nbufs); nbufs = 0; } @@ -109,7 +109,7 @@ static int do_readahead(journal_t *journal, unsigned int start) } if (nbufs) - ll_rw_block(REQ_OP_READ, nbufs, bufs); + bh_readahead_batch(nbufs, bufs, 0); err = 0; failed: @@ -152,9 +152,14 @@ static int jread(struct buffer_head **bhp, journal_t *journal, return -ENOMEM; if (!buffer_uptodate(bh)) { - /* If this is a brand new buffer, start readahead. - Otherwise, we assume we are already reading it. */ - if (!buffer_req(bh)) + /* + * If this is a brand new buffer, start readahead. + * Otherwise, we assume we are already reading it. + */ + bool need_readahead = !buffer_req(bh); + + bh_read_nowait(bh, 0); + if (need_readahead) do_readahead(journal, offset); wait_on_buffer(bh); } @@ -687,7 +692,6 @@ static int do_one_pass(journal_t *journal, mark_buffer_dirty(nbh); BUFFER_TRACE(nbh, "marking uptodate"); ++info->nr_replays; - /* ll_rw_block(WRITE, 1, &nbh); */ unlock_buffer(nbh); brelse(obh); brelse(nbh); From patchwork Thu Sep 1 13:34:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 12962615 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 aib29ajc250.phx1.oracleemaildelivery.com (aib29ajc250.phx1.oracleemaildelivery.com [192.29.103.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C5907ECAAD1 for ; Thu, 1 Sep 2022 13:24:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=djRViFw8AAZ8KgNCZf4YmPiPpRLNTezYH5/pgBkztco=; b=sXm5h/Jrau+KjpKowF1hpL8L1EyLNpJs75QOJyj9p7A39IN9BoRUwzi3o1FpzEzTGbR5IKTAHlDj 7QeDOr+RhHY31BpTcKYy9oD5HQoh3M5D6g31AetD0b2/Vm6cf7n10ZD3VfCKCBjRQoxAJ/cm3UK9 RtPIv6FoHR6AU7Mr4eQXu9LnytwS+M8FFYqtxzbKvPhxD97EqWXO9YcvvC0jy8B4jZ4tSOxVb6Gs 1C5/GFLS8kIN3dYFn23YrOc5s1jEyI4Erl9cNRloX1HW8zMiWl69n8bywChqB+DfgEEwZqHptgZc FMh5QSqWMRiZpaZP/x8ligtNTxQdVLwlJaP0Cg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=djRViFw8AAZ8KgNCZf4YmPiPpRLNTezYH5/pgBkztco=; b=CrRj7y2U4SoJWW2GTnxy5OAOC5IidEG1pSIquPqeV/C6NkIuDvA8uHbjFh7F7FolLo61aRT1Dd4Q 1abk33Os/iEpcySginVn2byBWjcAkvNGYshBiq9MWLDr99/UlUr/yyviFpvNPy860r0CAARMdW8z JzJ2itylJ+nJoCsAyFbMGAf7VsIEapTMGKjjfKdGwpjH/lE3zYNnaz4hAlUgQhjjXC0XZa/jaU/g Cv/n0xHnxbLeiXvJKOh3t2ZqKpiw5PBzGjZaMu3XbUIkZGD+ZNIUNOAnJ5da8eINVmhdw4tW75u1 QIidcq+w3z8epoE32/tNBB6QnBZKQGiY1zL9Jg== Received: by omta-ad2-fd3-201-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220817 64bit (built Aug 17 2022)) with ESMTPS id <0RHJ00KSO98MOB90@omta-ad2-fd3-201-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Thu, 01 Sep 2022 13:24:22 +0000 (GMT) To: , , , , , , , Date: Thu, 1 Sep 2022 21:34:58 +0800 Message-id: <20220901133505.2510834-8-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 X-Originating-IP: [10.175.127.227] X-Source-IP: 45.249.212.188 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10457 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 mlxscore=0 phishscore=0 suspectscore=0 adultscore=0 priorityscore=207 mlxlogscore=919 clxscore=119 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209010060 domainage_hfrom=8269 Cc: axboe@kernel.dk, hch@infradead.org, tytso@mit.edu, agruenba@redhat.com, yi.zhang@huawei.com, almaz.alexandrovich@paragon-software.com, viro@zeniv.linux.org.uk, yukuai3@huawei.com, rpeterso@redhat.com, dushistov@mail.ru, chengzhihao1@huawei.com Subject: [Ocfs2-devel] [PATCH v2 07/14] ntfs3: replace ll_rw_block() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Zhang Yi via Ocfs2-devel Reply-to: Zhang Yi Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com 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-ServerName: szxga02-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-ORIG-GUID: QyRY08evVn4TPPUTQBkTqFRROIPb4t2A X-Proofpoint-GUID: QyRY08evVn4TPPUTQBkTqFRROIPb4t2A Reporting-Meta: AAFfKULcNnd8ob+lv6Rmz0hm+4jDKQ4SjPSny5cvGolflXJrnpD5Lyc4004Eim79 lfs3wydxjdEcRtNumiJrLKMuve7pRRZ4ZDK/dmJNkwpDTG0p3lAkzlF3Z8a/Gygo fALVmHEEQdlFUbYt2Rw6Ul94rLiJlCrwsB7umc8DQmcux6HP6QRfphYSUDe/h32B CJ/Rf3mynCiisIiR9C1o97P9o7eHX+071e2po6u1O7PC+4lSuaVoVjL9PUW/jCyA CPHnpkeAoEkcSndj7SKH7bdxu9aRBKGKa82hpxa3Q2FmQQniUR/q8tX3tXpTTKkZ nmAJFsJqeVO4eaWpLQzSFcKhQupmNu0DjdhAEYh7x0RVTnYBufvZvCFaYkNn4q/q Z/93SHuMrHl3WtcrH3GqXRXFUHP3AMdqiATTQXenmUI3rbDB80H/F1UcFmy+c/oU +ay4wEihkGicaq5LWGsW1E+SK4PsbrPA1qop2HRG71767Es/bdSThB97FyNUzgLX BFvmMpqP3kCFPxgm9iUG7L8wvp+Hdt0leYFUUpokmkFK ll_rw_block() is not safe for the sync read path because it cannot guarantee that submitting read IO if the buffer has been locked. We could get false positive EIO after wait_on_buffer() if the buffer has been locked by others. So stop using ll_rw_block() in ntfs_get_block_vbo(). Signed-off-by: Zhang Yi Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig --- fs/ntfs3/inode.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 51363d4e8636..cadbfa111539 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -630,12 +630,9 @@ static noinline int ntfs_get_block_vbo(struct inode *inode, u64 vbo, bh->b_size = block_size; off = vbo & (PAGE_SIZE - 1); set_bh_page(bh, page, off); - ll_rw_block(REQ_OP_READ, 1, &bh); - wait_on_buffer(bh); - if (!buffer_uptodate(bh)) { - err = -EIO; + err = bh_read(bh, 0); + if (err < 0) goto out; - } zero_user_segment(page, off + voff, off + block_size); } } From patchwork Thu Sep 1 13:34:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 12962617 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 aib29ajc245.phx1.oracleemaildelivery.com (aib29ajc245.phx1.oracleemaildelivery.com [192.29.103.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E63C3C54EE9 for ; Thu, 1 Sep 2022 13:24:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=zzI0gP26ea96Q5IJDXOrP0UxV/GWQmexJipTYVd2zcI=; b=EBUx16h+f6UnGen5RPBsykJhRtXGi+TlfuC4RAZXIvLl3UlyLTEVH2y/JUzru0DSjrW8Cy8ty5Gf /pKMpqiY4af+Q7yq4GVbWNHb6yyxqIK0246LjaZtomfA6cc0gAWDDgUUm/ScUVDk4A03LMuYyNh0 tG3BaT8w9d4wieVcBf8QRCZXJXRHIa10fP38adeyu600GFQWJn8QPyIeafQea4OgVzvi4+wdiNcm 9GF+lrgSr4yHmOlkU2wwYcKx7tQHP6eg9UE4C+pbOm0SiOAgnP/TzrNOIfNoop+MLBUDjIF/OrC3 R1d/+0LdlQxK2O06yV27RDUvdzf8RBr5oTjlKw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=zzI0gP26ea96Q5IJDXOrP0UxV/GWQmexJipTYVd2zcI=; b=TVYJazN4b78S+be4gCZWC9UuHpBPjzzAIVSidJL+YJCzLlMI+4KKQzZHZYeYO80N2TGInDQKN4VP Y03y8/m5pLqXPvEvumAy9fDu5dpYvWfQDLoxrOYRy9w1cC6/APWAk7zR8w1gGMjKSEDKPrrLuxS0 0qEDtT0JYHlnrQO3Y92xe+Pbx3NwiqSJ3QwHV+sxwHMr+p4Pgsza21LsP/S1tjSpxrxRIIJaufAg 4C0XV/n5r4gRfBB0wz6KJGeHTYywHgnut1dqp8BkTqnIy98/GLP2maz4AyXx50GlyR/H4EDXbt2O DP031lidnOqCKGAXHCwfy011NkHOFtLRkxE2kA== Received: by omta-ad1-fd1-102-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220817 64bit (built Aug 17 2022)) with ESMTPS id <0RHJ00CB198MZX90@omta-ad1-fd1-102-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Thu, 01 Sep 2022 13:24:22 +0000 (GMT) To: , , , , , , , Date: Thu, 1 Sep 2022 21:34:59 +0800 Message-id: <20220901133505.2510834-9-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 X-Originating-IP: [10.175.127.227] X-Source-IP: 45.249.212.188 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10457 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 spamscore=0 impostorscore=0 suspectscore=0 clxscore=115 priorityscore=207 lowpriorityscore=0 mlxlogscore=733 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209010060 domainage_hfrom=8269 Cc: axboe@kernel.dk, hch@infradead.org, tytso@mit.edu, agruenba@redhat.com, yi.zhang@huawei.com, almaz.alexandrovich@paragon-software.com, viro@zeniv.linux.org.uk, yukuai3@huawei.com, rpeterso@redhat.com, dushistov@mail.ru, chengzhihao1@huawei.com Subject: [Ocfs2-devel] [PATCH v2 08/14] ocfs2: replace ll_rw_block() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Zhang Yi via Ocfs2-devel Reply-to: Zhang Yi Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com 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-ServerName: szxga02-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-GUID: BwtjV5nO64YBLtIACXsrRXVaVjPfGm_d X-Proofpoint-ORIG-GUID: BwtjV5nO64YBLtIACXsrRXVaVjPfGm_d Reporting-Meta: AAH2QI4RcI5b9Z4mlTCy5jQDN4kdQjOWzHu6hIm5fv8MbG8HD4XbQHhKGac7vKdv uHhWjPJ3bq9u0mZVCF7dVq7aNWZgefRogcJ/EVmhJAh6S+jO/+vTGXedBcZaQK5s Dcr5mrNJ2Vg1OhqSt5GBNYebipoWnhlmQHJv6re9gtdjDWmWfnF18O558bKwhXQ+ sDXXNyPpJukb36bkKMz3qrp+jMLQFoQeSBGbKPWiu3caVSRXKY0LvJSQnAFCMbB2 cIjDhk2h0+mSWhYKNR1Dd5UL487WwVM6n1pcjaU9DzUO4QZDS8in8nFIr3xp0SD0 WAULHHryAWbFbLwUfJoobGCv90+rjpMIWlPaSXdB4OijcBJbq5LHZ0te+Tz0MbWz IbX+26X9QRhhET1teKVTG+t4LVE6+et53htbqNifqYoZJzcJ8qjhPSr1hWA2nYsl 9aWtK0g+9EN2m1MVvWVcHHuN9kX8k+Jnf9ZQoG9Efw/qgxFf/bYJq42ergKRlHvV AobYJpUyeIKrvFAw7Xu9imGf8MpQPliVOZtzFGaNVgSL ll_rw_block() is not safe for the sync read path because it cannot guarantee that submitting read IO if the buffer has been locked. We could get false positive EIO after wait_on_buffer() if the buffer has been locked by others. So stop using ll_rw_block() in ocfs2. Signed-off-by: Zhang Yi Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig Reviewed-by: Joseph Qi --- fs/ocfs2/aops.c | 2 +- fs/ocfs2/super.c | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index af4157f61927..1d65f6ef00ca 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -636,7 +636,7 @@ int ocfs2_map_page_blocks(struct page *page, u64 *p_blkno, !buffer_new(bh) && ocfs2_should_read_blk(inode, page, block_start) && (block_start < from || block_end > to)) { - ll_rw_block(REQ_OP_READ, 1, &bh); + bh_read_nowait(bh, 0); *wait_bh++=bh; } diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index e2cc9eec287c..26b4c2bfee49 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -1764,9 +1764,7 @@ static int ocfs2_get_sector(struct super_block *sb, if (!buffer_dirty(*bh)) clear_buffer_uptodate(*bh); unlock_buffer(*bh); - ll_rw_block(REQ_OP_READ, 1, bh); - wait_on_buffer(*bh); - if (!buffer_uptodate(*bh)) { + if (bh_read(*bh, 0) < 0) { mlog_errno(-EIO); brelse(*bh); *bh = NULL; From patchwork Thu Sep 1 13:35:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 12962620 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 aib29ajc253.phx1.oracleemaildelivery.com (aib29ajc253.phx1.oracleemaildelivery.com [192.29.103.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 831A0C0502C for ; Thu, 1 Sep 2022 13:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=FnBFUDctRZuMPp9lE4eox8Qm2TozzW+0nlP/weJjg4A=; b=CXHKA6F40F8PckyaXCeQsfLZuIQgGV47Q4WV5Tp+1MHGOEWQKe0gJ9i3aXE/wJdr1/dDkG/Cw+5u FuUVsAx+4NonRz+dYjU7w0dkjgp7HkZ8A9ftORc+0BnION7DvBflAyEKFebpQEGNGpopgLBIZvmW MKZSvY4Sc97lA0Ok3Uvfl1ytAI02/kfsrtV/Sp27W7wEPeEK2IXs1XUTcgW+ULcxZW7T15MOuwJ4 McrGor06+359bQLM0p2kPN0Z47Gll+uT9Ym0dnnMCQYNrQ1ndZ9cEUK2ThAbug8vsCd/izIm+m+9 rSCzBW1JnaitP4Vi9WOM2da0A2HCltoFdqYQGA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=FnBFUDctRZuMPp9lE4eox8Qm2TozzW+0nlP/weJjg4A=; b=NYJIaVHo9m3WrfqdChvnZISFfZ+9F4iSdECU7eJrajzfGluFQhB5ePkH5ydRnDkSs6qO7Ps1ziPg +Q7COaXO4g2NHv1LoyiB0eQ0/O0gphvtFGNV3/9jfo3th26htGJ0EHEMroXWQP8Bwg4L7tJWpGv/ 4g65ZLiDzLpfW80Onjqym9pabek5sOF2KUy07Ul5aXn2DVG/aIpriSvT7KJSVtCean9H/636JegE 2L46SlIjVOwDUPulBnKTz2G8pVt6NMcfqUJOAT8HDQygtD6+Gf0iQbJ7a1TVh3BpfVYO/872cVBK 6UQj5JXrNohc4m9tI+Gx98aEHVwmRjy35lu64w== Received: by omta-ad3-fd1-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220817 64bit (built Aug 17 2022)) with ESMTPS id <0RHJ00OZ098UJP00@omta-ad3-fd1-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Thu, 01 Sep 2022 13:24:30 +0000 (GMT) To: , , , , , , , Date: Thu, 1 Sep 2022 21:35:00 +0800 Message-id: <20220901133505.2510834-10-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 X-Originating-IP: [10.175.127.227] X-Source-IP: 45.249.212.188 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10457 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 mlxscore=0 phishscore=0 suspectscore=0 adultscore=0 priorityscore=207 mlxlogscore=674 clxscore=123 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209010060 domainage_hfrom=8269 Cc: axboe@kernel.dk, hch@infradead.org, tytso@mit.edu, agruenba@redhat.com, yi.zhang@huawei.com, almaz.alexandrovich@paragon-software.com, viro@zeniv.linux.org.uk, yukuai3@huawei.com, rpeterso@redhat.com, dushistov@mail.ru, chengzhihao1@huawei.com Subject: [Ocfs2-devel] [PATCH v2 09/14] reiserfs: replace ll_rw_block() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Zhang Yi via Ocfs2-devel Reply-to: Zhang Yi Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com 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-ServerName: szxga02-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-ORIG-GUID: 2K-MPgsXywyqTHkY2UzxuY2Pfbwqq-Ao X-Proofpoint-GUID: 2K-MPgsXywyqTHkY2UzxuY2Pfbwqq-Ao Reporting-Meta: AAGsrZJKzDFQ9B9qbMleSJLV4kL2+Qe2JkqimM4H46YGgyoIoZ1RosoSOqKKgS2H Wy/wZuv0iy2H71roir5OPUDG87NpZ8mgyWfAo3PrdJzDK2cw8Gd8MxB5FHGW06bg 6/qOavg90W0+aVS7P+qU5JSJq/f/Dm7/lk/4jhd0ukZAW3n7WPAgPoWnawqItVk5 6fu+p1UBtdt3g/9hdz4CoNqvcpzQXtb/cjr4oBEGBl0yj5zuVJRdnaqynH1ZC3We 6eS8rw+1sJfuq/OXdOc/fLT2Vwu2qrOvAWolrWKabIYDVbuOTkEClsoqYkycuIwA O0Chl4lQA/2WgSMAW/H+MvbHGf/miK9ivGrfmr/02BNlsaQD4P7oi4/GZKuZmH7g 41yFKogrlAOiJ0FQducEMesMfUlMKSCluseJ/09idRBwYVX6Wf5GlkMYiPPHxxEo QbPUpIkFQajz1gtFaTbsHkYYsO96GMoJyniz4COT8wWxfXIA+pUPfOjwf9Cqf2kz Q4LO0DHe0GVbEwbLK4rGqIlwWEL/4NMuZ3r734Mg27OZ ll_rw_block() is not safe for the sync read/write path because it cannot guarantee that submitting read/write IO if the buffer has been locked. We could get false positive EIO after wait_on_buffer() in read path if the buffer has been locked by others. So stop using ll_rw_block() in reiserfs. We also switch to new bh_readahead_batch() helper for the buffer array readahead path. Signed-off-by: Zhang Yi Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig --- fs/reiserfs/journal.c | 11 ++++++----- fs/reiserfs/stree.c | 4 ++-- fs/reiserfs/super.c | 4 +--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c index 94addfcefede..9f62da7471c9 100644 --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c @@ -868,7 +868,7 @@ static int write_ordered_buffers(spinlock_t * lock, */ if (buffer_dirty(bh) && unlikely(bh->b_page->mapping == NULL)) { spin_unlock(lock); - ll_rw_block(REQ_OP_WRITE, 1, &bh); + write_dirty_buffer(bh, 0); spin_lock(lock); } put_bh(bh); @@ -1054,7 +1054,7 @@ static int flush_commit_list(struct super_block *s, if (tbh) { if (buffer_dirty(tbh)) { depth = reiserfs_write_unlock_nested(s); - ll_rw_block(REQ_OP_WRITE, 1, &tbh); + write_dirty_buffer(tbh, 0); reiserfs_write_lock_nested(s, depth); } put_bh(tbh) ; @@ -2240,7 +2240,7 @@ static int journal_read_transaction(struct super_block *sb, } } /* read in the log blocks, memcpy to the corresponding real block */ - ll_rw_block(REQ_OP_READ, get_desc_trans_len(desc), log_blocks); + bh_read_batch(get_desc_trans_len(desc), log_blocks); for (i = 0; i < get_desc_trans_len(desc); i++) { wait_on_buffer(log_blocks[i]); @@ -2342,10 +2342,11 @@ static struct buffer_head *reiserfs_breada(struct block_device *dev, } else bhlist[j++] = bh; } - ll_rw_block(REQ_OP_READ, j, bhlist); + bh = bhlist[0]; + bh_read_nowait(bh, 0); + bh_readahead_batch(j - 1, &bhlist[1], 0); for (i = 1; i < j; i++) brelse(bhlist[i]); - bh = bhlist[0]; wait_on_buffer(bh); if (buffer_uptodate(bh)) return bh; diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c index 9a293609a022..84c12a1947b2 100644 --- a/fs/reiserfs/stree.c +++ b/fs/reiserfs/stree.c @@ -579,7 +579,7 @@ static int search_by_key_reada(struct super_block *s, if (!buffer_uptodate(bh[j])) { if (depth == -1) depth = reiserfs_write_unlock_nested(s); - ll_rw_block(REQ_OP_READ | REQ_RAHEAD, 1, bh + j); + bh_readahead(bh[j], REQ_RAHEAD); } brelse(bh[j]); } @@ -685,7 +685,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *key, if (!buffer_uptodate(bh) && depth == -1) depth = reiserfs_write_unlock_nested(sb); - ll_rw_block(REQ_OP_READ, 1, &bh); + bh_read_nowait(bh, 0); wait_on_buffer(bh); if (depth != -1) diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index c88cd2ce0665..a5ffec0c7517 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c @@ -1702,9 +1702,7 @@ static int read_super_block(struct super_block *s, int offset) /* after journal replay, reread all bitmap and super blocks */ static int reread_meta_blocks(struct super_block *s) { - ll_rw_block(REQ_OP_READ, 1, &SB_BUFFER_WITH_SB(s)); - wait_on_buffer(SB_BUFFER_WITH_SB(s)); - if (!buffer_uptodate(SB_BUFFER_WITH_SB(s))) { + if (bh_read(SB_BUFFER_WITH_SB(s), 0) < 0) { reiserfs_warning(s, "reiserfs-2504", "error reading the super"); return 1; } From patchwork Thu Sep 1 13:35:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 12962623 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 aib29ajc247.phx1.oracleemaildelivery.com (aib29ajc247.phx1.oracleemaildelivery.com [192.29.103.247]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A37BC64991 for ; Thu, 1 Sep 2022 13:24:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=qVpoeu/Rtni6Kk7BYlQj/KCbh2ncdGOujq9oJOtxFrY=; b=eiXTfEiAgxVoZ8NekbqvF+E5usW2rIGq8QkQPLnH3Q3jiAE4n6uwYzWFp+qiXnblbmOR61EEoekZ m+NDAd3YAoN15on16Sjw10uzbYK3GZdIf5c5JYkOP0Xu8tfxnwNli09rcPmR91aG34rs699O21JQ 29lZH85hDQhR/1VqUiHQO+xMMwLiwyX2zwNh4XhnpoQIZCzImsfpmyDNITS5Ipjiyj0FZgJBD/tx droD4jZfBckArwD1IC1oUsqf2t6kyMqPd+NJ5fXcbiyIGihkVCyCW4x+aR8z+KzeNmzeC1l+t5SN jNohnlVtZDqJYluXZ/TTZOEEseIaJGwC7J5WvA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=qVpoeu/Rtni6Kk7BYlQj/KCbh2ncdGOujq9oJOtxFrY=; b=AsYocTJMX3HY4xVRr+UpzbN3YW0M2y7uHCxea99gR7g4HbysYC+wdIG8SSGOSIrRCyD+/cZRrrD1 6RxXomirOly26a4tH2BTTOEIuJz/LRkh8eYmUszts8yFFc2RmQwN5vCuizyQQmgAyy2bSpstqVl+ sy650cTJtjtyJn18geOcbu3djTftcdFmmcCOOwaTYPgkfM/9h+gZmhnxsEs587gl9ty09kJP2B3n ZG/Qyr+VIP2sLmDTYUvYKC6Gj9PSzz/0U566qZZFLMmunGbwuevV0+oYjo8/PlohjTO42AYKWy4A MQqE2VI8FpbHxICJ9vBeqQ1VpmcW6j8qlkJbRQ== Received: by omta-ad1-fd3-102-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220817 64bit (built Aug 17 2022)) with ESMTPS id <0RHJ00L8298X6S90@omta-ad1-fd3-102-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Thu, 01 Sep 2022 13:24:33 +0000 (GMT) To: , , , , , , , Date: Thu, 1 Sep 2022 21:35:01 +0800 Message-id: <20220901133505.2510834-11-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 X-Originating-IP: [10.175.127.227] X-Source-IP: 45.249.212.189 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10457 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 clxscore=138 bulkscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=244 impostorscore=0 adultscore=0 phishscore=0 malwarescore=0 mlxlogscore=689 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209010060 domainage_hfrom=8269 Cc: axboe@kernel.dk, hch@infradead.org, tytso@mit.edu, agruenba@redhat.com, yi.zhang@huawei.com, almaz.alexandrovich@paragon-software.com, viro@zeniv.linux.org.uk, yukuai3@huawei.com, rpeterso@redhat.com, dushistov@mail.ru, chengzhihao1@huawei.com Subject: [Ocfs2-devel] [PATCH v2 10/14] udf: replace ll_rw_block() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Zhang Yi via Ocfs2-devel Reply-to: Zhang Yi Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com 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-ServerName: szxga03-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-GUID: xUel3bQJhXb2U6Vxe1e6jzBGB-X_dxWe X-Proofpoint-ORIG-GUID: xUel3bQJhXb2U6Vxe1e6jzBGB-X_dxWe Reporting-Meta: AAFdaXJug+1dphSKhMOHk4yHkC2XCuok5IGn10hvwPVAu7k3Fjitu6OvNzq95dzS sRH5H6PXi3O39XnADUKdprNY2px9cni64OeT97hC9Gu6haEIa87YuRoGg46T7MFC Tw5BTSLjgowzy90bnUsncfGNVmYTsgDg/JfgkJMPYpOedqejVYmDrAVg3gk7CnAf ldDvpHeFTsH+iKThhANmQmYETa5c6crcvGSjiUv5VaVVTWBe/tF9ZDZ1xeGn9WOn OS12wGeWB+d5JRVPyKuaWBp+9vx8H9hgsx/1he28ENx2+kIZ/emtfXdCk+AERZLs C8yDyUH4zFSGXmmGmE5dZYZ3NL8HHyCtnnp2dZF+0MtqV4hw/OmHIcQsbFjpoOEh 6Hi7U547A7NKkOYeYkxKdf7uXkOS43HEQR9FCwgkfJLvHnmYyPoRlbtvRjLqAruw z4QtPnsqK4ta48knMelRPQKQVpBrlJRDdtuIXKGGwDJ47C3f2+V5iShqYVlYQj/B uBqPB68VAK7J9B93mpzfOOLFsJgwSaRji2OgqToiOQ9V ll_rw_block() is not safe for the sync read path because it cannot guarantee that submitting read IO if the buffer has been locked. We could get false positive EIO after wait_on_buffer() if the buffer has been locked by others. So stop using ll_rw_block(). We also switch to new bh_readahead_batch() helper for the buffer array readahead path. Signed-off-by: Zhang Yi Reviewed-by: Christoph Hellwig --- fs/udf/dir.c | 2 +- fs/udf/directory.c | 2 +- fs/udf/inode.c | 8 +------- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/fs/udf/dir.c b/fs/udf/dir.c index cad3772f9dbe..be640f4b2f2c 100644 --- a/fs/udf/dir.c +++ b/fs/udf/dir.c @@ -130,7 +130,7 @@ static int udf_readdir(struct file *file, struct dir_context *ctx) brelse(tmp); } if (num) { - ll_rw_block(REQ_OP_READ | REQ_RAHEAD, num, bha); + bh_readahead_batch(num, bha, REQ_RAHEAD); for (i = 0; i < num; i++) brelse(bha[i]); } diff --git a/fs/udf/directory.c b/fs/udf/directory.c index a2adf6293093..16bcf2c6b8b3 100644 --- a/fs/udf/directory.c +++ b/fs/udf/directory.c @@ -89,7 +89,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos, brelse(tmp); } if (num) { - ll_rw_block(REQ_OP_READ | REQ_RAHEAD, num, bha); + bh_readahead_batch(num, bha, REQ_RAHEAD); for (i = 0; i < num; i++) brelse(bha[i]); } diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 8d06daed549f..dce6ae9ae306 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -1211,13 +1211,7 @@ struct buffer_head *udf_bread(struct inode *inode, udf_pblk_t block, if (!bh) return NULL; - if (buffer_uptodate(bh)) - return bh; - - ll_rw_block(REQ_OP_READ, 1, &bh); - - wait_on_buffer(bh); - if (buffer_uptodate(bh)) + if (bh_read(bh, 0) >= 0) return bh; brelse(bh); From patchwork Thu Sep 1 13:35:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 12962618 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 aib29ajc250.phx1.oracleemaildelivery.com (aib29ajc250.phx1.oracleemaildelivery.com [192.29.103.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DDC77C67868 for ; Thu, 1 Sep 2022 13:24:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=sVDY+Vx/Ikd6g06gydbDCurhGwPJjk8SpcaiuVHLYRI=; b=rrGZhg9CtG2RcYcEcW2UAuWIbOG0DMTnrEA2FH+soAgIaOfZdNOK3+MFXhgDclKwXIR90mSTU+6k xUBTp6zFJHBa04m4/IPxVrD6QKGILXv7EwV7ZJxXcsSch7CroP4k6s4XvheuhIixpBu7RzqTeD42 4//S/KB/ND+q6coHPr/37U7hRyysSkyK47mpcMXPJYmy6bTJ2Qs36xwH9NGl0x67i/aPvWqTWbod K/Xqd4imorvB2XiQwxaw/EPHmxrvl9snkYl4C2xCSKMZm2Ry66OgE+XtlYyyQdmyqLaxHjw74QrE 1coGD7TYgcW25xBpo86nyjHq8rZALFOPF4uUkA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=sVDY+Vx/Ikd6g06gydbDCurhGwPJjk8SpcaiuVHLYRI=; b=Nb6+crV4sONEceZ+gJ4q8C0PjjWuIN8hU4ErJczFQh1qRnN/HB9ykJIzizewnpX1UtIf+dZflfPd wwmG3LTYlB6ZbcikmygYhXkJQsABKf2/te9IKD4PsF3MfTw5JYghubNwZylCLXhwkw52DaIfVS2Q i5TsCeg8CZ866Oof2ywhBWZxhd9kPQPhP8skaDVcbEaEEiXZgZiLqrtjieMoftpYIII5nbQWMiVv 0n4OsRQlJDTd9AqSwVPvOGxtHy7bYSXmYxBDdn7jKM2VLJHPyojbeyfKUORC0sRowsxbmx1galiG wb7g8xa2j/WLKSaNec/bxzbTH4Sv9z329UIvfg== Received: by omta-ad2-fd3-201-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220817 64bit (built Aug 17 2022)) with ESMTPS id <0RHJ00KT298MOB90@omta-ad2-fd3-201-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Thu, 01 Sep 2022 13:24:22 +0000 (GMT) To: , , , , , , , Date: Thu, 1 Sep 2022 21:35:02 +0800 Message-id: <20220901133505.2510834-12-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 X-Originating-IP: [10.175.127.227] X-Source-IP: 45.249.212.187 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10457 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 malwarescore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 bulkscore=0 mlxlogscore=904 spamscore=0 clxscore=138 mlxscore=0 priorityscore=244 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209010060 domainage_hfrom=8269 Cc: axboe@kernel.dk, hch@infradead.org, tytso@mit.edu, agruenba@redhat.com, yi.zhang@huawei.com, almaz.alexandrovich@paragon-software.com, viro@zeniv.linux.org.uk, yukuai3@huawei.com, rpeterso@redhat.com, dushistov@mail.ru, chengzhihao1@huawei.com Subject: [Ocfs2-devel] [PATCH v2 11/14] ufs: replace ll_rw_block() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Zhang Yi via Ocfs2-devel Reply-to: Zhang Yi Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com 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-ServerName: szxga01-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-ORIG-GUID: _ni-NyigUww1Q9IASoPRPT733NgpzSPq X-Proofpoint-GUID: _ni-NyigUww1Q9IASoPRPT733NgpzSPq Reporting-Meta: AAEvsXxrkCYpKGbRnx3zhEdDS91cssipNXFIGGd1HXl6fVd1DyjQSXTlMaaN51aK onUneFj1a5RWMIkFwivfnLKRJwJCCAoXtkCSmPTG8A2GCnkwc9Ej7H6MUa88fpeG O4DaRVbGKFsMkXAO/aQYuWFkduwl3N9SiYluMxtQcV0QP/KRiJ/6l/tppGZcPLfq TWziE1+zbMq+Pb+qK0f6z9q9AdUo4D4wzd1DynbTxCITVr19fsh47L6Sth2U/pR+ ZAmX+7P4L6xZGYmh/s4npwxKUbRKArjPIJBLicVJ1eCV2x37OHRw0WprYEMXUD/D AGxPLSxUwLBV0zuy3uqsnSRUF4x3MFxIDf/J9JG2G82Ajq/84boe4jmwi3tfi+CE 75S2DpoG+J+ULLC9L6iz5nDQiZPRHb0NJC72BQDHB/opoE+615LQPjuzY9wDaJfq TzMMA9LvOWa0uq75kxxE+a1Mtk2Nr7cPI4/K5+MF0xaL/assRePCBXD/UnH1e03W LOvpPr+9/xZOUY1cG8fTmqCs4Lw9gf1QODp2xBFqX38t ll_rw_block() is not safe for the sync read path because it cannot guarantee that submitting read IO if the buffer has been locked. We could get false positive EIO after wait_on_buffer() if the buffer has been locked by others. So stop using ll_rw_block() in ufs. Signed-off-by: Zhang Yi Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig --- fs/ufs/balloc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c index bd810d8239f2..2436e3f82147 100644 --- a/fs/ufs/balloc.c +++ b/fs/ufs/balloc.c @@ -295,14 +295,10 @@ static void ufs_change_blocknr(struct inode *inode, sector_t beg, if (!buffer_mapped(bh)) map_bh(bh, inode->i_sb, oldb + pos); - if (!buffer_uptodate(bh)) { - ll_rw_block(REQ_OP_READ, 1, &bh); - wait_on_buffer(bh); - if (!buffer_uptodate(bh)) { - ufs_error(inode->i_sb, __func__, - "read of block failed\n"); - break; - } + if (bh_read(bh, 0) < 0) { + ufs_error(inode->i_sb, __func__, + "read of block failed\n"); + break; } UFSD(" change from %llu to %llu, pos %u\n", From patchwork Thu Sep 1 13:35:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 12962624 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 aib29ajc250.phx1.oracleemaildelivery.com (aib29ajc250.phx1.oracleemaildelivery.com [192.29.103.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 90561C0502C for ; Thu, 1 Sep 2022 13:24:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=boVy8TY9FW4BKLBxuNuoZRnxXXdUjWOqYsm5wJUWR9s=; b=EPPZ8q7j232S5vRfLL8KldxLU1dF7HurpcDYTNfUHebaO0UC7QbYOnXuzlycCHm24rFmcwI8nI2E rgJtJeH7AY44Ba4WTO9F/y9LDUWhWScDzGYc+jm37PWfLVtcsVnwQuy9iKl0lGw2y0AAU1InBmT4 dqv+r7VdfZXMi1CFvbiSs/2q6aOcjTsJJ23FQO41OTrrPtzUwLCPCUPgcdDspBOAbX1vLTG8TxeJ HRrFWNKXrXiMK2l7HMJ5LclGV3h3pmre6EWzJgSnlwpGTO7TKDUaumnhbETxcPwLhAr5eGmSB2HV nlmbe98xQtJ2JpQU0BmEK79PVo2w1xnfF7mB/g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=boVy8TY9FW4BKLBxuNuoZRnxXXdUjWOqYsm5wJUWR9s=; b=U6dyjXXaWRQnfE5fKE9DIsCrxTSWFZnKnsBabpuRZWxmVz3coSMD8lYfV4JIGveRdpqv9KbyxIYl FEil5kTkfRofApl35wDz/TudeB+iFoNS2BLbHfIWHIPnPIIWy9iL3BvGJ3dpAGPFOWFo2UPRZK7J 93mK4BmLl0IKguUtogBIpDORKZU114qysmFFJPx2+srOk95O6n6W4szLOkyFezRhNaFLbyp7V5cd vFoJCOz0PfcIES7mGOmlkWjYv+DVZtvOJCRznKiRrzCPynB55BDdh/le9aD/GetGNrdrrK9oSPS+ KGEu8dCoWshkwb4FHXHsMvtC7G9bZKjm1+mvJQ== Received: by omta-ad2-fd3-201-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220817 64bit (built Aug 17 2022)) with ESMTPS id <0RHJ00KVY98WOB90@omta-ad2-fd3-201-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Thu, 01 Sep 2022 13:24:34 +0000 (GMT) To: , , , , , , , Date: Thu, 1 Sep 2022 21:35:03 +0800 Message-id: <20220901133505.2510834-13-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 X-Originating-IP: [10.175.127.227] X-Source-IP: 45.249.212.255 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10457 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 clxscore=138 priorityscore=244 lowpriorityscore=0 adultscore=0 spamscore=0 impostorscore=0 mlxscore=0 phishscore=0 mlxlogscore=910 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209010060 domainage_hfrom=8269 Cc: axboe@kernel.dk, hch@infradead.org, tytso@mit.edu, agruenba@redhat.com, yi.zhang@huawei.com, almaz.alexandrovich@paragon-software.com, viro@zeniv.linux.org.uk, yukuai3@huawei.com, rpeterso@redhat.com, dushistov@mail.ru, chengzhihao1@huawei.com Subject: [Ocfs2-devel] [PATCH v2 12/14] fs/buffer: remove ll_rw_block() helper X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Zhang Yi via Ocfs2-devel Reply-to: Zhang Yi Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com 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-ServerName: szxga08-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-ORIG-GUID: yobtq7M516eOYZ9rhL9pPz0uMLvtfjnf X-Proofpoint-GUID: yobtq7M516eOYZ9rhL9pPz0uMLvtfjnf Reporting-Meta: AAHz86uIGYaCXzeJ64tcaSWcdP6CcNW1SXJyYWEpRFqt/Hw15iqb2HDsCZa5aXWC slMVf8xFytDvzQAgeJaQ31lro7gqF9YfqFk6c1YgwsR3AOGnWCCgfdhjFbkQMutj 5Mk/9Wd/PNMQ+VaJ2HvfsX36sAzJd2daGLVghXy0uu5YNLbQegX3+htwIvVTtZ0I aAncLK3V3baWCzub9BBotBGjqh61n7AB4NXigr1YJXQ4Qs7ExftG3y6U3D3SRqEB etgMz+wkqtUQflmEE7shodVKSvDktlUhh6AAF/JyY9erVmPlHfyoY+wBMlp5X5gg Evs1TPHQ2dF/Rg1QRAPsEMssk7mvRy2Q/wlYLc1XBrBlSxBCYGwMZYwmXMfDF0xh O3RWoubipZs+wXabkgnSaQM1fysh+QLla8psCGTd5xUpcZDzxsJ8ADyVRrX5sXnF VNiwxPETEW3lbtG+0ZF+Kt5coR078DwRC3Lscvz2tZn6lHpnhvXtpJaP4SKjVyHV s7m5aa0135LM0iAj53WVyyRX5rGt80kAlqg4WdAMzwrz Now that all ll_rw_block() users has been replaced to new safe helpers, we just remove it here. Signed-off-by: Zhang Yi Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig --- fs/buffer.c | 63 +++---------------------------------- include/linux/buffer_head.h | 1 - 2 files changed, 4 insertions(+), 60 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index aec568b3ae52..2cccc7586b99 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -152,7 +152,7 @@ static void __end_buffer_read_notouch(struct buffer_head *bh, int uptodate) /* * Default synchronous end-of-IO handler.. Just mark it up-to-date and - * unlock the buffer. This is what ll_rw_block uses too. + * unlock the buffer. */ void end_buffer_read_sync(struct buffer_head *bh, int uptodate) { @@ -491,8 +491,8 @@ int inode_has_buffers(struct inode *inode) * all already-submitted IO to complete, but does not queue any new * writes to the disk. * - * To do O_SYNC writes, just queue the buffer writes with ll_rw_block as - * you dirty the buffers, and then use osync_inode_buffers to wait for + * To do O_SYNC writes, just queue the buffer writes with write_dirty_buffer + * as you dirty the buffers, and then use osync_inode_buffers to wait for * completion. Any other dirty buffers which are not yet queued for * write will not be flushed to disk by the osync. */ @@ -1806,7 +1806,7 @@ int __block_write_full_page(struct inode *inode, struct page *page, /* * The page was marked dirty, but the buffers were * clean. Someone wrote them back by hand with - * ll_rw_block/submit_bh. A rare case. + * write_dirty_buffer/submit_bh. A rare case. */ end_page_writeback(page); @@ -2713,61 +2713,6 @@ int submit_bh(blk_opf_t opf, struct buffer_head *bh) } EXPORT_SYMBOL(submit_bh); -/** - * ll_rw_block: low-level access to block devices (DEPRECATED) - * @opf: block layer request operation and flags. - * @nr: number of &struct buffer_heads in the array - * @bhs: array of pointers to &struct buffer_head - * - * ll_rw_block() takes an array of pointers to &struct buffer_heads, and - * requests an I/O operation on them, either a %REQ_OP_READ or a %REQ_OP_WRITE. - * @opf contains flags modifying the detailed I/O behavior, most notably - * %REQ_RAHEAD. - * - * This function drops any buffer that it cannot get a lock on (with the - * BH_Lock state bit), any buffer that appears to be clean when doing a write - * request, and any buffer that appears to be up-to-date when doing read - * request. Further it marks as clean buffers that are processed for - * writing (the buffer cache won't assume that they are actually clean - * until the buffer gets unlocked). - * - * ll_rw_block sets b_end_io to simple completion handler that marks - * the buffer up-to-date (if appropriate), unlocks the buffer and wakes - * any waiters. - * - * All of the buffers must be for the same device, and must also be a - * multiple of the current approved size for the device. - */ -void ll_rw_block(const blk_opf_t opf, int nr, struct buffer_head *bhs[]) -{ - const enum req_op op = opf & REQ_OP_MASK; - int i; - - for (i = 0; i < nr; i++) { - struct buffer_head *bh = bhs[i]; - - if (!trylock_buffer(bh)) - continue; - if (op == REQ_OP_WRITE) { - if (test_clear_buffer_dirty(bh)) { - bh->b_end_io = end_buffer_write_sync; - get_bh(bh); - submit_bh(opf, bh); - continue; - } - } else { - if (!buffer_uptodate(bh)) { - bh->b_end_io = end_buffer_read_sync; - get_bh(bh); - submit_bh(opf, bh); - continue; - } - } - unlock_buffer(bh); - } -} -EXPORT_SYMBOL(ll_rw_block); - void write_dirty_buffer(struct buffer_head *bh, blk_opf_t op_flags) { lock_buffer(bh); diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 6d09785bed9f..b415d8bc2a09 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -223,7 +223,6 @@ struct buffer_head *alloc_buffer_head(gfp_t gfp_flags); void free_buffer_head(struct buffer_head * bh); void unlock_buffer(struct buffer_head *bh); void __lock_buffer(struct buffer_head *bh); -void ll_rw_block(blk_opf_t, int, struct buffer_head * bh[]); int sync_dirty_buffer(struct buffer_head *bh); int __sync_dirty_buffer(struct buffer_head *bh, blk_opf_t op_flags); void write_dirty_buffer(struct buffer_head *bh, blk_opf_t op_flags); From patchwork Thu Sep 1 13:35:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 12962621 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 aib29ajc251.phx1.oracleemaildelivery.com (aib29ajc251.phx1.oracleemaildelivery.com [192.29.103.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 450B3ECAAD1 for ; Thu, 1 Sep 2022 13:24:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=hyDlGBdRidwf+m/lNOr+vaBoawrzDx3ENhg0E+Lc4Iw=; b=KDEIy3O3Vykg8+8WBZP5E5TMx4m0q0cWH6XuoVIcgqNfk1Q3C7H0q3VIB6mpeaabCAwEfl9yP5No 1k4rQjgixM1At0Kx/55baQZxd9NGy+waQ3jhiNduKl1Zt10p7TuTxEIvjnm8rBwldOrDtVLtv0y2 s1vcyK+7erK4uw17dsadmM/RDZ8wWSeV06ZQkHBiJs5SMTg2hOru70TTXFtTKLvIWLyN6cAHc8cs U9bt6ZivoIozth30N59ShRosnGmyqFMdtrwSFn/UpZk3zsrQc4cE9djFQBZIEk2Hbz0F/MbKnAGZ 7mcoG+eV83WWvKXlp1xunopqLiaJhSoavK2HKg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=hyDlGBdRidwf+m/lNOr+vaBoawrzDx3ENhg0E+Lc4Iw=; b=mrdlpVXL3TFoxwmp570GARoKaSOs5l7Mt3NqBfSpnLR7w1bSl6tJqQNZfK915YTdTe27CC6uVPQ2 HQypC3SM5LNHXAlbOr6fTGZW0EXTCBj3LfyzXXvEsBZ6gvE4zKacC+pDdYtnaf4KQdKYUxGZ7KqL mKJruGgj5S0GRmGh2UxC6w/PLCWkr+R+Hq9p4BnjO0lxLo0678l+1SpbEMIp9dmwfGaottIEh2Ww N9J3x1lW/jW2yJ6VImzQ3IpJ84dwMJgBJqjefpUSQ10TzqMlIXUFA6TN/h7me81NZE7yHCB8IYcL moaCvWXVjYdtEtKvhjCcNBtgOsf3TCxx7R8CwA== Received: by omta-ad2-fd3-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220817 64bit (built Aug 17 2022)) with ESMTPS id <0RHJ006SZ98WTG00@omta-ad2-fd3-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Thu, 01 Sep 2022 13:24:32 +0000 (GMT) To: , , , , , , , Date: Thu, 1 Sep 2022 21:35:04 +0800 Message-id: <20220901133505.2510834-14-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 X-Originating-IP: [10.175.127.227] X-Source-IP: 45.249.212.189 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10457 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 clxscore=138 bulkscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=244 impostorscore=0 adultscore=0 phishscore=0 malwarescore=0 mlxlogscore=914 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209010060 domainage_hfrom=8269 Cc: axboe@kernel.dk, hch@infradead.org, tytso@mit.edu, agruenba@redhat.com, yi.zhang@huawei.com, almaz.alexandrovich@paragon-software.com, viro@zeniv.linux.org.uk, yukuai3@huawei.com, rpeterso@redhat.com, dushistov@mail.ru, chengzhihao1@huawei.com Subject: [Ocfs2-devel] [PATCH v2 13/14] ext2: replace bh_submit_read() helper with bh_read_locked() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Zhang Yi via Ocfs2-devel Reply-to: Zhang Yi Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com 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-ServerName: szxga03-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-ORIG-GUID: Y74eo9SaY-RSeDkhma3wokN_x37HANHS X-Proofpoint-GUID: Y74eo9SaY-RSeDkhma3wokN_x37HANHS Reporting-Meta: AAGsrZJKzDFQ9B9qbMleSJLV4kL2+Qe2JkqimM4H46YGgyoIoZ1RosoSOqKKgS2H Wy/wZuv0iy2H71roir5aPUDG87NpZ8mgyWe90AL5VwOi8ihXIdfGdQiEZbtZ6oE1 OG33BKSFjDBMx1TzaHWoFAX139Vm93Y0Wp4SzYDgva149OEOWvkNgyKAuJffN0gV hMTARm7O5yVMy7qz02gHlT0op83lWQ9B+mer8ec315sDObBcIjiIpTDtr/uIMob7 hy7u69MheFwSjpCo0LcIP4sw42i+NwcLDvTl5Nn6cT8kIQhE0j+ncZRd6P6co3zB SnIZSsU4sOfACuid9fCPB2M7315TwJ9QTxbWusp7+eVnv9wmyktQsacZ/1ABdhlJ rw/yjVcnarWBOrfuBC7pKXVQPkuZHW1bB064sf3Az34B9Ckv9wg4QMdfUs2Lcy3d 3YOJZwHnZVkAGJpnlzMWziemJ89AFoqDTlSaXHdB9q4Aaa5sMDGjwFJnwA3kRSn2 toAe1ZsBnfiZAnxEGEL30DvMkTxfC1JIh2eV7lwaK9xn bh_submit_read() and the uptodate check logic in bh_uptodate_or_lock() has been integrated in bh_read() helper, so switch to use it directly. Signed-off-by: Zhang Yi Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig --- fs/ext2/balloc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c index c17ccc19b938..5dc0a31f4a08 100644 --- a/fs/ext2/balloc.c +++ b/fs/ext2/balloc.c @@ -126,6 +126,7 @@ read_block_bitmap(struct super_block *sb, unsigned int block_group) struct ext2_group_desc * desc; struct buffer_head * bh = NULL; ext2_fsblk_t bitmap_blk; + int ret; desc = ext2_get_group_desc(sb, block_group, NULL); if (!desc) @@ -139,10 +140,10 @@ read_block_bitmap(struct super_block *sb, unsigned int block_group) block_group, le32_to_cpu(desc->bg_block_bitmap)); return NULL; } - if (likely(bh_uptodate_or_lock(bh))) + ret = bh_read(bh, 0); + if (ret > 0) return bh; - - if (bh_submit_read(bh) < 0) { + if (ret < 0) { brelse(bh); ext2_error(sb, __func__, "Cannot read block bitmap - " From patchwork Thu Sep 1 13:35:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 12962619 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 aib29ajc251.phx1.oracleemaildelivery.com (aib29ajc251.phx1.oracleemaildelivery.com [192.29.103.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3839EECAAD1 for ; Thu, 1 Sep 2022 13:24:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=b2D7/vIYyzBkrDaKF/hyCf2eaehFqzPv1OPbcMWE1h8=; b=VPlN256ESWRZjgyaaGtMsERsGNirNlbk4BbjkYbXCD3jiNBpp4Izthwdpi/QWB2euWK9f3xDWbxI VO6no6JTtPyo56Y86qDIe4PGlTmTtwAYrxsL8MLjXCFvDOa1aLBvR5EMDU/g41clOOI55NhLhazh PYcBM1d7F2S3DpGoGbH5KCaXx/W6prOXvAFs1V5bJNhz87+7QM++eoGumP4mS5eDmOfj9eq6sLsP hByWxNWeDek8rywIr7Tt3qLYS5Wq7beSTbsAwxH+74FXQTfNEEmrJQHOxX3zbresVHHwl5UGRxw1 M1YP0iqJ6Qa1Vk1mi3047EaPMp3yxWiPPWs2YA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=b2D7/vIYyzBkrDaKF/hyCf2eaehFqzPv1OPbcMWE1h8=; b=dT/+VNKLAQ0z/m6iqwVbPMBm1sJGlG9d92hDPymoDsUU/RVCz9Mor726lRGqklLWz0lnkO9uYD4P 0vrwjUivi2RP9S1w42gHXs3tzQ/RzWIcuIolyRn2I8WDJHWGryjDbvOj2+JZ+TvTG7NUgv/eAYHB DnTttiVwgFZipnDoohEef+6IArADelcUGrqrr/l27djdo9NB8GFM6RSv6o+AqXyWi4JI58KUWbyl m8ufECli3oXFcK/WCVhhCQqmxFoQqu92TaFaChkLQt65jn0FFfUOpK4PWhwXZwSlD1IKwb8JP8gI OuGyGi7NoTmq9H7lgVVnxDPCoFdJMZ+bKtcs+g== Received: by omta-ad2-fd3-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220817 64bit (built Aug 17 2022)) with ESMTPS id <0RHJ006RF98STG00@omta-ad2-fd3-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Thu, 01 Sep 2022 13:24:28 +0000 (GMT) To: , , , , , , , Date: Thu, 1 Sep 2022 21:35:05 +0800 Message-id: <20220901133505.2510834-15-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 X-Originating-IP: [10.175.127.227] X-Source-IP: 45.249.212.187 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10457 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 spamscore=0 impostorscore=0 suspectscore=0 clxscore=123 priorityscore=207 lowpriorityscore=0 mlxlogscore=820 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209010060 domainage_hfrom=8269 Cc: axboe@kernel.dk, hch@infradead.org, tytso@mit.edu, agruenba@redhat.com, yi.zhang@huawei.com, almaz.alexandrovich@paragon-software.com, viro@zeniv.linux.org.uk, yukuai3@huawei.com, rpeterso@redhat.com, dushistov@mail.ru, chengzhihao1@huawei.com Subject: [Ocfs2-devel] [PATCH v2 14/14] fs/buffer: remove bh_submit_read() helper X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Zhang Yi via Ocfs2-devel Reply-to: Zhang Yi Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com 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-ServerName: szxga01-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-ORIG-GUID: pITi41pZmmBjVeoYWtnu7u8OnGBKZ6O6 X-Proofpoint-GUID: pITi41pZmmBjVeoYWtnu7u8OnGBKZ6O6 Reporting-Meta: AAGQck1dSvgGil4LAhqtcj2Hy+5Br1LgJrdv5GHsgHLXoFpI9PWWxCEDx6QX8zOv FOL+MoFWBW9MwyIQVmvdoFpoWf0p9D5T6DYsB+O/hQqxEvOOirDuI74Q/40uIcf6 RxKut3LXUwHIABY/kuztVtCmGQYYBrtubsVfAU0KmaiYk+HZ56iX1CI44DVrUNzx O+TcMx0YSV6VyCeiOBLxMt0b/MnbuVSiWw8UjJfawYktaatgxvu8+bBogfDiKRY0 7KL/noEwDYQsis5uRDIEZXiUvGwttoZDdT4KHU05yvQbuVmt6ji1dc3HlJ7anctf IcNkM5eUYWFKa2/NwGoNrFeTOM8xUVehvPvY3bZwoIEjfjt/oZvoWU28seTZlSvA kH5Qfg1iXG1AokY0/7xsTfvaizS358EFg/3kYpL0aJKyWrBbs3e95Le66l6hcqtS eHsnKXyBCaa2KkMyXvAnq7C+imLXKJn1/nCnVjByXDFw/r7wHxvCvZZeR/OHGdtA QC5BSE64UraiLZrZ4dcqfx/ysFR6o5/RjxdFWD5Ep06N bh_submit_read() has no user anymore, just remove it. Signed-off-by: Zhang Yi Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig --- fs/buffer.c | 25 ------------------------- include/linux/buffer_head.h | 1 - 2 files changed, 26 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 2cccc7586b99..b4c9fff3ab6c 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3025,31 +3025,6 @@ void __bh_read_batch(int nr, struct buffer_head *bhs[], } EXPORT_SYMBOL(__bh_read_batch); -/** - * bh_submit_read - Submit a locked buffer for reading - * @bh: struct buffer_head - * - * Returns zero on success and -EIO on error. - */ -int bh_submit_read(struct buffer_head *bh) -{ - BUG_ON(!buffer_locked(bh)); - - if (buffer_uptodate(bh)) { - unlock_buffer(bh); - return 0; - } - - get_bh(bh); - bh->b_end_io = end_buffer_read_sync; - submit_bh(REQ_OP_READ, bh); - wait_on_buffer(bh); - if (buffer_uptodate(bh)) - return 0; - return -EIO; -} -EXPORT_SYMBOL(bh_submit_read); - void __init buffer_init(void) { unsigned long nrpages; diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index b415d8bc2a09..9b6556d3f110 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -230,7 +230,6 @@ int submit_bh(blk_opf_t, struct buffer_head *); void write_boundary_block(struct block_device *bdev, sector_t bblock, unsigned blocksize); int bh_uptodate_or_lock(struct buffer_head *bh); -int bh_submit_read(struct buffer_head *bh); int __bh_read(struct buffer_head *bh, blk_opf_t op_flags, bool wait); void __bh_read_batch(int nr, struct buffer_head *bhs[], blk_opf_t op_flags, bool force_lock);