Home Home > GIT Browse > SLE15-AZURE
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2019-05-15 14:28:53 +0800
committerQu Wenruo <wqu@suse.com>2019-05-15 14:28:53 +0800
commiteedfcc910a1fe9b6f950fd92a8ec45c368ce3d57 (patch)
treeb182d1bda7a43e228ad2b22e5fbc99fc51296dc0
parentc190c41fb2e45114027544fa93d23be179c35bf0 (diff)
- btrfs: delayed-ref: Use btrfs_ref to refactor
btrfs_add_delayed_tree_ref() (bsc#1063638 bsc#1128052 bsc#1108838). - Refresh patches.suse/revert-btrfs-qgroup-move-half-of-the-qgroup-accounting-time-out-of-commit-trans.patch.
-rw-r--r--patches.suse/0003-btrfs-delayed-ref-Use-btrfs_ref-to-refactor-btrfs_ad.patch213
-rw-r--r--patches.suse/revert-btrfs-qgroup-move-half-of-the-qgroup-accounting-time-out-of-commit-trans.patch20
-rw-r--r--series.conf1
3 files changed, 224 insertions, 10 deletions
diff --git a/patches.suse/0003-btrfs-delayed-ref-Use-btrfs_ref-to-refactor-btrfs_ad.patch b/patches.suse/0003-btrfs-delayed-ref-Use-btrfs_ref-to-refactor-btrfs_ad.patch
new file mode 100644
index 0000000000..7b7a9005e9
--- /dev/null
+++ b/patches.suse/0003-btrfs-delayed-ref-Use-btrfs_ref-to-refactor-btrfs_ad.patch
@@ -0,0 +1,213 @@
+From ed4f255b9bacb774c99ded17647f138c3f61546d Mon Sep 17 00:00:00 2001
+From: Qu Wenruo <wqu@suse.com>
+Date: Thu, 4 Apr 2019 14:45:31 +0800
+Git-commit: ed4f255b9bacb774c99ded17647f138c3f61546d
+References: bsc#1063638 bsc#1128052 bsc#1108838
+Patch-mainline: v5.2-rc1
+Subject: [PATCH 3/9] btrfs: delayed-ref: Use btrfs_ref to refactor
+ btrfs_add_delayed_tree_ref()
+
+btrfs_add_delayed_tree_ref() has a longer and longer parameter list, and
+some callers like btrfs_inc_extent_ref() are using @owner as level for
+delayed tree ref.
+
+Instead of making the parameter list longer, use btrfs_ref to refactor
+it, so each parameter assignment should be self-explaining without dirty
+level/owner trick, and provides the basis for later refactoring.
+
+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/delayed-ref.c | 24 +++++++++++++++++-------
+ fs/btrfs/delayed-ref.h | 3 +--
+ fs/btrfs/extent-tree.c | 48 ++++++++++++++++++++++++++++--------------------
+ 3 files changed, 46 insertions(+), 29 deletions(-)
+
+--- a/fs/btrfs/delayed-ref.c
++++ b/fs/btrfs/delayed-ref.c
+@@ -723,8 +723,7 @@ static void init_delayed_ref_common(stru
+ */
+ int btrfs_add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
+ struct btrfs_trans_handle *trans,
+- u64 bytenr, u64 num_bytes, u64 parent,
+- u64 ref_root, int level, int action,
++ struct btrfs_ref *generic_ref,
+ struct btrfs_delayed_extent_op *extent_op,
+ int *old_ref_mod, int *new_ref_mod)
+ {
+@@ -733,10 +732,18 @@ int btrfs_add_delayed_tree_ref(struct bt
+ struct btrfs_delayed_ref_root *delayed_refs;
+ struct btrfs_qgroup_extent_record *record = NULL;
+ int qrecord_inserted;
+- bool is_system = (ref_root == BTRFS_CHUNK_TREE_OBJECTID);
++ bool is_system;
++ int action = generic_ref->action;
++ int level = generic_ref->tree_ref.level;
+ int ret;
++ u64 bytenr = generic_ref->bytenr;
++ u64 num_bytes = generic_ref->len;
++ u64 parent = generic_ref->parent;
+ u8 ref_type;
+
++ is_system = (generic_ref->real_root == BTRFS_CHUNK_TREE_OBJECTID);
++
++ ASSERT(generic_ref->type == BTRFS_REF_METADATA && generic_ref->action);
+ BUG_ON(extent_op && extent_op->is_data);
+ ref = kmem_cache_alloc(btrfs_delayed_tree_ref_cachep, GFP_NOFS);
+ if (!ref)
+@@ -747,8 +754,8 @@ int btrfs_add_delayed_tree_ref(struct bt
+ else
+ ref_type = BTRFS_TREE_BLOCK_REF_KEY;
+ init_delayed_ref_common(fs_info, &ref->node, bytenr, num_bytes,
+- ref_root, action, ref_type);
+- ref->root = ref_root;
++ generic_ref->tree_ref.root, action, ref_type);
++ ref->root = generic_ref->tree_ref.root;
+ ref->parent = parent;
+ ref->level = level;
+
+@@ -757,14 +764,17 @@ int btrfs_add_delayed_tree_ref(struct bt
+ goto free_ref;
+
+ if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) &&
+- is_fstree(ref_root)) {
++ is_fstree(generic_ref->real_root) &&
++ is_fstree(generic_ref->tree_ref.root) &&
++ !generic_ref->skip_qgroup) {
+ record = kzalloc(sizeof(*record), GFP_NOFS);
+ if (!record)
+ goto free_head_ref;
+ }
+
+ init_delayed_ref_head(head_ref, record, bytenr, num_bytes,
+- ref_root, 0, action, false, is_system);
++ generic_ref->tree_ref.root, 0, action, false,
++ is_system);
+ head_ref->extent_op = extent_op;
+
+ delayed_refs = &trans->transaction->delayed_refs;
+--- a/fs/btrfs/delayed-ref.h
++++ b/fs/btrfs/delayed-ref.h
+@@ -346,8 +346,7 @@ static inline void btrfs_put_delayed_ref
+
+ int btrfs_add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
+ struct btrfs_trans_handle *trans,
+- u64 bytenr, u64 num_bytes, u64 parent,
+- u64 ref_root, int level, int action,
++ struct btrfs_ref *generic_ref,
+ struct btrfs_delayed_extent_op *extent_op,
+ int *old_ref_mod, int *new_ref_mod);
+ int btrfs_add_delayed_data_ref(struct btrfs_fs_info *fs_info,
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -2113,18 +2113,20 @@ int btrfs_inc_extent_ref(struct btrfs_tr
+ u64 bytenr, u64 num_bytes, u64 parent,
+ u64 root_objectid, u64 owner, u64 offset)
+ {
++ 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);
+
++ 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) {
+- ret = btrfs_add_delayed_tree_ref(fs_info, trans, bytenr,
+- num_bytes, parent,
+- root_objectid, (int)owner,
+- BTRFS_ADD_DELAYED_REF, NULL,
+- &old_ref_mod, &new_ref_mod);
++ btrfs_init_tree_ref(&generic_ref, (int)owner, root_objectid);
++ ret = btrfs_add_delayed_tree_ref(fs_info, trans, &generic_ref,
++ NULL, &old_ref_mod, &new_ref_mod);
+ } else {
+ ret = btrfs_add_delayed_data_ref(fs_info, trans, bytenr,
+ num_bytes, parent,
+@@ -7121,18 +7123,20 @@ void btrfs_free_tree_block(struct btrfs_
+ u64 parent, int last_ref)
+ {
+ struct btrfs_fs_info *fs_info = root->fs_info;
++ struct btrfs_ref generic_ref = { 0 };
+ int pin = 1;
+ int ret;
+
++ btrfs_init_generic_ref(&generic_ref, BTRFS_DROP_DELAYED_REF,
++ buf->start, buf->len, parent);
++ btrfs_init_tree_ref(&generic_ref, btrfs_header_level(buf),
++ root->root_key.objectid);
++
+ if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) {
+ int old_ref_mod, new_ref_mod;
+
+- ret = btrfs_add_delayed_tree_ref(fs_info, trans, buf->start,
+- buf->len, parent,
+- root->root_key.objectid,
+- btrfs_header_level(buf),
+- BTRFS_DROP_DELAYED_REF, NULL,
+- &old_ref_mod, &new_ref_mod);
++ ret = btrfs_add_delayed_tree_ref(fs_info, trans, &generic_ref, NULL,
++ &old_ref_mod, &new_ref_mod);
+ BUG_ON(ret); /* -ENOMEM */
+ pin = old_ref_mod >= 0 && new_ref_mod < 0;
+ }
+@@ -7183,6 +7187,7 @@ int btrfs_free_extent(struct btrfs_trans
+ u64 bytenr, u64 num_bytes, u64 parent, u64 root_objectid,
+ u64 owner, u64 offset)
+ {
++ struct btrfs_ref generic_ref = { 0 };
+ int old_ref_mod, new_ref_mod;
+ int ret;
+
+@@ -7190,6 +7195,9 @@ int btrfs_free_extent(struct btrfs_trans
+ return 0;
+
+
++ btrfs_init_generic_ref(&generic_ref, BTRFS_DROP_DELAYED_REF, bytenr,
++ num_bytes, parent);
++ generic_ref.real_root = root_objectid;
+ /*
+ * tree log blocks never actually go into the extent allocation
+ * tree, just update pinning info and exit early.
+@@ -7201,11 +7209,9 @@ int btrfs_free_extent(struct btrfs_trans
+ old_ref_mod = new_ref_mod = 0;
+ ret = 0;
+ } else if (owner < BTRFS_FIRST_FREE_OBJECTID) {
+- ret = btrfs_add_delayed_tree_ref(fs_info, trans, bytenr,
+- num_bytes, parent,
+- root_objectid, (int)owner,
+- BTRFS_DROP_DELAYED_REF, NULL,
+- &old_ref_mod, &new_ref_mod);
++ btrfs_init_tree_ref(&generic_ref, (int)owner, root_objectid);
++ ret = btrfs_add_delayed_tree_ref(fs_info, trans, &generic_ref,
++ NULL, &old_ref_mod, &new_ref_mod);
+ } else {
+ ret = btrfs_add_delayed_data_ref(fs_info, trans, bytenr,
+ num_bytes, parent,
+@@ -8335,6 +8341,7 @@ struct extent_buffer *btrfs_alloc_tree_b
+ struct btrfs_block_rsv *block_rsv;
+ struct extent_buffer *buf;
+ struct btrfs_delayed_extent_op *extent_op;
++ struct btrfs_ref generic_ref = { 0 };
+ u64 flags = 0;
+ int ret;
+ u32 blocksize = fs_info->nodesize;
+@@ -8388,10 +8395,11 @@ struct extent_buffer *btrfs_alloc_tree_b
+ extent_op->is_data = false;
+ extent_op->level = level;
+
+- ret = btrfs_add_delayed_tree_ref(fs_info, trans, ins.objectid,
+- ins.offset, parent,
+- root_objectid, level,
+- BTRFS_ADD_DELAYED_EXTENT,
++ btrfs_init_generic_ref(&generic_ref, BTRFS_ADD_DELAYED_EXTENT,
++ ins.objectid, ins.offset, parent);
++ generic_ref.real_root = root->root_key.objectid;
++ btrfs_init_tree_ref(&generic_ref, level, root_objectid);
++ ret = btrfs_add_delayed_tree_ref(fs_info, trans, &generic_ref,
+ extent_op, NULL, NULL);
+ if (ret)
+ goto out_free_delayed;
diff --git a/patches.suse/revert-btrfs-qgroup-move-half-of-the-qgroup-accounting-time-out-of-commit-trans.patch b/patches.suse/revert-btrfs-qgroup-move-half-of-the-qgroup-accounting-time-out-of-commit-trans.patch
index 1ff8b31a3b..a099ef80ca 100644
--- a/patches.suse/revert-btrfs-qgroup-move-half-of-the-qgroup-accounting-time-out-of-commit-trans.patch
+++ b/patches.suse/revert-btrfs-qgroup-move-half-of-the-qgroup-accounting-time-out-of-commit-trans.patch
@@ -80,15 +80,15 @@ Acked-by: Jeff Mahoney <jeffm@suse.com>
if (new_ref_mod)
*new_ref_mod = head_ref->total_ref_mod;
-@@ -732,7 +726,6 @@ int btrfs_add_delayed_tree_ref(struct bt
+@@ -731,7 +725,6 @@ int btrfs_add_delayed_tree_ref(struct bt
struct btrfs_delayed_ref_head *head_ref;
struct btrfs_delayed_ref_root *delayed_refs;
struct btrfs_qgroup_extent_record *record = NULL;
- int qrecord_inserted;
- bool is_system = (ref_root == BTRFS_CHUNK_TREE_OBJECTID);
- int ret;
- u8 ref_type;
-@@ -775,8 +768,7 @@ int btrfs_add_delayed_tree_ref(struct bt
+ bool is_system;
+ int action = generic_ref->action;
+ int level = generic_ref->tree_ref.level;
+@@ -785,8 +778,7 @@ int btrfs_add_delayed_tree_ref(struct bt
* the spin lock
*/
head_ref = add_delayed_ref_head(fs_info, trans, head_ref, record,
@@ -98,7 +98,7 @@ Acked-by: Jeff Mahoney <jeffm@suse.com>
ret = insert_delayed_ref(trans, delayed_refs, head_ref, &ref->node);
-@@ -788,8 +780,6 @@ int btrfs_add_delayed_tree_ref(struct bt
+@@ -798,8 +790,6 @@ int btrfs_add_delayed_tree_ref(struct bt
if (ret > 0)
kmem_cache_free(btrfs_delayed_tree_ref_cachep, ref);
@@ -107,7 +107,7 @@ Acked-by: Jeff Mahoney <jeffm@suse.com>
return 0;
free_head_ref:
-@@ -814,7 +804,6 @@ int btrfs_add_delayed_data_ref(struct bt
+@@ -824,7 +814,6 @@ int btrfs_add_delayed_data_ref(struct bt
struct btrfs_delayed_ref_head *head_ref;
struct btrfs_delayed_ref_root *delayed_refs;
struct btrfs_qgroup_extent_record *record = NULL;
@@ -115,7 +115,7 @@ Acked-by: Jeff Mahoney <jeffm@suse.com>
int ret;
u8 ref_type;
-@@ -863,8 +852,7 @@ int btrfs_add_delayed_data_ref(struct bt
+@@ -873,8 +862,7 @@ int btrfs_add_delayed_data_ref(struct bt
* the spin lock
*/
head_ref = add_delayed_ref_head(fs_info, trans, head_ref, record,
@@ -125,7 +125,7 @@ Acked-by: Jeff Mahoney <jeffm@suse.com>
ret = insert_delayed_ref(trans, delayed_refs, head_ref, &ref->node);
spin_unlock(&delayed_refs->lock);
-@@ -875,8 +863,6 @@ int btrfs_add_delayed_data_ref(struct bt
+@@ -885,8 +873,6 @@ int btrfs_add_delayed_data_ref(struct bt
if (ret > 0)
kmem_cache_free(btrfs_delayed_data_ref_cachep, ref);
@@ -134,7 +134,7 @@ Acked-by: Jeff Mahoney <jeffm@suse.com>
return 0;
}
-@@ -902,7 +888,7 @@ int btrfs_add_delayed_extent_op(struct b
+@@ -912,7 +898,7 @@ int btrfs_add_delayed_extent_op(struct b
add_delayed_ref_head(fs_info, trans, head_ref, NULL,
BTRFS_UPDATE_DELAYED_HEAD,
diff --git a/series.conf b/series.conf
index 7b69a9964f..9c9a4de676 100644
--- a/series.conf
+++ b/series.conf
@@ -21787,6 +21787,7 @@
patches.fixes/0001-btrfs-reloc-Fix-NULL-pointer-dereference-due-to-expa.patch
patches.suse/0001-btrfs-delayed-ref-Introduce-better-documented-delaye.patch
patches.suse/0002-btrfs-extent-tree-Open-code-process_func-in-__btrfs_.patch
+ patches.suse/0003-btrfs-delayed-ref-Use-btrfs_ref-to-refactor-btrfs_ad.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