From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 ED6C13D6488 for ; Thu, 2 Jul 2026 23:59:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.128.48 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783036795; cv=pass; b=Fyqt5baLbLZuU2qwkrbCXt0jrCOqziEHrj1A3/Bf/DgcMM2PZPpHNd+LJvhp+T5/hreZqX/CB1G8DyaxhLu0RydtwwmgY9WIPWH4kMeQmwtzF5XajfgM4baFcuBuop/+ZyvLlsu4UtxAPW9+ACXNAD0sECkm8gl9Faw/T4hFO+0= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783036795; c=relaxed/simple; bh=9mfrTGat0AT7NLP1gbhbIUiw0dL1UYJaiMio4afATB0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=mtqEF/yrSete055ygt1X+tRucSU+0WRy4CxtxPUX6/t5Pf8k7r18sEczvs7UX71/8nGu3eYnUWitbRUBhYVr8D6ww5HLVwety/7CYA5BPb06kSC3X8v9M//VV7QYm/++Ghm7pzjqdtluw19OykSmtqVvxxVCrml2sJyywDLSLQ4= 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=LuRB4kcA; arc=pass smtp.client-ip=209.85.128.48 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="LuRB4kcA" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-493bc8fda98so21092835e9.0 for ; Thu, 02 Jul 2026 16:59:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783036792; cv=none; d=google.com; s=arc-20260327; b=AgPBa9QSE05kFUfNc4chUY8rHhAoxGE0/5Vd0Mk/fmTmK56htBoEe4i+v1QZ687p// KFvEil8HJmCPUC67zWVRy2xK7yCq0pj+TLK5e189Snqe+zQ7HmZndGK87y1T2DYLO06X C5uUOeK8DLDzSeLzrMvBHBVv+dM7iVCrVMacZhwffnunV+dgAhjzjxlQP/ke4mBMjb/P 7ylli0cjh37aXNlH9w4wWpEQE9QwzRNpde5qGimzhUm7kds8CR6yatAUmC2mnA3fkryn m85wzDCkD9GzP1uqTRgnSaYlt94jdRuLVAStAIAs0VpI5cJ1K3NO67cmM2gXF7syO68w x5Og== 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=Lr71FjY8xrzyOTpsfFewrECV5PtfY/nu/gI0pAnlh+k=; fh=3DZoeAnwHUC5/JvQwk3mM686uVxpTiYS3XVkJyoEEjc=; b=YvHWTdwOqbZsSlJvilqwSFV1X83mr0sZOLLnNiALFNWaQjZj9L8PtOQ216upWVdEti 9YOU6PzNDoYAV9xprsqZn/iCS+2xFKNh1QDqetMQAu4XsVduCQiDBspiiA0yP7CzNYbz 4oveBFZamMZrDuCJskDiiWz/LWjrJdud8s84Vj/fKIsbTL4jB9NNVxGa4Cl9cURCyQf/ Tmh25o32QD0CP3ANdAltvuNk0Bb5cMWovVvl7o6Ge8LWIF0nvSyBGMRN+CpirmYYAUKR WTJlYGAaj5XLPiBpmzD4s/ejcbyMdD85vmKyx/k76RfDK2BV4rvhkaFrmI+tMWwLyqeV OwMg==; 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=1783036792; x=1783641592; darn=vger.kernel.org; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Lr71FjY8xrzyOTpsfFewrECV5PtfY/nu/gI0pAnlh+k=; b=LuRB4kcAQ9y8MIh/YvJtL+KSYYf77KFXLPxOyovtVvvxUHgY0YjXmkAZKsLwfpa8jG GUkFHhPhYd+M6tHa3Flt0x2uLlVRCQ6HrtYLmsu/ZKg+yhOqpvoC+1SlEkYocacz0KDV UjmI1kBSJk7VR81NuS4u7mLSYR/FG9Gr5Y9wUJuZkf5oEAABAtveNRpIWXNm0W5nBCDm EwXZPxpIdqvrovrJdohH94O5YoE6oyQSvHBUZXxlIyQeHfmfvFRfnVYJXYWRlfEwyEVS 8lqrVie50IoGIFy0cVztoVHbk6/Ikbl1Q2pN7Y9BW9IMK7FcLsc8UpWrUc7eqPcXeZon fgoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783036792; x=1783641592; h=content-transfer-encoding:content-type: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 :content-type; bh=Lr71FjY8xrzyOTpsfFewrECV5PtfY/nu/gI0pAnlh+k=; b=LDcxV0G8O53RjME9MWhGajzV/zo3uOGRtPKoJ/R4cv7PIStifYMGw8XVXMLRoRmccm ny6+DwRSOMcXYBjx5P5JH7vPDgkNBmbEGzH6BKeSJO0owex/KRNgKU+a1vtYk1tKE7ln oLFntUMNBuNGGhMOhK2ofOwW/o87uv8hRkatUr3N9KzKLTSfZ10JNKyjBpQI7aSq/aIq 10ao0C/NZ9oVxVxC/wp/yyyKXrVXcpraKCHoUvk9ucd4wFMkHUFbiGv1WtoxAJr3gml5 JDYzrQQfNinZacgHjVWGBn2PleV3q4V0Sld7AYTORtf0NOao0jFuwXytaphhyeNgd8kz 3AHQ== X-Forwarded-Encrypted: i=1; AHgh+RqaapC+ZWVUeUmXRLwkW2sDJsRQOW2kBCOl/l1yuP05dUCFbyeU4eL52PE7+tg7PrvJK45aQB3B390wn6M=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3o+7U2n4QWGIJVP9vlvKQhTZKDVVGrWfismo4aWuuNWMChhEv Lnv99NtET165HfHqPZKZS19Xsxq5DF+4xP7wg8ZoOhWErXuxaRutwSH8NCsQ52IdFs0zIE0JWhr 7O6lOXfUltIaQQcPkq3G/1AEqbkrt5nU= X-Gm-Gg: AfdE7ckTZmzod+i4u5W2nOxFATNBEWNhZljOAI35hbow8jslyYgZSAIGdi2wX0qfGtR xk5pvzusKsU4XAyxb1ydemJhdyULlHg4UXUEhhVTpbnSLPR6nDU7KtpWAqHdkwedlxK3nw1tr3l MvYacviLSuI1wceK7LgYLpoTLmJioN5rnDscyxKMZtbWx8+D8spqiu5INJ3P3o3n+oBkm/76RSE Eye5itmg1SLEwSvIb67ct3QYQjdsE9VzoJaSDQqlCJz9fAGxBwueMlFlyESDWbrKVs0zhqy3GuH J7iPqqg51nk17U3bNdcBnUqkkMmSlJpdenaWP0bypJa6dYgYK+cI X-Received: by 2002:a05:6000:178d:b0:46f:7127:9f70 with SMTP id ffacd0b85a97d-477b3889564mr11032946f8f.18.1783036792138; Thu, 02 Jul 2026 16:59:52 -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-3-joannelkoong@gmail.com> <20260702164339.GI9392@frogsfrogsfrogs> In-Reply-To: <20260702164339.GI9392@frogsfrogsfrogs> From: Joanne Koong Date: Thu, 2 Jul 2026 16:59:39 -0700 X-Gm-Features: AVVi8CfRMLQ82BMABsxnrmWXO9hzG4sO4-QzmTQ2Zp72T-55jYigQ-9-a_U5Uvo Message-ID: Subject: Re: [PATCH v2 02/18] xfs: convert iomap ops to ->iomap_next() 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, Carlos Maiolino , open list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jul 2, 2026 at 9:43=E2=80=AFAM Darrick J. Wong = wrote: > > On Tue, Jun 30, 2026 at 05:09:17PM -0700, Joanne Koong wrote: > > Convert xfs iomap_ops to the new ->iomap_next() callback. This uses the > > iomap_process() helper, which finishes the previous mapping if needed > > and produces the next one. No functional changes are intended. > > > > Signed-off-by: Joanne Koong > > --- > > fs/xfs/xfs_file.c | 4 +- > > fs/xfs/xfs_iomap.c | 96 +++++++++++++++++++++++++++++++++++++++++----- > > 2 files changed, 88 insertions(+), 12 deletions(-) > > > > diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c > > index 845a97c9b063..7f8bef1a9954 100644 > > --- a/fs/xfs/xfs_file.c > > +++ b/fs/xfs/xfs_file.c > > @@ -857,9 +857,9 @@ xfs_file_dio_write_atomic( > > NULL, 0); > > > > /* > > - * The retry mechanism is based on the ->iomap_begin method retur= ning > > + * The retry mechanism is based on the ->iomap_next method return= ing > > * -ENOPROTOOPT, which would be when the REQ_ATOMIC-based write i= s not > > - * possible. The REQ_ATOMIC-based method typically not be possibl= e if > > + * possible. The REQ_ATOMIC-based method is typically not possibl= e if > > * the write spans multiple extents or the disk blocks are misali= gned. > > */ > > if (ret =3D=3D -ENOPROTOOPT && dops =3D=3D &xfs_direct_write_ioma= p_ops) { > > diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c > > index 225c3de88d03..4fa1a5c985db 100644 > > --- a/fs/xfs/xfs_iomap.c > > +++ b/fs/xfs/xfs_iomap.c > > @@ -1037,8 +1037,18 @@ xfs_direct_write_iomap_begin( > > return error; > > } > > > > +static int > > +xfs_direct_write_iomap_next( > > + const struct iomap_iter *iter, > > + struct iomap *iomap, > > + struct iomap *srcmap) > > > > Now that I see the callsites, I think the "next" name could use some > bikeshedding . The purpose of this function is either > > (a) to look up the first mapping to start iterating; > (b) to release whatever resources were attached during the current > iteration and look up the next mapping to continue iterating; or > (c) to decide that it's time to stop iterating. > > From that it seems obvious to me that xfs_direct_write_iomap_next yields > iomaps for iteration. In Python those are called generator functions; > in Rust they're called objects that implement the Iterator trait (or > iterators for short). > > How about s/iomap_next/iomap_iter/ ? > > Then this function would be called xfs_direct_write_iomap_iter, which > IMO is a closer description of what the function does, which is to say > iterates iomaps for direct writes. > > (Yes, my brain might be polluted with thinking that "iomap next" refers > to a major shift, in the sense of "linux next". :P) Thanks for sharing your thoughts. The idea makes sense to me in theory but I think in rust and python the "iter" naming is reserved for the iterator object itself and the method / callback for advancing and yielding the next item in the iteration is named "next" (eg Iterator::next in rust and __next__() in python)? I wonder if the s/_next/_iter gets confusing with multiple things in iomap already called iter (eg the struct iomap_iter, the iomap_iter() function). I'm not sure, I'm happy to rename this if that's the preference. Thanks, Joanne > > > +{ > > + return iomap_process(iter, iomap, srcmap, xfs_direct_write_iomap_= begin, > > + NULL); > > But then "iomap_iter" sets up a new problem: should iomap_process have a > new name that goes along with that? iomap_iter is already taken for the > legacy path. If we were emulating python I'd suggest iomap_iter_yield > but this is C so we get to reinvent everything from scratch so who > knows. > > --D >