Skip to content
  • Ryusuke Konishi's avatar
    nilfs2: buffer and page operations · 0bd49f94
    Ryusuke Konishi authored
    
    
    This adds common routines for buffer/page operations used in B-tree
    node caches, meta data files, or segment constructor (log writer).
    
    NILFS uses copy functions for buffers and pages due to the following
    reasons:
    
     1) Relocation required for COW
        Since NILFS changes address of on-disk blocks, moving buffers
        in page cache is needed for the buffers which are not addressed
        by a file offset.  If buffer size is smaller than page size,
        this involves partial copy of pages.
    
     2) Freezing mmapped pages
        NILFS calculates checksums for each log to ensure its validity.
        If page data changes after the checksum calculation, this validity
        check will not work correctly.  To avoid this failure for mmaped
        pages, NILFS freezes their data by copying.
    
     3) Copy-on-write for DAT pages
        NILFS makes clones of DAT page caches in a copy-on-write manner
        during GC processes, and this ensures atomicity and consistency
        of the DAT in the transient state.
    
    In addition, NILFS uses two obsolete functions, nilfs_mark_buffer_dirty()
    and nilfs_clear_page_dirty() respectively.
    
    * nilfs_mark_buffer_dirty() was required to avoid NULL pointer
      dereference faults:
    
      Since the page cache of B-tree node pages or data page cache of pseudo
      inodes does not have a valid mapping->host, calling mark_buffer_dirty()
      for their buffers causes the fault; it calls __mark_inode_dirty(NULL)
      through __set_page_dirty().
    
    * nilfs_clear_page_dirty() was needed in the two cases:
    
     1) For B-tree node pages and data pages of the dat/gcdat, NILFS2 clears
        page dirty flags when it copies back pages from the cloned cache
        (gcdat->{i_mapping,i_btnode_cache}) to its original cache
        (dat->{i_mapping,i_btnode_cache}).
    
     2) Some B-tree operations like insertion or deletion may dispose buffers
        in dirty state, and this needs to cancel the dirty state of their
        pages.  clear_page_dirty_for_io() caused faults because it does not
        clear the dirty tag on the page cache.
    
    Signed-off-by: default avatarSeiji Kihara <kihara.seiji@lab.ntt.co.jp>
    Signed-off-by: default avatarRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    0bd49f94