10 May, 2011

3 commits

  • This replaces nilfs_mdt_mark_buffer_dirty and nilfs_btnode_mark_dirty
    macros with mark_buffer_dirty and gets rid of nilfs_mark_buffer_dirty,
    an own mark buffer dirty function.

    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     
  • In the current nilfs, page cache for btree nodes and meta data files
    do not set a valid back pointer to the host inode in mapping->host.

    This will change it so that every address space in nilfs uses
    mapping->host to hold its host inode.

    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     
  • Previously, nilfs was cloning pages for mmapped region to freeze their
    data and ensure consistency of checksum during writeback cycles. A
    private page allocator was used for this page cloning. But, we no
    longer need to do that since clear_page_dirty_for_io function sets up
    pte so that vm_ops->page_mkwrite function is called right before the
    mmapped pages are modified and nilfs_page_mkwrite function can safely
    wait for the pages to be written back to disk.

    So, this stops making a copy of mmapped pages during writeback, and
    eliminates the private page allocation and deallocation functions from
    nilfs.

    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     

06 Apr, 2011

1 commit

  • With the ->sync_page() hook gone, we have a few users that
    add their own static address_space_operations without any
    functions defined.

    fs/inode.c already has an empty_aops that it uses for init
    purposes. Lets export that and use it in the places where
    an otherwise empty aops was defined.

    Signed-off-by: Jens Axboe

    Jens Axboe
     

30 Mar, 2011

1 commit

  • Nilfs in 2.6.39-rc1 hit the following oops:

    BUG: unable to handle kernel NULL pointer dereference at 0000000000000048
    IP: [] try_to_release_page+0x2a/0x3d
    PGD 234cb6067 PUD 234c72067 PMD 0
    Oops: 0000 [#1] SMP

    Process truncate (pid: 10995, threadinfo ffff8802353c2000, task ffff880234cfa000)
    Stack:
    ffff8802333c77b8 ffffffff810b64b0 0000000000003802 ffffffffa0052cca
    0000000000000000 ffff8802353c3b58 0000000000000000 ffff8802353c3b58
    0000000000000001 0000000000000000 ffffea0007b92308 ffffea0007b92308
    Call Trace:
    [] ? invalidate_inode_pages2_range+0x15f/0x273
    [] ? nilfs_palloc_get_block+0x2d/0xaf [nilfs2]
    [] ? bit_waitqueue+0x14/0xa1
    [] ? wake_up_bit+0x10/0x20
    [] ? nilfs_forget_buffer+0x66/0x7a [nilfs2]
    [] ? nilfs_btree_concat_left+0x5c/0x77 [nilfs2]
    [] ? nilfs_btree_delete+0x395/0x3cf [nilfs2]
    [] ? nilfs_bmap_do_delete+0x6e/0x79 [nilfs2]
    [] ? nilfs_btree_last_key+0x14b/0x15e [nilfs2]
    [] ? nilfs_bmap_truncate+0x2f/0x83 [nilfs2]
    [] ? nilfs_bmap_last_key+0x35/0x62 [nilfs2]
    [] ? nilfs_truncate_bmap+0x6b/0xc7 [nilfs2]
    [] ? nilfs_truncate+0x79/0xe4 [nilfs2]
    [] ? vmtruncate+0x33/0x3b
    [] ? nilfs_setattr+0x4d/0x8c [nilfs2]
    [] ? do_page_fault+0x31b/0x356
    [] ? notify_change+0x17d/0x262
    [] ? do_truncate+0x65/0x80
    [] ? sys_ftruncate+0xf1/0xf6
    [] ? system_call_fastpath+0x16/0x1b
    Code: c3 48 83 ec 08 48 8b 17 48 8b 47 18 80 e2 01 75 04 0f 0b eb fe 48 8b 17 80 e6 20 74 05 31 c0 41 59 c3 48 85 c0 74 11 48 8b 40 58
    8b 40 48 48 85 c0 74 04 41 58 ff e0 59 e9 b1 b5 05 00 41 54
    RIP [] try_to_release_page+0x2a/0x3d
    RSP
    CR2: 0000000000000048

    This oops was brought in by the change "block: remove per-queue
    plugging" (commit: 7eaceaccab5f40bb). It initializes mapping->a_ops
    with a NULL pointer for some pages in nilfs (e.g. btree node pages),
    but mm code doesn't NULL pointer checks against mapping->a_ops. (the
    check is done for each callback function)

    This corrects the aops initialization and fixes the oops.

    Signed-off-by: Ryusuke Konishi
    Acked-by: Jens Axboe

    Ryusuke Konishi
     

10 Mar, 2011

2 commits


24 Feb, 2011

1 commit

  • Michael Leun reported that running parallel opens on a fuse filesystem
    can trigger a "kernel BUG at mm/truncate.c:475"

    Gurudas Pai reported the same bug on NFS.

    The reason is, unmap_mapping_range() is not prepared for more than
    one concurrent invocation per inode. For example:

    thread1: going through a big range, stops in the middle of a vma and
    stores the restart address in vm_truncate_count.

    thread2: comes in with a small (e.g. single page) unmap request on
    the same vma, somewhere before restart_address, finds that the
    vma was already unmapped up to the restart address and happily
    returns without doing anything.

    Another scenario would be two big unmap requests, both having to
    restart the unmapping and each one setting vm_truncate_count to its
    own value. This could go on forever without any of them being able to
    finish.

    Truncate and hole punching already serialize with i_mutex. Other
    callers of unmap_mapping_range() do not, and it's difficult to get
    i_mutex protection for all callers. In particular ->d_revalidate(),
    which calls invalidate_inode_pages2_range() in fuse, may be called
    with or without i_mutex.

    This patch adds a new mutex to 'struct address_space' to prevent
    running multiple concurrent unmap_mapping_range() on the same mapping.

    [ We'll hopefully get rid of all this with the upcoming mm
    preemptibility series by Peter Zijlstra, the "mm: Remove i_mmap_mutex
    lockbreak" patch in particular. But that is for 2.6.39 ]

    Signed-off-by: Miklos Szeredi
    Reported-by: Michael Leun
    Reported-by: Gurudas Pai
    Tested-by: Gurudas Pai
    Acked-by: Hugh Dickins
    Cc: stable@kernel.org
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     

10 Jan, 2011

2 commits

  • Will correct the following checkpatch error:

    ERROR: trailing whitespace
    #494: FILE: page.c:494:
    + $

    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     
  • This adds fiemap to nilfs. Two new functions, nilfs_fiemap and
    nilfs_find_uncommitted_extent are added.

    nilfs_fiemap() implements the fiemap inode operation, and
    nilfs_find_uncommitted_extent() helps to get a range of data blocks
    whose physical location has not been determined.

    nilfs_fiemap() collects extent information by looping through
    nilfs_bmap_lookup_contig and nilfs_find_uncommitted_extent routines.

    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     

23 Oct, 2010

3 commits

  • This applies prepared rollback function and redirect function of
    metadata file to DAT file, and eliminates GCDAT inode.

    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     
  • During garbage collection (GC), DAT file, which converts virtual block
    number to real block number, may return disk block number that is not
    yet written to the device.

    To avoid access to unwritten blocks, the current implementation stores
    changes to the caches of GCDAT during GC and atomically commit the
    changes into the DAT file after they are written to the device.

    This patch, instead, adds a function that makes a copy of specified
    buffer and stores it in nilfs_shadow_map, and a function to get the
    backup copy as needed (nilfs_mdt_freeze_buffer and
    nilfs_mdt_get_frozen_buffer respectively).

    Before DAT changes block number in an entry block, it makes a copy and
    redirect access to the buffer so that address conversion function
    (i.e. nilfs_dat_translate) refers to the old address saved in the
    copy.

    This patch gives requisites for such redirection.

    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     
  • This adds optional function to metadata files which makes a copy of
    bmap, page caches, and b-tree node cache, and rolls back to the copy
    as needed.

    This enhancement is intended to displace gcdat inode that provides a
    similar function in a different way.

    In this patch, nilfs_shadow_map structure is added to store a copy of
    the foregoing states. nilfs_mdt_setup_shadow_map relates this
    structure to a metadata file. And, nilfs_mdt_save_to_shadow_map() and
    nilfs_mdt_restore_from_shadow_map() provides save and restore
    functions respectively. Finally, nilfs_mdt_clear_shadow_map() clears
    states of nilfs_shadow_map.

    The copy of b-tree node cache and page cache is made by duplicating
    only dirty pages into corresponding caches in nilfs_shadow_map. Their
    restoration is done by clearing dirty pages from original caches and
    by copying dirty pages back from nilfs_shadow_map.

    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     

23 Jul, 2010

1 commit


30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

14 Mar, 2010

1 commit


10 May, 2009

1 commit

  • This would fix the following failure during GC:

    nilfs_cpfile_delete_checkpoints: cannot delete block
    NILFS: GC failed during preparation: cannot delete checkpoints: err=-2

    The problem was caused by a break in state consistency between page
    cache and btree; the above block was removed from the btree but the
    page buffering the block was remaining in the page cache in dirty
    state.

    This resolves the inconsistency by ensuring to clear dirty state of
    the page buffering the deleted block.

    Reported-by: David Arendt
    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     

07 Apr, 2009

2 commits

  • Pekka Enberg advised me:
    > It would be nice if BUG(), BUG_ON(), and panic() calls would be
    > converted to proper error handling using WARN_ON() calls. The BUG()
    > call in nilfs_cpfile_delete_checkpoints(), for example, looks to be
    > triggerable from user-space via the ioctl() system call.

    This will follow the comment and keep them to a minimum.

    Acked-by: Pekka Enberg
    Signed-off-by: Ryusuke Konishi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ryusuke Konishi
     
  • 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: Seiji Kihara
    Signed-off-by: Ryusuke Konishi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ryusuke Konishi