linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: core: Fixed bug in one erase-group budget TRIM
@ 2015-08-04  6:58 Robin van der Gracht
  2015-08-25 12:05 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Robin van der Gracht @ 2015-08-04  6:58 UTC (permalink / raw)
  To: ulf.hansson; +Cc: david, linux-mmc, Robin van der Gracht

When requesting a trim for several bytes, everything up to the next
erase-group is erased. This causes data corruption.

Signed-off-by: Robin van der Gracht <robin@protonic.nl>
---
 drivers/mmc/core/core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 083cade..57edb2a 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2227,9 +2227,8 @@ int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr,
 	 * and call mmc_do_erase() twice if necessary. This special case is
 	 * identified by the card->eg_boundary flag.
 	 */
-	if ((arg & MMC_TRIM_ARGS) && (card->eg_boundary) &&
-	    (from % card->erase_size)) {
-		rem = card->erase_size - (from % card->erase_size);
+	rem = card->erase_size - (from % card->erase_size);
+	if ((arg & MMC_TRIM_ARGS) && (card->eg_boundary) && (nr > rem)) {
 		err = mmc_do_erase(card, from, from + rem - 1, arg);
 		from += rem;
 		if ((err) || (to <= from))
-- 
2.1.4


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

* Re: [PATCH] mmc: core: Fixed bug in one erase-group budget TRIM
  2015-08-04  6:58 [PATCH] mmc: core: Fixed bug in one erase-group budget TRIM Robin van der Gracht
@ 2015-08-25 12:05 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2015-08-25 12:05 UTC (permalink / raw)
  To: Robin van der Gracht; +Cc: David Jander, linux-mmc

On 4 August 2015 at 08:58, Robin van der Gracht <robin@protonic.nl> wrote:
> When requesting a trim for several bytes, everything up to the next
> erase-group is erased. This causes data corruption.
>
> Signed-off-by: Robin van der Gracht <robin@protonic.nl>

Thanks, applied for next!

Kind regards
Uffe

> ---
>  drivers/mmc/core/core.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 083cade..57edb2a 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -2227,9 +2227,8 @@ int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr,
>          * and call mmc_do_erase() twice if necessary. This special case is
>          * identified by the card->eg_boundary flag.
>          */
> -       if ((arg & MMC_TRIM_ARGS) && (card->eg_boundary) &&
> -           (from % card->erase_size)) {
> -               rem = card->erase_size - (from % card->erase_size);
> +       rem = card->erase_size - (from % card->erase_size);
> +       if ((arg & MMC_TRIM_ARGS) && (card->eg_boundary) && (nr > rem)) {
>                 err = mmc_do_erase(card, from, from + rem - 1, arg);
>                 from += rem;
>                 if ((err) || (to <= from))
> --
> 2.1.4
>

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

end of thread, other threads:[~2015-08-25 12:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-04  6:58 [PATCH] mmc: core: Fixed bug in one erase-group budget TRIM Robin van der Gracht
2015-08-25 12:05 ` Ulf Hansson

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).