From: Sasha Levin Date: Mon, 31 Aug 2020 20:08:11 +0000 (-0400) Subject: Fixes for 4.4 X-Git-Tag: v4.4.235~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4625f06f04c415c49cc3e545b1e57ae4e8b3d792;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 4.4 Signed-off-by: Sasha Levin --- diff --git a/queue-4.4/btrfs-check-the-right-error-variable-in-btrfs_del_di.patch b/queue-4.4/btrfs-check-the-right-error-variable-in-btrfs_del_di.patch new file mode 100644 index 00000000000..73a95cdb516 --- /dev/null +++ b/queue-4.4/btrfs-check-the-right-error-variable-in-btrfs_del_di.patch @@ -0,0 +1,59 @@ +From 473547ffd9d6eeaa24d7dfc8132a85a30a12a4b0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 10 Aug 2020 17:31:16 -0400 +Subject: btrfs: check the right error variable in btrfs_del_dir_entries_in_log + +From: Josef Bacik + +[ Upstream commit fb2fecbad50964b9f27a3b182e74e437b40753ef ] + +With my new locking code dbench is so much faster that I tripped over a +transaction abort from ENOSPC. This turned out to be because +btrfs_del_dir_entries_in_log was checking for ret == -ENOSPC, but this +function sets err on error, and returns err. So instead of properly +marking the inode as needing a full commit, we were returning -ENOSPC +and aborting in __btrfs_unlink_inode. Fix this by checking the proper +variable so that we return the correct thing in the case of ENOSPC. + +The ENOENT needs to be checked, because btrfs_lookup_dir_item_index() +can return -ENOENT if the dir item isn't in the tree log (which would +happen if we hadn't fsync'ed this guy). We actually handle that case in +__btrfs_unlink_inode, so it's an expected error to get back. + +Fixes: 4a500fd178c8 ("Btrfs: Metadata ENOSPC handling for tree log") +CC: stable@vger.kernel.org # 4.4+ +Reviewed-by: Filipe Manana +Signed-off-by: Josef Bacik +Reviewed-by: David Sterba +[ add note and comment about ENOENT ] +Signed-off-by: David Sterba +Signed-off-by: Sasha Levin +--- + fs/btrfs/tree-log.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c +index 820d3b5bc4150..8f0f91de436d5 100644 +--- a/fs/btrfs/tree-log.c ++++ b/fs/btrfs/tree-log.c +@@ -3169,11 +3169,13 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans, + btrfs_free_path(path); + out_unlock: + mutex_unlock(&BTRFS_I(dir)->log_mutex); +- if (ret == -ENOSPC) { ++ if (err == -ENOSPC) { + btrfs_set_log_full_commit(root->fs_info, trans); +- ret = 0; +- } else if (ret < 0) +- btrfs_abort_transaction(trans, root, ret); ++ err = 0; ++ } else if (err < 0 && err != -ENOENT) { ++ /* ENOENT can be returned if the entry hasn't been fsynced yet */ ++ btrfs_abort_transaction(trans, root, err); ++ } + + btrfs_end_log_trans(root); + +-- +2.25.1 + diff --git a/queue-4.4/series b/queue-4.4/series index c43c376a269..b4b61cd4b17 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -57,3 +57,4 @@ usb-quirks-add-no-lpm-quirk-for-another-raydium-touchscreen.patch usb-ignore-uas-for-jmicron-jms567-ata-atapi-bridge.patch usb-host-ohci-exynos-fix-error-handling-in-exynos_ohci_probe.patch usb-storage-add-unusual_uas-entry-for-sony-psz-drives.patch +btrfs-check-the-right-error-variable-in-btrfs_del_di.patch