]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.19-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 3 Feb 2020 19:50:42 +0000 (19:50 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 3 Feb 2020 19:50:42 +0000 (19:50 +0000)
added patches:
btrfs-do-not-zero-f_bavail-if-we-have-available-space.patch

queue-4.19/btrfs-do-not-zero-f_bavail-if-we-have-available-space.patch [new file with mode: 0644]
queue-4.19/series

diff --git a/queue-4.19/btrfs-do-not-zero-f_bavail-if-we-have-available-space.patch b/queue-4.19/btrfs-do-not-zero-f_bavail-if-we-have-available-space.patch
new file mode 100644 (file)
index 0000000..bfab1a5
--- /dev/null
@@ -0,0 +1,61 @@
+From d55966c4279bfc6a0cf0b32bf13f5df228a1eeb6 Mon Sep 17 00:00:00 2001
+From: Josef Bacik <josef@toxicpanda.com>
+Date: Fri, 31 Jan 2020 09:31:05 -0500
+Subject: btrfs: do not zero f_bavail if we have available space
+
+From: Josef Bacik <josef@toxicpanda.com>
+
+commit d55966c4279bfc6a0cf0b32bf13f5df228a1eeb6 upstream.
+
+There was some logic added a while ago to clear out f_bavail in statfs()
+if we did not have enough free metadata space to satisfy our global
+reserve.  This was incorrect at the time, however didn't really pose a
+problem for normal file systems because we would often allocate chunks
+if we got this low on free metadata space, and thus wouldn't really hit
+this case unless we were actually full.
+
+Fast forward to today and now we are much better about not allocating
+metadata chunks all of the time.  Couple this with d792b0f19711 ("btrfs:
+always reserve our entire size for the global reserve") which now means
+we'll easily have a larger global reserve than our free space, we are
+now more likely to trip over this while still having plenty of space.
+
+Fix this by skipping this logic if the global rsv's space_info is not
+full.  space_info->full is 0 unless we've attempted to allocate a chunk
+for that space_info and that has failed.  If this happens then the space
+for the global reserve is definitely sacred and we need to report
+b_avail == 0, but before then we can just use our calculated b_avail.
+
+Reported-by: Martin Steigerwald <martin@lichtvoll.de>
+Fixes: ca8a51b3a979 ("btrfs: statfs: report zero available if metadata are exhausted")
+CC: stable@vger.kernel.org # 4.5+
+Reviewed-by: Qu Wenruo <wqu@suse.com>
+Tested-By: Martin Steigerwald <martin@lichtvoll.de>
+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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/btrfs/super.c |   10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+--- a/fs/btrfs/super.c
++++ b/fs/btrfs/super.c
+@@ -2167,7 +2167,15 @@ static int btrfs_statfs(struct dentry *d
+        */
+       thresh = SZ_4M;
+-      if (!mixed && total_free_meta - thresh < block_rsv->size)
++      /*
++       * We only want to claim there's no available space if we can no longer
++       * allocate chunks for our metadata profile and our global reserve will
++       * not fit in the free metadata space.  If we aren't ->full then we
++       * still can allocate chunks and thus are fine using the currently
++       * calculated f_bavail.
++       */
++      if (!mixed && block_rsv->space_info->full &&
++          total_free_meta - thresh < block_rsv->size)
+               buf->f_bavail = 0;
+       buf->f_type = BTRFS_SUPER_MAGIC;
index bf5bbcdeb7f79b153d946590439fcd485a721019..9537d44c515d405f2d2f3e99f2da6e84c684390f 100644 (file)
@@ -68,3 +68,4 @@ net-fsl-fman-rename-if_mode_xgmii-to-if_mode_10g.patch
 seq_tab_next-should-increase-position-index.patch
 l2t_seq_next-should-increase-position-index.patch
 net-fix-skb-csum-update-in-inet_proto_csum_replace16.patch
+btrfs-do-not-zero-f_bavail-if-we-have-available-space.patch