Skip to contentSkip to conversation

list.h related cleanups

PATCH In review Akinobu Mita 11 participants 22 messages Mar 30, 2006 – Apr 10, 2006

Subsystems (32)
lore
Share & tools
lore
#0 lore raw

cover list.h related cleanups

This patch set does:

- Introduce hlist_add_head() and use it
- Use list_add_tail() instead of list_add(A, B.prev)
- Use list_move() instead of the combination of list_del() and list_add()

for readability and micro optimization.
--

#1 lore raw

PATCH 1/8 introduce hlist_move_head()

This patch introduces the function hlist_move_head(). This function deletes from one hash list and add as another's head

 include/linux/list.h |    5 +++++
 1 files changed, 5 insertions(+)
include/linux/list.h +5 -0
Index: 2.6-git/include/linux/list.h
===================================================================
@@ -656,6 +656,11 @@ static inline void hlist_add_head(struct
 	n->pprev = &h->first;
 }
 
+static inline void hlist_move_head(struct hlist_node *n, struct hlist_head *h)
+{
+	__hlist_del(n);
+	hlist_add_head(n, h);
+}
 
 /**
  * hlist_add_head_rcu - adds the specified element to the specified hlist,

--

#2 lore raw

PATCH 2/8 use hlist_move_head()

In reply to Akinobu Mita

This patch converts the combination of hlist_del(A) and hlist_add_head(A, B) to hlist_move_head(A, B).

CC Neil Brown <[email protected]>
CC Prasanna S Panchamukhi <[email protected]>
CC "David S. Miller" <[email protected]>
 fs/nfsd/nfscache.c                      |    3 +--
 kernel/kprobes.c                        |   10 +++++-----
 net/core/dev.c                          |    3 +--
 net/ipv4/fib_hash.c                     |    4 +---
 net/ipv4/fib_semantics.c                |    8 ++------
 net/ipv4/ip_fragment.c                  |    4 +---
 net/ipv6/netfilter/nf_conntrack_reasm.c |    3 +--
 net/ipv6/reassembly.c                   |    4 +---
 net/sunrpc/auth.c                       |    9 +++------
 9 files changed, 16 insertions(+), 32 deletions(-)
fs/nfsd/nfscache.c +1 -2
Index: 2.6-git/fs/nfsd/nfscache.c
===================================================================
@@ -113,8 +113,7 @@ lru_put_end(struct svc_cacherep *rp)
 static void
 hash_refile(struct svc_cacherep *rp)
 {
-	hlist_del_init(&rp->c_hash);
-	hlist_add_head(&rp->c_hash, hash_list + REQHASH(rp->c_xid));
+	hlist_move_head(&rp->c_hash, hash_list + REQHASH(rp->c_xid));
 }
 
 /*
kernel/kprobes.c +5 -5
Index: 2.6-git/kernel/kprobes.c
===================================================================
@@ -307,11 +307,11 @@ void __kprobes recycle_rp_inst(struct kr
 	/* remove rp inst off the rprobe_inst_table */
 	hlist_del(&ri->hlist);
 	if (ri->rp) {
-		/* remove rp inst off the used list */
-		hlist_del(&ri->uflist);
-		/* put rp inst back onto the free list */
-		INIT_HLIST_NODE(&ri->uflist);
-		hlist_add_head(&ri->uflist, &ri->rp->free_instances);
+		/*
+		 * remove rp inst off the used list
+		 * and put rp inst back onto the free list
+		 */ 
+		hlist_move_head(&ri->uflist, &ri->rp->free_instances);
 	} else
 		/* Unregistering */
 		kfree(ri);
net/core/dev.c +1 -2
Index: 2.6-git/net/core/dev.c
===================================================================
@@ -734,8 +734,7 @@ int dev_change_name(struct net_device *d
 
 	err = class_device_rename(&dev->class_dev, dev->name);
 	if (!err) {
-		hlist_del(&dev->name_hlist);
-		hlist_add_head(&dev->name_hlist, dev_name_hash(dev->name));
+		hlist_move_head(&dev->name_hlist, dev_name_hash(dev->name));
 		blocking_notifier_call_chain(&netdev_chain,
 				NETDEV_CHANGENAME, dev);
 	}
net/ipv4/fib_hash.c +1 -3
Index: 2.6-git/net/ipv4/fib_hash.c
===================================================================
@@ -124,10 +124,8 @@ static inline void fn_rebuild_zone(struc
 		hlist_for_each_entry_safe(f, node, n, &old_ht[i], fn_hash) {
 			struct hlist_head *new_head;
 
-			hlist_del(&f->fn_hash);
-
 			new_head = &fz->fz_hash[fn_hash(f->fn_key, fz)];
-			hlist_add_head(&f->fn_hash, new_head);
+			hlist_move_head(&f->fn_hash, new_head);
 		}
 	}
 }
net/ipv4/fib_semantics.c +2 -6
Index: 2.6-git/net/ipv4/fib_semantics.c
===================================================================
@@ -613,11 +613,9 @@ static void fib_hash_move(struct hlist_h
 			struct hlist_head *dest;
 			unsigned int new_hash;
 
-			hlist_del(&fi->fib_hash);
-
 			new_hash = fib_info_hashfn(fi);
 			dest = &new_info_hash[new_hash];
-			hlist_add_head(&fi->fib_hash, dest);
+			hlist_move_head(&fi->fib_hash, dest);
 		}
 	}
 	fib_info_hash = new_info_hash;
@@ -631,11 +629,9 @@ static void fib_hash_move(struct hlist_h
 			struct hlist_head *ldest;
 			unsigned int new_hash;
 
-			hlist_del(&fi->fib_lhash);
-
 			new_hash = fib_laddr_hashfn(fi->fib_prefsrc);
 			ldest = &new_laddrhash[new_hash];
-			hlist_add_head(&fi->fib_lhash, ldest);
+			hlist_move_head(&fi->fib_lhash, ldest);
 		}
 	}
 	fib_info_laddrhash = new_laddrhash;
net/ipv4/ip_fragment.c +1 -3
Index: 2.6-git/net/ipv4/ip_fragment.c
===================================================================
@@ -149,10 +149,8 @@ static void ipfrag_secret_rebuild(unsign
 						      q->daddr, q->protocol);
 
 			if (hval != i) {
-				hlist_del(&q->list);
-
 				/* Relink to new hash chain. */
-				hlist_add_head(&q->list, &ipq_hash[hval]);
+				hlist_move_head(&q->list, &ipq_hash[hval]);
 			}
 		}
 	}
net/ipv6/netfilter/nf_conntrack_reasm.c +1 -2
Index: 2.6-git/net/ipv6/netfilter/nf_conntrack_reasm.c
===================================================================
@@ -162,9 +162,8 @@ static void nf_ct_frag6_secret_rebuild(u
 						       &q->saddr,
 						       &q->daddr);
 			if (hval != i) {
-				hlist_del(&q->list);
 				/* Relink to new hash chain. */
-				hlist_add_head(&q->list,
+				hlist_move_head(&q->list,
 					       &nf_ct_frag6_hash[hval]);
 			}
 		}
net/ipv6/reassembly.c +1 -3
Index: 2.6-git/net/ipv6/reassembly.c
===================================================================
@@ -168,10 +168,8 @@ static void ip6_frag_secret_rebuild(unsi
 						       &q->daddr);
 
 			if (hval != i) {
-				hlist_del(&q->list);
-
 				/* Relink to new hash chain. */
-				hlist_add_head(&q->list,
+				hlist_move_head(&q->list,
 					       &ip6_frag_hash[hval]);
 
 			}
net/sunrpc/auth.c +3 -6
Index: 2.6-git/net/sunrpc/auth.c
===================================================================
@@ -149,8 +149,7 @@ rpcauth_free_credcache(struct rpc_auth *
 	for (i = 0; i < RPC_CREDCACHE_NR; i++) {
 		hlist_for_each_safe(pos, next, &cache->hashtable[i]) {
 			cred = hlist_entry(pos, struct rpc_cred, cr_hash);
-			__hlist_del(&cred->cr_hash);
-			hlist_add_head(&cred->cr_hash, &free);
+			hlist_move_head(&cred->cr_hash, &free);
 		}
 	}
 	spin_unlock(&rpc_credcache_lock);
@@ -164,10 +163,8 @@ rpcauth_prune_expired(struct rpc_auth *a
 	       return;
 	if (time_after(jiffies, cred->cr_expire + auth->au_credcache->expire))
 		cred->cr_flags &= ~RPCAUTH_CRED_UPTODATE;
-	if (!(cred->cr_flags & RPCAUTH_CRED_UPTODATE)) {
-		__hlist_del(&cred->cr_hash);
-		hlist_add_head(&cred->cr_hash, free);
-	}
+	if (!(cred->cr_flags & RPCAUTH_CRED_UPTODATE))
+		hlist_move_head(&cred->cr_hash, free);
 }
 
 /*

--

#3 lore raw

Re: [patch 2/8] use hlist_move_head()

Quoted 9 lines · Akinobu Mita

This patch converts the combination of hlist_del(A) and hlist_add_head(A, B) to hlist_move_head(A, B).

...

fs/nfsd/nfscache.c lru_put_end(struct svc_cacherep *rp) · line 117

Quoted 7 lines
fs/nfsd/nfscache.c +1 -2
@@ -113,8 +113,7 @@ lru_put_end(struct svc_cacherep *rp)
 static void
 hash_refile(struct svc_cacherep *rp)
 {
-	hlist_del_init(&rp->c_hash);
-	hlist_add_head(&rp->c_hash, hash_list + REQHASH(rp->c_xid));
+	hlist_move_head(&rp->c_hash, hash_list + REQHASH(rp->c_xid));
 }

Just got an oops here.

BUG: unable to handle kernel NULL pointer dereference at virtual address 00000000
 printing eip:
f8a06fde
*pde = 00000000
Oops: 0002 [#1]
SMP
last sysfs file: /devices/pci0000:00/0000:00:1f.3/i2c-0/0-0050/name
Modules linked in: usblp pcspkr nfsd exportfs lockd sunrpc parport_pc lp parport autofs video button battery ac
CPU:    0
EIP:    0060:[<f8a06fde>]    Not tainted VLI
EFLAGS: 00010246   (2.6.17-rc1-mm2 #88)

EIP is at hash_refile+0x20/0x3a [nfsd]
eax: 00000000 ebx: f7c07e1c ecx: f77b3180 edx: 00000000
esi: 00000006 edi: f8a26d38 ebp: f73eff08 esp: f73eff04
ds: 007b es: 007b ss: 0068
Process nfsd (pid: 2545, threadinfo=f73ef000 task=f7201000)

Stack: <0>f77b3180 f73eff3c f8a07146 f7c19a00 f7c19a40 00000002 00000008 00000003
       00000006 c6a1f621 00000000 f7c19a00 f7c19a00 f8a26d38 f73eff58 f89ff5b0
       f8a26b40 f05a7018 f7c19a64 f7c19a00 f8a26d38 f73effa8 f89a740f 00000075
Call Trace:
 <c0103379> show_stack_log_lvl+0x7d/0x99   <c01034fb> show_registers+0x127/0x182
 <c01036e6> die+0x11a/0x1ea   <c01121b6> do_page_fault+0x31c/0x607
 <c010304f> error_code+0x4f/0x54   <f8a07146> nfsd_cache_lookup+0x14e/0x2d2 [nfsd]
 <f89ff5b0> nfsd_dispatch+0x2a/0x1b2 [nfsd]   <f89a740f> svc_process+0x490/0x5f5 [sunrpc]
 <f89ff3e7> nfsd+0x174/0x313 [nfsd]   <c0100e8d> kernel_thread_helper+0x5/0xb
Code: ec a2 f8 89 0a 89 51 04 5b 5d c3 55 89 c1 8b 15 84 ec a2 f8 89 e5 53 0f b6 40 27 33 41 24 83 e0 3f 8d 1c 82 8b 51 04 8b 01 85 c0 <89> 02 74 03 89 50 04 8b 03 85 c0 89 01 74 03 89 48 04 89 0b 89
EIP: [<f8a06fde>] hash_refile+0x20/0x3a [nfsd] SS:ESP 0068:f73eff04

I don't think you've made an equivalent transformation here. hlist_del_init() won't call __hlist_del() if !n->pprev.

But if that was the problem, I'd have expected to see an access address of 0x00000004, not 0x00000000. Perhaps n->next is NULL as well.

#4 lore raw

Re: [patch 2/8] use hlist_move_head()

Quoted 7 lines · On Monday April 10, [email protected] wrote:
Quoted 6 lines · Akinobu Mita

This patch converts the combination of hlist_del(A) and hlist_add_head(A, B) to hlist_move_head(A, B).

...

Quoted 12 lines

fs/nfsd/nfscache.c lru_put_end(struct svc_cacherep *rp) · line 117

Quoted 10 lines
fs/nfsd/nfscache.c +1 -2
@@ -113,8 +113,7 @@ lru_put_end(struct svc_cacherep *rp)
 static void
 hash_refile(struct svc_cacherep *rp)
 {
-	hlist_del_init(&rp->c_hash);
-	hlist_add_head(&rp->c_hash, hash_list + REQHASH(rp->c_xid));
+	hlist_move_head(&rp->c_hash, hash_list + REQHASH(rp->c_xid));
 }

Just got an oops here.

Hmmm:
static inline void hlist_del_init(struct hlist_node *n)

{
	if (n->pprev)  {
		__hlist_del(n);
		INIT_HLIST_NODE(n);
	}
}

.....

static inline void hlist_move_head(struct hlist_node *n, struct hlist_head *h)

{
	__hlist_del(n);
	hlist_add_head(n, h);
}

I guess n->pprev was NULL

NeilBrown

Quoted 2 lines
BUG: unable to handle kernel NULL pointer dereference at virtual address 00000000
                                                                           ^^^^^^^^

Yep!

NeilBrown

#5 lore raw

PATCH 3/8 use list_add_tail() instead of list_add()

In reply to Akinobu Mita

This patch converts list_add(A, B.prev) to list_add_tail(A, &B) for readability.

CC Karsten Keil <[email protected]>
CC Jan Harkes <[email protected]>
CC Jan Kara <[email protected]>
CC David Woodhouse <[email protected]>
CC Sridhar Samudrala <[email protected]>
 drivers/isdn/capi/capi.c |    2 +-
 fs/coda/psdev.c          |    2 +-
 fs/coda/upcall.c         |    2 +-
 fs/dcache.c              |    2 +-
 fs/dquot.c               |    4 ++--
 fs/jffs2/compr.c         |    4 ++--
 net/sctp/outqueue.c      |    2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)
drivers/isdn/capi/capi.c +1 -1
Index: 2.6-git/drivers/isdn/capi/capi.c
===================================================================
@@ -238,7 +238,7 @@ static struct capiminor *capiminor_alloc
 		
 		if (minor < capi_ttyminors) {
 			mp->minor = minor;
-			list_add(&mp->list, p->list.prev);
+			list_add_tail(&mp->list, &p->list);
 		}
 	}
 		write_unlock_irqrestore(&capiminor_list_lock, flags);
fs/coda/psdev.c +1 -1
Index: 2.6-git/fs/coda/psdev.c
===================================================================
@@ -259,7 +259,7 @@ static ssize_t coda_psdev_read(struct fi
 	/* If request was not a signal, enqueue and don't free */
 	if (!(req->uc_flags & REQ_ASYNC)) {
 		req->uc_flags |= REQ_READ;
-		list_add(&(req->uc_chain), vcp->vc_processing.prev);
+		list_add_tail(&(req->uc_chain), &vcp->vc_processing);
 		goto out;
 	}
 
fs/coda/upcall.c +1 -1
Index: 2.6-git/fs/coda/upcall.c
===================================================================
@@ -725,7 +725,7 @@ static int coda_upcall(struct coda_sb_in
 	((union inputArgs *)buffer)->ih.unique = req->uc_unique;
 
 	/* Append msg to pending queue and poke Venus. */
-	list_add(&(req->uc_chain), vcommp->vc_pending.prev);
+	list_add_tail(&(req->uc_chain), &vcommp->vc_pending);
         
 	wake_up_interruptible(&vcommp->vc_waitq);
 	/* We can be interrupted while we wait for Venus to process
fs/dcache.c +1 -1
Index: 2.6-git/fs/dcache.c
===================================================================
@@ -584,7 +584,7 @@ resume:
 		 * of the unused list for prune_dcache
 		 */
 		if (!atomic_read(&dentry->d_count)) {
-			list_add(&dentry->d_lru, dentry_unused.prev);
+			list_add_tail(&dentry->d_lru, &dentry_unused);
 			dentry_stat.nr_unused++;
 			found++;
 		}
fs/dquot.c +2 -2
Index: 2.6-git/fs/dquot.c
===================================================================
@@ -250,7 +250,7 @@ static inline struct dquot *find_dquot(u
 /* Add a dquot to the tail of the free list */
 static inline void put_dquot_last(struct dquot *dquot)
 {
-	list_add(&dquot->dq_free, free_dquots.prev);
+	list_add_tail(&dquot->dq_free, &free_dquots);
 	dqstats.free_dquots++;
 }
 
@@ -266,7 +266,7 @@ static inline void put_inuse(struct dquo
 {
 	/* We add to the back of inuse list so we don't have to restart
 	 * when traversing this list and we block */
-	list_add(&dquot->dq_inuse, inuse_list.prev);
+	list_add_tail(&dquot->dq_inuse, &inuse_list);
 	dqstats.allocated_dquots++;
 }
 
fs/jffs2/compr.c +2 -2
Index: 2.6-git/fs/jffs2/compr.c
===================================================================
@@ -231,7 +231,7 @@ int jffs2_register_compressor(struct jff
 
         list_for_each_entry(this, &jffs2_compressor_list, list) {
                 if (this->priority < comp->priority) {
-                        list_add(&comp->list, this->list.prev);
+                        list_add_tail(&comp->list, &this->list);
                         goto out;
                 }
         }
@@ -394,7 +394,7 @@ reinsert:
         list_del(&comp->list);
         list_for_each_entry(this, &jffs2_compressor_list, list) {
                 if (this->priority < comp->priority) {
-                        list_add(&comp->list, this->list.prev);
+                        list_add_tail(&comp->list, &this->list);
                         spin_unlock(&jffs2_compressor_list_lock);
                         return 0;
                 }
net/sctp/outqueue.c +1 -1
Index: 2.6-git/net/sctp/outqueue.c
===================================================================
@@ -370,7 +370,7 @@ static void sctp_insert_list(struct list
 		lchunk = list_entry(pos, struct sctp_chunk, transmitted_list);
 		ltsn = ntohl(lchunk->subh.data_hdr->tsn);
 		if (TSN_lt(ntsn, ltsn)) {
-			list_add(new, pos->prev);
+			list_add_tail(new, pos);
 			done = 1;
 			break;
 		}

--

Acked-by on v1 3/8
#6 lore raw

Re: [patch 3/8] use list_add_tail() instead of list_add()

On Thu, Mar 30, 2006 at 04:16:08PM +0800, Akinobu Mita wrote:

This patch converts list_add(A, B.prev) to list_add_tail(A, &B) for readability.

for the ISDN/CAPI part.

CC Jan Harkes <[email protected]>
CC Jan Kara <[email protected]>
CC David Woodhouse <[email protected]>
CC Sridhar Samudrala <[email protected]>
 drivers/isdn/capi/capi.c |    2 +-
 fs/coda/psdev.c          |    2 +-
 fs/coda/upcall.c         |    2 +-
 fs/dcache.c              |    2 +-
 fs/dquot.c               |    4 ++--
 fs/jffs2/compr.c         |    4 ++--
 net/sctp/outqueue.c      |    2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)
drivers/isdn/capi/capi.c +1 -1
Index: 2.6-git/drivers/isdn/capi/capi.c
===================================================================
@@ -238,7 +238,7 @@ static struct capiminor *capiminor_alloc
 		
 		if (minor < capi_ttyminors) {
 			mp->minor = minor;
-			list_add(&mp->list, p->list.prev);
+			list_add_tail(&mp->list, &p->list);
 		}
 	}
 		write_unlock_irqrestore(&capiminor_list_lock, flags);
Signature · 3 lines
Karsten Keil
SuSE Labs
ISDN development
reviewer Acked-by on v1 3/8
#7 lore raw

Re: [patch 3/8] use list_add_tail() instead of list_add()

In reply to Akinobu Mita
Quoted 9 lines

This patch converts list_add(A, B.prev) to list_add_tail(A, &B) for readability.

CC Karsten Keil <[email protected]>
CC Jan Harkes <[email protected]>
CC Jan Kara <[email protected]>
CC David Woodhouse <[email protected]>
CC Sridhar Samudrala <[email protected]>

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SuSE CR Labs
#9 lore raw

Re: [patch 3/8] use list_add_tail() instead of list_add()

In reply to Akinobu Mita
Quoted 11 lines · Akinobu Mita

This patch converts list_add(A, B.prev) to list_add_tail(A, &B) for readability.

 drivers/isdn/capi/capi.c |    2 +-
 fs/coda/psdev.c          |    2 +-
 fs/coda/upcall.c         |    2 +-
 fs/dcache.c              |    2 +-
 fs/dquot.c               |    4 ++--
 fs/jffs2/compr.c         |    4 ++--
 net/sctp/outqueue.c      |    2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)

I realized that the replacements in isdn, jffs2, and sctp made them less readable. Because these are trying to insert the list node into right place, not trying to insert the tail of the list head.

This patch reverts them.

net/sctp/outqueue.c +1 -1
Index: 2.6-git/net/sctp/outqueue.c
===================================================================
@@ -370,7 +370,7 @@ static void sctp_insert_list(struct list
 		lchunk = list_entry(pos, struct sctp_chunk, transmitted_list);
 		ltsn = ntohl(lchunk->subh.data_hdr->tsn);
 		if (TSN_lt(ntsn, ltsn)) {
-			list_add_tail(new, pos);
+			list_add(new, pos->prev);
 			done = 1;
 			break;
 		}
drivers/isdn/capi/capi.c +1 -1
Index: 2.6-git/drivers/isdn/capi/capi.c
===================================================================
@@ -238,7 +238,7 @@ static struct capiminor *capiminor_alloc
 		
 		if (minor < capi_ttyminors) {
 			mp->minor = minor;
-			list_add_tail(&mp->list, &p->list);
+			list_add(&mp->list, p->list.prev);
 		}
 	}
 		write_unlock_irqrestore(&capiminor_list_lock, flags);
fs/jffs2/compr.c +2 -2
Index: 2.6-git/fs/jffs2/compr.c
===================================================================
@@ -231,7 +231,7 @@ int jffs2_register_compressor(struct jff
 
         list_for_each_entry(this, &jffs2_compressor_list, list) {
                 if (this->priority < comp->priority) {
-                        list_add_tail(&comp->list, &this->list);
+                        list_add(&comp->list, this->list.prev);
                         goto out;
                 }
         }
@@ -394,7 +394,7 @@ reinsert:
         list_del(&comp->list);
         list_for_each_entry(this, &jffs2_compressor_list, list) {
                 if (this->priority < comp->priority) {
-                        list_add_tail(&comp->list, &this->list);
+                        list_add(&comp->list, this->list.prev);
                         spin_unlock(&jffs2_compressor_list_lock);
                         return 0;
                 }
#10 lore raw

PATCH 4/8 arch: use list_move()

In reply to Akinobu Mita

This patch converts the combination of list_del(A) and list_add(A, B) to list_move(A, B) under arch/.

CC Geert Uytterhoeven <[email protected]>
CC "David S. Miller" <[email protected]>
 arch/i386/pci/pcbios.c    |    6 ++----
 arch/m68k/mm/memory.c     |    6 ++----
 arch/m68k/sun3/sun3dvma.c |    6 ++----
 arch/sparc64/kernel/pci.c |    6 ++----
 4 files changed, 8 insertions(+), 16 deletions(-)
arch/i386/pci/pcbios.c +2 -4
Index: 2.6-git/arch/i386/pci/pcbios.c
===================================================================
@@ -371,8 +371,7 @@ void __devinit pcibios_sort(void)
 			list_for_each(ln, &pci_devices) {
 				d = pci_dev_g(ln);
 				if (d->bus->number == bus && d->devfn == devfn) {
-					list_del(&d->global_list);
-					list_add_tail(&d->global_list, &sorted_devices);
+					list_move_tail(&d->global_list, &sorted_devices);
 					if (d == dev)
 						found = 1;
 					break;
@@ -390,8 +389,7 @@ void __devinit pcibios_sort(void)
 		if (!found) {
 			printk(KERN_WARNING "PCI: Device %s not found by BIOS\n",
 				pci_name(dev));
-			list_del(&dev->global_list);
-			list_add_tail(&dev->global_list, &sorted_devices);
+			list_move_tail(&dev->global_list, &sorted_devices);
 		}
 	}
 	list_splice(&sorted_devices, &pci_devices);
arch/m68k/mm/memory.c +2 -4
Index: 2.6-git/arch/m68k/mm/memory.c
===================================================================
@@ -94,8 +94,7 @@ pmd_t *get_pointer_table (void)
 	PD_MARKBITS(dp) = mask & ~tmp;
 	if (!PD_MARKBITS(dp)) {
 		/* move to end of list */
-		list_del(dp);
-		list_add_tail(dp, &ptable_list);
+		list_move_tail(dp, &ptable_list);
 	}
 	return (pmd_t *) (page_address(PD_PAGE(dp)) + off);
 }
@@ -123,8 +122,7 @@ int free_pointer_table (pmd_t *ptable)
 		 * move this descriptor to the front of the list, since
 		 * it has one or more free tables.
 		 */
-		list_del(dp);
-		list_add(dp, &ptable_list);
+		list_move(dp, &ptable_list);
 	}
 	return 0;
 }
arch/m68k/sun3/sun3dvma.c +2 -4
Index: 2.6-git/arch/m68k/sun3/sun3dvma.c
===================================================================
@@ -119,8 +119,7 @@ static inline int refill(void)
 		if(hole->end == prev->start) {
 			hole->size += prev->size;
 			hole->end = prev->end;
-			list_del(&(prev->list));
-			list_add(&(prev->list), &hole_cache);
+			list_move(&(prev->list), &hole_cache);
 			ret++;
 		}
 
@@ -182,8 +181,7 @@ static inline unsigned long get_baddr(in
 #endif
 			return hole->end;
 		} else if(hole->size == newlen) {
-			list_del(&(hole->list));
-			list_add(&(hole->list), &hole_cache);
+			list_move(&(hole->list), &hole_cache);
 			dvma_entry_use(hole->start) = newlen;
 #ifdef DVMA_DEBUG
 			dvma_allocs++;
arch/sparc64/kernel/pci.c +2 -4
Index: 2.6-git/arch/sparc64/kernel/pci.c
===================================================================
@@ -328,10 +328,8 @@ static void __init pci_reorder_devs(void
 		struct pci_dev *pdev = pci_dev_g(walk);
 		struct list_head *walk_next = walk->next;
 
-		if (pdev->irq && (__irq_ino(pdev->irq) & 0x20)) {
-			list_del(walk);
-			list_add(walk, pci_onboard);
-		}
+		if (pdev->irq && (__irq_ino(pdev->irq) & 0x20))
+			list_move(walk, pci_onboard);
 
 		walk = walk_next;
 	}

--

#11 lore raw

PATCH 5/8 core: use list_move()

In reply to Akinobu Mita

This patch converts the combination of list_del(A) and list_add(A, B) to list_move(A, B).

CC Greg Kroah-Hartman <[email protected]>
CC Ram Pai <[email protected]>
 drivers/base/power/resume.c  |    6 ++----
 drivers/base/power/suspend.c |   13 +++++--------
 fs/dcache.c                  |    3 +--
 fs/libfs.c                   |   10 ++++------
 fs/namespace.c               |    6 ++----
 fs/pnode.c                   |    9 +++------
 fs/sysfs/dir.c               |   10 ++++------
 mm/swap.c                    |    3 +--
 8 files changed, 22 insertions(+), 38 deletions(-)
fs/dcache.c +1 -2
Index: 2.6-git/fs/dcache.c
===================================================================
@@ -468,8 +468,7 @@ void shrink_dcache_sb(struct super_block
 		dentry = list_entry(tmp, struct dentry, d_lru);
 		if (dentry->d_sb != sb)
 			continue;
-		list_del(tmp);
-		list_add(tmp, &dentry_unused);
+		list_move(tmp, &dentry_unused);
 	}
 
 	/*
fs/libfs.c +4 -6
Index: 2.6-git/fs/libfs.c
===================================================================
@@ -149,10 +149,9 @@ int dcache_readdir(struct file * filp, v
 			/* fallthrough */
 		default:
 			spin_lock(&dcache_lock);
-			if (filp->f_pos == 2) {
-				list_del(q);
-				list_add(q, &dentry->d_subdirs);
-			}
+			if (filp->f_pos == 2)
+				list_move(q, &dentry->d_subdirs);
+
 			for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
 				struct dentry *next;
 				next = list_entry(p, struct dentry, d_u.d_child);
@@ -164,8 +163,7 @@ int dcache_readdir(struct file * filp, v
 					return 0;
 				spin_lock(&dcache_lock);
 				/* next is still alive */
-				list_del(q);
-				list_add(q, p);
+				list_move(q, p);
 				p = q;
 				filp->f_pos++;
 			}
fs/namespace.c +2 -4
Index: 2.6-git/fs/namespace.c
===================================================================
@@ -517,10 +517,8 @@ void umount_tree(struct vfsmount *mnt, i
 {
 	struct vfsmount *p;
 
-	for (p = mnt; p; p = next_mnt(p, mnt)) {
-		list_del(&p->mnt_hash);
-		list_add(&p->mnt_hash, kill);
-	}
+	for (p = mnt; p; p = next_mnt(p, mnt))
+		list_move(&p->mnt_hash, kill);
 
 	if (propagate)
 		propagate_umount(kill);
fs/pnode.c +3 -6
Index: 2.6-git/fs/pnode.c
===================================================================
@@ -53,8 +53,7 @@ static int do_make_slave(struct vfsmount
 	if (master) {
 		list_for_each_entry(slave_mnt, &mnt->mnt_slave_list, mnt_slave)
 			slave_mnt->mnt_master = master;
-		list_del(&mnt->mnt_slave);
-		list_add(&mnt->mnt_slave, &master->mnt_slave_list);
+		list_move(&mnt->mnt_slave, &master->mnt_slave_list);
 		list_splice(&mnt->mnt_slave_list, master->mnt_slave_list.prev);
 		INIT_LIST_HEAD(&mnt->mnt_slave_list);
 	} else {
@@ -283,10 +282,8 @@ static void __propagate_umount(struct vf
 		 * umount the child only if the child has no
 		 * other children
 		 */
-		if (child && list_empty(&child->mnt_mounts)) {
-			list_del(&child->mnt_hash);
-			list_add_tail(&child->mnt_hash, &mnt->mnt_hash);
-		}
+		if (child && list_empty(&child->mnt_mounts))
+			list_move_tail(&child->mnt_hash, &mnt->mnt_hash);
 	}
 }
 
fs/sysfs/dir.c +4 -6
Index: 2.6-git/fs/sysfs/dir.c
===================================================================
@@ -429,10 +429,9 @@ static int sysfs_readdir(struct file * f
 			i++;
 			/* fallthrough */
 		default:
-			if (filp->f_pos == 2) {
-				list_del(q);
-				list_add(q, &parent_sd->s_children);
-			}
+			if (filp->f_pos == 2)
+				list_move(q, &parent_sd->s_children);
+
 			for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
 				struct sysfs_dirent *next;
 				const char * name;
@@ -454,8 +453,7 @@ static int sysfs_readdir(struct file * f
 						 dt_type(next)) < 0)
 					return 0;
 
-				list_del(q);
-				list_add(q, p);
+				list_move(q, p);
 				p = q;
 				filp->f_pos++;
 			}
mm/swap.c +1 -2
Index: 2.6-git/mm/swap.c
===================================================================
@@ -86,8 +86,7 @@ int rotate_reclaimable_page(struct page 
 	zone = page_zone(page);
 	spin_lock_irqsave(&zone->lru_lock, flags);
 	if (PageLRU(page) && !PageActive(page)) {
-		list_del(&page->lru);
-		list_add_tail(&page->lru, &zone->inactive_list);
+		list_move_tail(&page->lru, &zone->inactive_list);
 		inc_page_state(pgrotated);
 	}
 	if (!test_clear_page_writeback(page))
drivers/base/power/resume.c +2 -4
Index: 2.6-git/drivers/base/power/resume.c
===================================================================
@@ -49,8 +49,7 @@ void dpm_resume(void)
 		struct device * dev = to_device(entry);
 
 		get_device(dev);
-		list_del_init(entry);
-		list_add_tail(entry, &dpm_active);
+		list_move_tail(entry, &dpm_active);
 
 		up(&dpm_list_sem);
 		if (!dev->power.prev_state.event)
@@ -97,8 +96,7 @@ void dpm_power_up(void)
 		struct device * dev = to_device(entry);
 
 		get_device(dev);
-		list_del_init(entry);
-		list_add_tail(entry, &dpm_active);
+		list_move_tail(entry, &dpm_active);
 		resume_device(dev);
 		put_device(dev);
 	}
drivers/base/power/suspend.c +5 -8
Index: 2.6-git/drivers/base/power/suspend.c
===================================================================
@@ -101,12 +101,10 @@ int device_suspend(pm_message_t state)
 		/* Check if the device got removed */
 		if (!list_empty(&dev->power.entry)) {
 			/* Move it to the dpm_off or dpm_off_irq list */
-			if (!error) {
-				list_del(&dev->power.entry);
-				list_add(&dev->power.entry, &dpm_off);
-			} else if (error == -EAGAIN) {
-				list_del(&dev->power.entry);
-				list_add(&dev->power.entry, &dpm_off_irq);
+			if (!error)
+				list_move(&dev->power.entry, &dpm_off);
+			else if (error == -EAGAIN) {
+				list_move(&dev->power.entry, &dpm_off_irq);
 				error = 0;
 			}
 		}
@@ -124,8 +122,7 @@ int device_suspend(pm_message_t state)
 		 */
 		while (!list_empty(&dpm_off_irq)) {
 			struct list_head * entry = dpm_off_irq.next;
-			list_del(entry);
-			list_add(entry, &dpm_off);
+			list_move(entry, &dpm_off);
 		}
 		dpm_resume();
 	}

--

#12 lore raw

PATCH 6/8 net/rxrpc: use list_move()

In reply to Akinobu Mita

This patch converts the combination of list_del(A) and list_add(A, B) to list_move(A, B) under net/rxrpc.

 net/rxrpc/call.c       |    3 +--
 net/rxrpc/connection.c |    3 +--
 net/rxrpc/krxsecd.c    |    3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)
net/rxrpc/call.c +1 -2
Index: 2.6-git/net/rxrpc/call.c
===================================================================
@@ -1098,8 +1098,7 @@ static void rxrpc_call_receive_data_pack
 
 		call->app_ready_seq = pmsg->seq;
 		call->app_ready_qty += pmsg->dsize;
-		list_del_init(&pmsg->link);
-		list_add_tail(&pmsg->link, &call->app_readyq);
+		list_move_tail(&pmsg->link, &call->app_readyq);
 	}
 
 	/* see if we've got the last packet yet */
net/rxrpc/connection.c +1 -2
Index: 2.6-git/net/rxrpc/connection.c
===================================================================
@@ -402,8 +402,7 @@ void rxrpc_put_connection(struct rxrpc_c
 
 	/* move to graveyard queue */
 	_debug("burying connection: {%08x}", ntohl(conn->conn_id));
-	list_del(&conn->link);
-	list_add_tail(&conn->link, &peer->conn_graveyard);
+	list_move_tail(&conn->link, &peer->conn_graveyard);
 
 	rxrpc_krxtimod_add_timer(&conn->timeout, rxrpc_conn_timeout * HZ);
 
net/rxrpc/krxsecd.c +1 -2
Index: 2.6-git/net/rxrpc/krxsecd.c
===================================================================
@@ -160,8 +160,7 @@ void rxrpc_krxsecd_clear_transport(struc
 	list_for_each_safe(_p, _n, &rxrpc_krxsecd_initmsgq) {
 		msg = list_entry(_p, struct rxrpc_message, link);
 		if (msg->trans == trans) {
-			list_del(&msg->link);
-			list_add_tail(&msg->link, &tmp);
+			list_move_tail(&msg->link, &tmp);
 			atomic_dec(&rxrpc_krxsecd_qcount);
 		}
 	}

--

maintainer Acked-by on v1 6/8
#13 lore raw

Re: [patch 6/8] net/rxrpc: use list_move()

Quoted 2 lines · Akinobu Mita

This patch converts the combination of list_del(A) and list_add(A, B) to list_move(A, B) under net/rxrpc.

#14 lore raw

PATCH 7/8 drivers: use list_move()

In reply to Akinobu Mita

This patch converts the combination of list_del(A) and list_add(A, B) to list_move(A, B) under drivers/.

CC Corey Minyard <[email protected]>
CC Ben Collins <[email protected]>
CC Roland Dreier <[email protected]>
CC Alasdair Kergon <[email protected]>
CC Gerd Knorr <[email protected]>
CC Paul Mackerras <[email protected]>
CC Frank Pavlic <[email protected]>
CC Matthew Wilcox <[email protected]>
CC Andrew Vasquez <[email protected]>
CC Mikael Starvik <[email protected]>
CC Greg Kroah-Hartman <[email protected]>
 drivers/char/ipmi/ipmi_msghandler.c            |    7 +++----
 drivers/ieee1394/eth1394.c                     |    3 +--
 drivers/ieee1394/raw1394.c                     |    3 +--
 drivers/infiniband/core/mad.c                  |    9 +++------
 drivers/infiniband/core/mad_rmpp.c             |    3 +--
 drivers/infiniband/ulp/ipoib/ipoib_ib.c        |    7 +++----
 drivers/infiniband/ulp/ipoib/ipoib_multicast.c |    6 ++----
 drivers/md/dm-raid1.c                          |    6 ++----
 drivers/media/video/cx88/cx88-video.c          |    6 ++----
 drivers/net/ppp_generic.c                      |    3 +--
 drivers/s390/net/lcs.c                         |    7 +++----
 drivers/scsi/ncr53c8xx.c                       |    3 +--
 drivers/scsi/qla2xxx/qla_init.c                |    3 +--
 drivers/usb/host/hc_crisv10.c                  |    3 +--
 drivers/usb/serial/whiteheat.c                 |   19 +++++++------------
 15 files changed, 32 insertions(+), 56 deletions(-)
drivers/char/ipmi/ipmi_msghandler.c +3 -4
Index: 2.6-git/drivers/char/ipmi/ipmi_msghandler.c
===================================================================
@@ -936,10 +936,9 @@ int ipmi_set_gets_events(ipmi_user_t use
 
 	if (val) {
 		/* Deliver any queued events. */
-		list_for_each_entry_safe(msg, msg2, &intf->waiting_events, link) {
-			list_del(&msg->link);
-			list_add_tail(&msg->link, &msgs);
-		}
+		list_for_each_entry_safe(msg, msg2, &intf->waiting_events, link)
+			list_move_tail(&msg->link, &msgs);
+
 	}
 
 	/* Hold the events lock while doing this to preserve order. */
drivers/ieee1394/eth1394.c +1 -2
Index: 2.6-git/drivers/ieee1394/eth1394.c
===================================================================
@@ -1079,8 +1079,7 @@ static inline int update_partial_datagra
 
 	/* Move list entry to beginnig of list so that oldest partial
 	 * datagrams percolate to the end of the list */
-	list_del(lh);
-	list_add(lh, pdgl);
+	list_move(lh, pdgl);
 
 	return 0;
 }
drivers/ieee1394/raw1394.c +1 -2
Index: 2.6-git/drivers/ieee1394/raw1394.c
===================================================================
@@ -132,8 +132,7 @@ static void free_pending_request(struct 
 static void __queue_complete_req(struct pending_request *req)
 {
 	struct file_info *fi = req->file_info;
-	list_del(&req->list);
-	list_add_tail(&req->list, &fi->req_complete);
+	list_move_tail(&req->list, &fi->req_complete);
 
 	up(&fi->complete_sem);
 	wake_up_interruptible(&fi->poll_wait_complete);
drivers/infiniband/core/mad.c +3 -6
Index: 2.6-git/drivers/infiniband/core/mad.c
===================================================================
@@ -1648,11 +1648,9 @@ ib_find_send_mad(struct ib_mad_agent_pri
 void ib_mark_mad_done(struct ib_mad_send_wr_private *mad_send_wr)
 {
 	mad_send_wr->timeout = 0;
-	if (mad_send_wr->refcount == 1) {
-		list_del(&mad_send_wr->agent_list);
-		list_add_tail(&mad_send_wr->agent_list,
+	if (mad_send_wr->refcount == 1)
+		list_move_tail(&mad_send_wr->agent_list,
 			      &mad_send_wr->mad_agent_priv->done_list);
-	}
 }
 
 static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,
@@ -1977,8 +1975,7 @@ retry:
 		queued_send_wr = container_of(mad_list,
 					struct ib_mad_send_wr_private,
 					mad_list);
-		list_del(&mad_list->list);
-		list_add_tail(&mad_list->list, &send_queue->list);
+		list_move_tail(&mad_list->list, &send_queue->list);
 	}
 	spin_unlock_irqrestore(&send_queue->lock, flags);
 
drivers/infiniband/core/mad_rmpp.c +1 -2
Index: 2.6-git/drivers/infiniband/core/mad_rmpp.c
===================================================================
@@ -679,8 +679,7 @@ static void process_rmpp_ack(struct ib_m
 			goto out;
 
 		mad_send_wr->refcount++;
-		list_del(&mad_send_wr->agent_list);
-		list_add_tail(&mad_send_wr->agent_list,
+		list_move_tail(&mad_send_wr->agent_list,
 			      &mad_send_wr->mad_agent_priv->send_list);
 	}
 out:
drivers/infiniband/ulp/ipoib/ipoib_ib.c +3 -4
Index: 2.6-git/drivers/infiniband/ulp/ipoib/ipoib_ib.c
===================================================================
@@ -378,10 +378,9 @@ static void __ipoib_reap_ah(struct net_d
 
 	spin_lock_irq(&priv->lock);
 	list_for_each_entry_safe(ah, tah, &priv->dead_ahs, list)
-		if ((int) priv->tx_tail - (int) ah->last_send >= 0) {
-			list_del(&ah->list);
-			list_add_tail(&ah->list, &remove_list);
-		}
+		if ((int) priv->tx_tail - (int) ah->last_send >= 0)
+			list_move_tail(&ah->list, &remove_list);
+
 	spin_unlock_irq(&priv->lock);
 
 	list_for_each_entry_safe(ah, tah, &remove_list, list) {
drivers/infiniband/ulp/ipoib/ipoib_multicast.c +2 -4
Index: 2.6-git/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
===================================================================
@@ -877,8 +877,7 @@ void ipoib_mcast_restart_task(void *dev_
 
 			if (mcast) {
 				/* Destroy the send only entry */
-				list_del(&mcast->list);
-				list_add_tail(&mcast->list, &remove_list);
+				list_move_tail(&mcast->list, &remove_list);
 
 				rb_replace_node(&mcast->rb_node,
 						&nmcast->rb_node,
@@ -903,8 +902,7 @@ void ipoib_mcast_restart_task(void *dev_
 			rb_erase(&mcast->rb_node, &priv->multicast_tree);
 
 			/* Move to the remove list */
-			list_del(&mcast->list);
-			list_add_tail(&mcast->list, &remove_list);
+			list_move_tail(&mcast->list, &remove_list);
 		}
 	}
 
drivers/md/dm-raid1.c +2 -4
Index: 2.6-git/drivers/md/dm-raid1.c
===================================================================
@@ -458,11 +458,9 @@ static int __rh_recovery_prepare(struct 
 	/* Already quiesced ? */
 	if (atomic_read(&reg->pending))
 		list_del_init(&reg->list);
+	else
+		list_move(&reg->list, &rh->quiesced_regions);
 
-	else {
-		list_del_init(&reg->list);
-		list_add(&reg->list, &rh->quiesced_regions);
-	}
 	spin_unlock_irq(&rh->region_lock);
 
 	return 1;
drivers/media/video/cx88/cx88-video.c +2 -4
Index: 2.6-git/drivers/media/video/cx88/cx88-video.c
===================================================================
@@ -492,8 +492,7 @@ static int restart_video_queue(struct cx
 			return 0;
 		buf = list_entry(q->queued.next, struct cx88_buffer, vb.queue);
 		if (NULL == prev) {
-			list_del(&buf->vb.queue);
-			list_add_tail(&buf->vb.queue,&q->active);
+			list_move_tail(&buf->vb.queue, &q->active);
 			start_video_dma(dev, q, buf);
 			buf->vb.state = STATE_ACTIVE;
 			buf->count    = q->count++;
@@ -504,8 +503,7 @@ static int restart_video_queue(struct cx
 		} else if (prev->vb.width  == buf->vb.width  &&
 			   prev->vb.height == buf->vb.height &&
 			   prev->fmt       == buf->fmt) {
-			list_del(&buf->vb.queue);
-			list_add_tail(&buf->vb.queue,&q->active);
+			list_move_tail(&buf->vb.queue, &q->active);
 			buf->vb.state = STATE_ACTIVE;
 			buf->count    = q->count++;
 			prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
drivers/net/ppp_generic.c +1 -2
Index: 2.6-git/drivers/net/ppp_generic.c
===================================================================
@@ -2580,8 +2580,7 @@ ppp_find_channel(int unit)
 
 	list_for_each_entry(pch, &new_channels, list) {
 		if (pch->file.index == unit) {
-			list_del(&pch->list);
-			list_add(&pch->list, &all_channels);
+			list_move(&pch->list, &all_channels);
 			return pch;
 		}
 	}
drivers/s390/net/lcs.c +3 -4
Index: 2.6-git/drivers/s390/net/lcs.c
===================================================================
@@ -1145,10 +1145,9 @@ list_modified:
 		}
 	}
 	/* re-insert all entries from the failed_list into ipm_list */
-	list_for_each_entry_safe(ipm, tmp, &failed_list, list) {
-		list_del_init(&ipm->list);
-		list_add_tail(&ipm->list, &card->ipm_list);
-	}
+	list_for_each_entry_safe(ipm, tmp, &failed_list, list)
+		list_move_tail(&ipm->list, &card->ipm_list);
+
 	spin_unlock_irqrestore(&card->ipm_lock, flags);
 	if (card->state == DEV_STATE_UP)
 		netif_wake_queue(card->dev);
drivers/scsi/ncr53c8xx.c +1 -2
Index: 2.6-git/drivers/scsi/ncr53c8xx.c
===================================================================
@@ -5118,8 +5118,7 @@ static void ncr_ccb_skipped(struct ncb *
 		cp->host_status &= ~HS_SKIPMASK;
 		cp->start.schedule.l_paddr = 
 			cpu_to_scr(NCB_SCRIPT_PHYS (np, select));
-		list_del(&cp->link_ccbq);
-		list_add_tail(&cp->link_ccbq, &lp->skip_ccbq);
+		list_move_tail(&cp->link_ccbq, &lp->skip_ccbq);
 		if (cp->queued) {
 			--lp->queuedccbs;
 		}
drivers/scsi/qla2xxx/qla_init.c +1 -2
Index: 2.6-git/drivers/scsi/qla2xxx/qla_init.c
===================================================================
@@ -2273,8 +2273,7 @@ qla2x00_configure_fabric(scsi_qla_host_t
 			}
 
 			/* Remove device from the new list and add it to DB */
-			list_del(&fcport->list);
-			list_add_tail(&fcport->list, &ha->fcports);
+			list_move_tail(&fcport->list, &ha->fcports);
 
 			/* Login and update database */
 			qla2x00_fabric_dev_login(ha, fcport, &next_loopid);
drivers/usb/host/hc_crisv10.c +1 -2
Index: 2.6-git/drivers/usb/host/hc_crisv10.c
===================================================================
@@ -411,8 +411,7 @@ static inline void urb_list_move_last(st
 	urb_entry_t *urb_entry = __urb_list_entry(urb, epid);
 	assert(urb_entry);
 
-	list_del(&urb_entry->list);
-	list_add_tail(&urb_entry->list, &urb_list[epid]);
+	list_move_tail(&urb_entry->list, &urb_list[epid]);
 }
 
 /* Get the next urb in the list. */
drivers/usb/serial/whiteheat.c +7 -12
Index: 2.6-git/drivers/usb/serial/whiteheat.c
===================================================================
@@ -685,19 +685,16 @@ static void whiteheat_close(struct usb_s
 		wrap = list_entry(tmp, struct whiteheat_urb_wrap, list);
 		urb = wrap->urb;
 		usb_kill_urb(urb);
-		list_del(tmp);
-		list_add(tmp, &info->rx_urbs_free);
-	}
-	list_for_each_safe(tmp, tmp2, &info->rx_urb_q) {
-		list_del(tmp);
-		list_add(tmp, &info->rx_urbs_free);
+		list_move(tmp, &info->rx_urbs_free);
 	}
+	list_for_each_safe(tmp, tmp2, &info->rx_urb_q)
+		list_move(tmp, &info->rx_urbs_free);
+
 	list_for_each_safe(tmp, tmp2, &info->tx_urbs_submitted) {
 		wrap = list_entry(tmp, struct whiteheat_urb_wrap, list);
 		urb = wrap->urb;
 		usb_kill_urb(urb);
-		list_del(tmp);
-		list_add(tmp, &info->tx_urbs_free);
+		list_move(tmp, &info->tx_urbs_free);
 	}
 	spin_unlock_irqrestore(&info->lock, flags);
 
@@ -1079,8 +1076,7 @@ static void whiteheat_write_callback(str
 		err("%s - Not my urb!", __FUNCTION__);
 		return;
 	}
-	list_del(&wrap->list);
-	list_add(&wrap->list, &info->tx_urbs_free);
+	list_move(&wrap->list, &info->tx_urbs_free);
 	spin_unlock(&info->lock);
 
 	if (urb->status) {
@@ -1372,8 +1368,7 @@ static int start_port_read(struct usb_se
 				wrap = list_entry(tmp, struct whiteheat_urb_wrap, list);
 				urb = wrap->urb;
 				usb_kill_urb(urb);
-				list_del(tmp);
-				list_add(tmp, &info->rx_urbs_free);
+				list_move(tmp, &info->rx_urbs_free);
 			}
 			break;
 		}

--

#15 lore raw

Re: [patch 7/8] drivers: use list_move()

Quoted 7 lines · Akinobu Mita
 drivers/scsi/ncr53c8xx.c                       |    3 +--

Index: 2.6-git/drivers/scsi/ncr53c8xx.c
===================================================================

drivers/scsi/ncr53c8xx.c static void ncr_ccb_skipped(struct ncb * · line 5124

Quoted 9 lines
drivers/scsi/ncr53c8xx.c +1 -2
@@ -5118,8 +5118,7 @@ static void ncr_ccb_skipped(struct ncb *
 		cp->host_status &= ~HS_SKIPMASK;
 		cp->start.schedule.l_paddr = 
 			cpu_to_scr(NCB_SCRIPT_PHYS (np, select));
-		list_del(&cp->link_ccbq);
-		list_add_tail(&cp->link_ccbq, &lp->skip_ccbq);
+		list_move_tail(&cp->link_ccbq, &lp->skip_ccbq);
 		if (cp->queued) {
 			--lp->queuedccbs;
 		}

ACK. Thanks!

#16 lore raw

PATCH 8/8 fs: use list_move()

In reply to Akinobu Mita

This patch converts the combination of list_del(A) and list_add(A, B) to list_move(A, B) under fs/.

CC Ian Kent <[email protected]>
CC Joel Becker <[email protected]>
CC Neil Brown <[email protected]>
CC Hans Reiser <[email protected]>
CC Urban Widmark <[email protected]>
CC David Howells <[email protected]>
CC Mark Fasheh <[email protected]>
 fs/afs/cell.c              |    3 +--
 fs/afs/kafsasyncd.c        |    9 +++------
 fs/afs/server.c            |    6 ++----
 fs/afs/vlocation.c         |    6 ++----
 fs/afs/vnode.c             |    3 +--
 fs/autofs4/expire.c        |    3 +--
 fs/configfs/dir.c          |    6 ++----
 fs/jffs2/erase.c           |   15 +++++----------
 fs/jffs2/nodemgmt.c        |    3 +--
 fs/jffs2/wbuf.c            |    3 +--
 fs/nfsd/nfs4state.c        |    3 +--
 fs/nfsd/nfscache.c         |    3 +--
 fs/ocfs2/dlm/dlmast.c      |    3 +--
 fs/ocfs2/dlm/dlmconvert.c  |    9 +++------
 fs/ocfs2/dlm/dlmlock.c     |    3 +--
 fs/ocfs2/dlm/dlmrecovery.c |    9 +++------
 fs/ocfs2/dlm/dlmthread.c   |    6 ++----
 fs/ocfs2/dlm/dlmunlock.c   |    3 +--
 fs/ocfs2/journal.c         |    3 +--
 fs/reiserfs/journal.c      |    6 ++----
 fs/smbfs/request.c         |    6 ++----
 fs/smbfs/smbiod.c          |    3 +--
 22 files changed, 38 insertions(+), 76 deletions(-)
fs/autofs4/expire.c +1 -2
Index: 2.6-git/fs/autofs4/expire.c
===================================================================
@@ -370,8 +370,7 @@ next:
 		DPRINTK("returning %p %.*s",
 			expired, (int)expired->d_name.len, expired->d_name.name);
 		spin_lock(&dcache_lock);
-		list_del(&expired->d_parent->d_subdirs);
-		list_add(&expired->d_parent->d_subdirs, &expired->d_u.d_child);
+		list_move(&expired->d_parent->d_subdirs, &expired->d_u.d_child);
 		spin_unlock(&dcache_lock);
 		return expired;
 	}
fs/configfs/dir.c +2 -4
Index: 2.6-git/fs/configfs/dir.c
===================================================================
@@ -954,8 +954,7 @@ static int configfs_readdir(struct file 
 			/* fallthrough */
 		default:
 			if (filp->f_pos == 2) {
-				list_del(q);
-				list_add(q, &parent_sd->s_children);
+				list_move(q, &parent_sd->s_children);
 			}
 			for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
 				struct configfs_dirent *next;
@@ -978,8 +977,7 @@ static int configfs_readdir(struct file 
 						 dt_type(next)) < 0)
 					return 0;
 
-				list_del(q);
-				list_add(q, p);
+				list_move(q, p);
 				p = q;
 				filp->f_pos++;
 			}
fs/nfsd/nfs4state.c +1 -2
Index: 2.6-git/fs/nfsd/nfs4state.c
===================================================================
@@ -482,8 +482,7 @@ move_to_confirmed(struct nfs4_client *cl
 
 	dprintk("NFSD: move_to_confirm nfs4_client %p\n", clp);
 	list_del_init(&clp->cl_strhash);
-	list_del_init(&clp->cl_idhash);
-	list_add(&clp->cl_idhash, &conf_id_hashtbl[idhashval]);
+	list_move(&clp->cl_idhash, &conf_id_hashtbl[idhashval]);
 	strhashval = clientstr_hashval(clp->cl_recdir);
 	list_add(&clp->cl_strhash, &conf_str_hashtbl[strhashval]);
 	renew_client(clp);
fs/nfsd/nfscache.c +1 -2
Index: 2.6-git/fs/nfsd/nfscache.c
===================================================================
@@ -103,8 +103,7 @@ nfsd_cache_shutdown(void)
 static void
 lru_put_end(struct svc_cacherep *rp)
 {
-	list_del(&rp->c_lru);
-	list_add_tail(&rp->c_lru, &lru_head);
+	list_move_tail(&rp->c_lru, &lru_head);
 }
 
 /*
fs/reiserfs/journal.c +2 -4
Index: 2.6-git/fs/reiserfs/journal.c
===================================================================
@@ -834,8 +834,7 @@ static int write_ordered_buffers(spinloc
 		get_bh(bh);
 		if (test_set_buffer_locked(bh)) {
 			if (!buffer_dirty(bh)) {
-				list_del_init(&jh->list);
-				list_add(&jh->list, &tmp);
+				list_move(&jh->list, &tmp);
 				goto loop_next;
 			}
 			spin_unlock(lock);
@@ -855,8 +854,7 @@ static int write_ordered_buffers(spinloc
 			ret = -EIO;
 		}
 		if (buffer_dirty(bh)) {
-			list_del_init(&jh->list);
-			list_add(&jh->list, &tmp);
+			list_move(&jh->list, &tmp);
 			add_to_chunk(&chunk, bh, lock, write_ordered_chunk);
 		} else {
 			reiserfs_free_jh(bh);
fs/smbfs/request.c +2 -4
Index: 2.6-git/fs/smbfs/request.c
===================================================================
@@ -398,8 +398,7 @@ static int smb_request_send_req(struct s
 	if (!(req->rq_flags & SMB_REQ_TRANSMITTED))
 		goto out;
 
-	list_del_init(&req->rq_queue);
-	list_add_tail(&req->rq_queue, &server->recvq);
+	list_move_tail(&req->rq_queue, &server->recvq);
 	result = 1;
 out:
 	return result;
@@ -433,8 +432,7 @@ int smb_request_send_server(struct smb_s
 	result = smb_request_send_req(req);
 	if (result < 0) {
 		server->conn_error = result;
-		list_del_init(&req->rq_queue);
-		list_add(&req->rq_queue, &server->xmitq);
+		list_move(&req->rq_queue, &server->xmitq);
 		result = -EIO;
 		goto out;
 	}
fs/smbfs/smbiod.c +1 -2
Index: 2.6-git/fs/smbfs/smbiod.c
===================================================================
@@ -183,8 +183,7 @@ int smbiod_retry(struct smb_sb_info *ser
 		if (req->rq_flags & SMB_REQ_RETRY) {
 			/* must move the request to the xmitq */
 			VERBOSE("retrying request %p on recvq\n", req);
-			list_del(&req->rq_queue);
-			list_add(&req->rq_queue, &server->xmitq);
+			list_move(&req->rq_queue, &server->xmitq);
 			continue;
 		}
 #endif
fs/afs/cell.c +1 -2
Index: 2.6-git/fs/afs/cell.c
===================================================================
@@ -413,8 +413,7 @@ int afs_server_find_by_peer(const struct
 
 	/* we found it in the graveyard - resurrect it */
  found_dead_server:
-	list_del(&server->link);
-	list_add_tail(&server->link, &cell->sv_list);
+	list_move_tail(&server->link, &cell->sv_list);
 	afs_get_server(server);
 	afs_kafstimod_del_timer(&server->timeout);
 	spin_unlock(&cell->sv_gylock);
fs/afs/kafsasyncd.c +3 -6
Index: 2.6-git/fs/afs/kafsasyncd.c
===================================================================
@@ -136,8 +136,7 @@ static int kafsasyncd(void *arg)
 			if (!list_empty(&kafsasyncd_async_attnq)) {
 				op = list_entry(kafsasyncd_async_attnq.next,
 						struct afs_async_op, link);
-				list_del(&op->link);
-				list_add_tail(&op->link,
+				list_move_tail(&op->link,
 					      &kafsasyncd_async_busyq);
 			}
 
@@ -204,8 +203,7 @@ void afs_kafsasyncd_begin_op(struct afs_
 	init_waitqueue_entry(&op->waiter, kafsasyncd_task);
 	add_wait_queue(&op->call->waitq, &op->waiter);
 
-	list_del(&op->link);
-	list_add_tail(&op->link, &kafsasyncd_async_busyq);
+	list_move_tail(&op->link, &kafsasyncd_async_busyq);
 
 	spin_unlock(&kafsasyncd_async_lock);
 
@@ -223,8 +221,7 @@ void afs_kafsasyncd_attend_op(struct afs
 
 	spin_lock(&kafsasyncd_async_lock);
 
-	list_del(&op->link);
-	list_add_tail(&op->link, &kafsasyncd_async_attnq);
+	list_move_tail(&op->link, &kafsasyncd_async_attnq);
 
 	spin_unlock(&kafsasyncd_async_lock);
 
fs/afs/server.c +2 -4
Index: 2.6-git/fs/afs/server.c
===================================================================
@@ -123,8 +123,7 @@ int afs_server_lookup(struct afs_cell *c
  resurrect_server:
 	_debug("resurrecting server");
 
-	list_del(&zombie->link);
-	list_add_tail(&zombie->link, &cell->sv_list);
+	list_move_tail(&zombie->link, &cell->sv_list);
 	afs_get_server(zombie);
 	afs_kafstimod_del_timer(&zombie->timeout);
 	spin_unlock(&cell->sv_gylock);
@@ -168,8 +167,7 @@ void afs_put_server(struct afs_server *s
 	}
 
 	spin_lock(&cell->sv_gylock);
-	list_del(&server->link);
-	list_add_tail(&server->link, &cell->sv_graveyard);
+	list_move_tail(&server->link, &cell->sv_graveyard);
 
 	/* time out in 10 secs */
 	afs_kafstimod_add_timer(&server->timeout, 10 * HZ);
fs/afs/vlocation.c +2 -4
Index: 2.6-git/fs/afs/vlocation.c
===================================================================
@@ -326,8 +326,7 @@ int afs_vlocation_lookup(struct afs_cell
 	/* found in the graveyard - resurrect */
 	_debug("found in graveyard");
 	atomic_inc(&vlocation->usage);
-	list_del(&vlocation->link);
-	list_add_tail(&vlocation->link, &cell->vl_list);
+	list_move_tail(&vlocation->link, &cell->vl_list);
 	spin_unlock(&cell->vl_gylock);
 
 	afs_kafstimod_del_timer(&vlocation->timeout);
@@ -478,8 +477,7 @@ static void __afs_put_vlocation(struct a
 	}
 
 	/* move to graveyard queue */
-	list_del(&vlocation->link);
-	list_add_tail(&vlocation->link,&cell->vl_graveyard);
+	list_move_tail(&vlocation->link,&cell->vl_graveyard);
 
 	/* remove from pending timeout queue (refcounted if actually being
 	 * updated) */
fs/afs/vnode.c +1 -2
Index: 2.6-git/fs/afs/vnode.c
===================================================================
@@ -104,8 +104,7 @@ static void afs_vnode_finalise_status_up
 					vnode->cb_expiry * HZ);
 
 		spin_lock(&afs_cb_hash_lock);
-		list_del(&vnode->cb_hash_link);
-		list_add_tail(&vnode->cb_hash_link,
+		list_move_tail(&vnode->cb_hash_link,
 			      &afs_cb_hash(server, &vnode->fid));
 		spin_unlock(&afs_cb_hash_lock);
 
fs/jffs2/erase.c +5 -10
Index: 2.6-git/fs/jffs2/erase.c
===================================================================
@@ -54,8 +54,7 @@ static void jffs2_erase_block(struct jff
 	if (!instr) {
 		printk(KERN_WARNING "kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n");
 		spin_lock(&c->erase_completion_lock);
-		list_del(&jeb->list);
-		list_add(&jeb->list, &c->erase_pending_list);
+		list_move(&jeb->list, &c->erase_pending_list);
 		c->erasing_size -= c->sector_size;
 		c->dirty_size += c->sector_size;
 		jeb->dirty_size = c->sector_size;
@@ -87,8 +86,7 @@ static void jffs2_erase_block(struct jff
 		/* Erase failed immediately. Refile it on the list */
 		D1(printk(KERN_DEBUG "Erase at 0x%08x failed: %d. Refiling on erase_pending_list\n", jeb->offset, ret));
 		spin_lock(&c->erase_completion_lock);
-		list_del(&jeb->list);
-		list_add(&jeb->list, &c->erase_pending_list);
+		list_move(&jeb->list, &c->erase_pending_list);
 		c->erasing_size -= c->sector_size;
 		c->dirty_size += c->sector_size;
 		jeb->dirty_size = c->sector_size;
@@ -162,8 +160,7 @@ static void jffs2_erase_succeeded(struct
 {
 	D1(printk(KERN_DEBUG "Erase completed successfully at 0x%08x\n", jeb->offset));
 	spin_lock(&c->erase_completion_lock);
-	list_del(&jeb->list);
-	list_add_tail(&jeb->list, &c->erase_complete_list);
+	list_move_tail(&jeb->list, &c->erase_complete_list);
 	spin_unlock(&c->erase_completion_lock);
 	/* Ensure that kupdated calls us again to mark them clean */
 	jffs2_erase_pending_trigger(c);
@@ -179,8 +176,7 @@ static void jffs2_erase_failed(struct jf
 		if (!jffs2_write_nand_badblock(c, jeb, bad_offset)) {
 			/* We'd like to give this block another try. */
 			spin_lock(&c->erase_completion_lock);
-			list_del(&jeb->list);
-			list_add(&jeb->list, &c->erase_pending_list);
+			list_move(&jeb->list, &c->erase_pending_list);
 			c->erasing_size -= c->sector_size;
 			c->dirty_size += c->sector_size;
 			jeb->dirty_size = c->sector_size;
@@ -192,8 +188,7 @@ static void jffs2_erase_failed(struct jf
 	spin_lock(&c->erase_completion_lock);
 	c->erasing_size -= c->sector_size;
 	c->bad_size += c->sector_size;
-	list_del(&jeb->list);
-	list_add(&jeb->list, &c->bad_list);
+	list_move(&jeb->list, &c->bad_list);
 	c->nr_erasing_blocks--;
 	spin_unlock(&c->erase_completion_lock);
 	wake_up(&c->erase_wait);
fs/jffs2/nodemgmt.c +1 -2
Index: 2.6-git/fs/jffs2/nodemgmt.c
===================================================================
@@ -207,8 +207,7 @@ static int jffs2_find_nextblock(struct j
 			struct jffs2_eraseblock *ejeb;
 
 			ejeb = list_entry(c->erasable_list.next, struct jffs2_eraseblock, list);
-			list_del(&ejeb->list);
-			list_add_tail(&ejeb->list, &c->erase_pending_list);
+			list_move_tail(&ejeb->list, &c->erase_pending_list);
 			c->nr_erasing_blocks++;
 			jffs2_erase_pending_trigger(c);
 			D1(printk(KERN_DEBUG "jffs2_find_nextblock: Triggering erase of erasable block at 0x%08x\n",
fs/jffs2/wbuf.c +1 -2
Index: 2.6-git/fs/jffs2/wbuf.c
===================================================================
@@ -382,8 +382,7 @@ static void jffs2_wbuf_recover(struct jf
 	if (first_raw == &jeb->first_node) {
 		jeb->last_node = NULL;
 		D1(printk(KERN_DEBUG "Failing block at %08x is now empty. Moving to erase_pending_list\n", jeb->offset));
-		list_del(&jeb->list);
-		list_add(&jeb->list, &c->erase_pending_list);
+		list_move(&jeb->list, &c->erase_pending_list);
 		c->nr_erasing_blocks++;
 		jffs2_erase_pending_trigger(c);
 	}
fs/ocfs2/dlm/dlmast.c +1 -2
Index: 2.6-git/fs/ocfs2/dlm/dlmast.c
===================================================================
@@ -381,8 +381,7 @@ do_ast:
 	ret = DLM_NORMAL;
 	if (past->type == DLM_AST) {
 		/* do not alter lock refcount.  switching lists. */
-		list_del_init(&lock->list);
-		list_add_tail(&lock->list, &res->granted);
+		list_move_tail(&lock->list, &res->granted);
 		mlog(0, "ast: adding to granted list... type=%d, "
 			  "convert_type=%d\n", lock->ml.type, lock->ml.convert_type);
 		if (lock->ml.convert_type != LKM_IVMODE) {
fs/ocfs2/dlm/dlmconvert.c +3 -6
Index: 2.6-git/fs/ocfs2/dlm/dlmconvert.c
===================================================================
@@ -231,8 +231,7 @@ switch_queues:
 
 	lock->ml.convert_type = type;
 	/* do not alter lock refcount.  switching lists. */
-	list_del_init(&lock->list);
-	list_add_tail(&lock->list, &res->converting);
+	list_move_tail(&lock->list, &res->converting);
 
 unlock_exit:
 	spin_unlock(&lock->spinlock);
@@ -248,8 +247,7 @@ void dlm_revert_pending_convert(struct d
 				struct dlm_lock *lock)
 {
 	/* do not alter lock refcount.  switching lists. */
-	list_del_init(&lock->list);
-	list_add_tail(&lock->list, &res->granted);
+	list_move_tail(&lock->list, &res->granted);
 	lock->ml.convert_type = LKM_IVMODE;
 	lock->lksb->flags &= ~(DLM_LKSB_GET_LVB|DLM_LKSB_PUT_LVB);
 }
@@ -294,8 +292,7 @@ enum dlm_status dlmconvert_remote(struct
 	res->state |= DLM_LOCK_RES_IN_PROGRESS;
 	/* move lock to local convert queue */
 	/* do not alter lock refcount.  switching lists. */
-	list_del_init(&lock->list);
-	list_add_tail(&lock->list, &res->converting);
+	list_move_tail(&lock->list, &res->converting);
 	lock->convert_pending = 1;
 	lock->ml.convert_type = type;
 
fs/ocfs2/dlm/dlmlock.c +1 -2
Index: 2.6-git/fs/ocfs2/dlm/dlmlock.c
===================================================================
@@ -239,8 +239,7 @@ static enum dlm_status dlmlock_remote(st
 		mlog(0, "%s: $RECOVERY lock for this node (%u) is "
 		     "mastered by %u; got lock, manually granting (no ast)\n",
 		     dlm->name, dlm->node_num, res->owner);
-		list_del_init(&lock->list);
-		list_add_tail(&lock->list, &res->granted);
+		list_move_tail(&lock->list, &res->granted);
 	}
 	spin_unlock(&res->spinlock);
 
fs/ocfs2/dlm/dlmrecovery.c +3 -6
Index: 2.6-git/fs/ocfs2/dlm/dlmrecovery.c
===================================================================
@@ -905,13 +905,11 @@ static void dlm_move_reco_locks_to_list(
 			mlog(0, "found lockres owned by dead node while "
 				  "doing recovery for node %u. sending it.\n",
 				  dead_node);
-			list_del_init(&res->recovering);
-			list_add_tail(&res->recovering, list);
+			list_move_tail(&res->recovering, list);
 		} else if (res->owner == DLM_LOCK_RES_OWNER_UNKNOWN) {
 			mlog(0, "found UNKNOWN owner while doing recovery "
 				  "for node %u. sending it.\n", dead_node);
-			list_del_init(&res->recovering);
-			list_add_tail(&res->recovering, list);
+			list_move_tail(&res->recovering, list);
 		}
 	}
 	spin_unlock(&dlm->spinlock);
@@ -1529,8 +1527,7 @@ static int dlm_process_recovery_data(str
 
 			/* move the lock to its proper place */
 			/* do not alter lock refcount.  switching lists. */
-			list_del_init(&lock->list);
-			list_add_tail(&lock->list, queue);
+			list_move_tail(&lock->list, queue);
 			spin_unlock(&res->spinlock);
 
 			mlog(0, "just reordered a local lock!\n");
fs/ocfs2/dlm/dlmthread.c +2 -4
Index: 2.6-git/fs/ocfs2/dlm/dlmthread.c
===================================================================
@@ -318,8 +318,7 @@ converting:
 
 		target->ml.type = target->ml.convert_type;
 		target->ml.convert_type = LKM_IVMODE;
-		list_del_init(&target->list);
-		list_add_tail(&target->list, &res->granted);
+		list_move_tail(&target->list, &res->granted);
 
 		BUG_ON(!target->lksb);
 		target->lksb->status = DLM_NORMAL;
@@ -380,8 +379,7 @@ blocked:
 		     target->ml.type, target->ml.node);
 
 		// target->ml.type is already correct
-		list_del_init(&target->list);
-		list_add_tail(&target->list, &res->granted);
+		list_move_tail(&target->list, &res->granted);
 
 		BUG_ON(!target->lksb);
 		target->lksb->status = DLM_NORMAL;
fs/ocfs2/dlm/dlmunlock.c +1 -2
Index: 2.6-git/fs/ocfs2/dlm/dlmunlock.c
===================================================================
@@ -271,8 +271,7 @@ void dlm_commit_pending_unlock(struct dl
 void dlm_commit_pending_cancel(struct dlm_lock_resource *res,
 			       struct dlm_lock *lock)
 {
-	list_del_init(&lock->list);
-	list_add_tail(&lock->list, &res->granted);
+	list_move_tail(&lock->list, &res->granted);
 	lock->ml.convert_type = LKM_IVMODE;
 }
 
fs/ocfs2/journal.c +1 -2
Index: 2.6-git/fs/ocfs2/journal.c
===================================================================
@@ -222,8 +222,7 @@ void ocfs2_handle_add_inode(struct ocfs2
 	BUG_ON(!list_empty(&OCFS2_I(inode)->ip_handle_list));
 
 	OCFS2_I(inode)->ip_handle = handle;
-	list_del(&(OCFS2_I(inode)->ip_handle_list));
-	list_add_tail(&(OCFS2_I(inode)->ip_handle_list), &(handle->inode_list));
+	list_move_tail(&(OCFS2_I(inode)->ip_handle_list), &(handle->inode_list));
 }
 
 static void ocfs2_handle_unlock_inodes(struct ocfs2_journal_handle *handle)

--

#17 lore raw

PATCH 1/1 reiser4fs: use list_move()

This patch converts the combination of list_del(A) and list_add(A, B) to list_move(A, B) under fs/reiser4.

 fs/reiser4/flush.c                        |    3 +--
 fs/reiser4/flush_queue.c                  |    3 +--
 fs/reiser4/plugin/item/extent_flush_ops.c |    6 ++----
 fs/reiser4/search.c                       |    9 +++------
 fs/reiser4/txnmgr.c                       |    9 +++------
 5 files changed, 10 insertions(+), 20 deletions(-)
fs/reiser4/flush.c +1 -2
Index: work/fs/reiser4/flush.c
===================================================================
@@ -940,8 +940,7 @@ static jnode * find_flush_start_jnode(
 
 		if (JF_ISSET(node, JNODE_WRITEBACK)) {
 			/* move node to the end of atom's writeback list */
-			list_del_init(&node->capture_link);
-			list_add_tail(&node->capture_link, ATOM_WB_LIST(atom));
+			list_move_tail(&node->capture_link, ATOM_WB_LIST(atom));
 
 			/*
 			 * jnode is not necessarily on dirty list: if it was dirtied when
fs/reiser4/flush_queue.c +1 -2
Index: work/fs/reiser4/flush_queue.c
===================================================================
@@ -214,8 +214,7 @@ void queue_jnode(flush_queue_t * fq, jno
 	assert("vs-1481", NODE_LIST(node) != FQ_LIST);
 
 	mark_jnode_queued(fq, node);
-	list_del(&node->capture_link);
-	list_add_tail(&node->capture_link, ATOM_FQ_LIST(fq));
+	list_move_tail(&node->capture_link, ATOM_FQ_LIST(fq));
 
 	ON_DEBUG(count_jnode(node->atom, node, NODE_LIST(node),
 			     FQ_LIST, 1));
fs/reiser4/plugin/item/extent_flush_ops.c +2 -4
Index: work/fs/reiser4/plugin/item/extent_flush_ops.c
===================================================================
@@ -470,8 +470,7 @@ static void protect_reloc_node(struct li
 	assert_spin_locked(&(node->guard));
 
 	JF_SET(node, JNODE_EPROTECTED);
-	list_del_init(&node->capture_link);
-	list_add_tail(&node->capture_link, jnodes);
+	list_move_tail(&node->capture_link, jnodes);
 	ON_DEBUG(count_jnode(node->atom, node, DIRTY_LIST, PROTECT_LIST, 0));
 }
 
@@ -751,8 +750,7 @@ static void make_node_ovrwr(struct list_
 	assert("zam-918", !JF_ISSET(node, JNODE_OVRWR));
 
 	JF_SET(node, JNODE_OVRWR);
-	list_del_init(&node->capture_link);
-	list_add_tail(&node->capture_link, jnodes);
+	list_move_tail(&node->capture_link, jnodes);
 	ON_DEBUG(count_jnode(node->atom, node, DIRTY_LIST, OVRWR_LIST, 0));
 
 	spin_unlock_jnode(node);
fs/reiser4/search.c +3 -6
Index: work/fs/reiser4/search.c
===================================================================
@@ -153,8 +153,7 @@ void cbk_cache_invalidate(const znode * 
 	write_lock(&(cache->guard));
 	for (i = 0, slot = cache->slot; i < cache->nr_slots; ++i, ++slot) {
 		if (slot->node == node) {
-			list_del(&slot->lru);
-			list_add_tail(&slot->lru, &cache->lru);
+			list_move_tail(&slot->lru, &cache->lru);
 			slot->node = NULL;
 			break;
 		}
@@ -191,8 +190,7 @@ static void cbk_cache_add(const znode *n
 		slot = list_entry(cache->lru.prev, cbk_cache_slot, lru);
 		slot->node = (znode *) node;
 	}
-	list_del(&slot->lru);
-	list_add(&slot->lru, &cache->lru);
+	list_move(&slot->lru, &cache->lru);
 	write_unlock(&(cache->guard));
 	assert("nikita-2473", cbk_cache_invariant(cache));
 }
@@ -1257,8 +1255,7 @@ static int cbk_cache_scan_slots(cbk_hand
 			if (slot->node == h->active_lh->node /*node */ ) {
 				/* if this node is still in cbk cache---move
 				   its slot to the head of the LRU list. */
-				list_del(&slot->lru);
-				list_add(&slot->lru, &cache->lru);
+				list_move(&slot->lru, &cache->lru);
 			}
 			write_unlock(&(cache->guard));
 		}
fs/reiser4/txnmgr.c +3 -6
Index: work/fs/reiser4/txnmgr.c
===================================================================
@@ -981,8 +981,7 @@ static void dispatch_wb_list(txn_atom * 
 				queue_jnode(fq, cur);
 			} else {
 				/* move jnode to atom's clean list */
-				list_del(&cur->capture_link);
-				list_add_tail(&cur->capture_link,
+				list_move_tail(&cur->capture_link,
 					      ATOM_CLEAN_LIST(atom));
 			}
 		}
@@ -2474,8 +2473,7 @@ static void do_jnode_make_dirty(jnode * 
 		assert("nikita-2606", level <= REAL_MAX_ZTREE_HEIGHT);
 
 		/* move node to atom's dirty list */
-		list_del(&node->capture_link);
-		list_add_tail(&node->capture_link, ATOM_DIRTY_LIST(atom, level));
+		list_move_tail(&node->capture_link, ATOM_DIRTY_LIST(atom, level));
 		ON_DEBUG(count_jnode
 			 (atom, node, NODE_LIST(node), DIRTY_LIST, 1));
 		/*
@@ -2748,8 +2746,7 @@ void jnode_make_wander_nolock(jnode * no
 
 	JF_SET(node, JNODE_OVRWR);
 	/* move node to atom's overwrite list */
-	list_del(&node->capture_link);
-	list_add_tail(&node->capture_link, ATOM_OVRWR_LIST(atom));
+	list_move_tail(&node->capture_link, ATOM_OVRWR_LIST(atom));
 	ON_DEBUG(count_jnode(atom, node, DIRTY_LIST, OVRWR_LIST, 1));
 }
 
Acked-by on v1 8/8
#19 lore raw

Re: [patch 8/8] fs: use list_move()

In reply to Akinobu Mita
Quoted 11 lines · Akinobu Mita

This patch converts the combination of list_del(A) and list_add(A, B) to list_move(A, B) under fs/.

CC Ian Kent <[email protected]>
CC Joel Becker <[email protected]>
CC Neil Brown <[email protected]>
CC Hans Reiser <[email protected]>
CC Urban Widmark <[email protected]>
CC David Howells <[email protected]>
CC Mark Fasheh <[email protected]>
Signature · 10 lines
"And yet I find,
 And yet I find repeating in my head.
 If I can't be my own, 
 I'd feel better dead."

Joel Becker
Principal Software Developer
Oracle
E-mail: [email protected]
Phone: (650) 506-8127
#20 lore raw

Re: [patch 8/8] fs: use list_move()

Quoted 12 lines · Joel Becker
Quoted 11 lines · Akinobu Mita

This patch converts the combination of list_del(A) and list_add(A, B) to list_move(A, B) under fs/.

CC Ian Kent <[email protected]>
CC Joel Becker <[email protected]>
CC Neil Brown <[email protected]>
CC Hans Reiser <[email protected]>
CC Urban Widmark <[email protected]>
CC David Howells <[email protected]>
CC Mark Fasheh <[email protected]>
Quoted 8 lines
Signature · 4 lines
"And yet I find,
 And yet I find repeating in my head.
 If I can't be my own, 
 I'd feel better dead."

ACK