All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
To: Shaohua Li <shli@fb.com>
Cc: linux-raid@vger.kernel.org, linux-block@vger.kernel.org
Subject: Re: [PATCH] badblocks: badblocks_set/clear update unacked_exist
Date: Fri, 21 Oct 2016 16:35:30 +0200	[thread overview]
Message-ID: <20161021143530.GB8376@proton.igk.intel.com> (raw)
In-Reply-To: <39f303dcb7bdf2958b6f82a0646467dfbc8d1abd.1476999400.git.shli@fb.com>

On Thu, Oct 20, 2016 at 02:40:06PM -0700, Shaohua Li wrote:
> When bandblocks_set acknowledges a range or badblocks_clear a range,
> it's possible all badblocks are acknowledged. We should update
> unacked_exist if this occurs.
> 
> Signed-off-by: Shaohua Li <shli@fb.com>
> ---
>  block/badblocks.c | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/block/badblocks.c b/block/badblocks.c
> index 7be53cb..139115d2 100644
> --- a/block/badblocks.c
> +++ b/block/badblocks.c
> @@ -133,6 +133,26 @@ int badblocks_check(struct badblocks *bb, sector_t s, int sectors,
>  }
>  EXPORT_SYMBOL_GPL(badblocks_check);
>  
> +static void badblocks_update_acked(struct badblocks *bb)
> +{
> +	u64 *p = bb->page;
> +	int i;
> +	bool unacked = false;
> +
> +	if (!bb->unacked_exist)
> +		return;
> +
> +	for (i = 0; i < bb->count ; i++) {
> +		if (!BB_ACK(p[i])) {
> +			unacked = true;
> +			break;
> +		}
> +	}
> +
> +	if (!unacked)
> +		bb->unacked_exist = 0;
> +}
> +
>  /**
>   * badblocks_set() - Add a range of bad blocks to the table.
>   * @bb:		the badblocks structure that holds all badblock information
> @@ -294,6 +314,8 @@ int badblocks_set(struct badblocks *bb, sector_t s, int sectors,
>  	bb->changed = 1;
>  	if (!acknowledged)
>  		bb->unacked_exist = 1;
> +	else
> +		badblocks_update_acked(bb);
>  	write_sequnlock_irqrestore(&bb->lock, flags);
>  
>  	return rv;
> @@ -399,6 +421,7 @@ int badblocks_clear(struct badblocks *bb, sector_t s, int sectors)
>  		}
>  	}
>  
> +	badblocks_update_acked(bb);
>  	bb->changed = 1;
>  out:
>  	write_sequnlock_irq(&bb->lock);
> -- 
> 2.9.3

Reviewed-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Tested-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>

  reply	other threads:[~2016-10-21 14:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-20 21:40 [PATCH] badblocks: badblocks_set/clear update unacked_exist Shaohua Li
2016-10-20 21:40 ` Shaohua Li
2016-10-21 14:35 ` Tomasz Majchrzak [this message]
2016-10-21 16:15 ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161021143530.GB8376@proton.igk.intel.com \
    --to=tomasz.majchrzak@intel.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=shli@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.