[haiku-development] Re: transaction questions in block_cache

  • From: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Fri, 14 Jul 2017 15:12:43 +0200

Hi,

Am 14. Juli 2017 14:18:23 MESZ schrieb Hy Che <cvghy116@xxxxxxxxx>:

I have some questions about transaction in block cache api.
1. What is the use of sub transaction, as I know there is only one
transaction is active at a time, so it is kinda weird to me.

A sub transaction allows you to combine several transactions together. The 
current transaction can always be aborted, but not the ones already 
acknowledged. To complete a transaction the disk's write buffers must be 
flushed, which is a very time consuming operation.
Sub transactions allow you to have fine grained transactions without 
sacrificing disk bandwidth.
HTH

2. What is main_num_blocks ?

I can't look it up right now, but that's probably the number of blocks that are 
in the parent transaction without counting the sub transaction into account.

3. Correct me if Im wrong, under a condition (event) a transaction
listener will trigger a call to hook for that event that we defined
for it.
+ TRANSACTION_WRITTEN is when all the blocks are flushed to disk.
+ TRANSACTION_ENDED is when cache_end_transaction is called.
+ TRANSACTION_ABORTED is when cache_abort_transaction is called.
+ TRANSACTION_IDLE is when the blocks are idle in 2 seconds.

I don't really remember, but it does sound okay.

Bye,
   Axel.

Other related posts: