From patchwork Wed Apr 10 13:28:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 13624578 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FDF0CD128A for ; Wed, 10 Apr 2024 13:37:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7FA946B00A6; Wed, 10 Apr 2024 09:37:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 75A976B00A7; Wed, 10 Apr 2024 09:37:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 62D6B6B00A8; Wed, 10 Apr 2024 09:37:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 3F4CF6B00A7 for ; Wed, 10 Apr 2024 09:37:08 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 10DE480321 for ; Wed, 10 Apr 2024 13:37:08 +0000 (UTC) X-FDA: 81993723336.15.9B07BCD Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by imf11.hostedemail.com (Postfix) with ESMTP id A49C940005 for ; Wed, 10 Apr 2024 13:37:05 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf11.hostedemail.com: domain of yi.zhang@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=yi.zhang@huaweicloud.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712756226; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fpA/4lqRQbydf8z9xn3F9nf8xQRgGteQQM2P1EKzZvU=; b=3FBzXTIseLeBJ8OXONtFrncnXbBDmu6QsoUT2cJX4uV3Hmz85kgSvBpkXuOBgCO7GKn3Gb AkU7mTUB9HmCnWf19rvjguENz8JmbwPSDYf0T8rFmNZNRxfJPY4Na85kGM8RQeytd4Ojeq DiOd8UR+KLkc6KTkccyLyvWwnW8dBm8= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf11.hostedemail.com: domain of yi.zhang@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=yi.zhang@huaweicloud.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712756226; a=rsa-sha256; cv=none; b=gnVqiBaeFYKxDQNZadrHmu5yZJ3XLaDgw0zYIz6bH3HMG8Z04jmnvCLAEKbgpTaq3Hic1B ApatwU59zhNXYuiJWo/UEy5u3DKpPs1Znm9XGgLx/9XErPS/OXlPQ77BlcfVAHYRJYNohS nTorSmuJQSKnPVIAyiIz4Pd9D1HXxNo= Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VF3lY5Whzz4f3jkd for ; Wed, 10 Apr 2024 21:36:57 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 31BC61A016E for ; Wed, 10 Apr 2024 21:37:02 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAn+RHolRZmeCl4Jg--.8806S27; Wed, 10 Apr 2024 21:37:01 +0800 (CST) From: Zhang Yi To: linux-ext4@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, ritesh.list@gmail.com, hch@infradead.org, djwong@kernel.org, willy@infradead.org, zokeefe@google.com, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com, wangkefeng.wang@huawei.com Subject: [RFC PATCH v4 23/34] ext4: implement buffered read iomap path Date: Wed, 10 Apr 2024 21:28:07 +0800 Message-Id: <20240410132818.2812377-24-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240410132818.2812377-1-yi.zhang@huaweicloud.com> References: <20240410132818.2812377-1-yi.zhang@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: cCh0CgAn+RHolRZmeCl4Jg--.8806S27 X-Coremail-Antispam: 1UD129KBjvJXoW7urW3XF4fAFy7KF1UXrW7XFb_yoW8uFy3pF 98KFy5GF47XrnI9F4SgFZrJr1Yk3Wxtr4UZrWfWasxGFyYkrW2gayjgFyYyF1Yq3y7Ary8 WF1jkr18GF4UArDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUP214x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW5JVW7JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr 0_Cr1lIxAIcVC2z280aVCY1x0267AKxVWxJr0_GcJvcSsGvfC2KfnxnUUI43ZEXa7VU17G YJUUUUU== X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ X-Rspamd-Queue-Id: A49C940005 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: e6sg95krax3kysehoc8n6a8rp9tz16kc X-HE-Tag: 1712756225-847073 X-HE-Meta: U2FsdGVkX19zfYxs0v6OeJg0lZmP+S+iLAmdWpVvzyPtLHWo0EgjMrcYsw7WSAsP5RMKIG6aM+nyfZliVKgq67jjRligqOtpMVXZgLqWXlqivgyHhaXUq7LN2aYnk2djzrI1zn5XmSbtHODOfFkoc0WPLzoJMZ3ksyOdcqOiCgOM8I2+yAgmSaaMBhd1y42KN1QVaG+Jn1h1MVjQVMWxTM0mkRS7mxjIrk3KRxHQVk44Cwreh1hKXQCb9r1zjtpp2rmHqxfmIJslFpezzMAM4nAseBAL4H3JoHi9ovUW6zMa7EAwCKxnJrhX7UgaoKIYbV/cc6GrLqe0SZdxe181dw0+hBlp3uAfeBkhmJe+We8Qth3IB/bU5TEWV7BL6NVs91ZTBONBuBk8SWhoTFCBK2SfNsY4+EA4gQtNtO2zeNrk6RYPj/kV76YYaezvx7xfwQq8h32QPqyrn4vMVFB6qyXfJ7cufosG4HOGSWEsM0G7ytg0JYqRIe4WtRvdwG6kTMGacLfM5g3rjAkcOhPlu88Wsg+BLz/1OiTeLgsdKdC9jL/dL/aNvWYShgSAdAotOS0qFsdSnbqGbNlp1fBvPkblUNwfNuc64NscTz+6XB1XOL+rjKqiCYR/SnNfOVnOZScKZJehh3cbcokwTtZPzXdDd+wmxCx5sMcLUeWOykzKg5T1pcJAX2Y0kaR39dbM9FzA94Gd7ip4sTKkJGaNXEoehx4FUh44zdCzLnu5EQ9CzzC+JmC9e0GYp5v/mO4DkNy7TuZEoYC4qUO57yyK6AuDCt/za6FAq5emQVQhG5/u76p06/EaOd4GkU6fdj3LpXy2brmHCA0t5QunZ/FW4bUp0oJG9kXjmF7T6kmu69ms/6Xho3FGmN4D9dJK4AlNyOZTslcszHCWJyOsNPu8ZIZzXqXgiOo5XK2CR/5FSnYfc4v6XwkN15a55t+C11pLUA6g2kfwDbGtwhkHKGZ XfudnYgt cFk42kYGWv42Myd3a9kuafqVzTmj1kN8Ijgb8gVyBb/Ob8FGImS203FIBGh478DQeDx06hhKUdioTwD+L/mE/8uFFDvlG5cj7xPXOrfzFMF3ddy6Cnsx8oyRZgjBGjnsTOJzQ4xHbmLnYD4vJnCH6hJ3hOjnaUBirQnlqUMlZfZ1qEz54C9a9+efKh4wwWhtlSBK7F++K2rA061eZ5Wwuy3dOiADrn49BFyESWI5rOQF198mxhOTL6/7JCUIg+BUZ/xtj X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Zhang Yi Add ext4_iomap_buffered_io_begin() for the iomap read path, it call ext4_map_blocks() to query map status and call ext4_set_iomap() to convert ext4 map to iomap. Signed-off-by: Zhang Yi --- fs/ext4/inode.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 4c1fed516d9e..20eb772f4f62 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3523,14 +3523,46 @@ const struct iomap_ops ext4_iomap_report_ops = { .iomap_begin = ext4_iomap_begin_report, }; -static int ext4_iomap_read_folio(struct file *file, struct folio *folio) +static int ext4_iomap_buffered_io_begin(struct inode *inode, loff_t offset, + loff_t length, unsigned int iomap_flags, + struct iomap *iomap, struct iomap *srcmap) { + int ret; + struct ext4_map_blocks map; + u8 blkbits = inode->i_blkbits; + + if (unlikely(ext4_forced_shutdown(inode->i_sb))) + return -EIO; + if ((offset >> blkbits) > EXT4_MAX_LOGICAL_BLOCK) + return -EINVAL; + if (WARN_ON_ONCE(ext4_has_inline_data(inode))) + return -ERANGE; + + /* Calculate the first and last logical blocks respectively. */ + map.m_lblk = offset >> blkbits; + map.m_len = min_t(loff_t, (offset + length - 1) >> blkbits, + EXT4_MAX_LOGICAL_BLOCK) - map.m_lblk + 1; + + ret = ext4_map_blocks(NULL, inode, &map, 0); + if (ret < 0) + return ret; + + ext4_set_iomap(inode, iomap, &map, offset, length, iomap_flags); return 0; } -static void ext4_iomap_readahead(struct readahead_control *rac) +const struct iomap_ops ext4_iomap_buffered_read_ops = { + .iomap_begin = ext4_iomap_buffered_io_begin, +}; + +static int ext4_iomap_read_folio(struct file *file, struct folio *folio) { + return iomap_read_folio(folio, &ext4_iomap_buffered_read_ops); +} +static void ext4_iomap_readahead(struct readahead_control *rac) +{ + iomap_readahead(rac, &ext4_iomap_buffered_read_ops); } static int ext4_iomap_writepages(struct address_space *mapping,