Message ID | 20250409075557.3535745-41-hch@lst.de (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [01/45] xfs: generalize the freespace and reserved blocks handling | expand |
On Wed, Apr 09, 2025 at 09:55:43AM +0200, Christoph Hellwig wrote: > Deal with the synthetic fmr_device values and the rt device offset when > calculating RG numbers. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Looks ok, Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> --D > --- > io/fsmap.c | 33 ++++++++++++++++++++++++++------- > 1 file changed, 26 insertions(+), 7 deletions(-) > > diff --git a/io/fsmap.c b/io/fsmap.c > index 3cc1b510316c..41f2da50f344 100644 > --- a/io/fsmap.c > +++ b/io/fsmap.c > @@ -247,8 +247,13 @@ dump_map_verbose( > (long long)BTOBBT(agoff), > (long long)BTOBBT(agoff + p->fmr_length - 1)); > } else if (p->fmr_device == xfs_rt_dev && fsgeo->rgcount > 0) { > - agno = p->fmr_physical / bperrtg; > - agoff = p->fmr_physical % bperrtg; > + uint64_t start = p->fmr_physical - > + fsgeo->rtstart * fsgeo->blocksize; > + > + agno = start / bperrtg; > + if (agno < 0) > + agno = -1; > + agoff = start % bperrtg; > snprintf(abuf, sizeof(abuf), > "(%lld..%lld)", > (long long)BTOBBT(agoff), > @@ -326,8 +331,13 @@ dump_map_verbose( > "%lld", > (long long)agno); > } else if (p->fmr_device == xfs_rt_dev && fsgeo->rgcount > 0) { > - agno = p->fmr_physical / bperrtg; > - agoff = p->fmr_physical % bperrtg; > + uint64_t start = p->fmr_physical - > + fsgeo->rtstart * fsgeo->blocksize; > + > + agno = start / bperrtg; > + if (agno < 0) > + agno = -1; > + agoff = start % bperrtg; > snprintf(abuf, sizeof(abuf), > "(%lld..%lld)", > (long long)BTOBBT(agoff), > @@ -478,9 +488,18 @@ fsmap_f( > return 0; > } > > - xfs_data_dev = file->fs_path.fs_datadev; > - xfs_log_dev = file->fs_path.fs_logdev; > - xfs_rt_dev = file->fs_path.fs_rtdev; > + /* > + * File systems with internal rt device use synthetic device values. > + */ > + if (file->geom.rtstart) { > + xfs_data_dev = XFS_DEV_DATA; > + xfs_log_dev = XFS_DEV_LOG; > + xfs_rt_dev = XFS_DEV_RT; > + } else { > + xfs_data_dev = file->fs_path.fs_datadev; > + xfs_log_dev = file->fs_path.fs_logdev; > + xfs_rt_dev = file->fs_path.fs_rtdev; > + } > > memset(head, 0, sizeof(*head)); > l = head->fmh_keys; > -- > 2.47.2 > >
diff --git a/io/fsmap.c b/io/fsmap.c index 3cc1b510316c..41f2da50f344 100644 --- a/io/fsmap.c +++ b/io/fsmap.c @@ -247,8 +247,13 @@ dump_map_verbose( (long long)BTOBBT(agoff), (long long)BTOBBT(agoff + p->fmr_length - 1)); } else if (p->fmr_device == xfs_rt_dev && fsgeo->rgcount > 0) { - agno = p->fmr_physical / bperrtg; - agoff = p->fmr_physical % bperrtg; + uint64_t start = p->fmr_physical - + fsgeo->rtstart * fsgeo->blocksize; + + agno = start / bperrtg; + if (agno < 0) + agno = -1; + agoff = start % bperrtg; snprintf(abuf, sizeof(abuf), "(%lld..%lld)", (long long)BTOBBT(agoff), @@ -326,8 +331,13 @@ dump_map_verbose( "%lld", (long long)agno); } else if (p->fmr_device == xfs_rt_dev && fsgeo->rgcount > 0) { - agno = p->fmr_physical / bperrtg; - agoff = p->fmr_physical % bperrtg; + uint64_t start = p->fmr_physical - + fsgeo->rtstart * fsgeo->blocksize; + + agno = start / bperrtg; + if (agno < 0) + agno = -1; + agoff = start % bperrtg; snprintf(abuf, sizeof(abuf), "(%lld..%lld)", (long long)BTOBBT(agoff), @@ -478,9 +488,18 @@ fsmap_f( return 0; } - xfs_data_dev = file->fs_path.fs_datadev; - xfs_log_dev = file->fs_path.fs_logdev; - xfs_rt_dev = file->fs_path.fs_rtdev; + /* + * File systems with internal rt device use synthetic device values. + */ + if (file->geom.rtstart) { + xfs_data_dev = XFS_DEV_DATA; + xfs_log_dev = XFS_DEV_LOG; + xfs_rt_dev = XFS_DEV_RT; + } else { + xfs_data_dev = file->fs_path.fs_datadev; + xfs_log_dev = file->fs_path.fs_logdev; + xfs_rt_dev = file->fs_path.fs_rtdev; + } memset(head, 0, sizeof(*head)); l = head->fmh_keys;
Deal with the synthetic fmr_device values and the rt device offset when calculating RG numbers. Signed-off-by: Christoph Hellwig <hch@lst.de> --- io/fsmap.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-)