[Tux3] Block state transitions

Daniel Phillips phillips at phunq.net
Mon Nov 24 04:17:56 PST 2008


This is a little out of context, I really need to explain the background 
more, but I want to get a preliminary version of this posted right now.  
So here goes, damm the torpedos.

The delta pipeline:

The Tux3 atomic commit pipeline will normally have three deltas in it at 
a time, they are named:

  active delta: the view that userspace sees, in which changes are
     happening via file writes, attribute changes and namespace
     operations

  staging delta: being prepared for transfer to disk.  Physical
     locations for blocks are assigned, cached index blocks are updated,
     and log commit blocks are set up, complete with a logical
     description of changes to index blocks

  commit delta: currently being pushed into the block queue and
     transferred to disk

Delta counter and dirty bits:

We have a delta counter which is the number of the active delta.  The 
low two bits are used to select one of 4 dirty states, dirty0/1/2/3.  
(In other words, the low two bits of the dirty state is the delta 
counter mod 4.)  When a block is dirtied in the active delta and it is 
already dirty in an earlier delta, the front end knows that it has to 
fork the block in order to avoid blocking on delta completion.  If it 
did not do this and went ahead and dirtied such a block, an 
inconsistent filesystem state could be recorded on disk.

A block can be in one of six states:

   empty - newly created or sharing a page with a block in some other
      state

   clean - the block data matches data on disk

   dirty - one of four dirty states, dirty0/1/2/3

Block state transitions

With the delta pipeline, delta counter and block states defined, we can 
now look at the state transitions a block may take, which is the point 
of this post.

clean to dirty0/1/2/3
  - caused by set_block_dirty
  - if the block was clean, put it on current delta dirty list
    (otherwise it was already on the list)
  - regular file and directory blocks can only be dirtied in the current
    delta
  - metadata blocks except directory and inode table blocks can only
    be dirtied in the staging delta
  - inode table blocks can be dirtied in the current or staging delta
    (needs synchronization)
  - dirty in the committing delta is an error

empty to dirty0/1/2/3
  - only allowed in mapping a block to a file hole in read

dirty0/1/2/3 to clean
  - in write endio

empty to clean
  - in read endio
  - not allowed anywhere else

clean to empty
  - in truncate

dirty to empty
  - in truncate

dirty0/1/2/3 to different dirty0/1/2/3
  - always a bug

clean to dirty0/1/2/3
  - set_block_dirty
  - if the block was clean, put it on active delta dirty list
    (otherwise it was already on the list)
  - regular file and directory blocks can only be dirtied in the active
    delta
  - metadata blocks except directory and inode table blocks can only
    be dirtied in the staging delta
  - inode table blocks can be dirtied in the active or staging delta
    (needs synchronization)
  - dirtying a block in the committing delta is an error (we fork to
    avoid this)

empty to dirty0/1/2/3
  - only allowed in mapping a block to a file hole in read

dirty0/1/2/3 to clean
  - only allowed in write endio

empty to clean
  - only allowed in read endio

clean to empty
  - in truncate

dirty to empty
  - in truncate

dirty0/1/2/3 to different dirty0/1/2/3
  - always a bug

_______________________________________________
Tux3 mailing list
Tux3 at tux3.org
http://tux3.org/cgi-bin/mailman/listinfo/tux3



More information about the Tux3 mailing list