From nobody Tue Apr 7 17:12:23 2026 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (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 C66551CD1E4 for ; Sun, 1 Mar 2026 00:41:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772325679; cv=none; b=bwuoQ27FceUm5LKEsq3Srg/birzZwAJJwBPqLKOMxn+b6h8p9W9jLwKulvxUln9oBqZrO8Ld17T1o4SLsdFrH18HnQODMud2trUbClV6tbZo/2usij2z6UA7zg68vmwETHZgYnSL3Xbztj8jvHts35NjouG50ku/44E9sdhVLNY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772325679; c=relaxed/simple; bh=Vv7Erq2ZiEMpKTxq/A99SyVYZ9w1AJ9522b6JIzBTYk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=RqpCbjLs9w9L2P/ld2iSVXykVhWwEjHnyQfWwOnuxwyMIurnzxvUalQSrmELWhJXe8Y37SftZvN6KZwipFj0hgbZ1P+PVIu1Y4Rvm8tyqkLBILEUyRph/diKtb1SZ1OoAziYEaKn1k8b+Kx4sZeHezXOb7Fq19xJI8pqW+cV6PY= 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=jx9yJKaw; arc=none smtp.client-ip=209.85.216.45 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="jx9yJKaw" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-3597c40a838so240278a91.1 for ; Sat, 28 Feb 2026 16:41:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772325677; x=1772930477; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hhGTDgaaohLTr2ABCzAU6hrkLau/xiHtalhCAkjhyT8=; b=jx9yJKawPrxcAxUo1c2o2bCxcuR0F98+BgztEWWhnhKB1FmpfddrOYkMoHgB7+bFfz KAcba+bxeiqZ48XgCGlA9z20FBZ+46zcGvQ0zvpf5QjK2LF40e4OBdf452srBt8tgevS 1X1rVQfDpm450b3FVzxCz/Q5PvJAlKBPTV7YYuTqcKB+ywZJTxVh87KwhxLCXyolE719 cQm+zhS+LosogD9SMcXyiihJik6wp032qhf8HeiKdEYoTUGYkoBH8bVz0m5fo5lnqVTm MLTkLBX6u3ZfZgaybaoVxmq7s7zL1FJkU5hLDoClEjMxG+0Z7Ln7VpycIEu72E0fZdYQ EAvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772325677; x=1772930477; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hhGTDgaaohLTr2ABCzAU6hrkLau/xiHtalhCAkjhyT8=; b=VlcqtyZ4UHg+PuvyGJMk7KYMdWaAN4NpAUODoodrGKwd3+1QzYyodahPpOj3ILRu4a J6foU06tU4ljmVKrZ+7dONRXN+f8opaq+mCFPtJ98og0kTcsT3K/YPeNQEgt9Slj8c+V +6TC31slLXeCpcSy+ZKhsCBerMO4ceHIsBW2zjZ8suT0KsFloJvTyf39bV4i4n1SYBZm pxqifQFgKptn7/bMivz4u1oqtvB5/PyReRbGF8mtNwNpgwnx84OIWgGIHQYlGm4czCgS J1cIp8qwePoU40w+bkoS0egJvOZPpbs/X2bWQ9XH5+VnUhFQqwdFa136oAWWkiKe0Yno 78lQ== X-Forwarded-Encrypted: i=1; AJvYcCX1UJhdjCAAETixhXC+/zFVUtFCmDeJvzT/uOX8eu5gGpaSjQbMSryfZVkR+2lAguR4/vryDofWTMqI6PI=@vger.kernel.org X-Gm-Message-State: AOJu0Yy/3Ygx5GDTOXrknDYDiPqj53U96Dj3g+vG86MQe0HeniTMWjQQ TpT7cSlODBIfGKK0W9Z8z9IbdRlIqhtjjJtby2S5hebfxIn4JpONVMpa X-Gm-Gg: ATEYQzxZ0kcscEFGYkrh0rzVR5lp707GGqsMTOTS2Ag3gDrCT5/qWgxYBR/VzMtapR0 cCnHeAp8iCLkFozxsSCwfNrSZj1bei9ZGZi/R8QEZTtmrEf03NLvCXdoclETkNHJK9qlYBf2CAD 1SdgIl9J6XUUB+GI9KmUkFLASSol4IFqu7ojtuCkXq7YiEyFdt6moMaDZT++6BL+p7GinHvAwKm PE1TWOaZGAUB+sLvRMi13rzQVMRC0K+iMEYJfJFWbhsARgta/5P8BFvkPlB73gG3BT5D87LwCzv NqW8VC19YDV7MDzroQTmUa8hLmM31hSwnWh5LFke8sdUPJPc94k8doR2Q8KHc6dRrukFULZ3ZGa FtQnimmMHqeBufc/7Yno55k2HmHX0LbxuIRyd3JeWSN1QGFk5pebNu+pWH9V24wwQqHpn7N1z1I CM0H/t1EgUIcIyvnNb3LgGrMH9ufT87qgWPu/iBzDrjL6nMgPVTpVSrza9EGaVNbYy/09utArJN apN5COaDlGwXkuTxZUcYA== X-Received: by 2002:a17:90b:4fc6:b0:354:c3a4:397 with SMTP id 98e67ed59e1d1-35965d02b63mr5957635a91.32.1772325677052; Sat, 28 Feb 2026 16:41:17 -0800 (PST) Received: from zenbook (122-150-206-24.dyn.ip.vocus.au. [122.150.206.24]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35982814773sm1402491a91.0.2026.02.28.16.41.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Feb 2026 16:41:16 -0800 (PST) From: Wilfred Mallawa To: Carlos Maiolino Cc: linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig , "Darrick J . Wong" , Wilfred Mallawa Subject: [PATCH v2] xfs: add write pointer to xfs_rtgroup_geometry Date: Sun, 1 Mar 2026 10:34:35 +1000 Message-ID: <20260301003432.605428-4-wilfred.opensource@gmail.com> X-Mailer: git-send-email 2.53.0 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" From: Wilfred Mallawa There is currently no XFS ioctl that allows userspace to retrieve the write pointer for a specific realtime group block for zoned XFS. On zoned block devices, userspace can obtain this information via zone reports from the underlying device. However, for zoned XFS operating on regular block devices, no equivalent mechanism exists. Access to the realtime group write pointer is useful to userspace development and analysis tools such as Zonar [1]. So extend the existing struct xfs_rtgroup_geometry to add a new rg_writepointer field. This field is valid if XFS_RTGROUP_GEOM_WRITEPOINTER flag is set. The rg_writepointer field specifies the location of the current writepointer as a block offset into the respective rtgroup. [1] https://lwn.net/Articles/1059364/ Signed-off-by: Wilfred Mallawa Reviewed-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig --- V1 -> V2: - Use a __u32 to instead of __u64 to store the write pointer - This, also drop the previously added padding. - Directly retun the writepointer block instead of converting with XFS_FSB_TO_BB(), for consistentcy in struct xfs_rtgroup_geometry (i.e rg_length is in fs blocks). --- fs/xfs/libxfs/xfs_fs.h | 5 ++++- fs/xfs/xfs_ioctl.c | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index d165de607d17..185f09f327c0 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -995,7 +995,8 @@ struct xfs_rtgroup_geometry { __u32 rg_sick; /* o: sick things in ag */ __u32 rg_checked; /* o: checked metadata in ag */ __u32 rg_flags; /* i/o: flags for this ag */ - __u32 rg_reserved[27]; /* o: zero */ + __u32 rg_writepointer; /* o: write pointer block offset for zoned */ + __u32 rg_reserved[26]; /* o: zero */ }; #define XFS_RTGROUP_GEOM_SICK_SUPER (1U << 0) /* superblock */ #define XFS_RTGROUP_GEOM_SICK_BITMAP (1U << 1) /* rtbitmap */ @@ -1003,6 +1004,8 @@ struct xfs_rtgroup_geometry { #define XFS_RTGROUP_GEOM_SICK_RMAPBT (1U << 3) /* reverse mappings */ #define XFS_RTGROUP_GEOM_SICK_REFCNTBT (1U << 4) /* reference counts */ =20 +#define XFS_RTGROUP_GEOM_WRITEPOINTER (1U << 0) /* write pointer */ + /* Health monitor event domains */ =20 /* affects the whole fs */ diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index facffdc8dca8..46e234863644 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -37,12 +37,15 @@ #include "xfs_ioctl.h" #include "xfs_xattr.h" #include "xfs_rtbitmap.h" +#include "xfs_rtrmap_btree.h" #include "xfs_file.h" #include "xfs_exchrange.h" #include "xfs_handle.h" #include "xfs_rtgroup.h" #include "xfs_healthmon.h" #include "xfs_verify_media.h" +#include "xfs_zone_priv.h" +#include "xfs_zone_alloc.h" =20 #include #include @@ -413,6 +416,7 @@ xfs_ioc_rtgroup_geometry( { struct xfs_rtgroup *rtg; struct xfs_rtgroup_geometry rgeo; + xfs_rgblock_t highest_rgbno; int error; =20 if (copy_from_user(&rgeo, arg, sizeof(rgeo))) @@ -433,6 +437,21 @@ xfs_ioc_rtgroup_geometry( if (error) return error; =20 + if (xfs_has_zoned(mp)) { + xfs_rtgroup_lock(rtg, XFS_RTGLOCK_RMAP); + if (rtg->rtg_open_zone) { + rgeo.rg_writepointer =3D rtg->rtg_open_zone->oz_allocated; + } else { + highest_rgbno =3D xfs_rtrmap_highest_rgbno(rtg); + if (highest_rgbno =3D=3D NULLRGBLOCK) + rgeo.rg_writepointer =3D 0; + else + rgeo.rg_writepointer =3D highest_rgbno + 1; + } + xfs_rtgroup_unlock(rtg, XFS_RTGLOCK_RMAP); + rgeo.rg_flags |=3D XFS_RTGROUP_GEOM_WRITEPOINTER; + } + if (copy_to_user(arg, &rgeo, sizeof(rgeo))) return -EFAULT; return 0; --=20 2.53.0