]> git.hungrycats.org Git - linux/commit
Btrfs: account merges/splits properly
authorJosef Bacik <jbacik@fb.com>
Fri, 13 Mar 2015 19:01:24 +0000 (15:01 -0400)
committerZygo Blaxell <zblaxell@waya.furryterror.org>
Fri, 27 Mar 2015 03:34:22 +0000 (23:34 -0400)
commitbc3579eb34d95f819635d1b2fb715fc5a3c3c3cb
treef11c735c02cb72d2d7395e0adf57231da90b3b1b
parenta196988290d69dbf6bcc389e2b18cf523ec49a7a
Btrfs: account merges/splits properly

My fix

Btrfs: fix merge delalloc logic

only fixed half of the problems, it didn't fix the case where we have two large
extents on either side and then join them together with a new small extent.  We
need to instead keep track of how many extents we have accounted for with each
side of the new extent, and then see how many extents we need for the new large
extent.  If they match then we know we need to keep our reservation, otherwise
we need to drop our reservation.  This shows up with a case like this

[BTRFS_MAX_EXTENT_SIZE+4K][4K HOLE][BTRFS_MAX_EXTENT_SIZE+4K]

Previously the logic would have said that the number extents required for the
new size (3) is larger than the number of extents required for the largest side
(2) therefore we need to keep our reservation.  But this isn't the case, since
both sides require a reservation of 2 which leads to 4 for the whole range
currently reserved, but we only need 3, so we need to drop one of the
reservations.  The same problem existed for splits, we'd think we only need 3
extents when creating the hole but in reality we need 4.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
(cherry picked from commit ba117213554bc747561c5b7bf274d60ac93b8598)
fs/btrfs/inode.c