]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
f2fs: fix to account IO correctly
authorChao Yu <yuchao0@huawei.com>
Mon, 22 Oct 2018 01:12:51 +0000 (09:12 +0800)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:57:01 +0000 (19:57 -0600)
BugLink: https://bugs.launchpad.net/bugs/1836802
commit 4c58ed076875f36dae0f240da1e25e99e5d4afb8 upstream.

Below race can cause reversed reference on dirty count, fix it by
relocating __submit_bio() and inc_page_count().

Thread A Thread B
- f2fs_inplace_write_data
 - f2fs_submit_page_bio
  - __submit_bio
- f2fs_write_end_io
 - dec_page_count
  - inc_page_count

Cc: <stable@vger.kernel.org>
Fixes: d1b3e72d5490 ("f2fs: submit bio of in-place-update pages")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
fs/f2fs/data.c

index f24d7b8858ed5375844f329e4a0dfa8b17e16b9d..1ca00f0bd261544bfd0e4372d984f99108870417 100644 (file)
@@ -381,10 +381,10 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio)
        }
        bio_set_op_attrs(bio, fio->op, fio->op_flags);
 
-       __submit_bio(fio->sbi, bio, fio->type);
-
        if (!is_read_io(fio->op))
                inc_page_count(fio->sbi, WB_DATA_TYPE(fio->page));
+
+       __submit_bio(fio->sbi, bio, fio->type);
        return 0;
 }