From: David Sterba <dsterba@suse.cz>
To: Liu Bo <bo.li.liu@oracle.com>
Cc: linux-btrfs@vger.kernel.org, Filipe Manana <fdmanana@suse.com>
Subject: Re: [PATCH v2] Btrfs: fix list_add corruption and soft lockups in fsync
Date: Mon, 27 Nov 2017 17:41:17 +0100 [thread overview]
Message-ID: <20171127164117.GC3553@twin.jikos.cz> (raw)
In-Reply-To: <20171121213540.20656-1-bo.li.liu@oracle.com>
On Tue, Nov 21, 2017 at 02:35:40PM -0700, Liu Bo wrote:
> Xfstests btrfs/146 revealed this corruption,
>
> [ 58.138831] Buffer I/O error on dev dm-0, logical block 2621424, async page read
> [ 58.151233] BTRFS error (device sdf): bdev /dev/mapper/error-test errs: wr 1, rd 0, flush 0, corrupt 0, gen 0
> [ 58.152403] list_add corruption. prev->next should be next (ffff88005e6775d8), but was ffffc9000189be88. (prev=ffffc9000189be88).
> [ 58.153518] ------------[ cut here ]------------
> [ 58.153892] WARNING: CPU: 1 PID: 1287 at lib/list_debug.c:31 __list_add_valid+0x169/0x1f0
> ...
> [ 58.157379] RIP: 0010:__list_add_valid+0x169/0x1f0
> ...
> [ 58.161956] Call Trace:
> [ 58.162264] btrfs_log_inode_parent+0x5bd/0xfb0 [btrfs]
> [ 58.163583] btrfs_log_dentry_safe+0x60/0x80 [btrfs]
> [ 58.164003] btrfs_sync_file+0x4c2/0x6f0 [btrfs]
> [ 58.164393] vfs_fsync_range+0x5f/0xd0
> [ 58.164898] do_fsync+0x5a/0x90
> [ 58.165170] SyS_fsync+0x10/0x20
> [ 58.165395] entry_SYSCALL_64_fastpath+0x1f/0xbe
> ...
>
> It turns out that we could record btrfs_log_ctx:io_err in
> log_one_extents when IO fails, but make log_one_extents() return '0'
> instead of -EIO, so the IO error is not acknowledged by the callers,
> i.e. btrfs_log_inode_parent(), which would remove btrfs_log_ctx:list
> from list head 'root->log_ctxs'. Since btrfs_log_ctx is allocated
> from stack memory, it'd get freed with a object alive on the
> list. then a future list_add will throw the above warning.
>
> This returns the correct error in the above case.
>
> Jeff also reported this while testing against his fsync error
> patch set[1].
>
> [1]: https://www.spinics.net/lists/linux-btrfs/msg65308.html
> "btrfs list corruption and soft lockups while testing writeback error handling"
>
> Fixes: 8407f553268a4611f254 ("Btrfs: fix data corruption after fast fsync and writeback error")
> Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
prev parent reply other threads:[~2017-11-27 16:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-13 17:57 [PATCH] Btrfs: fix list_add corruption and soft lockups in fsync Liu Bo
2017-11-20 17:34 ` David Sterba
2017-11-20 17:37 ` Liu Bo
2017-11-21 14:00 ` David Sterba
2017-11-21 21:35 ` [PATCH v2] " Liu Bo
2017-11-27 16:41 ` David Sterba [this message]
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=20171127164117.GC3553@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=bo.li.liu@oracle.com \
--cc=fdmanana@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/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).