Date: Monday, November 25, 2013 @ 12:34:42
  Author: tpowa
Revision: 200307

upgpkg: linux 3.12.1-2

fix btrfs balance bug

Added:
  linux/trunk/3.12-btrfs-relocate-csums.patch
Modified:
  linux/trunk/PKGBUILD

---------------------------------+
 3.12-btrfs-relocate-csums.patch |   63 ++++++++++++++++++++++++++++++++++++++
 PKGBUILD                        |   25 +++++++++------
 2 files changed, 79 insertions(+), 9 deletions(-)

Added: 3.12-btrfs-relocate-csums.patch
===================================================================
--- 3.12-btrfs-relocate-csums.patch                             (rev 0)
+++ 3.12-btrfs-relocate-csums.patch     2013-11-25 11:34:42 UTC (rev 200307)
@@ -0,0 +1,63 @@
+From 4577b014d1bc3db386da3246f625888fc48083a9 Mon Sep 17 00:00:00 2001
+From: Josef Bacik <[email protected]>
+Date: Fri, 27 Sep 2013 13:33:09 +0000
+Subject: Btrfs: relocate csums properly with prealloc extents
+
+A user reported a problem where they were getting csum errors when running a
+balance and running systemd's journal.  This is because systemd is awesome and
+fallocate()'s its log space and writes into it.  Unfortunately we assume that
+when we read in all the csums for an extent that they are sequential starting 
at
+the bytenr we care about.  This obviously isn't the case for prealloc extents,
+where we could have written to the middle of the prealloc extent only, which
+means the csum would be for the bytenr in the middle of our range and not the
+front of our range.  Fix this by offsetting the new bytenr we are logging to
+based on the original bytenr the csum was for.  With this patch I no longer see
+the csum errors I was seeing.  Thanks,
+
+Cc: [email protected]
+Reported-by: Chris Murphy <[email protected]>
+Signed-off-by: Josef Bacik <[email protected]>
+Signed-off-by: Chris Mason <[email protected]>
+---
+diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
+index dec4f5a..0359eec 100644
+--- a/fs/btrfs/relocation.c
++++ b/fs/btrfs/relocation.c
+@@ -4472,6 +4472,7 @@ int btrfs_reloc_clone_csums(struct inode *inode, u64 
file_pos, u64 len)
+       struct btrfs_root *root = BTRFS_I(inode)->root;
+       int ret;
+       u64 disk_bytenr;
++      u64 new_bytenr;
+       LIST_HEAD(list);
+ 
+       ordered = btrfs_lookup_ordered_extent(inode, file_pos);
+@@ -4483,13 +4484,24 @@ int btrfs_reloc_clone_csums(struct inode *inode, u64 
file_pos, u64 len)
+       if (ret)
+               goto out;
+ 
+-      disk_bytenr = ordered->start;
+       while (!list_empty(&list)) {
+               sums = list_entry(list.next, struct btrfs_ordered_sum, list);
+               list_del_init(&sums->list);
+ 
+-              sums->bytenr = disk_bytenr;
+-              disk_bytenr += sums->len;
++              /*
++               * We need to offset the new_bytenr based on where the csum is.
++               * We need to do this because we will read in entire prealloc
++               * extents but we may have written to say the middle of the
++               * prealloc extent, so we need to make sure the csum goes with
++               * the right disk offset.
++               *
++               * We can do this because the data reloc inode refers strictly
++               * to the on disk bytes, so we don't have to worry about
++               * disk_len vs real len like with real inodes since it's all
++               * disk length.
++               */
++              new_bytenr = ordered->start + (sums->bytenr - disk_bytenr);
++              sums->bytenr = new_bytenr;
+ 
+               btrfs_add_ordered_sum(inode, ordered, sums);
+       }
+--
+cgit v0.9.2

Modified: PKGBUILD
===================================================================
--- PKGBUILD    2013-11-25 08:16:32 UTC (rev 200306)
+++ PKGBUILD    2013-11-25 11:34:42 UTC (rev 200307)
@@ -6,7 +6,7 @@
 #pkgbase=linux-custom       # Build kernel with a different name
 _srcname=linux-3.12
 pkgver=3.12.1
-pkgrel=1
+pkgrel=2
 arch=('i686' 'x86_64')
 url="http://www.kernel.org/";
 license=('GPL2')
@@ -19,14 +19,8 @@
         # standard config files for mkinitcpio ramdisk
         'linux.preset'
         'change-default-console-loglevel.patch'
-        'criu-no-expert.patch')
-md5sums=('cc6ee608854e0da4b64f6c1ff8b6398c'
-         '5a8cb5a659baeeb6df3fe22de8d32df6'
-         '798bca5d2f0a1505c9b86a5227a2b339'
-         '8fa6cbb28dda5a4b38730c7f728e1845'
-         'eb14dcfd80c00852ef81ded6e826826a'
-         '98beb36f9b8cf16e58de2483ea9985e3'
-         'd50c1ac47394e9aec637002ef3392bd1')
+        'criu-no-expert.patch'
+        '3.12-btrfs-relocate-csums.patch')
 
 _kernelname=${pkgbase#linux}
 
@@ -54,6 +48,11 @@
   # patch from fedora
   patch -Np1 -i "${srcdir}/criu-no-expert.patch"
 
+  # fix btrfs balance bug
+  # https://bugzilla.kernel.org/show_bug.cgi?id=63411
+  # https://bugs.archlinux.org/task/37867
+  patch -Np1 -i "${srcdir}/3.12-btrfs-relocate-csums.patch"
+
   if [ "${CARCH}" = "x86_64" ]; then
     cat "${srcdir}/config.x86_64" > ./.config
   else
@@ -334,3 +333,11 @@
 done
 
 # vim:set ts=8 sts=2 sw=2 et:
+md5sums=('cc6ee608854e0da4b64f6c1ff8b6398c'
+         '5a8cb5a659baeeb6df3fe22de8d32df6'
+         '798bca5d2f0a1505c9b86a5227a2b339'
+         '8fa6cbb28dda5a4b38730c7f728e1845'
+         'eb14dcfd80c00852ef81ded6e826826a'
+         '98beb36f9b8cf16e58de2483ea9985e3'
+         'd50c1ac47394e9aec637002ef3392bd1'
+         '923c1728634d4e0f7b77177c36d94791')

Reply via email to