public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@nokia.com>
To: Chuanxiao Dong <chuanxiao.dong@intel.com>
Cc: linux-mmc@vger.kernel.org, cjb@laptop.org,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Subject: Re: [PATCH v4 1/3]mmc: set max_discard_sectors value for mmc queue
Date: Mon, 14 Feb 2011 16:08:34 +0200	[thread overview]
Message-ID: <4D593762.7020006@nokia.com> (raw)
In-Reply-To: <20110212062214.GB25519@intel.com>

On 12/02/11 08:22, ext Chuanxiao Dong wrote:
> max_discard_sectors value is UINT_MAX which means kernel block layer can pass
> down unlimited sectors to MMC driver to erase. But erasing so many sectors may
> delay some other important I/O requests. This is not preferred.
>
> So use 'pref_erase' to set a suitable max_discard_sectors value for mmc queue to
> avoid erasing too many sectors at one time.
>
> Signed-off-by: Chuanxiao Dong<chuanxiao.dong@intel.com>
> ---
>   drivers/mmc/card/queue.c |    3 ++-
>   drivers/mmc/core/core.c  |   20 ++++++++++++++++++++
>   include/linux/mmc/core.h |    1 +
>   3 files changed, 23 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
> index 4e42d03..6c13859 100644
> --- a/drivers/mmc/card/queue.c
> +++ b/drivers/mmc/card/queue.c
> @@ -131,7 +131,8 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
>   	queue_flag_set_unlocked(QUEUE_FLAG_NONROT, mq->queue);
>   	if (mmc_can_erase(card)) {
>   		queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, mq->queue);
> -		mq->queue->limits.max_discard_sectors = UINT_MAX;
> +		mq->queue->limits.max_discard_sectors =
> +			mmc_set_max_discard_sectors(card);
>   		if (card->erased_byte == 0)
>   			mq->queue->limits.discard_zeroes_data = 1;
>   		if (!mmc_can_trim(card)&&  is_power_of_2(card->erase_size)) {
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 34a7e8c..0eb27aa 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -1470,6 +1470,26 @@ int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from,
>   }
>   EXPORT_SYMBOL(mmc_erase_group_aligned);
>
> +/*
> + * Set max_discard_sectors for mmc queue.
> + * max_discard_sectors will determine how many sectors can be erased at one
> + * time. Sometimes user may want to erase a large area of SD or MMC card, it may
> + * take long time which delay some other important I/O requests. So we would
> + * better set some values for max_discard_sectors which can forbid block layer
> + * pass too many sectors at one time.
> + *
> + * 'pref_erase' is initialized for this purpose. We can use it to set a preferred
> + * value for it.
> + */
> +int mmc_set_max_discard_sectors(struct mmc_card *card)
> +{
> +	if (card->pref_erase)
> +		return card->pref_erase;

This will cause orders of magnitude decrease in secure erase
performance for eMMC.

> +	else
> +		return UINT_MAX;
> +}
> +EXPORT_SYMBOL(mmc_set_max_discard_sectors);
> +
>   int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen)
>   {
>   	struct mmc_command cmd;
> diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h
> index 64e013f..a218d57 100644
> --- a/include/linux/mmc/core.h
> +++ b/include/linux/mmc/core.h
> @@ -152,6 +152,7 @@ extern int mmc_can_trim(struct mmc_card *card);
>   extern int mmc_can_secure_erase_trim(struct mmc_card *card);
>   extern int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from,
>   				   unsigned int nr);
> +extern int mmc_set_max_discard_sectors(struct mmc_card *card);
>
>   extern int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen);
>


      parent reply	other threads:[~2011-02-14 14:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-12  6:22 [PATCH v4 1/3]mmc: set max_discard_sectors value for mmc queue Chuanxiao Dong
2011-02-12  8:38 ` Arnd Bergmann
2011-02-12 10:42   ` Dong, Chuanxiao
2011-02-12 18:04     ` Arnd Bergmann
2011-02-14  7:01       ` Dong, Chuanxiao
2011-02-14 12:13         ` Arnd Bergmann
2011-02-14 14:08 ` Adrian Hunter [this message]

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=4D593762.7020006@nokia.com \
    --to=adrian.hunter@nokia.com \
    --cc=akpm@linux-foundation.org \
    --cc=chuanxiao.dong@intel.com \
    --cc=cjb@laptop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox