static void
check_rtfile_contents(
struct xfs_mount *mp,
- const char *filename,
- xfs_ino_t ino,
- void *buf,
- xfs_fileoff_t filelen,
- const struct xfs_buf_ops *buf_ops)
+ bool is_bitmap)
{
- struct xfs_bmbt_irec map;
- struct xfs_buf *bp;
+ const struct xfs_buf_ops *buf_ops = NULL;
+ const char *filename;
+ xfs_ino_t ino;
+ void *buf;
+ xfs_fileoff_t filelen;
struct xfs_inode *ip;
xfs_fileoff_t bno = 0;
int error;
+ if (is_bitmap) {
+ if (xfs_has_rtgroups(mp))
+ buf_ops = &xfs_rtbitmap_buf_ops;
+ filename = "rtbitmap";
+ ino = mp->m_sb.sb_rbmino;
+ buf = btmcompute;
+ filelen = mp->m_sb.sb_rbmblocks;
+ } else {
+ if (xfs_has_rtgroups(mp))
+ buf_ops = &xfs_rtsummary_buf_ops;
+ filename = "rtsummary";
+ ino = mp->m_sb.sb_rsumino;
+ buf = sumcompute;
+ filelen = XFS_B_TO_FSB(mp, mp->m_rsumsize);
+ }
+
error = -libxfs_iget(mp, NULL, ino, 0, &ip);
if (error) {
do_warn(_("unable to open %s file, err %d\n"), filename, error);
}
while (bno < filelen) {
- xfs_daddr_t daddr;
- int nmap = 1;
+ unsigned int offset = 0;
+ int nmap = 1;
+ struct xfs_bmbt_irec map;
+ struct xfs_buf *bp;
error = -libxfs_bmapi_read(ip, bno, 1, &map, &nmap, 0);
if (error) {
break;
}
- daddr = XFS_FSB_TO_DADDR(mp, map.br_startblock);
- error = -libxfs_buf_read_uncached(mp->m_dev, daddr,
+ error = -libxfs_buf_read_uncached(mp->m_dev,
+ XFS_FSB_TO_DADDR(mp, map.br_startblock),
XFS_FSB_TO_BB(mp, map.br_blockcount),
0, &bp, buf_ops);
if (error) {
break;
}
- if (buf_ops == &xfs_rtbitmap_buf_ops) {
- struct xfs_rtalloc_args args = {
- .mp = mp,
- };
+ if (xfs_has_rtgroups(mp)) {
struct xfs_rtbuf_blkinfo *hdr = bp->b_addr;
- union xfs_rtword_raw *incore = buf;
- union xfs_rtword_raw *ondisk;
if (hdr->rt_owner != cpu_to_be64(ino)) {
do_warn(
filename, (unsigned long long)bno);
}
- args.rbmbp = bp;
- ondisk = xfs_rbmblock_wordptr(&args, 0);
- check_rtwords(mp, filename, bno, ondisk, incore);
- buf += mp->m_blockwsize << XFS_WORDLOG;
- } else if (buf_ops == &xfs_rtsummary_buf_ops) {
- struct xfs_rtalloc_args args = {
- .mp = mp,
- };
- struct xfs_rtbuf_blkinfo *hdr = bp->b_addr;
- union xfs_suminfo_raw *incore = buf;
- union xfs_suminfo_raw *ondisk;
-
- if (hdr->rt_owner != cpu_to_be64(ino)) {
- do_warn(
- _("corrupt owner in %s at dblock 0x%llx\n"),
- filename, (unsigned long long)bno);
- }
-
- args.sumbp = bp;
- ondisk = xfs_rsumblock_infoptr(&args, 0);
- check_rtwords(mp, filename, bno, ondisk, incore);
- buf += mp->m_blockwsize << XFS_WORDLOG;
- } else {
- check_rtwords(mp, filename, bno, bp->b_addr, buf);
- buf += XFS_FSB_TO_B(mp, map.br_blockcount);
+ offset = sizeof(*hdr);
}
- bno += map.br_blockcount;
+ check_rtwords(mp, filename, bno, bp->b_addr + offset, buf);
+
+ buf += mp->m_blockwsize << XFS_WORDLOG;
+ bno++;
libxfs_buf_relse(bp);
}
check_rtbitmap(
struct xfs_mount *mp)
{
- const struct xfs_buf_ops *buf_ops = NULL;
-
if (need_rbmino)
return;
- if (xfs_has_rtgroups(mp))
- buf_ops = &xfs_rtbitmap_buf_ops;
-
- check_rtfile_contents(mp, "rtbitmap", mp->m_sb.sb_rbmino, btmcompute,
- mp->m_sb.sb_rbmblocks, buf_ops);
+ check_rtfile_contents(mp, true);
}
void
check_rtsummary(
struct xfs_mount *mp)
{
- const struct xfs_buf_ops *buf_ops = NULL;
-
if (need_rsumino)
return;
- if (xfs_has_rtgroups(mp))
- buf_ops = &xfs_rtsummary_buf_ops;
-
- check_rtfile_contents(mp, "rtsummary", mp->m_sb.sb_rsumino, sumcompute,
- XFS_B_TO_FSB(mp, mp->m_rsumsize), buf_ops);
+ check_rtfile_contents(mp, false);
}
void