linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Liu Bo <bo.li.liu@oracle.com>,
	Josef Bacik <jbacik@fb.com>, David Sterba <dsterba@suse.com>
Subject: [PATCH 4.4 21/33] Btrfs: fix unexpected -EEXIST when creating new inode
Date: Wed, 21 Feb 2018 13:45:04 +0100	[thread overview]
Message-ID: <20180221124410.701736732@linuxfoundation.org> (raw)
In-Reply-To: <20180221124409.564661689@linuxfoundation.org>

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Liu Bo <bo.li.liu@oracle.com>

commit 900c9981680067573671ecc5cbfa7c5770be3a40 upstream.

The highest objectid, which is assigned to new inode, is decided at
the time of initializing fs roots.  However, in cases where log replay
gets processed, the btree which fs root owns might be changed, so we
have to search it again for the highest objectid, otherwise creating
new inode would end up with -EEXIST.

cc: <stable@vger.kernel.org> v4.4-rc6+
Fixes: f32e48e92596 ("Btrfs: Initialize btrfs_root->highest_objectid when loading tree root and subvolume roots")
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/btrfs/tree-log.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -26,6 +26,7 @@
 #include "print-tree.h"
 #include "backref.h"
 #include "hash.h"
+#include "inode-map.h"
 
 /* magic values for the inode_only field in btrfs_log_inode:
  *
@@ -5523,6 +5524,23 @@ again:
 						      path);
 		}
 
+		if (!ret && wc.stage == LOG_WALK_REPLAY_ALL) {
+			struct btrfs_root *root = wc.replay_dest;
+
+			btrfs_release_path(path);
+
+			/*
+			 * We have just replayed everything, and the highest
+			 * objectid of fs roots probably has changed in case
+			 * some inode_item's got replayed.
+			 *
+			 * root->objectid_mutex is not acquired as log replay
+			 * could only happen during mount.
+			 */
+			ret = btrfs_find_highest_objectid(root,
+						  &root->highest_objectid);
+		}
+
 		key.offset = found_key.offset - 1;
 		wc.replay_dest->log_root = NULL;
 		free_extent_buffer(log->node);

  parent reply	other threads:[~2018-02-21 12:45 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-21 12:44 [PATCH 4.4 00/33] 4.4.117-stable review Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 01/33] IB/mlx4: Fix incorrectly releasing steerable UD QPs when have only ETH ports Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 02/33] PM / devfreq: Propagate error from devfreq_add_device() Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 03/33] s390: fix handling of -1 in set{,fs}[gu]id16 syscalls Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 04/33] ARM: dts: STi: Add gpio polarity for "hdmi,hpd-gpio" property Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 05/33] arm: spear600: Add missing interrupt-parent of rtc Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 06/33] arm: spear13xx: Fix dmas cells Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 07/33] arm: spear13xx: Fix spics gpio controllers warning Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 08/33] ALSA: seq: Fix regression by incorrect ioctl_mutex usages Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 09/33] KVM/x86: Reduce retpoline performance impact in slot_handle_level_range(), by always inlining iterator helper methods Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 10/33] x86/cpu: Change type of x86_cache_size variable to unsigned int Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 11/33] drm/radeon: adjust tested variable Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 12/33] rtc-opal: Fix handling of firmware error codes, prevent busy loops Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 13/33] ext4: save error to disk in __ext4_grp_locked_error() Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 14/33] ext4: correct documentation for grpid mount option Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 15/33] mm: hide a #warning for COMPILE_TEST Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 16/33] video: fbdev: atmel_lcdfb: fix display-timings lookup Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 17/33] console/dummy: leave .con_font_get set to NULL Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 18/33] rtlwifi: rtl8821ae: Fix connection lost problem correctly Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 19/33] Btrfs: fix deadlock in run_delalloc_nocow Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 20/33] Btrfs: fix crash due to not cleaning up tree log blocks dirty bits Greg Kroah-Hartman
2018-02-21 12:45 ` Greg Kroah-Hartman [this message]
2018-02-21 12:45 ` [PATCH 4.4 22/33] ALSA: hda - Fix headset mic detection problem for two Dell machines Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 23/33] ALSA: usb-audio: Fix UAC2 get_ctl request with a RANGE attribute Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 24/33] ALSA: hda/realtek: PCI quirk for Fujitsu U7x7 Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 25/33] ALSA: usb-audio: add implicit fb quirk for Behringer UFX1204 Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 26/33] ALSA: seq: Fix racy pool initializations Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 27/33] mvpp2: fix multicast address filter Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 28/33] dm: correctly handle chained bios in dec_pending() Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 29/33] x86: fix build warnign with 32-bit PAE Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 30/33] vfs: dont do RCU lookup of empty pathnames Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 31/33] ARM: pxa/tosa-bt: add MODULE_LICENSE tag Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 32/33] ARM: dts: s5pv210: add interrupt-parent for ohci Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 33/33] media: r820t: fix r820t_write_reg for KASAN Greg Kroah-Hartman
2018-02-21 14:46 ` [PATCH 4.4 00/33] 4.4.117-stable review Nathan Chancellor
2018-02-21 15:30   ` Greg Kroah-Hartman
2018-02-21 17:58 ` Naresh Kamboju
2018-02-21 18:57 ` kernelci.org bot
2018-02-21 20:12 ` Shuah Khan
2018-02-22 14:11 ` Guenter Roeck

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=20180221124410.701736732@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=bo.li.liu@oracle.com \
    --cc=dsterba@suse.com \
    --cc=jbacik@fb.com \
    --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).