From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1073C3CE4B5 for ; Thu, 2 Jul 2026 22:41:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.221.42 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783032093; cv=pass; b=tSWTDDugBJWxJhSQOGDTKrYll9XwbVzb6VOjAj/FNYT6Erhr5GCb5C7RzyFcmy/8gV9kuEACuP5fyRJFi8vhDCwZcpzbDAAjnVhSz6cH/rn7WOqZ8xRTOrfBnsa1MDAlFs45H/3Wv3IdUrbLmntWCSWrEPmiWBJc5/o4ga9E+Ic= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783032093; c=relaxed/simple; bh=WIAOw+mwvcTYeXCgk6/3W7/rb4zmiahpFKaV0/jt0YU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=b/N1h7Pv4eOqRYaP3/nKbEjFGQ3Y0546cZKrPGK+WyWPHK3DCaOjLkm8moaA5txB7B3ki1odDPPZl9oNnaaVP8wecuTd6OCMlQzxluMgmL/RnCBjWglTvgs2REJL/+CTWdGSG7sDCoa1/Tf0y+cy75h5Wv7Vf0M/vC6WFQ7o/xg= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YqosHtCU; arc=pass smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YqosHtCU" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-471eeac43bfso1930890f8f.3 for ; Thu, 02 Jul 2026 15:41:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783032088; cv=none; d=google.com; s=arc-20260327; b=Ejx+bcxZuz2+cRQq1m9EQPuEuMM0RCqZmlwdouK2L6x9ioQxe7rY48sIplci7kfYfo tqkafKZV3mcmTapyiUsX58UXllqIEKty33VcT962BbXgr0yN5Lb7w/wLK5XPkVLvLTDO Vcp1S5DDAkhDuz+Fk9B6m1oknbmg8iSGpK5vi6S5JQjLg4ZcqWAfqfPs7ffndWEhhxZv YGsMvm7RH8n1yypk0hsampoYETAAaKYfVffNtn4rzewDZjR07kwHFGiyHeK8WETPGpq7 C7FmmYyCatG/F0JBai6jdlxQfSzy+Zwuz4V7MRIRgNBv4WAvqOna/N5hWTqtUKrVx4fi bYoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=h9a02slDLUgWwDo+yKrdEPAIuAXAqNrHLiCEZt+6Lmg=; fh=1YPrDewT9MeRzUJnfpyVk0Eo8JZMdV+gcaQvNzbGLHQ=; b=WflZljIUi/xWpg1wcDgVLJgItPv1iWN9t6J8mlFdrFxVX3qw8+8vuTG63pYIpj4Ten aILR19XMDvc2wg3rkkcDClom6Amd4UVb4m6rEhhgfsfWoAbPmIi3/TtgjA2sRoUZayKi Zjckklsbv3f9xFPoIjXGKSbERRtiwhhYl+IIZVze/vAvkWEakyWyXsuriG8lIpOeBJ/C WncZocSSfv+4tHxbXmu7Brijfnb9gfGdlvnMEAvcDzWcfpJwsNjHkRNxMl4t549j0w/j +Qvjc/q4HcWflTmAoVV7wpTmbgtw20awOaUsnSq757Zjqrn7AsEPczVDZGZqdz8PD3dx doSQ==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783032088; x=1783636888; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=h9a02slDLUgWwDo+yKrdEPAIuAXAqNrHLiCEZt+6Lmg=; b=YqosHtCUXNzXfWUzNNlHrQf51o9AW413o3K7p4zaIw34/4ZuK2aEFAhm1/IVmUGR0Z 8e3t/5uSeJwHAflA9cHsPJqYd4AuE7d94ljSpndkHSd5GoC/dfHFK7BU8yc4X0EEIMGm 0MHnIVPrtn9AhoyBsKW1mkeE7m2HAijVu9AVyRIi7Aia++iHmJqev4LWKfdgD/tYfuhf WMvTxzqWF28Ptc8QQN2gHd0hscbIpy0/lXSjXacD8jKKViyVnN/H5TA39jCmaWVOi6zg diot39qwe8DwfIYsLTFdP4wGRIOEijiVNQnp0BCrN9MBYUkyK7Niv3HsTdqJVC0cN/CN Gvaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783032088; x=1783636888; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=h9a02slDLUgWwDo+yKrdEPAIuAXAqNrHLiCEZt+6Lmg=; b=nW0FPQVUidrFWrGgXwYB1zE+niuWiG+aDPR/3ND1zJSmyzRFMKWuEpufZ5GiXZSUYW ATjwL2Wi5NFvzI4BM2jZxgLsSPemY95nRMmpv/LrfZTJ6EfTM7XjeESYZD8c4QVUqOie 6j2ZJmT6VRHa0Kl5xAC5zeoPty7vS8rcg1Y7K5fOEU3lHTUCpq7VImVpy3tMp2NvTuoo Nl2FZHPElQhmjhzb4olIjiaF3ICmy+zae2i1bVJ/pW1PlOVnwYIdQF/mW/aObqMqU2al /l2vaMjYT2BdS/lVgLlHEgliNgoI0e61U/2ZFpH1BS8VGKUdtyBgV4RWosot9nkB8Y33 8mhw== X-Forwarded-Encrypted: i=1; AFNElJ+HzYfu7y17AxA1xn9xBGmGBzZyb7gU5LrTH2lGfrz+mwi7CWTzuKo2zhwwrQDSeDXjMMGePfEf9DDrH/s=@vger.kernel.org X-Gm-Message-State: AOJu0YyvrzKAsOH+LVLuqiZ1djIFcmX0gN0YkHEu6CZ6W/zUsh4w9aJv vMzhPSb4a/3AwtVgsOZRetGGp8aA6JTByhEaW0NJyamwQ9jzEE6oAaTSC2pPFTAIW9MALTNzHyk P7ByuwwVZUITN0udK9hoRCg3qRNH9aUk= X-Gm-Gg: AfdE7cmeX7Is8Z5be+fh7FYYCNmvXc8sg7VauyXvW2JD3hekhLlstGBTNenPm5TQl/D bSPYeU6mNrs5CvZCNm++HiNJLc6UjD+rtL73L4en80lDNNBOEvS5vogiypPdwXgof/vZoitb/gU bp0jG6Wfzq1LPo8NplR4ig+UOnMGHs54TTxQqG5p961tMEJakDGqAS83lHuG7q3Z3LhWscowUzk Nl8R/zFGFXBJYPkM66mRrdfE1TQn2kTab+aTa+oDwh5aRbhRGaWtZWxHiwyL6mX71dYCsdkEMuY PerIwibCkhNqhXpeDE+TxgnL1ydu9kJd2iEGRjQT03KskuKf0e3a X-Received: by 2002:a05:600c:4f94:b0:493:adc3:cced with SMTP id 5b1f17b1804b1-493c2b9826fmr112815045e9.34.1783032087995; Thu, 02 Jul 2026 15:41:27 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260701000949.1666714-1-joannelkoong@gmail.com> <20260701000949.1666714-2-joannelkoong@gmail.com> <20260702162308.GH9392@frogsfrogsfrogs> In-Reply-To: <20260702162308.GH9392@frogsfrogsfrogs> From: Joanne Koong Date: Thu, 2 Jul 2026 15:41:15 -0700 X-Gm-Features: AVVi8CcF6CmN9sR8NoQCdzue53Nqs4TLr02dXcvyfMRXcWTVkIDv2UbgUVh2ijY Message-ID: Subject: Re: [PATCH v2 01/18] iomap: add ->iomap_next() and iomap_process() helper To: "Darrick J. Wong" Cc: brauner@kernel.org, hch@lst.de, willy@infradead.org, hsiangkao@linux.alibaba.com, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, open list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jul 2, 2026 at 9:23=E2=80=AFAM Darrick J. Wong = wrote: > > On Tue, Jun 30, 2026 at 05:09:16PM -0700, Joanne Koong wrote: > > Have one ->iomap_next() callback instead of ->iomap_begin() and > > ->iomap_end(). ->iomap_next() finishes the previous mapping if needed, > > and produces the next mapping. This lets performance-critical callers > > inline the iteration with a fixed callback, which the compiler is able > > to call directly instead of indirectly. > > Er... what is being called directly here? The iomap_{begin,end} > functions? It looks to me like ->iomap_next is still an indirect call > even at the end of the series, right? That's still a net reduction of > indirect calls at least. > > Oh, wait, it's the __always_inline iomap_process function that a smart > compiler can use to turn the indirect calls into direct ones, isn't it? > It might be useful to add a comment to that function saying that out > loud so that dolts like me will pick up on why it's critical for it to > be an inline function. Ahh the sentence was confusingly / ambiguously worded, sorry about that - I was trying to say that it lets callers have the ability to inline iomap_iter() with passing a const iomap_next callback as an arg which lets the iomap_next callback be a plain direct call. But your interpretation of it is also true. I'll add the comment you suggested to spell what you mentioned out and reword the commit message to make what I was trying to say more clear. > > I like how this is going. :) > > > iomap_iter() uses ->iomap_next() when the filesystem provides that > > callback and otherwise falls back to the ->iomap_begin()/->iomap_end() > > path, so filesystems can be converted one at a time. > > > Add a iomap_process() inline helper that does most of the logic needed > > in an ->iomap_next() implementation. > > > > Suggested-by: Christoph Hellwig > > Suggested-by: Matthew Wilcox (Oracle) > > Signed-off-by: Joanne Koong > > --- > > fs/iomap/iter.c | 113 ++++++++++++++++++++++++++++++++++++------ > > include/linux/iomap.h | 91 +++++++++++++++++++++++++++------- > > 2 files changed, 171 insertions(+), 33 deletions(-) > > > > diff --git a/fs/iomap/iter.c b/fs/iomap/iter.c > > index e4a29829591a..1062e4e34c38 100644 > > --- a/fs/iomap/iter.c > > +++ b/fs/iomap/iter.c > > + > > +/** > > + * iomap_iter_continue - decide whether iteration should continue > > + * @iter: iteration structure > > + * @iomap: the mapping that was just processed > > + * @srcmap: the source mapping that was just processed > > + * > > + * Helper for ->iomap_next() implementations, normally called via > > + * iomap_process(). Called after the previous mapping has been finish= ed to > > + * determine whether there is more of the file range left to process. > > + * > > + * Returns 1 if there is more work to do, in which case @iomap and @sr= cmap are > > + * cleared so the caller can produce the next mapping; zero if the ran= ge is > > + * fully consumed; or a negative errno on error. Any folio batch atta= ched to > > + * the mapping is released before returning. > > + */ > > +int iomap_iter_continue(const struct iomap_iter *iter, struct iomap *i= omap, > > + struct iomap *srcmap, int ret) > > +{ > > + bool stale =3D iomap->flags & IOMAP_F_STALE; > > + ssize_t advanced =3D iter->pos - iter->iter_start_pos; > > These both could be const, right? > I'll mark these as const. Thanks for looking at these patches! Thanks, Joanne