From nobody Tue Oct 7 00:25:10 2025 Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB5B82F1FF4 for ; Wed, 16 Jul 2025 09:23:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.119 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752657787; cv=none; b=UHWgH15t04cTQm2uz3lUrkizQGy9kXuXFCQMG7Rz1CTn5LjqEDZNCXjrajkV06KGgx84BJuqp34ZHFVQTCuzEkahQo3B4sA/84ZP8aA2a+j5ns2nEebPCaik+g5dgI6aVhgfebwIGg2viJLxO6+YmSKzYUO0PNxDs3VyhX39Wck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752657787; c=relaxed/simple; bh=DdkpaP3zWqzNKWwedXzH0thTe+J2eOPHl6Lt4jjzkJE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=SNJYPykZbv2sm63ijO732V3W8FiqsNvN+Ht8Zu2f41cxhKP9Vv7Fz0WFkWE2CplcDgZs4gpoyQ3muK1LtLKpajkWzlSu4/Ce6x7S2qq+V0RmLQuMKGz8GiTZjq8TwI+RUKHrtAe9cRBv1jbzbvfiGcWfE4VALBbR8NZFMOoUl44= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=m4Zc/ixF; arc=none smtp.client-ip=115.124.30.119 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="m4Zc/ixF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1752657781; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=oRq1da1ShbWLicICYakMfFg739TWglB9aY30Dnetp14=; b=m4Zc/ixFSvAPtPmcyybzbsCFKeq+8PC4Z0Qp4THIGfabslKfj9MSKeTRUXu+HLQbPmAZVVgkXUe2Q6kS2OiH/j4z94wu6PFobQQrGSFwX0ZJMsq3OEqr9j5mNokRIbDR4eJpf1e7+7Ja1h5my+25W3uMs0RbnZRrdIwQrQj+ewA= Received: from x31i01179.sqa.na131.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0Wj3WLvn_1752657776 cluster:ay36) by smtp.aliyun-inc.com; Wed, 16 Jul 2025 17:23:01 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org Cc: LKML , Gao Xiang Subject: [PATCH] erofs: refine erofs_iomap_begin() Date: Wed, 16 Jul 2025 17:22:54 +0800 Message-ID: <20250716092254.3826715-1-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.43.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" - Avoid calling erofs_map_dev() for unmapped extents; - Assign `iomap->addr` for inline extents too (since they have physical location). Signed-off-by: Gao Xiang --- fs/erofs/data.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/fs/erofs/data.c b/fs/erofs/data.c index dd7d86809c18..383c1337e157 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -269,6 +269,16 @@ static int erofs_iomap_begin(struct inode *inode, loff= _t offset, loff_t length, if (ret < 0) return ret; =20 + iomap->offset =3D map.m_la; + iomap->length =3D map.m_llen; + iomap->flags =3D 0; + iomap->private =3D NULL; + if (!(map.m_flags & EROFS_MAP_MAPPED)) { + iomap->type =3D IOMAP_HOLE; + iomap->addr =3D IOMAP_NULL_ADDR; + return 0; + } + mdev =3D (struct erofs_map_dev) { .m_deviceid =3D map.m_deviceid, .m_pa =3D map.m_pa, @@ -277,22 +287,14 @@ static int erofs_iomap_begin(struct inode *inode, lof= f_t offset, loff_t length, if (ret) return ret; =20 - iomap->offset =3D map.m_la; if (flags & IOMAP_DAX) iomap->dax_dev =3D mdev.m_dif->dax_dev; else iomap->bdev =3D mdev.m_bdev; - iomap->length =3D map.m_llen; - iomap->flags =3D 0; - iomap->private =3D NULL; =20 - if (!(map.m_flags & EROFS_MAP_MAPPED)) { - iomap->type =3D IOMAP_HOLE; - iomap->addr =3D IOMAP_NULL_ADDR; - if (!iomap->length) - iomap->length =3D length; - return 0; - } + iomap->addr =3D mdev.m_dif->fsoff + mdev.m_pa; + if (flags & IOMAP_DAX) + iomap->addr +=3D mdev.m_dif->dax_part_off; =20 if (map.m_flags & EROFS_MAP_META) { void *ptr; @@ -306,9 +308,6 @@ static int erofs_iomap_begin(struct inode *inode, loff_= t offset, loff_t length, iomap->private =3D buf.base; } else { iomap->type =3D IOMAP_MAPPED; - iomap->addr =3D mdev.m_dif->fsoff + mdev.m_pa; - if (flags & IOMAP_DAX) - iomap->addr +=3D mdev.m_dif->dax_part_off; } return 0; } --=20 2.43.5