linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH] btrfs: skip file_extent generation check for free_space_inode in run_delalloc_nocow
Date: Thu, 29 Nov 2018 17:31:32 +0800	[thread overview]
Message-ID: <20181129093132.25147-1-lufq.fnst@cn.fujitsu.com> (raw)

The btrfs/001 with inode_cache mount option will encounter the following
warning:

WARNING: CPU: 1 PID: 23700 at fs/btrfs/inode.c:956 cow_file_range.isra.19+0x32b/0x430 [btrfs]
CPU: 1 PID: 23700 Comm: btrfs Kdump: loaded Tainted: G        W  O      4.20.0-rc4-custom+ #30
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015
RIP: 0010:cow_file_range.isra.19+0x32b/0x430 [btrfs]
Call Trace:
 ? free_extent_buffer+0x46/0x90 [btrfs]
 run_delalloc_nocow+0x455/0x900 [btrfs]
 btrfs_run_delalloc_range+0x1a7/0x360 [btrfs]
 writepage_delalloc+0xf9/0x150 [btrfs]
 __extent_writepage+0x125/0x3e0 [btrfs]
 extent_write_cache_pages+0x1b6/0x3e0 [btrfs]
 ? __wake_up_common_lock+0x63/0xc0
 extent_writepages+0x50/0x80 [btrfs]
 do_writepages+0x41/0xd0
 ? __filemap_fdatawrite_range+0x9e/0xf0
 __filemap_fdatawrite_range+0xbe/0xf0
 btrfs_fdatawrite_range+0x1b/0x50 [btrfs]
 __btrfs_write_out_cache+0x42c/0x480 [btrfs]
 btrfs_write_out_ino_cache+0x84/0xd0 [btrfs]
 btrfs_save_ino_cache+0x551/0x660 [btrfs]
 commit_fs_roots+0xc5/0x190 [btrfs]
 btrfs_commit_transaction+0x2bf/0x8d0 [btrfs]
 btrfs_mksubvol+0x48d/0x4d0 [btrfs]
 btrfs_ioctl_snap_create_transid+0x170/0x180 [btrfs]
 btrfs_ioctl_snap_create_v2+0x124/0x180 [btrfs]
 btrfs_ioctl+0x123f/0x3030 [btrfs]

The file extent generation of the free space inode is equal to the last
snapshot of the file root, so the inode will be passed to cow_file_rage.
But the inode was created and its extents were preallocated in
btrfs_save_ino_cache, there are no cow copies on disk.

The preallocated extents don't present on disk, and the
btrfs_cross_ref_exist will ignore the -ENOENT returned by
check_committed_ref, so we can directly write the inode to the disk.

Fixes: 78d4295b1eee ("btrfs: lift some btrfs_cross_ref_exist checks in nocow path")
Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
---
 fs/btrfs/inode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index d54bdef16d8d..9c5e9629eb6c 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1369,7 +1369,8 @@ static noinline int run_delalloc_nocow(struct inode *inode,
 			 * Do the same check as in btrfs_cross_ref_exist but
 			 * without the unnecessary search.
 			 */
-			if (btrfs_file_extent_generation(leaf, fi) <=
+			if (!nolock &&
+			    btrfs_file_extent_generation(leaf, fi) <=
 			    btrfs_root_last_snapshot(&root->root_item))
 				goto out_check;
 			if (extent_type == BTRFS_FILE_EXTENT_REG && !force)
-- 
2.19.2




             reply	other threads:[~2018-11-29  9:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-29  9:31 Lu Fengqi [this message]
2018-11-29 10:32 ` [PATCH] btrfs: skip file_extent generation check for free_space_inode in run_delalloc_nocow Filipe Manana
2018-12-04 14:23 ` 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=20181129093132.25147-1-lufq.fnst@cn.fujitsu.com \
    --to=lufq.fnst@cn.fujitsu.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).