From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Sean Young <sean@mess.org>
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH 2/4] mtd: rfd_ftl: add discard support
Date: Sat, 7 Aug 2021 12:35:47 +0200 [thread overview]
Message-ID: <20210807123547.5a50dbd9@xps13> (raw)
In-Reply-To: <20210807080633.GC2522@gofer.mess.org>
Hi Sean,
Sean Young <sean@mess.org> wrote on Sat, 7 Aug 2021 09:06:33 +0100:
> On Fri, Aug 06, 2021 at 08:18:20PM +0200, Miquel Raynal wrote:
> > Hi Sean,
> >
> > Sean Young <sean@mess.org> wrote on Tue, 13 Jul 2021 10:44:01 +0100:
> >
> > > I proposed this change 16 years ago before discard was a feature in
> > > the block layer: https://lwn.net/Articles/162776/
> > >
> > > Now that the block layer has discard, we can finally merge this change.
> >
> > Can you explain why this is needed here?
>
> Because discard is a huge win. This is also known as trim.
>
> By implementing discard, both fstrim and the discard filesystem option
> can be used.
>
> Implementing discard in the ftl means that when files are removed, there
> is less data in the ftl mapping. This means less stuff to move around for
> erasing and also less erasing to do. This means better wear levelling.
And this is a good commit message for v2 :-)
>
> There is also a wikipedia page on trim here:
>
> https://en.wikipedia.org/wiki/Trim_(computing)
Got it, thanks!
>
> Thanks,
>
> Sean
>
> > (also please add the maintainers in Cc: for the v2)
> >
> > > Signed-off-by: Sean Young <sean@mess.org>
> > > ---
> > > drivers/mtd/rfd_ftl.c | 29 +++++++++++++++++++++++++++++
> > > 1 file changed, 29 insertions(+)
> > >
> > > diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c
> > > index 7b243f2b2fa3..7f5f6d247cae 100644
> > > --- a/drivers/mtd/rfd_ftl.c
> > > +++ b/drivers/mtd/rfd_ftl.c
> > > @@ -705,6 +705,34 @@ static int rfd_ftl_writesect(struct mtd_blktrans_dev *dev, u_long sector, char *
> > > return rc;
> > > }
> > >
> > > +static int rfd_ftl_discardsect(struct mtd_blktrans_dev *dev,
> > > + unsigned long sector, unsigned int nr_sects)
> > > +{
> > > + struct partition *part = (struct partition *)dev;
> > > + u_long addr;
> > > + int rc;
> > > +
> > > + while (nr_sects) {
> > > + if (sector >= part->sector_count)
> > > + return -EIO;
> > > +
> > > + addr = part->sector_map[sector];
> > > +
> > > + if (addr != -1) {
> > > + rc = mark_sector_deleted(part, addr);
> > > + if (rc)
> > > + return rc;
> > > +
> > > + part->sector_map[sector] = -1;
> > > + }
> > > +
> > > + sector++;
> > > + nr_sects--;
> > > + }
> > > +
> > > + return 0;
> > > +}
> > > +
> > > static int rfd_ftl_getgeo(struct mtd_blktrans_dev *dev, struct hd_geometry *geo)
> > > {
> > > struct partition *part = (struct partition*)dev;
> > > @@ -786,6 +814,7 @@ static struct mtd_blktrans_ops rfd_ftl_tr = {
> > >
> > > .readsect = rfd_ftl_readsect,
> > > .writesect = rfd_ftl_writesect,
> > > + .discard = rfd_ftl_discardsect,
> > > .getgeo = rfd_ftl_getgeo,
> > > .add_mtd = rfd_ftl_add_mtd,
> > > .remove_dev = rfd_ftl_remove_dev,
> >
> >
> >
> >
> > Thanks,
> > Miquèl
> >
> > ______________________________________________________
> > Linux MTD discussion mailing list
> > http://lists.infradead.org/mailman/listinfo/linux-mtd/
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2021-08-07 10:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-13 9:43 [PATCH 0/4] Fix various issues with RFD and FTLs Sean Young
2021-07-13 9:44 ` [PATCH 1/4] mtd: rfd_ftl: allow use of MTD_RAM for testing purposes Sean Young
2021-08-06 18:16 ` Miquel Raynal
2021-08-07 7:53 ` Sean Young
2021-07-13 9:44 ` [PATCH 2/4] mtd: rfd_ftl: add discard support Sean Young
2021-08-06 18:18 ` Miquel Raynal
2021-08-07 8:06 ` Sean Young
2021-08-07 10:35 ` Miquel Raynal [this message]
2021-07-13 9:44 ` [PATCH 3/4] mtd: blk_devs: make discard work on FTLs Sean Young
2021-07-13 9:44 ` [PATCH 4/4] mtd: rfd_ftl: fix use-after-free Sean Young
2021-08-06 18:21 ` Miquel Raynal
2021-08-07 7:57 ` Sean Young
2021-08-07 10:34 ` Miquel Raynal
2021-08-07 21:33 ` Sean Young
2021-07-24 10:27 ` [PATCH 0/4] Fix various issues with RFD and FTLs Sean Young
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=20210807123547.5a50dbd9@xps13 \
--to=miquel.raynal@bootlin.com \
--cc=linux-mtd@lists.infradead.org \
--cc=sean@mess.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).