linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [kdave:misc-cleanups-4.5 9/9] fs/btrfs/backref.c:565:1-20: iterator with update on line 577
       [not found] <alpine.DEB.2.02.1601120706340.2042@localhost6.localdomain6>
@ 2016-01-12 15:23 ` Geliang Tang
  2016-01-12 15:23   ` [PATCH v3] btrfs: use list_for_each_entry* in backref.c Geliang Tang
  0 siblings, 1 reply; 4+ messages in thread
From: Geliang Tang @ 2016-01-12 15:23 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba, Julia Lawall
  Cc: Geliang Tang, linux-btrfs, linux-kernel

On Tue, Jan 12, 2016 at 07:07:24AM +0100, Julia Lawall wrote:
> I really have no idea if this is safe or not.
> 
> julia
> 
> On Tue, 12 Jan 2016, kbuild test robot wrote:
> 
> > CC: kbuild-all@01.org
> > TO: Geliang Tang <geliangtang@163.com>
> > CC: David Sterba <dsterba@suse.com>
> > 
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux misc-cleanups-4.5
> > head:   a7ca42256d9fad572fb7f2c471514d7d3572b1db
> > commit: a7ca42256d9fad572fb7f2c471514d7d3572b1db [9/9] btrfs: use list_for_each_entry* in backref.c
> > :::::: branch date: 5 days ago
> > :::::: commit date: 5 days ago
> > 
> > >> fs/btrfs/backref.c:565:1-20: iterator with update on line 577

Sorry for the trouble caused. It's probably unsafe. I updated my patch
to fix this problem.

- Geliang

Geliang Tang (1):
  btrfs: use list_for_each_entry* in backref.c

 fs/btrfs/backref.c | 25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

-- 
2.5.0



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3] btrfs: use list_for_each_entry* in backref.c
  2016-01-12 15:23 ` [kdave:misc-cleanups-4.5 9/9] fs/btrfs/backref.c:565:1-20: iterator with update on line 577 Geliang Tang
@ 2016-01-12 15:23   ` Geliang Tang
  2016-01-12 18:13     ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Geliang Tang @ 2016-01-12 15:23 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba, Julia Lawall
  Cc: Geliang Tang, linux-btrfs, linux-kernel

Use list_for_each_entry*() to simplify the code.

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
Changes in v3:
 - fix 'fs/btrfs/backref.c:565:1-20: iterator with update on line 577'

Changes in v2:
 - Use list_for_each_entry_safe_continue() in __merge_refs().
---
 fs/btrfs/backref.c | 25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index d453d62..b90cd37 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -520,13 +520,10 @@ static inline int ref_for_same_block(struct __prelim_ref *ref1,
 static int __add_missing_keys(struct btrfs_fs_info *fs_info,
 			      struct list_head *head)
 {
-	struct list_head *pos;
+	struct __prelim_ref *ref;
 	struct extent_buffer *eb;
 
-	list_for_each(pos, head) {
-		struct __prelim_ref *ref;
-		ref = list_entry(pos, struct __prelim_ref, list);
-
+	list_for_each_entry(ref, head, list) {
 		if (ref->parent)
 			continue;
 		if (ref->key_for_search.type)
@@ -563,23 +560,15 @@ static int __add_missing_keys(struct btrfs_fs_info *fs_info,
  */
 static void __merge_refs(struct list_head *head, int mode)
 {
-	struct list_head *pos1;
+	struct __prelim_ref *pos1;
 
-	list_for_each(pos1, head) {
-		struct list_head *n2;
-		struct list_head *pos2;
-		struct __prelim_ref *ref1;
+	list_for_each_entry(pos1, head, list) {
+		struct __prelim_ref *pos2 = pos1, *tmp;
 
-		ref1 = list_entry(pos1, struct __prelim_ref, list);
-
-		for (pos2 = pos1->next, n2 = pos2->next; pos2 != head;
-		     pos2 = n2, n2 = pos2->next) {
-			struct __prelim_ref *ref2;
-			struct __prelim_ref *xchg;
+		list_for_each_entry_safe_continue(pos2, tmp, head, list) {
+			struct __prelim_ref *xchg, *ref1 = pos1, *ref2 = pos2;
 			struct extent_inode_elem *eie;
 
-			ref2 = list_entry(pos2, struct __prelim_ref, list);
-
 			if (!ref_for_same_block(ref1, ref2))
 				continue;
 			if (mode == 1) {
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] btrfs: use list_for_each_entry* in backref.c
  2016-01-12 15:23   ` [PATCH v3] btrfs: use list_for_each_entry* in backref.c Geliang Tang
@ 2016-01-12 18:13     ` David Sterba
  2016-01-13 14:08       ` [PATCH] btrfs: fix iterator with update error " Geliang Tang
  0 siblings, 1 reply; 4+ messages in thread
From: David Sterba @ 2016-01-12 18:13 UTC (permalink / raw)
  To: Geliang Tang
  Cc: Chris Mason, Josef Bacik, David Sterba, Julia Lawall, linux-btrfs,
	linux-kernel

On Tue, Jan 12, 2016 at 11:23:16PM +0800, Geliang Tang wrote:
> Use list_for_each_entry*() to simplify the code.
> 
> Signed-off-by: Geliang Tang <geliangtang@163.com>

The patch has been pulled to 4.5 queue already, please do an incremental
against branch integration-4.5 (in Chris' git
git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs.git)
Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] btrfs: fix iterator with update error in backref.c
  2016-01-12 18:13     ` David Sterba
@ 2016-01-13 14:08       ` Geliang Tang
  0 siblings, 0 replies; 4+ messages in thread
From: Geliang Tang @ 2016-01-13 14:08 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba, Julia Lawall
  Cc: Geliang Tang, linux-btrfs, linux-kernel

Fix the following error:

fs/btrfs/backref.c:565:1-20: iterator with update on line 577

Fixes: a7ca422('btrfs: use list_for_each_entry* in backref.c')
Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 fs/btrfs/backref.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 08405a3..b90cd37 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -560,13 +560,13 @@ static int __add_missing_keys(struct btrfs_fs_info *fs_info,
  */
 static void __merge_refs(struct list_head *head, int mode)
 {
-	struct __prelim_ref *ref1;
+	struct __prelim_ref *pos1;
 
-	list_for_each_entry(ref1, head, list) {
-		struct __prelim_ref *ref2 = ref1, *tmp;
+	list_for_each_entry(pos1, head, list) {
+		struct __prelim_ref *pos2 = pos1, *tmp;
 
-		list_for_each_entry_safe_continue(ref2, tmp, head, list) {
-			struct __prelim_ref *xchg;
+		list_for_each_entry_safe_continue(pos2, tmp, head, list) {
+			struct __prelim_ref *xchg, *ref1 = pos1, *ref2 = pos2;
 			struct extent_inode_elem *eie;
 
 			if (!ref_for_same_block(ref1, ref2))
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-13 14:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <alpine.DEB.2.02.1601120706340.2042@localhost6.localdomain6>
2016-01-12 15:23 ` [kdave:misc-cleanups-4.5 9/9] fs/btrfs/backref.c:565:1-20: iterator with update on line 577 Geliang Tang
2016-01-12 15:23   ` [PATCH v3] btrfs: use list_for_each_entry* in backref.c Geliang Tang
2016-01-12 18:13     ` David Sterba
2016-01-13 14:08       ` [PATCH] btrfs: fix iterator with update error " Geliang Tang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).