From: Robin van der Gracht <robin@protonic.nl>
To: ulf.hansson@linaro.org
Cc: david@protonic.nl, linux-mmc@vger.kernel.org,
Robin van der Gracht <robin@protonic.nl>
Subject: [PATCH] mmc: core: Fixed bug in one erase-group budget TRIM
Date: Tue, 4 Aug 2015 08:58:33 +0200 [thread overview]
Message-ID: <1438671513-16218-1-git-send-email-robin@protonic.nl> (raw)
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
next reply other threads:[~2015-08-04 7:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-04 6:58 Robin van der Gracht [this message]
2015-08-25 12:05 ` [PATCH] mmc: core: Fixed bug in one erase-group budget TRIM Ulf Hansson
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=1438671513-16218-1-git-send-email-robin@protonic.nl \
--to=robin@protonic.nl \
--cc=david@protonic.nl \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.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;
as well as URLs for NNTP newsgroup(s).