linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: [PATCH 4/6] btrfs: move the !zoned assert into run_delalloc_cow
Date: Mon, 24 Jul 2023 07:22:41 -0700	[thread overview]
Message-ID: <20230724142243.5742-5-hch@lst.de> (raw)
In-Reply-To: <20230724142243.5742-1-hch@lst.de>

Having the assert in the actual helper documents the pre-conditions
much better than having it in the caller, so move it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/btrfs/inode.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 2d465b50c228ed..92182e0d27fdb5 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1978,6 +1978,13 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
 	u64 ino = btrfs_ino(inode);
 	struct can_nocow_file_extent_args nocow_args = { 0 };
 
+	/*
+	 * Normally on a zoned device we're only doing COW writes, but in case
+	 * of relocation on a zoned filesystem serializes I/O so that we're only
+	 * writing sequentially and can end up here as well.
+	 */
+	ASSERT(!btrfs_is_zoned(fs_info) || btrfs_is_data_reloc_root(root));
+
 	path = btrfs_alloc_path();
 	if (!path)
 		goto error;
@@ -2257,14 +2264,6 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page
 		 start >= page_offset(locked_page) + PAGE_SIZE));
 
 	if (should_nocow(inode, start, end)) {
-		/*
-		 * Normally on a zoned device we're only doing COW writes, but
-		 * in case of relocation on a zoned filesystem we have taken
-		 * precaution, that we're only writing sequentially. It's safe
-		 * to use run_delalloc_nocow() here, like for  regular
-		 * preallocated inodes.
-		 */
-		ASSERT(!zoned || btrfs_is_data_reloc_root(inode->root));
 		ret = run_delalloc_nocow(inode, locked_page, start, end);
 		goto out;
 	}
-- 
2.39.2


  parent reply	other threads:[~2023-07-24 14:22 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-24 14:22 btrfs NOCOW fix and cleanups Christoph Hellwig
2023-07-24 14:22 ` [PATCH 1/6] btrfs: fix error handling when in a COW window in run_delalloc_nocow Christoph Hellwig
2023-07-24 14:22 ` [PATCH 2/6] btrfs: cleanup the COW fallback logic " Christoph Hellwig
2023-07-24 14:22 ` [PATCH 3/6] btrfs: consolidate the error handling " Christoph Hellwig
2023-07-24 18:27   ` Boris Burkov
2023-07-24 19:48     ` Christoph Hellwig
2023-07-25 21:36       ` David Sterba
2023-07-24 14:22 ` Christoph Hellwig [this message]
2023-07-24 14:22 ` [PATCH 5/6] btrfs: use nocow_end for the loop iteration in run_delalloc_cow Christoph Hellwig
2023-08-10 17:00   ` David Sterba
2023-07-24 14:22 ` [PATCH 6/6] btrfs: clone relocation checksums in btrfs_alloc_ordered_extent Christoph Hellwig
2023-08-10 17:07   ` David Sterba
2023-07-24 18:30 ` btrfs NOCOW fix and cleanups Boris Burkov
2023-07-24 19:49   ` Christoph Hellwig
2023-07-24 19:58     ` Christoph Hellwig
2023-07-25 21:42       ` David Sterba
2023-07-26 12:56         ` Christoph Hellwig
2023-07-27 11:50           ` David Sterba
2023-08-10 16:56 ` 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=20230724142243.5742-5-hch@lst.de \
    --to=hch@lst.de \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --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).