linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Freemyer <greg.freemyer@gmail.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: Mark Lord <kernel@teksavvy.com>,
	Lukas Czerner <lczerner@redhat.com>,
	linux-ext4@vger.kernel.org, Jeff Moyer <jmoyer@redhat.com>,
	Edward Shishkin <eshishki@redhat.com>,
	Eric Sandeen <esandeen@redhat.com>,
	Ric Wheeler <rwheeler@redhat.com>
Subject: Re: [PATCH 2/2] Add batched discard support for ext4.
Date: Wed, 21 Apr 2010 14:59:21 -0400	[thread overview]
Message-ID: <v2w87f94c371004211159ue3a48923u6a543e8090dcdfa6@mail.gmail.com> (raw)
In-Reply-To: <4BCE66C5.3060906@redhat.com>

On Tue, Apr 20, 2010 at 10:45 PM, Eric Sandeen <sandeen@redhat.com> wrote:
> Mark Lord wrote:
>> On 20/04/10 05:21 PM, Greg Freemyer wrote:
>>> Mark,
>>>
>>> This is the patch implementing the new discard logic.
>> ..
>>> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
>> ..
>>>> +void ext4_trim_extent(struct super_block *sb, int start, int count,
>>>> +               ext4_group_t group, struct ext4_buddy *e4b)
>>>> +{
>>>> +       ext4_fsblk_t discard_block;
>>>> +       struct ext4_super_block *es = EXT4_SB(sb)->s_es;
>>>> +       struct ext4_free_extent ex;
>>>> +
>>>> +       assert_spin_locked(ext4_group_lock_ptr(sb, group));
>>>> +
>>>> +       ex.fe_start = start;
>>>> +       ex.fe_group = group;
>>>> +       ex.fe_len = count;
>>>> +
>>>> +       mb_mark_used(e4b,&ex);
>>>> +       ext4_unlock_group(sb, group);
>>>> +
>>>> +       discard_block = (ext4_fsblk_t)group *
>>>> +                       EXT4_BLOCKS_PER_GROUP(sb)
>>>> +                       + start
>>>> +                       + le32_to_cpu(es->s_first_data_block);
>>>> +       trace_ext4_discard_blocks(sb,
>>>> +                       (unsigned long long)discard_block,
>>>> +                       count);
>>>> +       sb_issue_discard(sb, discard_block, count);
>>>> +
>>>> +       ext4_lock_group(sb, group);
>>>> +       mb_free_blocks(NULL, e4b, start, ex.fe_len);
>>>> +}
>>>
>>> Mark, unless I'm missing something, sb_issue_discard() above is going
>>> to trigger a trim command for just the one range.  I thought the
>>> benchmarks you did showed that a collection of ranges needed to be
>>> built, then a single trim command invoked that trimmed that group of
>>> ranges.
>> ..
>>
>> Mmm.. If that's what it is doing, then this patch set would be a
>> complete disaster.
>> It would take *hours* to do the initial TRIM.
>>
>> Lukas ?
>
> I'm confused; do we have an interface to send a trim command for multiple ranges?
>
> I didn't think so ...  Lukas' patch is finding free ranges (above a size threshold)
> to discard; it's not doing it a block at a time, if that's the concern.
>
> -Eric

Eric,

I don't know what kernel APIs have been created to support discard,
but the ATA8 draft spec. allows for specifying multiple ranges in one
trim command.

See section 7.10.3.1 and .2 of the latest draft spec.

Both talk about multiple trim ranges per trim command (think thousands
of ranges per command).

Recent hdparm versions accept a trim command argument that causes
multiple ranges to be trimmed per command.

 --trim-sector-ranges        Tell SSD firmware to discard unneeded
data sectors: lba:count ..
 --trim-sector-ranges-stdin  Same as above, but reads lba:count pairs from stdin

As I understand it, this is critical from a performance perspective
for the SSDs Mark tested with.  ie. He found a single trim command
with 1000 ranges takes much less time than 1000 discrete trim
commands.

Per Mark's comment's in wiper.sh, a trim command can have a minimum of
128KB of associated range information, so it is thousands of ranges
that can be discarded in a single command

ie. hdparm can accept extremely large lists of ranges on stdin, but it
parses the list into discrete trim commands with thousands of ranges
per command.

A kernel implementation which is trying to implement after that fact
discards as this patch is doing, also needs to somehow craft trim
commands with a large payload of ranges if it is going to be
efficient.

If the block layer cannot do this yet, then in my opinion this type of
batched discarding needs to stay in user space as done with Mark's
wiper.sh script and enhanced hdparm until the block layer grows that
ability.

Greg
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2010-04-21 18:59 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-19 10:55 Ext4: batched discard support Lukas Czerner
2010-04-19 10:55 ` [PATCH 1/2] Add ioctl FITRIM Lukas Czerner
2010-04-19 10:55   ` [PATCH 2/2] Add batched discard support for ext4 Lukas Czerner
2010-04-20 21:21     ` Greg Freemyer
2010-04-21  2:26       ` Mark Lord
2010-04-21  2:45         ` Eric Sandeen
2010-04-21 18:59           ` Greg Freemyer [this message]
2010-04-21 19:04             ` Ric Wheeler
2010-04-21 19:22               ` Jeff Moyer
2010-04-21 20:44                 ` Greg Freemyer
2010-04-21 20:53                   ` Greg Freemyer
2010-04-21 21:01                   ` Eric Sandeen
2010-04-21 21:03                     ` Ric Wheeler
2010-04-21 21:47                       ` Greg Freemyer
2010-04-21 21:56                         ` James Bottomley
2010-04-21 21:59                         ` Mark Lord
2010-04-23  8:23                   ` Lukas Czerner
2010-04-24 13:24                     ` Greg Freemyer
2010-04-24 13:48                       ` Ric Wheeler
2010-04-24 14:30                         ` Greg Freemyer
2010-04-24 14:43                           ` Eric Sandeen
2010-04-24 15:03                             ` Greg Freemyer
2010-04-24 17:04                               ` Ric Wheeler
2010-04-24 18:30                                 ` Greg Freemyer
2010-04-24 18:41                                   ` Ric Wheeler
2010-04-26 14:00                                     ` Mark Lord
2010-04-26 14:42                                       ` Martin K. Petersen
2010-04-26 15:27                                         ` Greg Freemyer
2010-04-26 15:51                                           ` Lukas Czerner
2010-04-28  1:25                                           ` Mark Lord
2010-04-26 15:48                                         ` Ric Wheeler
2010-04-24 19:06                                   ` Martin K. Petersen
2010-04-26 14:03                                     ` Mark Lord
2010-04-24 18:39                       ` Martin K. Petersen
2010-04-26 16:55                     ` Jan Kara
2010-04-26 17:46                       ` Lukas Czerner
2010-04-26 17:52                         ` Ric Wheeler
2010-04-26 18:14                           ` Lukas Czerner
2010-04-26 18:28                             ` Jeff Moyer
2010-04-26 18:38                               ` [PATCH 2/2] Add batched discard support for ext4 - using rbtree Lukas Czerner
2010-04-26 18:42                                 ` Lukas Czerner
2010-04-27 15:29                                   ` Edward Shishkin
2010-04-21 20:52                 ` [PATCH 2/2] Add batched discard support for ext4 Greg Freemyer
2010-04-19 16:20 ` Ext4: batched discard support Greg Freemyer
2010-04-19 16:30   ` Eric Sandeen
2010-04-19 17:58     ` Greg Freemyer
2010-04-19 18:04       ` Ric Wheeler
2010-04-20 20:24   ` Mark Lord
2010-04-20 20:34     ` Mark Lord
  -- strict thread matches above, loose matches on Subject: below --
2010-07-07  7:53 Ext4: batched discard support - simplified version Lukas Czerner
2010-07-07  7:53 ` [PATCH 2/2] Add batched discard support for ext4 Lukas Czerner
2010-07-14  8:33   ` Dmitry Monakhov
2010-07-14  9:40     ` Lukas Czerner
2010-07-14 10:03       ` Dmitry Monakhov
2010-07-14 11:43         ` Lukas Czerner

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=v2w87f94c371004211159ue3a48923u6a543e8090dcdfa6@mail.gmail.com \
    --to=greg.freemyer@gmail.com \
    --cc=esandeen@redhat.com \
    --cc=eshishki@redhat.com \
    --cc=jmoyer@redhat.com \
    --cc=kernel@teksavvy.com \
    --cc=lczerner@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=rwheeler@redhat.com \
    --cc=sandeen@redhat.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 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).