From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>, Sasha Levin <sashal@kernel.org>,
linux-btrfs@vger.kernel.org
Subject: [PATCH AUTOSEL 4.19 26/31] btrfs: fix error handling in __btrfs_update_delayed_inode
Date: Sun, 4 Jul 2021 19:10:38 -0400 [thread overview]
Message-ID: <20210704231043.1491209-26-sashal@kernel.org> (raw)
In-Reply-To: <20210704231043.1491209-1-sashal@kernel.org>
From: Josef Bacik <josef@toxicpanda.com>
[ Upstream commit bb385bedded3ccbd794559600de4a09448810f4a ]
If we get an error while looking up the inode item we'll simply bail
without cleaning up the delayed node. This results in this style of
warning happening on commit:
WARNING: CPU: 0 PID: 76403 at fs/btrfs/delayed-inode.c:1365 btrfs_assert_delayed_root_empty+0x5b/0x90
CPU: 0 PID: 76403 Comm: fsstress Tainted: G W 5.13.0-rc1+ #373
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-2.fc32 04/01/2014
RIP: 0010:btrfs_assert_delayed_root_empty+0x5b/0x90
RSP: 0018:ffffb8bb815a7e50 EFLAGS: 00010286
RAX: 0000000000000000 RBX: ffff95d6d07e1888 RCX: ffff95d6c0fa3000
RDX: 0000000000000002 RSI: 000000000029e91c RDI: ffff95d6c0fc8060
RBP: ffff95d6c0fc8060 R08: 00008d6d701a2c1d R09: 0000000000000000
R10: ffff95d6d1760ea0 R11: 0000000000000001 R12: ffff95d6c15a4d00
R13: ffff95d6c0fa3000 R14: 0000000000000000 R15: ffffb8bb815a7e90
FS: 00007f490e8dbb80(0000) GS:ffff95d73bc00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f6e75555cb0 CR3: 00000001101ce001 CR4: 0000000000370ef0
Call Trace:
btrfs_commit_transaction+0x43c/0xb00
? finish_wait+0x80/0x80
? vfs_fsync_range+0x90/0x90
iterate_supers+0x8c/0x100
ksys_sync+0x50/0x90
__do_sys_sync+0xa/0x10
do_syscall_64+0x3d/0x80
entry_SYSCALL_64_after_hwframe+0x44/0xae
Because the iref isn't dropped and this leaves an elevated node->count,
so any release just re-queues it onto the delayed inodes list. Fix this
by going to the out label to handle the proper cleanup of the delayed
node.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/delayed-inode.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index fea5ccfade5c..f3994ee1a6e6 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1030,12 +1030,10 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans,
nofs_flag = memalloc_nofs_save();
ret = btrfs_lookup_inode(trans, root, path, &key, mod);
memalloc_nofs_restore(nofs_flag);
- if (ret > 0) {
- btrfs_release_path(path);
- return -ENOENT;
- } else if (ret < 0) {
- return ret;
- }
+ if (ret > 0)
+ ret = -ENOENT;
+ if (ret < 0)
+ goto out;
leaf = path->nodes[0];
inode_item = btrfs_item_ptr(leaf, path->slots[0],
--
2.30.2
next prev parent reply other threads:[~2021-07-04 23:18 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-04 23:10 [PATCH AUTOSEL 4.19 01/31] spi: Make of_register_spi_device also set the fwnode Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 02/31] media: s5p: fix pm_runtime_get_sync() usage count Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 03/31] media: sh_vou: " Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 04/31] media: sti/bdisp: " Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 05/31] spi: spi-loopback-test: Fix 'tx_buf' might be 'rx_buf' Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 06/31] spi: spi-topcliff-pch: Fix potential double free in pch_spi_process_messages() Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 07/31] spi: omap-100k: Fix the length judgment problem Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 08/31] regulator: uniphier: Add missing MODULE_DEVICE_TABLE Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 09/31] crypto: nx - add " Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 10/31] media: cpia2: fix memory leak in cpia2_usb_probe Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 11/31] media: cobalt: fix race condition in setting HPD Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 12/31] media: pvrusb2: fix warning in pvr2_i2c_core_done Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 13/31] crypto: qat - check return code of qat_hal_rd_rel_reg() Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 14/31] crypto: qat - remove unused macro in FW loader Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 15/31] sched/fair: Fix ascii art by relpacing tabs Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 16/31] media: em28xx: Fix possible memory leak of em28xx struct Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 17/31] media: v4l2-core: Avoid the dangling pointer in v4l2_fh_release Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 18/31] media: bt8xx: Fix a missing check bug in bt878_probe Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 19/31] media: st-hva: Fix potential NULL pointer dereferences Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 20/31] media: dvd_usb: memory leak in cinergyt2_fe_attach Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 21/31] mmc: via-sdmmc: add a check against NULL pointer dereference Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 22/31] crypto: shash - avoid comparing pointers to exported functions under CFI Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 23/31] media: dvb_net: avoid speculation from net slot Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 24/31] media: siano: fix device register error path Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 25/31] media: imx-csi: Skip first few frames from a BT.656 source Sasha Levin
2021-07-04 23:10 ` Sasha Levin [this message]
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 27/31] btrfs: abort transaction if we fail to update the delayed inode Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 28/31] btrfs: make Private2 lifespan more consistent Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 29/31] btrfs: fix the filemap_range_has_page() call in btrfs_punch_hole_lock_range() Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 30/31] btrfs: disable build on platforms having page size 256K Sasha Levin
2021-07-04 23:10 ` [PATCH AUTOSEL 4.19 31/31] regulator: da9052: Ensure enough delay time for .set_voltage_time_sel Sasha Levin
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=20210704231043.1491209-26-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@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).