Permalink
Commits on Nov 8, 2015
  1. nilfs2-kmod6 v1.1 release

    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Nov 8, 2015
  2. nilfs2: free unused dat file blocks during garbage collection

    As a nilfs2 volume ages, the amount of available disk space decreases
    little by little due to bloat of DAT (disk address translation) metadata
    file.  Even if we delete all files in a file system and free their block
    addresses from the DAT file through a garbage collection, empty DAT blocks
    are not freed.
    
    This fixes the issue by extending the deallocator of block addresses so
    that empty data blocks and empty bitmap blocks of DAT are deleted.
    
    The following comparison shows the effect of this patch.  Each shows disk
    amount information of a nilfs2 volume that we cleaned out by deleting all
    files and running gc after having filled 90% of its capacity.
    
    Before:
    Filesystem     1K-blocks     Used Available Use% Mounted on
    /dev/sda1      500105212  3022844 472072192   1% /test
    
    After:
    Filesystem     1K-blocks     Used Available Use% Mounted on
    /dev/sda1      500105212    16380 475078656   1% /test
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [modified to support old kmap_atomic/kunmap_atomic and old bit-search macro]
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Nov 7, 2015
  3. nilfs2: add helper functions to delete blocks from dat file

    This adds delete functions for data blocks of metadata files using bitmap
    based allocator.  nilfs_palloc_delete_entry_block() deletes an entry block
    (e.g.  block storing dat entries), and nilfs_palloc_delete_bitmap_block()
    deletes a bitmap block, respectively.
    
    These helpers are intended to be used in the successive change on
    deallocator of block addresses ("nilfs2: free unused dat file blocks
    during garbage collection").
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Nov 7, 2015
  4. nilfs2: get rid of nilfs_palloc_group_is_in()

    This unfolds nilfs_palloc_group_is_in() helper function into
    nilfs_palloc_freev() function to simplify a range check and an index
    calculation repeatedy performed in a loop of the function.
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Nov 7, 2015
  5. nilfs2: refactor nilfs_palloc_find_available_slot()

    The current implementation of nilfs_palloc_find_available_slot() function
    is overkill.  The underlying bit search routine is well optimized, so this
    uses it more simply in nilfs_palloc_find_available_slot().
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Nov 7, 2015
  6. nilfs2: do not call nilfs_mdt_bgl_lock() needlessly

    In the bitmap based allocator implementation, nilfs_mdt_bgl_lock() helper
    is frequently used to get a spinlock protecting a target block group.
    This reduces its usage and simplifies arguments of some related functions
    by directly passing a pointer to the spinlock.
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Nov 7, 2015
  7. nilfs2: use nilfs_warning() in allocator implementation

    This uses nilfs_warning() to replace "printk(KERN_WARNING ...);" in the
    bitmap based allocator implementation of nilfs2.  The warning messages are
    modified to include the device name and the inode number in each message.
    This makes it clear which metadata file of which device has output
    warnings such as "entry number xxxx already freed".
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Nov 7, 2015
  8. Add mimic of rounddown() macro for old kernels

    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Nov 8, 2015
Commits on Jul 6, 2015
  1. NILFS2: support NFSv2 export

    The "fh_len" passed to ->fh_to_* is not guaranteed to be that same as that
    returned by encode_fh - it may be larger.
    
    With NFSv2, the filehandle is fixed length, so it may appear longer than
    expected and be zero-padded.
    
    So we must test that fh_len is at least some value, not exactly equal to
    it.
    
    Signed-off-by: NeilBrown <neilb@suse.de>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    neilbrown committed with konis Jun 25, 2015
Commits on Jun 7, 2015
  1. README: include vanilla kernel 2.6.{33,34,35} to supported versions

    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Jun 7, 2015
Commits on Jun 6, 2015
  1. Fix build warnings due to change of fsync()

    Dentry argument was removed from fop->fsync() in kernel 2.6.35.  This
    fixes build warnings due to the change.
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Jun 6, 2015
  2. Fix build error due to changes of blkdev_issue_{flush,discard}

    blkdev_issue_flush() function has a gfp flag argument since 2.6.35,
    and it also had a flag argument between 2.6.35 and 2.6.36.
    
    The flag argument of blkdev_issue_discard() function changed in kernel
    2.6.35, 2.6.36, and 2.6.37.  Type of the flag argument and available
    flags were changed.
    
    This fixes build failures due to these changes by introducing a
    wrapper functions compat_blkdev_issue_flush() and
    compat_blkdev_issue_discard().
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Jun 6, 2015
Commits on Jun 4, 2015
  1. Fix build on kernel 2.6.32 due to lack of discard_granularity

    Build of nilfs2 kmod fails against vanilla kernel 2.6.32 due to lack
    of discard_granularity parameter in queue_limits struct:
    
     fs/nilfs2/ioctl.c: In function 'nilfs_ioctl_trim_fs':
     fs/nilfs2/ioctl.c:1095:51: error: 'struct queue_limits' has no member named 'discard_granularity'
       range.minlen = max_t(u64, range.minlen, q->limits.discard_granularity);
                                                        ^
     include/linux/kernel.h:601:17: note: in definition of macro 'max_t'
       type __max2 = (y);   \
                      ^
    
    This fixes the issue by using block-size instead of
    discard_granularity for the 2.6.32 kernel.
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Jun 4, 2015
Commits on May 7, 2015
  1. nilfs2: fix sanity check of btree level in nilfs_btree_root_broken()

    The range check for b-tree level parameter in nilfs_btree_root_broken()
    is wrong; it accepts the case of "level == NILFS_BTREE_LEVEL_MAX" even
    though the level is limited to values in the range of 0 to
    (NILFS_BTREE_LEVEL_MAX - 1).
    
    Since the level parameter is read from storage device and used to index
    nilfs_btree_path array whose element count is NILFS_BTREE_LEVEL_MAX, it
    can cause memory overrun during btree operations if the boundary value
    is set to the level parameter on device.
    
    This fixes the broken sanity check and adds a comment to clarify that
    the upper bound NILFS_BTREE_LEVEL_MAX is exclusive.
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed May 5, 2015
Commits on Apr 19, 2015
  1. nilfs2-kmod6 v1.0 release

    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Apr 18, 2015
  2. README: correct spell of CentOS

    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Apr 18, 2015
Commits on Apr 18, 2015
  1. nilfs2: improve execution time of NILFS_IOCTL_GET_CPINFO ioctl

    The older a filesystem gets, the slower lscp command becomes.  This is
    because nilfs_cpfile_do_get_cpinfo() function meets more hole blocks
    as the start offset of valid checkpoint numbers gets bigger.
    
    This reduces the overhead by skipping hole blocks efficiently with
    nilfs_mdt_find_block() helper.
    
    A measurement result of this patch is as follows:
    
    Before:
    $ time lscp
                     CNO        DATE     TIME  MODE  FLG      BLKCNT       ICNT
                 5769303  2015-02-22 19:31:33   cp    -          108          1
                 5769304  2015-02-22 19:38:54   cp    -          108          1
    
    real    0m0.182s
    user    0m0.003s
    sys     0m0.180s
    
    After:
    $ time lscp
                     CNO        DATE     TIME  MODE  FLG      BLKCNT       ICNT
                 5769303  2015-02-22 19:31:33   cp    -          108          1
                 5769304  2015-02-22 19:38:54   cp    -          108          1
    
    real    0m0.003s
    user    0m0.001s
    sys     0m0.002s
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Apr 16, 2015
  2. nilfs2: add helper to find existent block on metadata file

    Add a new metadata file function, nilfs_mdt_find_block(), which finds
    an existent block on a metadata file in a given range of blocks.  This
    function skips continuous hole blocks efficiently by using
    nilfs_bmap_seek_key().
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Apr 16, 2015
  3. nilfs2: add bmap function to seek a valid key

    Add a new bmap function, nilfs_bmap_seek_key(), which seeks a valid
    entry and returns its key starting from a given key.  This function
    can be used to skip hole blocks efficiently.
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Cc: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Apr 16, 2015
  4. nilfs2: unify type of key arguments in bmap interface

    The type of key arguments in block mapping interface varies depending
    on function.  For instance, nilfs_bmap_lookup_at_level() takes "__u64"
    for its key argument whereas nilfs_bmap_lookup() takes "unsigned
    long".
    
    This fits them to "__u64" to eliminate the variation.
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Apr 16, 2015
  5. nilfs2: use set_mask_bits() for operations on buffer state bitmap

    nilfs_forget_buffer(), nilfs_clear_dirty_page(), and
    nilfs_segctor_complete_write() are using a bunch of atomic bit operations
    against buffer state bitmap.
    
    This reduces the number of them by utilizing set_mask_bits() macro.
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [add reference to "kern_feature.h" to page.c]
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Apr 16, 2015
  6. Add mimic of set_mask_bits() helper for old kernels

    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Apr 18, 2015
  7. nilfs2: do not use async write flag for segment summary buffers

    The async write flag is introduced to nilfs2 in the commit 7f42ec394156
    ("nilfs2: fix issue with race condition of competition between segments
    for dirty blocks"), but the flag only makes sense for data buffers and
    btree node buffers.  It is not needed for segment summary buffers.
    
    This gets rid of the latter uses as part of refactoring of atomic bit
    operations on buffer state bitmap.
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Cc: Vyacheslav Dubeyko <slava@dubeyko.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Apr 16, 2015
  8. nilfs2: use bgl_lock_ptr()

    Simplify nilfs_mdt_bgl_lock() by utilizing bgl_lock_ptr() helper in
    <linux/blockgroup_lock.h>.
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Apr 16, 2015
  9. nilfs2: use inode_set_flags() in nilfs_set_inode_flags()

    Use inode_set_flags() to atomically set i_flags instead of clearing out
    the S_IMMUTABLE, S_APPEND, etc.  flags and then setting them from the
    FS_IMMUTABLE_FL, FS_APPEND_FL flags to avoid a race where an immutable
    file has the immutable flag cleared for a brief window of time.
    
    This is a similar fix to commit 5f16f3225b06 ("ext4: atomically set
    inode->i_flags in ext4_set_inode_flags()").
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Cc: "Theodore Ts'o" <tytso@mit.edu>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Apr 17, 2015
  10. Add mimic of inode_set_flags() for old kernels

    inode_set_flags() is used to atomically set inode->i_flags.
    This adds the function as an inline to make it available
    in kernel 3.15 and earlier.
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Apr 18, 2015
  11. nilfs2: put out gfp mask manipulation from nilfs_set_inode_flags()

    nilfs_set_inode_flags() function adjusts gfp-mask of inode->i_mapping as
    well as i_flags, however, this coupling of operations is not appropriate.
    
    For instance, nilfs_ioctl_setflags(), one of three callers of
    nilfs_set_inode_flags(), doesn't need to reinitialize the gfp-mask at all.
     In addition, nilfs_new_inode(), another caller of
    nilfs_set_inode_flags(), doesn't either because it has already initialized
    the gfp-mask.
    
    Only __nilfs_read_inode(), the remaining caller, needs it.  So, this moves
    the gfp mask manipulation to __nilfs_read_inode() from
    nilfs_set_inode_flags().
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Apr 16, 2015
  12. nilfs2: fix gcc warning at nilfs_checkpoint_is_mounted()

    Fix the following build warning:
    
     fs/nilfs2/super.c: In function 'nilfs_checkpoint_is_mounted':
     fs/nilfs2/super.c:1023:10: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
       if (cno < 0 || cno > nilfs->ns_cno)
               ^
    
    This warning indicates that the comparision "cno < 0" is useless because
    variable "cno" has an unsigned integer type "__u64".
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Reported-by: David Binderman <dcb314@hotmail.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Apr 16, 2015
Commits on Mar 3, 2015
  1. nilfs2: fix potential memory overrun on inode

    Each inode of nilfs2 stores a root node of a b-tree, and it turned out to
    have a memory overrun issue:
    
    Each b-tree node of nilfs2 stores a set of key-value pairs and the number
    of them (in "bn_nchildren" member of nilfs_btree_node struct), as well as
    a few other "bn_*" members.
    
    Since the value of "bn_nchildren" is used for operations on the key-values
    within the b-tree node, it can cause memory access overrun if a large
    number is incorrectly set to "bn_nchildren".
    
    For instance, nilfs_btree_node_lookup() function determines the range of
    binary search with it, and too large "bn_nchildren" leads
    nilfs_btree_node_get_key() in that function to overrun.
    
    As for intermediate b-tree nodes, this is prevented by a sanity check
    performed when each node is read from a drive, however, no sanity check
    has been done for root nodes stored in inodes.
    
    This patch fixes the issue by adding missing sanity check against b-tree
    root nodes so that it's called when on-memory inodes are read from ifile,
    inode metadata file.
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Feb 27, 2015
Commits on Feb 7, 2015
  1. nilfs2-kmod-centos6: 0.6.3 release

    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Feb 7, 2015
Commits on Jan 17, 2015
  1. nilfs2: fix the nilfs_iget() vs. nilfs_new_inode() races

    Same story as in commit 41080b5a2401 ("nfsd race fixes: ext2") (similar
    ext2 fix) except that nilfs2 needs to use insert_inode_locked4() instead
    of insert_inode_locked() and a bug of a check for dead inodes needs to
    be fixed.
    
    If nilfs_iget() is called from nfsd after nilfs_new_inode() calls
    insert_inode_locked4(), nilfs_iget() will wait for unlock_new_inode() at
    the end of nilfs_mkdir()/nilfs_create()/etc to unlock the inode.
    
    If nilfs_iget() is called before nilfs_new_inode() calls
    insert_inode_locked4(), it will create an in-core inode and read its
    data from the on-disk inode.  But, nilfs_iget() will find i_nlink equals
    zero and fail at nilfs_read_inode_common(), which will lead it to call
    iget_failed() and cleanly fail.
    
    However, this sanity check doesn't work as expected for reused on-disk
    inodes because they leave a non-zero value in i_mode field and it
    hinders the test of i_nlink.  This patch also fixes the issue by
    removing the test on i_mode that nilfs2 doesn't need.
    
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Dec 10, 2014
Commits on Oct 19, 2014
  1. nilfs2-kmod-centos6: 0.6.2 release

    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Oct 19, 2014
Commits on Oct 18, 2014
  1. nilfs2: add missing blkdev_issue_flush() to nilfs_sync_fs()

    Under normal circumstances nilfs_sync_fs() writes out the super block,
    which causes a flush of the underlying block device.  But this depends
    on the THE_NILFS_SB_DIRTY flag, which is only set if the pointer to the
    last segment crosses a segment boundary.  So if only a small amount of
    data is written before the call to nilfs_sync_fs(), no flush of the
    block device occurs.
    
    In the above case an additional call to blkdev_issue_flush() is needed.
    To prevent unnecessary overhead, the new flag nilfs->ns_flushed_device
    is introduced, which is cleared whenever new logs are written and set
    whenever the block device is flushed.  For convenience the function
    nilfs_flush_device() is added, which contains the above logic.
    
    Signed-off-by: Andreas Rohner <andreas.rohner@gmx.net>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    zeitgeist87 committed with konis Oct 13, 2014
Commits on Sep 27, 2014
  1. nilfs2-kmod-centos6: 0.6.1 release

    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    konis committed Sep 27, 2014
  2. nilfs2: fix data loss with mmap()

    This bug leads to reproducible silent data loss, despite the use of
    msync(), sync() and a clean unmount of the file system.  It is easily
    reproducible with the following script:
    
      ----------------[BEGIN SCRIPT]--------------------
      mkfs.nilfs2 -f /dev/sdb
      mount /dev/sdb /mnt
    
      dd if=/dev/zero bs=1M count=30 of=/mnt/testfile
    
      umount /mnt
      mount /dev/sdb /mnt
      CHECKSUM_BEFORE="$(md5sum /mnt/testfile)"
    
      /root/mmaptest/mmaptest /mnt/testfile 30 10 5
    
      sync
      CHECKSUM_AFTER="$(md5sum /mnt/testfile)"
      umount /mnt
      mount /dev/sdb /mnt
      CHECKSUM_AFTER_REMOUNT="$(md5sum /mnt/testfile)"
      umount /mnt
    
      echo "BEFORE MMAP:\t$CHECKSUM_BEFORE"
      echo "AFTER MMAP:\t$CHECKSUM_AFTER"
      echo "AFTER REMOUNT:\t$CHECKSUM_AFTER_REMOUNT"
      ----------------[END SCRIPT]--------------------
    
    The mmaptest tool looks something like this (very simplified, with
    error checking removed):
    
      ----------------[BEGIN mmaptest]--------------------
      data = mmap(NULL, file_size - file_offset, PROT_READ | PROT_WRITE,
                  MAP_SHARED, fd, file_offset);
    
      for (i = 0; i < write_count; ++i) {
            memcpy(data + i * 4096, buf, sizeof(buf));
            msync(data, file_size - file_offset, MS_SYNC))
      }
      ----------------[END mmaptest]--------------------
    
    The output of the script looks something like this:
    
      BEFORE MMAP:    281ed1d5ae50e8419f9b978aab16de83  /mnt/testfile
      AFTER MMAP:     6604a1c31f10780331a6850371b3a313  /mnt/testfile
      AFTER REMOUNT:  281ed1d5ae50e8419f9b978aab16de83  /mnt/testfile
    
    So it is clear, that the changes done using mmap() do not survive a
    remount.  This can be reproduced a 100% of the time.  The problem was
    introduced in commit 136e8770cd5d ("nilfs2: fix issue of
    nilfs_set_page_dirty() for page at EOF boundary").
    
    If the page was read with mpage_readpage() or mpage_readpages() for
    example, then it has no buffers attached to it.  In that case
    page_has_buffers(page) in nilfs_set_page_dirty() will be false.
    Therefore nilfs_set_file_dirty() is never called and the pages are never
    collected and never written to disk.
    
    This patch fixes the problem by also calling nilfs_set_file_dirty() if the
    page has no buffers attached to it.
    
    [akpm@linux-foundation.org: s/PAGE_SHIFT/PAGE_CACHE_SHIFT/]
    Signed-off-by: Andreas Rohner <andreas.rohner@gmx.net>
    Tested-by: Andreas Rohner <andreas.rohner@gmx.net>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
    zeitgeist87 committed with konis Sep 25, 2014