Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1579405

Re: [PATCH] llist: Don't reinvent the wheel but use existing llist API

From NeilBrown <neilb@suse.com>
Newsgroups linux.kernel
Subject Re: [PATCH] llist: Don't reinvent the wheel but use existing llist API
Date 2017-02-13 06:00 +0100
Message-ID <tagU1-7f4-1@gated-at.bofh.it> (permalink)
References <taghj-6YW-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Mon, Feb 13 2017, Byungchul Park wrote:

> Although llist provides proper APIs, they are not used. Make them used.
>
> Signed-off-by: Byungchul Park <byungchul.park@lge.com>
> ---
>  drivers/md/bcache/closure.c | 15 ++-------------
>  drivers/md/raid5.c          |  4 +---
>  drivers/vhost/scsi.c        |  9 ++-------
>  fs/file_table.c             | 12 +++++-------
>  fs/namespace.c              | 12 +++++-------
>  include/linux/llist.h       |  3 +++
>  kernel/irq_work.c           |  6 +-----
>  kernel/sched/core.c         | 13 ++-----------
>  mm/vmalloc.c                |  8 +++-----
>  9 files changed, 24 insertions(+), 58 deletions(-)
>
...

> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index 36c13e4..c82243a 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -359,11 +359,9 @@ static int release_stripe_list(struct r5conf *conf,
>  
>  	head = llist_del_all(&conf->released_stripes);
>  	head = llist_reverse_order(head);
> -	while (head) {
> +	llist_for_each_entry(sh, head, release_list) {
>  		int hash;
>  
> -		sh = llist_entry(head, struct stripe_head, release_list);
> -		head = llist_next(head);
>  		/* sh could be readded after STRIPE_ON_RELEASE_LIST is cleard */
>  		smp_mb();
>  		clear_bit(STRIPE_ON_RELEASE_LIST, &sh->state);

This one is wrong (I haven't checked the rest).
As soon a STRIPE_ON_RELEASE_LIST is cleared, the llist_node can be
reused, so we need to call llist_next *before* the rest of the code.
You have moved the call to afterwards.

You could possibly change it to use llist_for_each_entry_safe()

NeilBrown

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] llist: Don't reinvent the wheel but use existing llist API Byungchul Park <byungchul.park@lge.com> - 2017-02-13 05:20 +0100
  Re: [PATCH] llist: Don't reinvent the wheel but use existing llist API NeilBrown <neilb@suse.com> - 2017-02-13 06:00 +0100
    Re: [PATCH] llist: Don't reinvent the wheel but use existing llist  API Byungchul Park <byungchul.park@lge.com> - 2017-02-13 06:20 +0100
  Re: [PATCH] llist: Don't reinvent the wheel but use existing llist API "Huang\, Ying" <ying.huang@intel.com> - 2017-02-13 06:40 +0100
    Re: [PATCH] llist: Don't reinvent the wheel but use existing llist  API Byungchul Park <byungchul.park@lge.com> - 2017-02-13 07:00 +0100
  Re: [PATCH] llist: Don't reinvent the wheel but use existing llist  API Al Viro <viro@ZenIV.linux.org.uk> - 2017-02-13 06:50 +0100
    Re: [PATCH] llist: Don't reinvent the wheel but use existing llist  API Byungchul Park <byungchul.park@lge.com> - 2017-02-13 07:10 +0100

csiph-web