Message ID | 173352752587.126362.15499339908546372305.stgit@frogsfrogsfrogs (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
Series | [01/50] libxfs: remove XFS_ILOCK_RT* | expand |
> + } else if (p->fmr_device == xfs_rt_dev && fsgeo->rgcount > 0) { > + agno = p->fmr_physical / bperrtg; > + agoff = p->fmr_physical - (agno * bperrtg); This second calculation seems awfully complicated vs the simple: agoff = p->fmr_physical % bperrtg; Any reason for that except for copy and pasting the AG version? > + } else if (p->fmr_device == xfs_rt_dev && fsgeo->rgcount > 0) { > + agno = p->fmr_physical / bperrtg; > + agoff = p->fmr_physical - (agno * bperrtg); Also a little annoying that all this is duplicated, but that also seems to be based off the AG version. So while this could all look a little nicer, the changes themselves looks good: Reviewed-by: Christoph Hellwig <hch@lst.de>
On Mon, Dec 09, 2024 at 10:00:16PM -0800, Christoph Hellwig wrote: > > + } else if (p->fmr_device == xfs_rt_dev && fsgeo->rgcount > 0) { > > + agno = p->fmr_physical / bperrtg; > > + agoff = p->fmr_physical - (agno * bperrtg); > > This second calculation seems awfully complicated vs the simple: > > agoff = p->fmr_physical % bperrtg; > > Any reason for that except for copy and pasting the AG version? > > > + } else if (p->fmr_device == xfs_rt_dev && fsgeo->rgcount > 0) { > > + agno = p->fmr_physical / bperrtg; > > + agoff = p->fmr_physical - (agno * bperrtg); > > Also a little annoying that all this is duplicated, but that also seems > to be based off the AG version. No particular reason outside of copy pasta. > So while this could all look a little nicer, the changes themselves > looks good: > > Reviewed-by: Christoph Hellwig <hch@lst.de> Thanks! --D
diff --git a/io/fsmap.c b/io/fsmap.c index bf1196390cf35d..545f619f5e1dc1 100644 --- a/io/fsmap.c +++ b/io/fsmap.c @@ -14,6 +14,7 @@ static cmdinfo_t fsmap_cmd; static dev_t xfs_data_dev; +static dev_t xfs_rt_dev; static void fsmap_help(void) @@ -170,7 +171,7 @@ dump_map_verbose( unsigned long long i; struct fsmap *p; int agno; - off_t agoff, bperag; + off_t agoff, bperag, bperrtg; int foff_w, boff_w, aoff_w, tot_w, agno_w, own_w; int nr_w, dev_w; char rbuf[40], bbuf[40], abuf[40], obuf[40]; @@ -185,6 +186,7 @@ dump_map_verbose( tot_w = MINTOT_WIDTH; bperag = (off_t)fsgeo->agblocks * (off_t)fsgeo->blocksize; + bperrtg = bytes_per_rtgroup(fsgeo); sunit = (fsgeo->sunit * fsgeo->blocksize); swidth = (fsgeo->swidth * fsgeo->blocksize); @@ -243,6 +245,13 @@ dump_map_verbose( "(%lld..%lld)", (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 - (agno * bperrtg); + snprintf(abuf, sizeof(abuf), + "(%lld..%lld)", + (long long)BTOBBT(agoff), + (long long)BTOBBT(agoff + p->fmr_length - 1)); } else abuf[0] = 0; aoff_w = max(aoff_w, strlen(abuf)); @@ -315,6 +324,16 @@ dump_map_verbose( snprintf(gbuf, sizeof(gbuf), "%lld", (long long)agno); + } else if (p->fmr_device == xfs_rt_dev && fsgeo->rgcount > 0) { + agno = p->fmr_physical / bperrtg; + agoff = p->fmr_physical - (agno * bperrtg); + snprintf(abuf, sizeof(abuf), + "(%lld..%lld)", + (long long)BTOBBT(agoff), + (long long)BTOBBT(agoff + p->fmr_length - 1)); + snprintf(gbuf, sizeof(gbuf), + "%lld", + (long long)agno); } else { abuf[0] = 0; gbuf[0] = 0; @@ -501,6 +520,7 @@ fsmap_f( } fs = fs_table_lookup(file->name, FS_MOUNT_POINT); xfs_data_dev = fs ? fs->fs_datadev : 0; + xfs_rt_dev = fs ? fs->fs_rtdev : 0; head->fmh_count = map_size; do {