xfs
[Top] [All Lists]

Re: [PATCH] ext4: fix race aio-dio vs freeze_fs

To: Jan Kara <jack@xxxxxxx>
Subject: Re: [PATCH] ext4: fix race aio-dio vs freeze_fs
From: Dmitry Monakhov <dmonakhovopenvz@xxxxxxxxx>
Date: Tue, 24 Nov 2015 20:55:40 +0400
Cc: Dmitriy Monakhov <dmonakhov@xxxxxxxxxx>, linux-fsdevel@xxxxxxxxxxxxxxx, xfs@xxxxxxxxxxx, tytso@xxxxxxx, linux-ext4@xxxxxxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=g67K2LHJK3qb0G83d7Rg7+Uar7MdJyXyYfxZmNacStk=; b=GsRaxmd6MngVxpzFL9i3qpCFcVkwe8ei3BezUh5dh5Ms1SfD4gnjqfUn4C+JN8Dzqj UGGyNJx+LNJvxI37Fh/3hP59p1GDI4d09UcjNZzmeGT3vvIyCXADEuQjI0BEHIhZywk8 CvXb7i5L2eK6j51Cy/O/b0b5SwAy62BEGdgMYVDEmCdJXKV/4x0o/2hnf2C5FhUB3Smj EsSoUhrbhc3GWxBJcdq9mZj8itaVKKrcEF7lEjMC//JIWNJjZ90A/7vMqw6i3TcxXzBw xDriyMEIhPkPyfkuyERGHs69mjx7gvK2UYoMCyLD+dnkGjJ5r+Gq7vO/VHnCe4ltKeJa vCmA==
In-reply-to: <20151124132421.GG25232@xxxxxxxxxxxxx>
References: <1448294568-20892-1-git-send-email-dmonakhov@xxxxxxxxxx> <20151124132421.GG25232@xxxxxxxxxxxxx>


On Nov 24, 2015 16:25, "Jan Kara" <jack@xxxxxxx> wrote:
>
> On Mon 23-11-15 20:02:48, Dmitry Monakhov wrote:
> > After freeze_fs was revoked (from Jan Kara) pages's write-back completion
> > is deffered before unwritten conversion, so explicit flush_unwritten_io()
> > was removed here: c724585b62411
> > But we still may face deferred conversion for aio-dio case
> > # Trivial testcase
> > for ((i=0;i<60;i++));do fsfreeze -f /mnt ;sleep 1;fsfreeze -u /mnt;done &
> > fio --bs=4k --ioengine=libaio --iodepth=128 --size=1g --direct=1 \
> >Â Â Â--runtime=60 --filename=/mnt/file --name=rand-write --rw=randwrite
> > NOTE: Sane testcase should be integrated to xfstests, but it requires
> > changes in common/* code, so let's use this this test at the moment.
> >
> > In order to fix this race we have to guard journal transaction with explicit
> > sb_{start,end}_intwrite()Â as we do with ext4_evict_inode here:8e8ad8a5
>
> Well, this problem seems to suggest that we have the freeze protection for
> AIO writes wrong. We should call file_end_write() from aio_complete() and
> not from aio_run_iocb()...
Yep. It was my first attempt to fix that issue, but unfortunately this trick will break lockdep. Caller will do file_start_write and exit to userspace. Lockdep treats such behaviour as bug (return to userspace with a lock held)

There are two way to fix that
1) add specific 'long' lock primitive to lockdep
2) let sync_filesystems to wait pended aio-dio

> I believe XFS and other filesystems may have
> problems with this as well (CCed). Attached patch (so far only compile
> tested since my test machine is pondering on something else) should fix
> this.
>
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Honza
>
> --
> Jan Kara <jack@xxxxxxxx>
> SUSE Labs, CR

<Prev in Thread] Current Thread [Next in Thread>