From: Nebojsa Trpkovic <trx.lists@gmail.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: linux-ext4@vger.kernel.org
Subject: Re: "data=writeback" and TRIM don't get along
Date: Thu, 08 Apr 2010 13:48:51 +0200 [thread overview]
Message-ID: <4BBDC2A3.1040901@gmail.com> (raw)
In-Reply-To: <4BBD5FDB.9010100@redhat.com>
On 04/08/10 06:47, Eric Sandeen wrote:
> Eric Sandeen wrote:
>> Eric Sandeen wrote:
>>> I'll have to think about the right way to do this... it seems pretty
>>> convoluted to me right now.
>>>
>> Something like this probably works, but I really REALLY would not test
>> it on an important filesystem. :)
>>
>> I'm not sure it's a good idea to discard it before returning it
>> to the prealloc pool, because it may well get re-used again
>> quickly.... not sure if that's helpful.
>
> (now I'm really talking to myself, but scratch that bit -
> ext4_mb_return_to_preallocation is pretty much a no-op)
>
> -Eric
>
>> Just a note, I think eventually we may move to more of a batch discard
>> in the background, because these little discards are actually quite
>> inefficient on the hardware we've tested so far.
>>
>> -Eric
>>
>> p.s. really. Don't test this with important data. I haven't tested
>> it at all yet.
>>
>> Index: linux-2.6/fs/ext4/mballoc.c
>> ===================================================================
>> --- linux-2.6.orig/fs/ext4/mballoc.c
>> +++ linux-2.6/fs/ext4/mballoc.c
>> @@ -4602,6 +4606,8 @@ do_more:
>> mb_clear_bits(bitmap_bh->b_data, bit, count);
>> ext4_mb_free_metadata(handle, &e4b, new_entry);
>> } else {
>> + ext4_fsblk_t discard_block;
>> +
>> /* need to update group_info->bb_free and bitmap
>> * with group lock held. generate_buddy look at
>> * them with group lock_held
>> @@ -4609,6 +4615,11 @@ do_more:
>> ext4_lock_group(sb, block_group);
>> mb_clear_bits(bitmap_bh->b_data, bit, count);
>> mb_free_blocks(inode, &e4b, bit, count);
>> + discard_block = bit +
>> + ext4_group_first_block_no(sb, block_group);
>> + trace_ext4_discard_blocks(sb,
>> + (unsigned long long)discard_block, count);
>> + sb_issue_discard(sb, discard_block, count);
>> ext4_mb_return_to_preallocation(inode, &e4b, block, count);
>> }
Well, to be honest, I'm not some programmer guy, so I doubt my skills
can be of any help here.
Second, unfortunately, my SSD is now my root partition (just one big
sda1), so I cannot experiment with it too much.
And finally,
>> I'm not sure it's a good idea to discard it before returning it
>> to the prealloc pool, because it may well get re-used again
>> quickly.... not sure if that's helpful.
I'm not sure I understood you well about this prealloc pool - re-using
mechanism, but...
AFAIK, modern SSDs are using very aggressive wear-leveling algorithms.
Writing two times into the same filesystem sector almost newer goes to
the same hardware sector. Therefore, saving sectors from discarding and
for re-using makes no much sense - once re-used it will be written to
some other physical NAND memory cell anyways. Guess we can discard it as
soon as we have no valid data in it.
Nebojsa
next prev parent reply other threads:[~2010-04-08 11:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-08 0:50 "data=writeback" and TRIM don't get along Nebojsa Trpkovic
2010-04-08 1:22 ` Eric Sandeen
2010-04-08 1:37 ` Nebojsa Trpkovic
2010-04-08 4:10 ` Eric Sandeen
2010-04-08 4:37 ` Eric Sandeen
2010-04-08 4:47 ` Eric Sandeen
2010-04-08 11:48 ` Nebojsa Trpkovic [this message]
2010-04-08 15:32 ` Eric Sandeen
2010-04-08 16:21 ` Nebojsa Trpkovic
2010-04-08 16:34 ` Eric Sandeen
2010-04-08 7:17 ` Dmitry Monakhov
2010-04-08 11:47 ` Nebojsa Trpkovic
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=4BBDC2A3.1040901@gmail.com \
--to=trx.lists@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--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).