]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
btrfs: nowait aio: Correct assignment of pos
authorGoldwyn Rodrigues <rgoldwyn@suse.com>
Wed, 5 Jul 2017 03:33:07 +0000 (22:33 -0500)
committerDavid Sterba <dsterba@suse.com>
Mon, 10 Jul 2017 13:29:44 +0000 (15:29 +0200)
commitff0fa73247e442518936baa43c3f037b17f10fa7
tree03cb6c5e75f63c117fbadec630830f5624b3ca2b
parentf95a0d6a95b12a79b7492da7ab687ae4cd741124
btrfs: nowait aio: Correct assignment of pos

Assigning pos for usage early messes up in append mode, where the pos is
re-assigned in generic_write_checks(). Assign pos later to get the
correct position to write from iocb->ki_pos.

Since check_can_nocow also uses the value of pos, we shift
generic_write_checks() before check_can_nocow(). Checks with IOCB_DIRECT
are present in generic_write_checks(), so checking for IOCB_NOWAIT is
enough.

Also, put locking sequence in the fast path.

This fixes a user visible bug, as reported:

"apparently breaks several shell related features on my system.
In zsh history stopped working, because no new entries are added
anymore.
I fist noticed the issue when I tried to build mplayer. It uses a shell
script to generate a help_mp.h file:
[...]

Here is a simple testcase:

 % echo "foo" >> test
 % echo "foo" >> test
 % cat test
 foo
 %
"

Fixes: edf064e7c6fe ("btrfs: nowait aio support")
CC: Jens Axboe <axboe@kernel.dk>
Reported-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Link: https://lkml.kernel.org/r/20170704042306.GA274@x4
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/file.c