From d161c321ee0ed0def8af5526fda5540dfe8c9839 Mon Sep 17 00:00:00 2001 From: Tobias Powalowski Date: Wed, 8 Apr 2015 06:49:55 +0000 Subject: [PATCH] fix btrfs deadlock on mount --- 0001-fix-btrfs-mount-deadlock.patch | 43 +++++++++++++++++++++++++++++ PKGBUILD | 11 ++++++-- 2 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 0001-fix-btrfs-mount-deadlock.patch diff --git a/0001-fix-btrfs-mount-deadlock.patch b/0001-fix-btrfs-mount-deadlock.patch new file mode 100644 index 0000000..9430d58 --- /dev/null +++ b/0001-fix-btrfs-mount-deadlock.patch @@ -0,0 +1,43 @@ +From 9c4f61f01d269815bb7c37be3ede59c5587747c6 Mon Sep 17 00:00:00 2001 +From: David Sterba +Date: Fri, 2 Jan 2015 19:12:57 +0100 +Subject: btrfs: simplify insert_orphan_item + +We can search and add the orphan item in one go, +btrfs_insert_orphan_item will find out if the item already exists. + +Signed-off-by: David Sterba + +diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c +index 5be45c1..25a1c36 100644 +--- a/fs/btrfs/tree-log.c ++++ b/fs/btrfs/tree-log.c +@@ -1254,21 +1254,13 @@ out: + } + + static int insert_orphan_item(struct btrfs_trans_handle *trans, +- struct btrfs_root *root, u64 offset) ++ struct btrfs_root *root, u64 ino) + { + int ret; +- struct btrfs_path *path; +- +- path = btrfs_alloc_path(); +- if (!path) +- return -ENOMEM; + +- ret = btrfs_find_item(root, path, BTRFS_ORPHAN_OBJECTID, +- offset, BTRFS_ORPHAN_ITEM_KEY, NULL); +- if (ret > 0) +- ret = btrfs_insert_orphan_item(trans, root, offset); +- +- btrfs_free_path(path); ++ ret = btrfs_insert_orphan_item(trans, root, ino); ++ if (ret == -EEXIST) ++ ret = 0; + + return ret; + } +-- +cgit v0.10.2 + diff --git a/PKGBUILD b/PKGBUILD index 94b01da..04b3ad5 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -5,7 +5,7 @@ pkgbase=linux # Build stock -ARCH kernel #pkgbase=linux-custom # Build kernel with a different name _srcname=linux-3.19 pkgver=3.19.3 -pkgrel=1 +pkgrel=2 arch=('i686' 'x86_64') url="http://www.kernel.org/" license=('GPL2') @@ -20,7 +20,7 @@ source=("https://www.kernel.org/pub/linux/kernel/v3.x/${_srcname}.tar.xz" # standard config files for mkinitcpio ramdisk 'linux.preset' 'change-default-console-loglevel.patch' - ) + '0001-fix-btrfs-mount-deadlock.patch') sha256sums=('be42511fe5321012bb4a2009167ce56a9e5fe362b4af43e8c371b3666859806c' 'SKIP' 'cd9474b61b859d68f83ff0b769bafef8489d2090e0a933d2a7e5f76a23cc071a' @@ -28,7 +28,8 @@ sha256sums=('be42511fe5321012bb4a2009167ce56a9e5fe362b4af43e8c371b3666859806c' '704a479de77c9022e5c7a797d2cd7fd0e4ba1f52f9039ec8a80efd57f7e9f0d8' '59830f47c1be39f874640d762dca55f972aca549a7a65ba2f1dac184251dabb2' 'f0d90e756f14533ee67afda280500511a62465b4f76adcc5effa95a40045179c' - '1256b241cd477b265a3c2d64bdc19ffe3c9bbcee82ea3994c590c2c76e767d99') + '1256b241cd477b265a3c2d64bdc19ffe3c9bbcee82ea3994c590c2c76e767d99' + '5967cf53cb9db9f070e8f346c3d7045748e4823a7fe2ee330acd18c9d02bbb77') validpgpkeys=( 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman @@ -50,6 +51,10 @@ prepare() { # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227) patch -p1 -i "${srcdir}/change-default-console-loglevel.patch" + # fix #44495 and #44385 deadlock on btrfs mount + # https://btrfs.wiki.kernel.org/index.php/Gotchas + patch -Np1 -i "${srcdir}/0001-fix-btrfs-mount-deadlock.patch" + if [ "${CARCH}" = "x86_64" ]; then cat "${srcdir}/config.x86_64" > ./.config else