]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
btrfs: use correct count in btrfs_file_write_iter()
authorOmar Sandoval <osandov@fb.com>
Thu, 15 Aug 2019 21:04:02 +0000 (14:04 -0700)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 14 Feb 2020 05:29:37 +0000 (00:29 -0500)
commit8a7f2e372e13e60eea5e40645666dd964c91dfb9
treefc7f0d654c2aecb8bb171ed9618fd7d533757f7c
parent2c3df5e8eae947318b2f4998591ac345d6fbb824
btrfs: use correct count in btrfs_file_write_iter()

BugLink: https://bugs.launchpad.net/bugs/1863019
[ Upstream commit c09767a8960ca0500fb636bf73686723337debf4 ]

generic_write_checks() may modify iov_iter_count(), so we must get the
count after the call, not before. Using the wrong one has a couple of
consequences:

1. We check a longer range in check_can_nocow() for nowait than we're
   actually writing.
2. We create extra hole extent maps in btrfs_cont_expand(). As far as I
   can tell, this is harmless, but I might be missing something.

These issues are pretty minor, but let's fix it before something more
important trips on it.

Fixes: edf064e7c6fe ("btrfs: nowait aio support")
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
fs/btrfs/file.c