summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file-item.c
diff options
context:
space:
mode:
authorChris Mason <clm@fb.com>2017-02-27 13:11:53 -0800
committerChris Mason <clm@fb.com>2017-02-27 13:11:53 -0800
commitef6ebf324216eaea95ff30da5a8e78e2a4311eba (patch)
tree5357c0d811540028845a3e303a1bf2101b9a22a6 /fs/btrfs/file-item.c
parent6288d6eabc7505f42dda34a2c2962f91914be3a4 (diff)
parent263d3995c93c6020576f6c93506412a0b9d1e932 (diff)
downloadlinux-stable-ef6ebf324216eaea95ff30da5a8e78e2a4311eba.tar.gz
linux-stable-ef6ebf324216eaea95ff30da5a8e78e2a4311eba.tar.bz2
linux-stable-ef6ebf324216eaea95ff30da5a8e78e2a4311eba.zip
Merge branch 'for-chris-4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/fdmanana/linux into for-linus-4.11
Diffstat (limited to 'fs/btrfs/file-item.c')
-rw-r--r--fs/btrfs/file-item.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index f7b9a92ad56d..e35df48b4383 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -643,7 +643,33 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
/* delete the entire item, it is inside our range */
if (key.offset >= bytenr && csum_end <= end_byte) {
- ret = btrfs_del_item(trans, root, path);
+ int del_nr = 1;
+
+ /*
+ * Check how many csum items preceding this one in this
+ * leaf correspond to our range and then delete them all
+ * at once.
+ */
+ if (key.offset > bytenr && path->slots[0] > 0) {
+ int slot = path->slots[0] - 1;
+
+ while (slot >= 0) {
+ struct btrfs_key pk;
+
+ btrfs_item_key_to_cpu(leaf, &pk, slot);
+ if (pk.offset < bytenr ||
+ pk.type != BTRFS_EXTENT_CSUM_KEY ||
+ pk.objectid !=
+ BTRFS_EXTENT_CSUM_OBJECTID)
+ break;
+ path->slots[0] = slot;
+ del_nr++;
+ key.offset = pk.offset;
+ slot--;
+ }
+ }
+ ret = btrfs_del_items(trans, root, path,
+ path->slots[0], del_nr);
if (ret)
goto out;
if (key.offset == bytenr)