From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Lukas Czerner <lczerner@redhat.com>
Cc: Kyungmin Park <kmpark@infradead.org>,
Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v6] fat: Batched discard support for fat
Date: Tue, 24 May 2011 19:07:25 +0900 [thread overview]
Message-ID: <874o4kjtsy.fsf@devron.myhome.or.jp> (raw)
In-Reply-To: <alpine.LFD.2.00.1105241102200.5457@dhcp-27-109.brq.redhat.com> (Lukas Czerner's message of "Tue, 24 May 2011 11:25:11 +0200 (CEST)")
Lukas Czerner <lczerner@redhat.com> writes:
>> No, no. Userland will know max-length from statvfs, right? So, let's
>> assume it is 100 (->f_blocks) * 1024 (->f_bsize).
>
> You do not need to know the filesystem size to do the discard, it should
> be adjusted within the kernel. Just specify ULLONG_MAX as a length. See
> fstrim tool in util-linux-ng.
>
>>
>> Now, userland know about max length, 102400, ok? Let's start to trim.
>>
>> Assume, userland want to trim whole. So, userland will specify like
>>
>> trim(0, 102400).
>>
>> What happen in kernel actually?
>>
>> Current implement doesn't map blocks. So, in the case of FAT, it adjusts
>> from 0 to 2 * 1024.
>>
>> So, it trims between 2048 and 102400. The problem is here. FS layout is
>> actually, 2048 and (102400 + 2048). I.e. actually userland has to do
>>
>> trim(2048, 102400 + 2048)
>>
>> to specify whole. How to know 2048?
>
> You do not need to know anything in userspace. If you want to trim the
> whole filesystem you just do trim(0, ULLONG_MAX) - which is what fstrim
> does when you do not specify range. And you just skip the filesystem
> metadata obviously, regardless if they are at the beginning of the
> filesystem or in the middle. Just do whatever you need to do within your
> filesystem.
>
> What we do in ext4 is, that we convert length and start passed in struct
> fstrim_range into filesystem block units and then get the last
> allocation group and block offset within that group (we do the same for
> the start block) and we try to discard free block ranges in from staring
> block to the last block.
>
> It is really not a rocket science and since every filesystem is
> different and has different internal data structures it is up to you how
> to do this. And if you shift a block or two, it really does not matter
> as much since user-land does not know about how the filesystem block are
> laid out anyway, nor user land knows which are free and which are not.
>
> I agree that the interface is a little bit fuzzy, but that is mainly
> because it is intended to be filesystem independent and we do have a lot
> of various filesystems, so I wanted it to be as flexibile as it should,
> hence the start, len in Bytes.
>
> Hope it helped.
No. If you want to trim whole with some chunk like 1GB and periodically
(IIRC in xfstest), what do? We have to trim until ULLONG_MAX for each
1GB?
Thanks.
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
next prev parent reply other threads:[~2011-05-24 10:07 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-28 10:34 [PATCH v6] fat: Batched discard support for fat Kyungmin Park
2011-03-29 5:04 ` OGAWA Hirofumi
2011-03-29 5:11 ` Kyungmin Park
2011-03-29 6:37 ` OGAWA Hirofumi
2011-03-29 6:42 ` Kyungmin Park
2011-03-29 7:28 ` OGAWA Hirofumi
2011-03-30 13:22 ` Arnd Bergmann
2011-03-30 13:50 ` Lukas Czerner
2011-03-30 13:58 ` Kyungmin Park
2011-03-30 14:45 ` Arnd Bergmann
2011-03-30 14:20 ` Arnd Bergmann
2011-03-30 14:44 ` Kyungmin Park
2011-03-30 15:06 ` Arnd Bergmann
2011-05-24 1:18 ` Kyungmin Park
2011-05-24 4:47 ` OGAWA Hirofumi
2011-05-24 5:21 ` Kyungmin Park
2011-05-24 6:39 ` OGAWA Hirofumi
2011-05-24 6:55 ` Kyungmin Park
2011-05-24 7:32 ` OGAWA Hirofumi
2011-05-24 8:54 ` Kyungmin Park
2011-05-24 9:44 ` OGAWA Hirofumi
2011-05-24 9:25 ` Lukas Czerner
2011-05-24 10:07 ` OGAWA Hirofumi [this message]
2011-05-24 10:44 ` Lukas Czerner
2011-05-24 11:14 ` OGAWA Hirofumi
2011-05-24 11:32 ` Lukas Czerner
2011-05-24 12:19 ` OGAWA Hirofumi
2011-05-24 13:30 ` Lukas Czerner
2011-05-24 14:19 ` OGAWA Hirofumi
2011-08-31 13:02 ` Kyungmin Park
2011-08-31 17:51 ` OGAWA Hirofumi
2011-10-05 14:38 ` 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=874o4kjtsy.fsf@devron.myhome.or.jp \
--to=hirofumi@mail.parknet.co.jp \
--cc=arnd@arndb.de \
--cc=kmpark@infradead.org \
--cc=lczerner@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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