From patchwork Wed Apr 10 14:29:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 13624716 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 DE1D1CD11C2 for ; Wed, 10 Apr 2024 14:39:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 251916B00A8; Wed, 10 Apr 2024 10:38:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 22D0C6B00AC; Wed, 10 Apr 2024 10:38:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 077F36B00AD; Wed, 10 Apr 2024 10:38:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C8F536B00A8 for ; Wed, 10 Apr 2024 10:38:46 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 90E8FA07E0 for ; Wed, 10 Apr 2024 14:38:46 +0000 (UTC) X-FDA: 81993878652.22.CCF8433 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by imf27.hostedemail.com (Postfix) with ESMTP id 25A5440017 for ; Wed, 10 Apr 2024 14:38:43 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf27.hostedemail.com: domain of yi.zhang@huaweicloud.com designates 45.249.212.56 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=1712759924; 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=SXDG5XixMuxezMUUhMaOGMs6/glxmCKVhiSJ2vLv4TYCj8Ekasud2XtV95GZSanWm8ou4x B/qGoLpudkeomYGO5v5M6SFOr3ZXxbGlbt9aZnwF6yZxK/euqTirnmwTbSEeFTe0mZMZlp VCbmoQd4TNVHWfI7cLOkcdKE+mEPnM0= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf27.hostedemail.com: domain of yi.zhang@huaweicloud.com designates 45.249.212.56 as permitted sender) smtp.mailfrom=yi.zhang@huaweicloud.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712759924; a=rsa-sha256; cv=none; b=5zDgWkuiu68Oi+mMKEXSbe1pZSnFdklN6HOpd+yxVSpy1gDVwMk6ddcPeg5K7GpbrVxHPw LRj235G+ZDex5nXJUoCHPYoTqusfHrKk02Wwgak3kiGcPkzePF4OVyHbC6o6OdncSTuV7l YqlSyG4Jtl/MJ8RYc7QFRLnFJoR/QRE= Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4VF56d5f4kz4f3kp1 for ; Wed, 10 Apr 2024 22:38:33 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 9DDDE1A0DFA for ; Wed, 10 Apr 2024 22:38:40 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAX6RFSpBZmcwR8Jg--.63000S27; Wed, 10 Apr 2024 22:38:40 +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, david@fromorbit.com, 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 22:29:37 +0800 Message-Id: <20240410142948.2817554-24-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240410142948.2817554-1-yi.zhang@huaweicloud.com> References: <20240410142948.2817554-1-yi.zhang@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: cCh0CgAX6RFSpBZmcwR8Jg--.63000S27 X-Coremail-Antispam: 1UD129KBjvJXoW7urW3XF4fAFy7KF1UXrW7XFb_yoW8uFy3pF 98KFy5GF47XrnI9F4SgFZrJr1Yk3Wxtr4UZrWfWasxGFyYkrW2gayjgFyYyF1Yq3y7Ary8 WF1jkr18GF4UArDanT9S1TB71UUUUUJqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUH214x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr1j6r xdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0D M2kKe7AKxVWUXVWUAwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4 xG6I80ewAv7VC0I7IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCa FVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI4 02YVCY1x02628vn2kIc2xKxwCY1x0262kKe7AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCF x2IqxVCFs4IE7xkEbVWUJVW8JwCFI7km07C267AKxVWUXVWUAwC20s026c02F40E14v26r 1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIxkGc2Ij 64vIr41lIxAIcVC0I7IYx2IY67AKxVWDJVCq3wCI42IY6xIIjxv20xvEc7CjxVAFwI0_Cr 1j6rxdMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8Jr0_Cr1U MIIF0xvEx4A2jsIEc7CjxVAFwI0_GcCE3sUvcSsGvfC2KfnxnUUI43ZEXa7sRibyCPUUUU U== X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ X-Rspam-User: X-Stat-Signature: crw1wmuocsee864q9xndcko56gepk5sy X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 25A5440017 X-HE-Tag: 1712759923-676001 X-HE-Meta: U2FsdGVkX19KR6f8ZCjWwiP8LYwQUg2XyQ2+l37ONcrTOcjhrUpbB5fiLicrLYjbJHRJkUsndx1fnS8klQJA/tOI+BhdhkpwW9k+k4lcdKBksOxAXSS73B6rmwB0DCBMjEazuhZER5cyNEYs8Fets8P7gEvIDsB53c/qQwDw/0V5Pb79nySBns/VBOI4Cs+Yt7ATZW//Tk6g5yheIi/1vZt/4VNvC28TXuguSj59HxF8CDQokrjZtTluNVmIrWMEj4p21NA68/mWW43lsYNE0RS6Z9gOwO5JWxipR0RIJAy84uK3BLLpxkdgElTUuccdW+IFkKRTJr1Hx5GxoNW00bAlN5kqq5IlpjKa72F7lI5IK+UpGtLQWCvr2NtF0W3ooEHVi42FLQDJ3FPqon4ctikPbSjZ5FktBZzdQszjo4ENUqYFhZ75m0gTbqPt8A1NcMnp/ee/B/ehpuGK2G4knAzcX/MuIDeqWIcnhBrCpXnYLBpthCXMmrmrJ0UWPM5jCGmnQaTttlZH4+qyXhXxJTWzcGG5r0WaoS/o/rFkwtLEM34De6BcwAVg9Dq8Y5z4RtilfaN9MxfL9ZvRjOlJBXAh3iw7/YKl4r0AD5C76hBrF7kvAzuljRyGSrZt1uUKIAk8cNlHPLcGsSN4BGO0EUtHs9WRbkrYvHqtqDqYFsHo5cJ65HUd2BZD/9XKcmlB6eTUJsBpgZhSnjU4fVpcbcEUXV9FRCHuJ1l+4OuP+2yFMCMKC0LDrwkesE7nv6VIpWkLfGDWusgeABFTW3dm8Ldgb8D7jH4YopiBB3Hx9KLSRvn/xxVsKmN2UVPvJsWfH8QH7D0V8bTruSp0GhGbTK1VaJqclXXKVNaVRQIzEQjh8/v2BOuyeIcGVtLVzQt00Q0ecP+9QRf8TuDJv8dKML9fbNIeDKjCjafVE/4fXzkw8X+qaykQf+jdIVaec78YjYmJdzsw1Aob65HG5ix /ifhTu2t 0wBllDFS1pUmZ28UBuH8cWXBX8tN9rpyT6GJYaXf3koZqbSUqmuquM6x4EW62D3ry1TymLHYCMG+C1Q4/1dJ/IxCrRmZk8scWHX2TVyxgbQx/uQLRJxWgyGQGrtUZ8Prm6F3+Nov4s/cVrCBp/I1y/PZRk77fG/CgbT7HfsTw+5OZid1eJheoyzurGEuqpeLpL3DpQOo4LyQD+lM/9mDhzKmhZwchPjzqXnmyfW2wuPCHPjQM/47GwH8Vb0gfbLFnPBOm 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,