Home Home > GIT Browse > SLE15-AZURE
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2019-05-15 15:47:36 +0800
committerQu Wenruo <wqu@suse.com>2019-05-15 18:22:36 +0800
commitc0ee85b6ba99b89f7f82e947c195fef35fb34efa (patch)
treef317c889c2543517cf755f4ba4ed137f414d578b
parent37707c4de7ae72bb785a3083f06798f65e1c0a60 (diff)
- btrfs: extent-tree: Use btrfs_ref to refactor
btrfs_inc_extent_ref() (bsc#1063638 bsc#1128052 bsc#1108838). - Refresh patches.suse/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch.
-rw-r--r--patches.suse/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch8
-rw-r--r--patches.suse/0007-btrfs-extent-tree-Use-btrfs_ref-to-refactor-btrfs_in.patch370
-rw-r--r--series.conf1
3 files changed, 375 insertions, 4 deletions
diff --git a/patches.suse/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch b/patches.suse/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch
index 01af8fc3c3..6eac1cfa99 100644
--- a/patches.suse/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch
+++ b/patches.suse/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch
@@ -76,12 +76,12 @@ Signed-off-by: David Sterba <dsterba@suse.com>
}
/*
-@@ -2135,7 +2147,7 @@ int btrfs_inc_extent_ref(struct btrfs_tr
- }
+@@ -2129,7 +2141,7 @@ int btrfs_inc_extent_ref(struct btrfs_tr
+ &old_ref_mod, &new_ref_mod);
if (ret == 0 && old_ref_mod < 0 && new_ref_mod >= 0)
-- add_pinned_bytes(fs_info, &generic_ref);
-+ sub_pinned_bytes(fs_info, &generic_ref);
+- add_pinned_bytes(fs_info, generic_ref);
++ sub_pinned_bytes(fs_info, generic_ref);
return ret;
}
diff --git a/patches.suse/0007-btrfs-extent-tree-Use-btrfs_ref-to-refactor-btrfs_in.patch b/patches.suse/0007-btrfs-extent-tree-Use-btrfs_ref-to-refactor-btrfs_in.patch
new file mode 100644
index 0000000000..4920713e43
--- /dev/null
+++ b/patches.suse/0007-btrfs-extent-tree-Use-btrfs_ref-to-refactor-btrfs_in.patch
@@ -0,0 +1,370 @@
+From 82fa113fccc41fe5204b4ce35341d69ebde0020f Mon Sep 17 00:00:00 2001
+From: Qu Wenruo <wqu@suse.com>
+Date: Thu, 4 Apr 2019 14:45:35 +0800
+Git-commit: 82fa113fccc41fe5204b4ce35341d69ebde0020f
+References: bsc#1063638 bsc#1128052 bsc#1108838
+Patch-mainline: v5.2-rc1
+Subject: [PATCH 7/9] btrfs: extent-tree: Use btrfs_ref to refactor
+ btrfs_inc_extent_ref()
+
+Use the new btrfs_ref structure and replace parameter list to clean up
+the usage of owner and level to distinguish the extent types.
+
+Signed-off-by: Qu Wenruo <wqu@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/ctree.h | 4 +--
+ fs/btrfs/extent-tree.c | 54 +++++++++++++++++++++++++++++--------------------
+ fs/btrfs/file.c | 18 +++++++++++-----
+ fs/btrfs/inode.c | 10 +++++----
+ fs/btrfs/ioctl.c | 15 +++++++++----
+ fs/btrfs/relocation.c | 41 ++++++++++++++++++++++++-------------
+ fs/btrfs/tree-log.c | 12 ++++++++--
+ 7 files changed, 99 insertions(+), 55 deletions(-)
+
+--- a/fs/btrfs/ctree.h
++++ b/fs/btrfs/ctree.h
+@@ -53,6 +53,7 @@ extern struct kmem_cache *btrfs_bit_radi
+ extern struct kmem_cache *btrfs_path_cachep;
+ extern struct kmem_cache *btrfs_free_space_cachep;
+ struct btrfs_ordered_sum;
++struct btrfs_ref;
+
+ #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
+ #define STATIC noinline
+@@ -2731,8 +2732,7 @@ int btrfs_finish_extent_commit(struct bt
+ struct btrfs_fs_info *fs_info);
+ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
+ struct btrfs_fs_info *fs_info,
+- u64 bytenr, u64 num_bytes, u64 parent,
+- u64 root_objectid, u64 owner, u64 offset);
++ struct btrfs_ref *generic_ref);
+
+ int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans,
+ struct btrfs_fs_info *fs_info);
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -2111,31 +2111,25 @@ int btrfs_discard_extent(struct btrfs_fs
+ /* Can return -ENOMEM */
+ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
+ struct btrfs_fs_info *fs_info,
+- u64 bytenr, u64 num_bytes, u64 parent,
+- u64 root_objectid, u64 owner, u64 offset)
++ struct btrfs_ref *generic_ref)
+ {
+- struct btrfs_ref generic_ref = { 0 };
+ int old_ref_mod, new_ref_mod;
+ int ret;
+
+- BUG_ON(owner < BTRFS_FIRST_FREE_OBJECTID &&
+- root_objectid == BTRFS_TREE_LOG_OBJECTID);
++ ASSERT(generic_ref->type != BTRFS_REF_NOT_SET &&
++ generic_ref->action);
++ BUG_ON(generic_ref->type == BTRFS_REF_METADATA &&
++ generic_ref->tree_ref.root == BTRFS_TREE_LOG_OBJECTID);
+
+- btrfs_init_generic_ref(&generic_ref, BTRFS_ADD_DELAYED_REF, bytenr,
+- num_bytes, parent);
+- generic_ref.real_root = root_objectid;
+- if (owner < BTRFS_FIRST_FREE_OBJECTID) {
+- btrfs_init_tree_ref(&generic_ref, (int)owner, root_objectid);
+- ret = btrfs_add_delayed_tree_ref(fs_info, trans, &generic_ref,
++ if (generic_ref->type == BTRFS_REF_METADATA)
++ ret = btrfs_add_delayed_tree_ref(fs_info, trans, generic_ref,
+ NULL, &old_ref_mod, &new_ref_mod);
+- } else {
+- btrfs_init_data_ref(&generic_ref, root_objectid, owner, offset);
+- ret = btrfs_add_delayed_data_ref(fs_info, trans, &generic_ref, 0,
++ else
++ ret = btrfs_add_delayed_data_ref(fs_info, trans, generic_ref, 0,
+ &old_ref_mod, &new_ref_mod);
+- }
+
+ if (ret == 0 && old_ref_mod < 0 && new_ref_mod >= 0)
+- add_pinned_bytes(fs_info, &generic_ref);
++ add_pinned_bytes(fs_info, generic_ref);
+
+ return ret;
+ }
+@@ -3254,7 +3248,10 @@ static int __btrfs_mod_ref(struct btrfs_
+ u32 nritems;
+ struct btrfs_key key;
+ struct btrfs_file_extent_item *fi;
++ struct btrfs_ref generic_ref = { 0 };
++ bool for_reloc = btrfs_header_flag(buf, BTRFS_HEADER_FLAG_RELOC);
+ int i;
++ int action;
+ int level;
+ int ret = 0;
+
+@@ -3272,6 +3269,10 @@ static int __btrfs_mod_ref(struct btrfs_
+ parent = buf->start;
+ else
+ parent = 0;
++ if (inc)
++ action = BTRFS_ADD_DELAYED_REF;
++ else
++ action = BTRFS_DROP_DELAYED_REF;
+
+ for (i = 0; i < nritems; i++) {
+ if (level == 0) {
+@@ -3289,10 +3290,15 @@ static int __btrfs_mod_ref(struct btrfs_
+
+ num_bytes = btrfs_file_extent_disk_num_bytes(buf, fi);
+ key.offset -= btrfs_file_extent_offset(buf, fi);
++ btrfs_init_generic_ref(&generic_ref, action, bytenr,
++ num_bytes, parent);
++ btrfs_init_data_ref(&generic_ref, ref_root, key.objectid,
++ key.offset);
++ generic_ref.real_root = root->root_key.objectid;
++ generic_ref.skip_qgroup = for_reloc;
+ if (inc)
+- ret = btrfs_inc_extent_ref(trans, fs_info, bytenr,
+- num_bytes, parent, ref_root,
+- key.objectid, key.offset);
++ ret = btrfs_inc_extent_ref(trans, fs_info,
++ &generic_ref);
+ else
+ ret = btrfs_free_extent(trans, fs_info, bytenr,
+ num_bytes, parent, ref_root,
+@@ -3302,10 +3308,14 @@ static int __btrfs_mod_ref(struct btrfs_
+ } else {
+ bytenr = btrfs_node_blockptr(buf, i);
+ num_bytes = fs_info->nodesize;
++ btrfs_init_generic_ref(&generic_ref, action, bytenr,
++ num_bytes, parent);
++ generic_ref.real_root = root->root_key.objectid;
++ btrfs_init_tree_ref(&generic_ref, level - 1, ref_root);
++ generic_ref.skip_qgroup = for_reloc;
+ if (inc)
+- ret = btrfs_inc_extent_ref(trans, fs_info, bytenr,
+- num_bytes, parent, ref_root,
+- level - 1, 0);
++ ret = btrfs_inc_extent_ref(trans, fs_info,
++ &generic_ref);
+ else
+ ret = btrfs_free_extent(trans, fs_info, bytenr,
+ num_bytes, parent, ref_root,
+--- a/fs/btrfs/file.c
++++ b/fs/btrfs/file.c
+@@ -762,6 +762,7 @@ int __btrfs_drop_extents(struct btrfs_tr
+ struct btrfs_fs_info *fs_info = root->fs_info;
+ struct extent_buffer *leaf;
+ struct btrfs_file_extent_item *fi;
++ struct btrfs_ref ref = { 0 };
+ struct btrfs_key key;
+ struct btrfs_key new_key;
+ u64 ino = btrfs_ino(BTRFS_I(inode));
+@@ -918,11 +919,15 @@ next_slot:
+ btrfs_mark_buffer_dirty(leaf);
+
+ if (update_refs && disk_bytenr > 0) {
+- ret = btrfs_inc_extent_ref(trans, fs_info,
+- disk_bytenr, num_bytes, 0,
++ btrfs_init_generic_ref(&ref,
++ BTRFS_ADD_DELAYED_REF,
++ disk_bytenr, num_bytes, 0);
++ btrfs_init_data_ref(&ref,
+ root->root_key.objectid,
+ new_key.objectid,
+ start - extent_offset);
++ ret = btrfs_inc_extent_ref(trans, fs_info,
++ &ref);
+ BUG_ON(ret); /* -ENOMEM */
+ }
+ key.offset = start;
+@@ -1151,6 +1156,7 @@ int btrfs_mark_extent_written(struct btr
+ struct extent_buffer *leaf;
+ struct btrfs_path *path;
+ struct btrfs_file_extent_item *fi;
++ struct btrfs_ref ref = { 0 };
+ struct btrfs_key key;
+ struct btrfs_key new_key;
+ u64 bytenr;
+@@ -1296,9 +1302,11 @@ again:
+ extent_end - split);
+ btrfs_mark_buffer_dirty(leaf);
+
+- ret = btrfs_inc_extent_ref(trans, fs_info, bytenr, num_bytes,
+- 0, root->root_key.objectid,
+- ino, orig_offset);
++ btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, bytenr,
++ num_bytes, 0);
++ btrfs_init_data_ref(&ref, root->root_key.objectid, ino,
++ orig_offset);
++ ret = btrfs_inc_extent_ref(trans, fs_info, &ref);
+ if (ret) {
+ btrfs_abort_transaction(trans, ret);
+ goto out;
+--- a/fs/btrfs/inode.c
++++ b/fs/btrfs/inode.c
+@@ -2519,6 +2519,7 @@ static noinline int relink_extent_backre
+ struct btrfs_file_extent_item *item;
+ struct btrfs_ordered_extent *ordered;
+ struct btrfs_trans_handle *trans;
++ struct btrfs_ref ref = { 0 };
+ struct btrfs_root *root;
+ struct btrfs_key key;
+ struct extent_buffer *leaf;
+@@ -2689,10 +2690,11 @@ again:
+ inode_add_bytes(inode, len);
+ btrfs_release_path(path);
+
+- ret = btrfs_inc_extent_ref(trans, fs_info, new->bytenr,
+- new->disk_len, 0,
+- backref->root_id, backref->inum,
+- new->file_pos); /* start - extent_offset */
++ btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, new->bytenr,
++ new->disk_len, 0);
++ btrfs_init_data_ref(&ref, backref->root_id, backref->inum,
++ new->file_pos); /* start - extent_offset */
++ ret = btrfs_inc_extent_ref(trans, fs_info, &ref);
+ if (ret) {
+ btrfs_abort_transaction(trans, ret);
+ goto out_free_path;
+--- a/fs/btrfs/ioctl.c
++++ b/fs/btrfs/ioctl.c
+@@ -3774,13 +3774,18 @@ process_slot:
+ datal);
+
+ if (disko) {
++ struct btrfs_ref ref = { 0 };
++
+ inode_add_bytes(inode, datal);
++ btrfs_init_generic_ref(&ref,
++ BTRFS_ADD_DELAYED_REF, disko,
++ diskl, 0);
++ btrfs_init_data_ref(&ref,
++ root->root_key.objectid,
++ btrfs_ino(BTRFS_I(inode)),
++ new_key.offset - datao);
+ ret = btrfs_inc_extent_ref(trans,
+- fs_info,
+- disko, diskl, 0,
+- root->root_key.objectid,
+- btrfs_ino(BTRFS_I(inode)),
+- new_key.offset - datao);
++ fs_info, &ref);
+ if (ret) {
+ btrfs_abort_transaction(trans,
+ ret);
+--- a/fs/btrfs/relocation.c
++++ b/fs/btrfs/relocation.c
+@@ -1679,6 +1679,8 @@ int replace_file_extents(struct btrfs_tr
+
+ nritems = btrfs_header_nritems(leaf);
+ for (i = 0; i < nritems; i++) {
++ struct btrfs_ref ref = { 0 };
++
+ cond_resched();
+ btrfs_item_key_to_cpu(leaf, &key, i);
+ if (key.type != BTRFS_EXTENT_DATA_KEY)
+@@ -1739,10 +1741,12 @@ int replace_file_extents(struct btrfs_tr
+ dirty = 1;
+
+ key.offset -= btrfs_file_extent_offset(leaf, fi);
+- ret = btrfs_inc_extent_ref(trans, fs_info, new_bytenr,
+- num_bytes, parent,
+- btrfs_header_owner(leaf),
+- key.objectid, key.offset);
++ btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, new_bytenr,
++ num_bytes, parent);
++ ref.real_root = root->root_key.objectid;
++ btrfs_init_data_ref(&ref, btrfs_header_owner(leaf),
++ key.objectid, key.offset);
++ ret = btrfs_inc_extent_ref(trans, fs_info, &ref);
+ if (ret) {
+ btrfs_abort_transaction(trans, ret);
+ break;
+@@ -1792,6 +1796,7 @@ int replace_path(struct btrfs_trans_hand
+ struct btrfs_fs_info *fs_info = dest->fs_info;
+ struct extent_buffer *eb;
+ struct extent_buffer *parent;
++ struct btrfs_ref ref = { 0 };
+ struct btrfs_key key;
+ u64 old_bytenr;
+ u64 new_bytenr;
+@@ -1950,13 +1955,17 @@ again:
+ path->slots[level], old_ptr_gen);
+ btrfs_mark_buffer_dirty(path->nodes[level]);
+
+- ret = btrfs_inc_extent_ref(trans, fs_info, old_bytenr,
+- blocksize, path->nodes[level]->start,
+- src->root_key.objectid, level - 1, 0);
++ btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, old_bytenr,
++ blocksize, path->nodes[level]->start);
++ ref.skip_qgroup = true;
++ btrfs_init_tree_ref(&ref, level - 1, src->root_key.objectid);
++ ret = btrfs_inc_extent_ref(trans, fs_info, &ref);
+ BUG_ON(ret);
+- ret = btrfs_inc_extent_ref(trans, fs_info, new_bytenr,
+- blocksize, 0, dest->root_key.objectid,
+- level - 1, 0);
++ btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, new_bytenr,
++ blocksize, 0);
++ ref.skip_qgroup = true;
++ btrfs_init_tree_ref(&ref, level - 1, dest->root_key.objectid);
++ ret = btrfs_inc_extent_ref(trans, fs_info, &ref);
+ BUG_ON(ret);
+
+ ret = btrfs_free_extent(trans, fs_info, new_bytenr, blocksize,
+@@ -2756,6 +2765,7 @@ static int do_relocation(struct btrfs_tr
+ rc->backref_cache.path[node->level] = node;
+ list_for_each_entry(edge, &node->upper, list[LOWER]) {
+ struct btrfs_key first_key;
++ struct btrfs_ref ref = { 0 };
+
+ cond_resched();
+
+@@ -2853,11 +2863,14 @@ static int do_relocation(struct btrfs_tr
+ trans->transid);
+ btrfs_mark_buffer_dirty(upper->eb);
+
++ btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF,
++ node->eb->start, blocksize,
++ upper->eb->start);
++ ref.real_root = root->root_key.objectid;
++ btrfs_init_tree_ref(&ref, node->level,
++ btrfs_header_owner(upper->eb));
+ ret = btrfs_inc_extent_ref(trans, root->fs_info,
+- node->eb->start, blocksize,
+- upper->eb->start,
+- btrfs_header_owner(upper->eb),
+- node->level, 0);
++ &ref);
+ BUG_ON(ret);
+
+ ret = btrfs_drop_subtree(trans, root, eb, upper->eb);
+--- a/fs/btrfs/tree-log.c
++++ b/fs/btrfs/tree-log.c
+@@ -717,9 +717,11 @@ static noinline int replay_one_extent(st
+ goto out;
+
+ if (ins.objectid > 0) {
++ struct btrfs_ref ref = { 0 };
+ u64 csum_start;
+ u64 csum_end;
+ LIST_HEAD(ordered_sums);
++
+ /*
+ * is this extent already allocated in the extent
+ * allocation tree? If so, just add a reference
+@@ -727,10 +729,14 @@ static noinline int replay_one_extent(st
+ ret = btrfs_lookup_data_extent(fs_info, ins.objectid,
+ ins.offset);
+ if (ret == 0) {
+- ret = btrfs_inc_extent_ref(trans, fs_info,
+- ins.objectid, ins.offset,
+- 0, root->root_key.objectid,
++ btrfs_init_generic_ref(&ref,
++ BTRFS_ADD_DELAYED_REF,
++ ins.objectid, ins.offset, 0);
++ btrfs_init_data_ref(&ref,
++ root->root_key.objectid,
+ key->objectid, offset);
++ ret = btrfs_inc_extent_ref(trans, fs_info,
++ &ref);
+ if (ret)
+ goto out;
+ } else {
diff --git a/series.conf b/series.conf
index 1c2e10f50f..5737f0b5f1 100644
--- a/series.conf
+++ b/series.conf
@@ -21790,6 +21790,7 @@
patches.suse/0003-btrfs-delayed-ref-Use-btrfs_ref-to-refactor-btrfs_ad.patch
patches.suse/0004-btrfs-delayed-ref-Use-btrfs_ref-to-refactor-btrfs_ad.patch
patches.suse/0006-btrfs-extent-tree-Use-btrfs_ref-to-refactor-add_pinn.patch
+ patches.suse/0007-btrfs-extent-tree-Use-btrfs_ref-to-refactor-btrfs_in.patch
patches.drivers/mmc-core-fix-possible-use-after-free-of-host.patch
patches.drivers/phy-sun4i-usb-Make-sure-to-disable-PHY0-passby-for-p.patch
patches.drivers/stm-class-Fix-channel-free-in-stm-output-free-path.patch