linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: fdmanana@kernel.org
To: linux-btrfs@vger.kernel.org
Cc: josef@toxicpanda.com
Subject: [PATCH v3 0/4] Btrfs: make ranged fsyncs always respect the given range
Date: Mon,  9 Mar 2020 12:41:04 +0000	[thread overview]
Message-ID: <20200309124108.18952-1-fdmanana@kernel.org> (raw)

From: Filipe Manana <fdmanana@suse.com>

This patchset fixes a bug when not using NO_HOLES and makes ranged fsyncs
respect the given file range when using the NO_HOLES feature.

The bug is about missing file extents items representing a hole after doing
a ranged fsync on a file and replaying the log.

Btrfs doesn't respect the given range for a fsync when the inode's has the
"need full sync" bit set - it treats the fsync as a full ranged one, operating
on the whole file, doing more IO and cpu work then needed.

That behaviour was needed to fix a corruption bug. Commit 0c713cbab6200b
("Btrfs: fix race between ranged fsync and writeback of adjacent ranges")
fixed that bug by turning the ranged fsync into a full ranged one.

Later the hole detection code of fsync was simplified a lot in order to
fix another bug when using the NO_HOLES feature - done by commit
0e56315ca147b3 ("Btrfs: fix missing hole after hole punching and fsync when
using NO_HOLES"). That commit now makes it easy to avoid turning the ranged
fsyncs into non-ranged fsyncs.

This patchset does those two changes. The first patch fixes the bug mentioned
before, patches 2 and 3 are preparation cleanups for patch 4, which is the
one that makes fsync respect the given file range when using NO_HOLES.

V3: Updated patch one so that the ranged is set to full before locking the
    inode. To make sure we do writeback and wait for ordered extent
    completion as much as possible before locking the inode.
    Remaining patches are unchanged.

V2: Added one more patch to the series, which is the first patch, that
    fixes the bug regarding missing holes after doing a ranged fsync.

    The remaining patches remain the same, only patch 4 had a trivial
    conflict when rebasing against patch 1 and got its changelog
    updated. Now all fstests pass with version 2 of this patchset.

Filipe Manana (4):
  Btrfs: fix missing file extent item for hole after ranged fsync
  Btrfs: add helper to get the end offset of a file extent item
  Btrfs: factor out inode items copy loop from btrfs_log_inode()
  Btrfs: make ranged full fsyncs more efficient

 fs/btrfs/ctree.h     |   1 +
 fs/btrfs/file-item.c |  40 ++++--
 fs/btrfs/file.c      |  23 ++--
 fs/btrfs/inode.c     |  10 +-
 fs/btrfs/send.c      |  44 +-----
 fs/btrfs/tree-log.c  | 379 +++++++++++++++++++++++++++++----------------------
 6 files changed, 261 insertions(+), 236 deletions(-)

-- 
2.11.0


             reply	other threads:[~2020-03-09 12:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-09 12:41 fdmanana [this message]
2020-03-09 12:41 ` [PATCH v3 1/4] Btrfs: fix missing file extent item for hole after ranged fsync fdmanana
2020-03-09 12:41 ` [PATCH v3 2/4] Btrfs: add helper to get the end offset of a file extent item fdmanana
2020-03-09 12:41 ` [PATCH v3 3/4] Btrfs: factor out inode items copy loop from btrfs_log_inode() fdmanana
2020-03-09 12:41 ` [PATCH v3 4/4] Btrfs: make ranged full fsyncs more efficient fdmanana
2020-03-11 17:44 ` [PATCH v3 0/4] Btrfs: make ranged fsyncs always respect the given range Josef Bacik
2020-03-12 20:33 ` David Sterba
2020-03-13 11:01   ` Filipe Manana
2020-03-13 13:17     ` David Sterba

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=20200309124108.18952-1-fdmanana@kernel.org \
    --to=fdmanana@kernel.org \
    --cc=josef@toxicpanda.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).