linux_dsm_epyc7002/fs/xfs/libxfs
Zheng Bin d0c7feaf87 xfs: add agf freeblocks verify in xfs_agf_verify
We recently used fuzz(hydra) to test XFS and automatically generate
tmp.img(XFS v5 format, but some metadata is wrong)

xfs_repair information(just one AG):
agf_freeblks 0, counted 3224 in ag 0
agf_longest 536874136, counted 3224 in ag 0
sb_fdblocks 613, counted 3228

Test as follows:
mount tmp.img tmpdir
cp file1M tmpdir
sync

In 4.19-stable, sync will stuck, the reason is:
xfs_mountfs
  xfs_check_summary_counts
    if ((!xfs_sb_version_haslazysbcount(&mp->m_sb) ||
       XFS_LAST_UNMOUNT_WAS_CLEAN(mp)) &&
       !xfs_fs_has_sickness(mp, XFS_SICK_FS_COUNTERS))
	return 0;  -->just return, incore sb_fdblocks still be 613
    xfs_initialize_perag_data

cp file1M tmpdir -->ok(write file to pagecache)
sync -->stuck(write pagecache to disk)
xfs_map_blocks
  xfs_iomap_write_allocate
    while (count_fsb != 0) {
      nimaps = 0;
      while (nimaps == 0) { --> endless loop
         nimaps = 1;
         xfs_bmapi_write(..., &nimaps) --> nimaps becomes 0 again
xfs_bmapi_write
  xfs_bmap_alloc
    xfs_bmap_btalloc
      xfs_alloc_vextent
        xfs_alloc_fix_freelist
          xfs_alloc_space_available -->fail(agf_freeblks is 0)

In linux-next, sync not stuck, cause commit c2b3164320 ("xfs:
use the latest extent at writeback delalloc conversion time") remove
the above while, dmesg is as follows:
[   55.250114] XFS (loop0): page discard on page ffffea0008bc7380, inode 0x1b0c, offset 0.

Users do not know why this page is discard, the better soultion is:
1. Like xfs_repair, make sure sb_fdblocks is equal to counted
(xfs_initialize_perag_data did this, who is not called at this mount)
2. Add agf verify, if fail, will tell users to repair

This patch use the second soultion.

Signed-off-by: Zheng Bin <zhengbin13@huawei.com>
Signed-off-by: Ren Xudong <renxudong1@huawei.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-02 20:55:50 -08:00
..
xfs_ag_resv.c xfs: fix missing header includes 2019-11-07 13:00:53 -08:00
xfs_ag_resv.h
xfs_ag.c xfs: make xfs_buf_get_uncached return an error code 2020-01-26 14:32:26 -08:00
xfs_ag.h
xfs_alloc_btree.c
xfs_alloc_btree.h
xfs_alloc.c xfs: add agf freeblocks verify in xfs_agf_verify 2020-03-02 20:55:50 -08:00
xfs_alloc.h
xfs_attr_leaf.c xfs: fix misuse of the XFS_ATTR_INCOMPLETE flag 2020-01-09 10:55:18 -08:00
xfs_attr_leaf.h xfs: streamline xfs_attr3_leaf_inactive 2020-01-16 08:07:23 -08:00
xfs_attr_remote.c xfs: make xfs_buf_read return an error code 2020-01-26 14:32:26 -08:00
xfs_attr_remote.h xfs: refactor remote attr value buffer invalidation 2020-01-16 08:07:23 -08:00
xfs_attr_sf.h
xfs_attr.c xfs: Remove all strlen in all xfs_attr_* functions for attr names. 2020-01-09 10:55:19 -08:00
xfs_attr.h xfs: Remove all strlen in all xfs_attr_* functions for attr names. 2020-01-09 10:55:19 -08:00
xfs_bit.c xfs: fix missing header includes 2019-11-07 13:00:53 -08:00
xfs_bit.h
xfs_bmap_btree.c
xfs_bmap_btree.h
xfs_bmap.c xfs: make xfs_*read_agf return EAGAIN to ALLOC_FLAG_TRYLOCK callers 2020-01-26 14:32:26 -08:00
xfs_bmap.h
xfs_btree.c xfs: remove the xfs_btree_get_buf[ls] functions 2020-01-26 14:32:26 -08:00
xfs_btree.h xfs: remove the xfs_btree_get_buf[ls] functions 2020-01-26 14:32:26 -08:00
xfs_cksum.h
xfs_da_btree.c xfs: make xfs_trans_get_buf_map return an error code 2020-01-26 14:32:26 -08:00
xfs_da_btree.h xfs: fix misuse of the XFS_ATTR_INCOMPLETE flag 2020-01-09 10:55:18 -08:00
xfs_da_format.h xfs: Add __packed to xfs_dir2_sf_entry_t definition 2020-01-15 08:45:51 -08:00
xfs_defer.c
xfs_defer.h
xfs_dir2_block.c xfs: remove the mappedbno argument to xfs_da_read_buf 2019-11-22 08:17:10 -08:00
xfs_dir2_data.c xfs: remove the mappedbno argument to xfs_da_get_buf 2019-11-22 08:17:10 -08:00
xfs_dir2_leaf.c xfs: remove the mappedbno argument to xfs_da_get_buf 2019-11-22 08:17:10 -08:00
xfs_dir2_node.c xfs: remove the mappedbno argument to xfs_da_get_buf 2019-11-22 08:17:10 -08:00
xfs_dir2_priv.h libxfs: resync with the userspace libxfs 2019-12-19 07:53:47 -08:00
xfs_dir2_sf.c libxfs: resync with the userspace libxfs 2019-12-19 07:53:47 -08:00
xfs_dir2.c libxfs: resync with the userspace libxfs 2019-12-19 07:53:47 -08:00
xfs_dir2.h xfs: Fix deadlock between AGI and AGF when target_ip exists in xfs_rename() 2019-11-13 11:13:45 -08:00
xfs_dquot_buf.c xfs: remove the xfs_disk_dquot_t and xfs_dquot_t 2019-11-13 11:13:45 -08:00
xfs_errortag.h
xfs_format.h xfs: introduce XFS_MAX_FILEOFF 2020-01-14 08:02:51 -08:00
xfs_fs.h New code for 5.5: 2019-12-02 14:46:22 -08:00
xfs_health.h
xfs_ialloc_btree.c
xfs_ialloc_btree.h
xfs_ialloc.c xfs: make xfs_trans_get_buf return an error code 2020-01-26 14:32:26 -08:00
xfs_ialloc.h xfs: don't commit sunit/swidth updates to disk if that would cause repair failures 2019-12-19 07:53:48 -08:00
xfs_iext_tree.c
xfs_inode_buf.c xfs: don't reset the "inode core" in xfs_iread 2019-11-13 11:13:45 -08:00
xfs_inode_buf.h xfs: merge the projid fields in struct xfs_icdinode 2019-11-13 11:13:45 -08:00
xfs_inode_fork.c xfs: Remove kmem_zone_free() wrapper 2019-11-18 08:40:44 -08:00
xfs_inode_fork.h xfs: refactor "does this fork map blocks" predicate 2019-11-10 10:22:51 -08:00
xfs_log_format.h xfs: make struct xfs_buf_log_format have a consistent size 2020-01-16 08:07:23 -08:00
xfs_log_recover.h xfs: remove unused typedef definitions 2019-11-13 18:22:40 -08:00
xfs_log_rlimit.c
xfs_quota_defs.h
xfs_refcount_btree.c
xfs_refcount_btree.h
xfs_refcount.c xfs: remove unnecessary null pointer checks from _read_agf callers 2020-01-26 14:32:27 -08:00
xfs_refcount.h
xfs_rmap_btree.c
xfs_rmap_btree.h
xfs_rmap.c xfs: convert open coded corruption check to use XFS_IS_CORRUPT 2019-11-13 11:08:01 -08:00
xfs_rmap.h
xfs_rtbitmap.c xfs: convert open coded corruption check to use XFS_IS_CORRUPT 2019-11-13 11:08:01 -08:00
xfs_sb.c xfs: make xfs_trans_get_buf return an error code 2020-01-26 14:32:26 -08:00
xfs_sb.h
xfs_shared.h
xfs_symlink_remote.c
xfs_trans_inode.c xfs: use a struct timespec64 for the in-core crtime 2019-11-13 11:13:45 -08:00
xfs_trans_resv.c xfs: Make the symbol 'xfs_rtalloc_log_count' static 2019-12-20 08:07:31 -08:00
xfs_trans_resv.h
xfs_trans_space.h
xfs_types.c
xfs_types.h xfs: remove unused structure members & simple typedefs 2019-11-13 18:22:41 -08:00