linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: "zhengbin (A)" <zhengbin13@huawei.com>,
	"Darrick J. Wong" <darrick.wong@oracle.com>,
	Dave Chinner <david@fromorbit.com>,
	sandeen@redhat.com, linux-xfs@vger.kernel.org
Cc: renxudong1@huawei.com, "zhangyi (F)" <yi.zhang@huawei.com>
Subject: Re: Questions about XFS abnormal img mount test
Date: Sun, 9 Feb 2020 21:59:26 -0600	[thread overview]
Message-ID: <e33d0416-5b2d-3b8e-1a5f-41c271b1b5d6@sandeen.net> (raw)
In-Reply-To: <ea7db6e3-8a3a-a66d-710c-4854c4e5126c@huawei.com>

On 2/9/20 9:02 PM, zhengbin (A) wrote:
> ### question
> We recently used fuzz(hydra) to test 4.19 stable XFS and automatically generate tmp.img (XFS v5 format, but some metadata is wrong)

Since you are testing a stable series kernel, the first thing to do
would be to test an upstream kernel and see if the problem persists.
If it does not you can bisect to the solution.

If the problem persists in the current upstream kernel, please let us know
and we can look into it further.

> Test as follows:
> mount tmp.img tmpdir
> cp file tmpdir
> sync  --> stuck
> 
> ### cause analysis
> This is because tmp.img (only 1 AG) has some problems. Using xfs_repair detect information as follows:
> 
> agf_freeblks 0, counted 3224 in ag 0
> agf_longest 536874136, counted 3224 in ag 0 
> sb_fdblocks 613, counted 3228
> 
> The reason sync is blocked is :
> xfs_vm_writepages(xfs_address_space_operations--writepages)
>   write_cache_pages
>     xfs_do_writepage
>       xfs_writepage_map
> 	xfs_map_blocks
>           allocate_blocks:
> 	    error = xfs_iomap_write_allocate
> 			
> xfs_iomap_write_allocate
>   while (count_fsb != 0) {
>     nimaps = 0;
>       while (nimaps == 0) { --> endless loop
> 	nimaps = 1;
> 	error = 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 --> less space than needed
> 
> xfs_alloc_space_available
>   alloc_len = args->minlen + (args->alignment - 1) + args->minalignslop;
>     longest = xfs_alloc_longest_free_extent(pag, min_free, reservation);
>     if (longest < alloc_len)
>        return false;
> 
>     /* do we have enough free space remaining for the allocation? */
>     available = (int)(pag->pagf_freeblks + pag->pagf_flcount -
>                         reservation - min_free - args->minleft);
>     if (available < (int)max(args->total, alloc_len))
>       return false;
> 
> ### solve
> 1. Detect the above metadata corruption when mounting XFS?
>    agf_freeblks 0, counted 3224 in ag 0
>    agf_longest 536874136, counted 3224 in ag 0 
>    sb_fdblocks 613, counted 3228
> 
> 2. xfs_repair detection at system boot? If xfs_repair fails, refuse to mount XFS

no, we won't be running repair at every boot.

-Eric

  reply	other threads:[~2020-02-10  3:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-10  3:02 Questions about XFS abnormal img mount test zhengbin (A)
2020-02-10  3:59 ` Eric Sandeen [this message]
2020-02-11  1:15 ` Dave Chinner
2020-02-13  8:33   ` zhengbin (A)
2020-02-13 17:11     ` Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e33d0416-5b2d-3b8e-1a5f-41c271b1b5d6@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=renxudong1@huawei.com \
    --cc=sandeen@redhat.com \
    --cc=yi.zhang@huawei.com \
    --cc=zhengbin13@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).