reiserfs-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* reiser4: discard support
@ 2014-04-30  7:43 Ivan Shapovalov
  2014-04-30 14:11 ` Edward Shishkin
       [not found] ` <1B07908E-B768-407D-ADFA-B3C539FABB49@gmail.com>
  0 siblings, 2 replies; 19+ messages in thread
From: Ivan Shapovalov @ 2014-04-30  7:43 UTC (permalink / raw)
  To: Edward Shishkin; +Cc: reiserfs-devel

[-- Attachment #1: Type: text/plain, Size: 1925 bytes --]

Hi Edward,

So I bit the bullet, ditched all tasks for the upcoming holidays and gave 
another try to the discard support in reiser4. Since my last status update, 
I've lost the local kernel tree due to bad scripting (decided to TRIM free 
space between partitions... and TRIM'ed everything that is NOT free space), so 
I had to start from scratch.

I decided to go with following algorithm:

During the transaction deallocated ranges are logged as-is to a list or array 
(let's call it "the delete log"). On atom commit we will generate a minimal 
superset of the delete log, comprised only of whole erase units ("the discard 
set").
So, at commit time the following actions take place:
- elements of the delete log are sorted;
- the delete log is iterated, merging any adjacent ranges;
- for each resulting range in the delete log its start is rounded down to the
  closest erase unit boundary, and, starting from this block, extents of erase
  unit length are created until whole range is covered;
- for each such new extent it is checked whether does it contain allocated
  blocks. If no (i. e. the range is completely deallocated), the range is
  added to the discard set.

Complexity of logging is thus O(n), added complexity of atom joining is O(1) 
and added complexity of atom commit is O(n*log(n) + n).

The first question is how to store the delete log.
- blocknr_set isn't ordered per se, so adjacent entries can't be easily merged
- simple linked list (extent per node) seems like too big overhead
- kmalloc()'ed arrays can't be joined in O(1) and they are static (imposes a 
hard limit on log size)
- kmem_cache... feels like using a sledge-hammer.

And oh, where in commit_current_atom() should these things be done? I guess 
right after the reiser4_write_logs(), under the tmgr mutex, but I can't really 
explain why I think so.

Thanks,
-- 
Ivan Shapovalov / intelfx /

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 230 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: reiser4: discard support
@ 2014-04-30 17:55 Edward Shishkin
  2014-04-30 18:53 ` Edward Shishkin
  0 siblings, 1 reply; 19+ messages in thread
From: Edward Shishkin @ 2014-04-30 17:55 UTC (permalink / raw)
  To: ReiserFS Development mailing list

On 04/30/2014 05:04 PM, Ivan Shapovalov wrote:
[...]
 >> There is a ready implementation of rb-trees in the kernel (see 
./lib/rbtree.c,
 >> ./lib/rbtree_test.c). Could you please take a look at this?
 >
 > I've checked it already. Well, in case of trees:
 > - combined extent insertion+adjacent extent merge complexity is 
O(n*log(n))

Actually, this is:

1) Add n extents one-by-one to empty tree:
log(1) + log(2) + ... + log(n-1)

2) Merge 2 trees of n extents:
log(n) + log(n+1) + ... + log(2n-1)

Total: log(1*2*...*2n-1) = log((2n-1)!)

in accordance with Stirling's formula:

log((2n)!) = log(((2n)^(1/2))*(2n/e)^n) =
= (1/2)*log(2n) + n*log(2n/e) < n + n*log(n)

Since atoms can be merged in parallel, we have that
trees work better than lists. Also tree of extents has
better memory consumption because of merging extents.


 >  against O(n+n*log(n)) in lists;
 > - joining two trees is not less than O(log(n)) against O(1) in lists.
 >
 > So I can't see any benefit in using trees, and join performance is a 
downside of these. Am I missing something?
 >
 >>
 >>>
[...]
 > Why after reiser4_invalidate_list()? I thought that it should be 
called between reiser4_write_logs(), but before reiser4_invalidate_list().

OK, insert before. I think, it doesn't matter, since we don't look
at this list when issuing discard requests, no? :)

 >
 > And why not after all reiser4_invalidate_list() calls?
 >
 >>
 >> Thanks,
 >> Edward.
 >> P.S.: You'll need to set up a debugging environment. Take a look at 
this:
 >> http://bipinkunal.blogspot.cz/2012/05/kgdb-tutorial.html
 >> Do you have a second machine with a serial port?
 >
 > No, I don't. Will a VM suffice?

Yes, if it works for you..

Thanks,
Edward.

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2014-05-07 21:04 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-30  7:43 reiser4: discard support Ivan Shapovalov
2014-04-30 14:11 ` Edward Shishkin
     [not found] ` <1B07908E-B768-407D-ADFA-B3C539FABB49@gmail.com>
     [not found]   ` <53613807.7090605@gmail.com>
2014-05-01 23:51     ` Ivan Shapovalov
     [not found]       ` <CAJZSrNK4=o9vocDfSM=4W5ZgtqZ6RVpmU66sGCu6HFsdN47OHw@mail.gmail.com>
2014-05-02 11:06         ` Ivan Shapovalov
2014-05-02 11:48       ` Edward Shishkin
2014-05-02 12:44         ` Edward Shishkin
2014-05-02 13:47           ` Ivan Shapovalov
2014-05-02 13:36         ` Ivan Shapovalov
2014-05-02 14:07           ` Edward Shishkin
2014-05-02 14:32             ` Ivan Shapovalov
2014-05-02 18:10               ` Edward Shishkin
2014-05-03 18:48                 ` Ivan Shapovalov
2014-05-03 20:21                   ` Edward Shishkin
2014-05-03 20:32                     ` Ivan Shapovalov
2014-05-06  8:58                       ` Edward Shishkin
2014-05-07  7:35                         ` Ivan Shapovalov
2014-05-07 21:04                           ` Edward Shishkin
  -- strict thread matches above, loose matches on Subject: below --
2014-04-30 17:55 Edward Shishkin
2014-04-30 18:53 ` Edward Shishkin

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).