From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 C7F9731DD90 for ; Mon, 8 Sep 2025 18:52:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757357543; cv=none; b=mhgmQlYJGuU4+NZCOwoy34b9meHJC/WV/5lePhMNBeHhpvGEgZ/47Eb6/uGmWJrDu2H5wuZFJuTNNj0c5V6Bclfs6RYYjIV5lQcYkYW+pB4j0hSmsDe72/yejr29Yer7IvQmUeqk8DaZro6CoTqWtFzcVD1NRBr+4WzjYYsr8tw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757357543; c=relaxed/simple; bh=03ZJHgsYmhlSs1nq+6Xf/GUNcyuYrHRU+DwlBYzjY0Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BeRSGYFg19fupWmQQnDl3c1WFQ83YeP7KFWx/TKRBJrUxLQKXzAhgoseO45/tDCeMB3PBdwm/aODX/X1S99v5lpHB/HcR3krgOHDHR+FL92zKwde72SMRcZiOmSLifV1l4SkZvaOTsUdS5zfFM/U+QDaGsfL/T27NR9JY5Uv5Yk= ARC-Authentication-Results:i=1; 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=VTXzRqoC; arc=none smtp.client-ip=209.85.214.182 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="VTXzRqoC" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-24eb713b2dfso27979515ad.0 for ; Mon, 08 Sep 2025 11:52:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757357541; x=1757962341; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0HVCkh1UKWPFtgzXfqyKtp7JpLoGe6FH7DH/+yG/OV4=; b=VTXzRqoCm+6Y11eiReJ/IXhafbnHwqo8622ZIjFgC/nLC1iAMyQL7TBycFUJa70xP8 5sFIDx0MroudO59MYX/QFoe9bB8dTK0IIElUUjiFqQ16ae58mjQ5SOp7OK3pVCtHXnks yoOqNX43+KQ+44f1lJT2PYBALQKpCQxzdQ+ODbxl0OJV3LhS0TN9v3asY26J7eRTeI7M 7SGe4WWrw+6Amfhd6OVe4Jy6MD4b9C/DFVvpMMqUanWr3WHmLZKIUfkBw8K1F9ZlKp19 lNnBfs78JdN6Az2sjieZCIYTr5juImNbHoB/W4QsFTTGdwytxzwe0efwQpQNS3oxCGl/ dUeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757357541; x=1757962341; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0HVCkh1UKWPFtgzXfqyKtp7JpLoGe6FH7DH/+yG/OV4=; b=FcbzyllxX0TAfixPVX2Yr8pokknO8+Jz29G5JWu+9x2ePZxH3yEcOnb964nKxdEWVk 2f4J+6tKF7gTr/0fmw9B9RVYP9U9TrtMRC3o2x+SeewERE9RD47fvpuoeTcNJK4BFD3p tdtgJvBKmL/+TEFOFm9rU2NpFHrbQMUscz8uEr0t4XuZ+i0pL60ql3o7VjRujYHB25dD kQabuDt2TC9HC8Ma0/jKtnbxlO7l+0Ym2rHAklO7APInMJLGDGF+/3sCNp+C1PVmrdvh 9Iu4KfHd8kkFPWl8IaQAWGUV3Fo7blnO+dRQT/a6O2kx/GkSPdZ0rOikUkPvDnTTwMjX 8Jbg== X-Forwarded-Encrypted: i=1; AJvYcCULbdCNo+ZcjMWwceP6v1D4dsSdmigQ56lWwLrphgHH+F91d53YkqmgiFEarByTl10c7q7z@lists.linux.dev X-Gm-Message-State: AOJu0YwscqtShnNryYEPJPQRvfcgBGttLmL9D41u2r6BLxx8Hn3dPNOx 5eS6aVd0+3XIqQAY3vy/PRu/sg7/gxDLzZwLkQKQmwrOE0ENYnn6zHDK X-Gm-Gg: ASbGncsJBuOjIQqA4e0qtx9kOHapOjKnrflpZRwRDsYtR3AW+TgEuDMWbX/Im/vU87+ bJf1NZLYQUimGmsdXKUDypP3ESs0RVjEMxQADVV5KWio7bE1jtPg1xz/Zg0bBztyBGSAk0ORCFF I+WA0KSGCkcZ31m3On0puyHWeEL5kuNV3ooRENIYy86Bn+NWSTMjJhy4VFMT+FucQOMkS2Q5DF7 X1hM+e7iy1bcCECvfK2WE879gFQSSnDrj0QQKcpRDcGaEjTn9I+hUG/hXOZbvZ04iWKgxPlEUhj 9zGzvR8RKKBhL15WVTqzsJ31793YmdtTiRmdsup5zR7X7LYeA0BtRzkwUKXWfC+dGLQp/1ON62C mG10Lrn/yYiJGC/4DXw== X-Google-Smtp-Source: AGHT+IFG72y7Clny8aCD6Sn14+X8WmcLDwUJIUWQp2xJBzCzAcXeYFo4xUxw3GPY5uaJ0Z21BiduUw== X-Received: by 2002:a17:903:1585:b0:24a:8d5e:932 with SMTP id d9443c01a7336-2516e981584mr116482435ad.23.1757357541032; Mon, 08 Sep 2025 11:52:21 -0700 (PDT) Received: from localhost ([2a03:2880:ff:5a::]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24c9669a0e1sm149008375ad.56.2025.09.08.11.52.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 11:52:20 -0700 (PDT) From: Joanne Koong To: brauner@kernel.org, miklos@szeredi.hu Cc: hch@infradead.org, djwong@kernel.org, hsiangkao@linux.alibaba.com, linux-block@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, kernel-team@meta.com, linux-xfs@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v2 03/16] iomap: rename cur_folio_in_bio to folio_owned Date: Mon, 8 Sep 2025 11:51:09 -0700 Message-ID: <20250908185122.3199171-4-joannelkoong@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250908185122.3199171-1-joannelkoong@gmail.com> References: <20250908185122.3199171-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: gfs2@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The purpose of struct iomap_readpage_ctx's cur_folio_in_bio is to track whether the folio is owned by the bio (where thus the bio is responsible for unlocking the folio) or if it needs to be unlocked by iomap. Rename this to folio_owned to make the purpose more clear and so that when iomap read/readahead logic is made generic, the name also makes sense for filesystems that don't use bios. Signed-off-by: Joanne Koong --- fs/iomap/buffered-io.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index a3b02ed5328f..598998269107 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -352,7 +352,12 @@ static void iomap_read_end_io(struct bio *bio) struct iomap_readpage_ctx { struct folio *cur_folio; - bool cur_folio_in_bio; + /* + * Is the folio owned by this readpage context, or by some + * external IO helper? Either way, the owner of the folio is + * responsible for unlocking it when the read completes. + */ + bool folio_owned; struct bio *bio; struct readahead_control *rac; }; @@ -381,7 +386,7 @@ static void iomap_read_folio_range_bio_async(const struct iomap_iter *iter, loff_t length = iomap_length(iter); sector_t sector; - ctx->cur_folio_in_bio = true; + ctx->folio_owned = true; if (ifs) { spin_lock_irq(&ifs->state_lock); ifs->read_bytes_pending += plen; @@ -493,7 +498,7 @@ int iomap_read_folio(struct folio *folio, const struct iomap_ops *ops) iomap_submit_read_bio(&ctx); - if (!ctx.cur_folio_in_bio) + if (!ctx.folio_owned) folio_unlock(folio); /* @@ -513,13 +518,13 @@ static int iomap_readahead_iter(struct iomap_iter *iter, while (iomap_length(iter)) { if (ctx->cur_folio && offset_in_folio(ctx->cur_folio, iter->pos) == 0) { - if (!ctx->cur_folio_in_bio) + if (!ctx->folio_owned) folio_unlock(ctx->cur_folio); ctx->cur_folio = NULL; } if (!ctx->cur_folio) { ctx->cur_folio = readahead_folio(ctx->rac); - ctx->cur_folio_in_bio = false; + ctx->folio_owned = false; } ret = iomap_readpage_iter(iter, ctx); if (ret) @@ -562,7 +567,7 @@ void iomap_readahead(struct readahead_control *rac, const struct iomap_ops *ops) iomap_submit_read_bio(&ctx); - if (ctx.cur_folio && !ctx.cur_folio_in_bio) + if (ctx.cur_folio && !ctx.folio_owned) folio_unlock(ctx.cur_folio); } EXPORT_SYMBOL_GPL(iomap_readahead); -- 2.47.3