03 Aug, 2016

2 commits

  • Replace most use of printk() in nilfs2 implementation with nilfs_msg(),
    and reduce the following checkpatch.pl warning:

    "WARNING: Prefer [subsystem eg: netdev]_crit([subsystem]dev, ...
    then dev_crit(dev, ... then pr_crit(... to printk(KERN_CRIT ..."

    This patch also fixes a minor checkpatch warning "WARNING: quoted string
    split across lines" that often accompanies the prior warning, and amends
    message format as needed.

    Link: http://lkml.kernel.org/r/1464875891-5443-5-git-send-email-konishi.ryusuke@lab.ntt.co.jp
    Signed-off-by: Ryusuke Konishi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ryusuke Konishi
     
  • Insert a back pointer to super block instance in nilfs object so that
    functions of nilfs2 easily refer to the super block instance. This
    simplifies replacement of printk() in the successive change.

    Link: http://lkml.kernel.org/r/1464875891-5443-4-git-send-email-konishi.ryusuke@lab.ntt.co.jp
    Signed-off-by: Ryusuke Konishi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ryusuke Konishi
     

25 Jun, 2016

1 commit

  • The value `bytes' comes from the filesystem which is about to be
    mounted. We cannot trust that the value is always in the range we
    expect it to be.

    Check its value before using it to calculate the length for the crc32_le
    call. It value must be larger (or equal) sumoff + 4.

    This fixes a kernel bug when accidentially mounting an image file which
    had the nilfs2 magic value 0x3434 at the right offset 0x406 by chance.
    The bytes 0x01 0x00 were stored at 0x408 and were interpreted as a
    s_bytes value of 1. This caused an underflow when substracting sumoff +
    4 (20) in the call to crc32_le.

    BUG: unable to handle kernel paging request at ffff88021e600000
    IP: crc32_le+0x36/0x100
    ...
    Call Trace:
    nilfs_valid_sb.part.5+0x52/0x60 [nilfs2]
    nilfs_load_super_block+0x142/0x300 [nilfs2]
    init_nilfs+0x60/0x390 [nilfs2]
    nilfs_mount+0x302/0x520 [nilfs2]
    mount_fs+0x38/0x160
    vfs_kern_mount+0x67/0x110
    do_mount+0x269/0xe00
    SyS_mount+0x9f/0x100
    entry_SYSCALL_64_fastpath+0x16/0x71

    Link: http://lkml.kernel.org/r/1466778587-5184-2-git-send-email-konishi.ryusuke@lab.ntt.co.jp
    Signed-off-by: Torsten Hilbrich
    Tested-by: Torsten Hilbrich
    Signed-off-by: Ryusuke Konishi
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Torsten Hilbrich
     

24 May, 2016

4 commits

  • This fixes block comments with proper formatting to eliminate the
    following checkpatch.pl warnings:

    "WARNING: Block comments use * on subsequent lines"
    "WARNING: Block comments use a trailing */ on a separate line"

    Link: http://lkml.kernel.org/r/1462886671-3521-8-git-send-email-konishi.ryusuke@lab.ntt.co.jp
    Signed-off-by: Ryusuke Konishi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ryusuke Konishi
     
  • This fixes checkpatch.pl warning "WARNING: Prefer 'unsigned int' to
    bare use of 'unsigned'".

    Link: http://lkml.kernel.org/r/1462886671-3521-5-git-send-email-konishi.ryusuke@lab.ntt.co.jp
    Signed-off-by: Ryusuke Konishi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ryusuke Konishi
     
  • E-mail addresses of osrg.net domain are no longer available. This
    removes them from authorship notices and prevents reporters from being
    confused.

    Link: http://lkml.kernel.org/r/1461935747-10380-5-git-send-email-konishi.ryusuke@lab.ntt.co.jp
    Signed-off-by: Ryusuke Konishi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ryusuke Konishi
     
  • This removes the extra paragraph which mentions FSF address in GPL
    notices from source code of nilfs2 and avoids the checkpatch.pl error
    related to it.

    Link: http://lkml.kernel.org/r/1461935747-10380-4-git-send-email-konishi.ryusuke@lab.ntt.co.jp
    Signed-off-by: Ryusuke Konishi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ryusuke Konishi
     

11 Dec, 2014

1 commit


09 Aug, 2014

2 commits

  • This patch integrates creation of sysfs groups and
    attributes into NILFS file system driver.

    It was found the issue with nilfs_sysfs_{create/delete}_snapshot_group
    functions by Michael L Semon in the first
    version of the patch:

    BUG: sleeping function called from invalid context at kernel/locking/mutex.c:579
    in_atomic(): 1, irqs_disabled(): 0, pid: 32676, name: umount.nilfs2
    2 locks held by umount.nilfs2/32676:
    #0: (&type->s_umount_key#21){++++..}, at: [] deactivate_super+0x37/0x58
    #1: (&(&nilfs->ns_cptree_lock)->rlock){+.+...}, at: [] nilfs_put_root+0x23/0x5a
    Preemption disabled at:[] nilfs_put_root+0x23/0x5a

    CPU: 0 PID: 32676 Comm: umount.nilfs2 Not tainted 3.14.0+ #2
    Hardware name: Dell Computer Corporation Dimension 2350/07W080, BIOS A01 12/17/2002
    Call Trace:
    dump_stack+0x4b/0x75
    __might_sleep+0x111/0x16f
    mutex_lock_nested+0x1e/0x3ad
    kernfs_remove+0x12/0x26
    sysfs_remove_dir+0x3d/0x62
    kobject_del+0x13/0x38
    nilfs_sysfs_delete_snapshot_group+0xb/0xd
    nilfs_put_root+0x2a/0x5a
    nilfs_detach_log_writer+0x1ab/0x2c1
    nilfs_put_super+0x13/0x68
    generic_shutdown_super+0x60/0xd1
    kill_block_super+0x1d/0x60
    deactivate_locked_super+0x22/0x3f
    deactivate_super+0x3e/0x58
    mntput_no_expire+0xe2/0x141
    SyS_oldumount+0x70/0xa5
    syscall_call+0x7/0xb

    The reason of the issue was placement of
    nilfs_sysfs_{create/delete}_snapshot_group() call under
    nilfs->ns_cptree_lock protection. But this protection is unnecessary and
    wrong solution. The second version of the patch fixes this issue.

    [fengguang.wu@intel.com: nilfs_sysfs_create_mounted_snapshots_group can be static]
    Reported-by: Michael L. Semon
    Signed-off-by: Vyacheslav Dubeyko
    Cc: Vyacheslav Dubeyko
    Cc: Ryusuke Konishi
    Tested-by: Michael L. Semon
    Signed-off-by: Fengguang Wu
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Vyacheslav Dubeyko
     
  • This patch adds creation of /sys/fs/nilfs2//superblock
    group.

    The superblock group contains attributes that describe
    superblock's details:
    (1) sb_write_time - show previous write time of super block in
    human-readable format.
    (2) sb_write_time_secs - show previous write time of super block
    in seconds.
    (3) sb_write_count - show write count of super block.
    (4) sb_update_frequency - show/set interval of periodical update
    of superblock (in seconds). You can set preferable frequency of
    superblock update by command:

    echo > /sys/fs/nilfs2//superblock/sb_update_frequency

    Signed-off-by: Vyacheslav Dubeyko
    Cc: Vyacheslav Dubeyko
    Cc: Ryusuke Konishi
    Cc: Michael L. Semon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Vyacheslav Dubeyko
     

04 Apr, 2014

1 commit

  • Add code to check sizes of on-disk data of metadata files such as inode
    size, segment usage size, DAT entry size, and checkpoint size. Although
    these sizes are read from disk, the current implementation doesn't check
    them.

    If these sizes are not sane on disk, it can cause out-of-range access to
    metadata or memory access overrun on metadata block buffers due to
    overflow in sundry calculations.

    Both lower limit and upper limit of metadata sizes are verified to
    prevent these issues.

    Signed-off-by: Ryusuke Konishi
    Cc: Andreas Rohner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ryusuke Konishi
     

04 Jul, 2013

1 commit

  • The cp_inodes_count and cp_blocks_count are represented as __le64 type in
    on-disk structure (struct nilfs_checkpoint). But analogous fields in
    in-core structure (struct nilfs_root) are represented by atomic_t type.

    This patch replaces atomic_t on atomic64_t type in representation of
    inodes_count and blocks_count fields in struct nilfs_root.

    Signed-off-by: Vyacheslav Dubeyko
    Acked-by: Ryusuke Konishi
    Acked-by: Joern Engel
    Cc: Clemens Eisserer
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Vyacheslav Dubeyko
     

31 Jul, 2012

1 commit

  • An fs-thaw ioctl causes deadlock with a chcp or mkcp -s command:

    chcp D ffff88013870f3d0 0 1325 1324 0x00000004
    ...
    Call Trace:
    nilfs_transaction_begin+0x11c/0x1a0 [nilfs2]
    wake_up_bit+0x20/0x20
    copy_from_user+0x18/0x30 [nilfs2]
    nilfs_ioctl_change_cpmode+0x7d/0xcf [nilfs2]
    nilfs_ioctl+0x252/0x61a [nilfs2]
    do_page_fault+0x311/0x34c
    get_unmapped_area+0x132/0x14e
    do_vfs_ioctl+0x44b/0x490
    __set_task_blocked+0x5a/0x61
    vm_mmap_pgoff+0x76/0x87
    __set_current_blocked+0x30/0x4a
    sys_ioctl+0x4b/0x6f
    system_call_fastpath+0x16/0x1b
    thaw D ffff88013870d890 0 1352 1351 0x00000004
    ...
    Call Trace:
    rwsem_down_failed_common+0xdb/0x10f
    call_rwsem_down_write_failed+0x13/0x20
    down_write+0x25/0x27
    thaw_super+0x13/0x9e
    do_vfs_ioctl+0x1f5/0x490
    vm_mmap_pgoff+0x76/0x87
    sys_ioctl+0x4b/0x6f
    filp_close+0x64/0x6c
    system_call_fastpath+0x16/0x1b

    where the thaw ioctl deadlocked at thaw_super() when called while chcp was
    waiting at nilfs_transaction_begin() called from
    nilfs_ioctl_change_cpmode(). This deadlock is 100% reproducible.

    This is because nilfs_ioctl_change_cpmode() first locks sb->s_umount in
    read mode and then waits for unfreezing in nilfs_transaction_begin(),
    whereas thaw_super() locks sb->s_umount in write mode. The locking of
    sb->s_umount here was intended to make snapshot mounts and the downgrade
    of snapshots to checkpoints exclusive.

    This fixes the deadlock issue by replacing the sb->s_umount usage in
    nilfs_ioctl_change_cpmode() with a dedicated mutex which protects snapshot
    mounts.

    Signed-off-by: Ryusuke Konishi
    Cc: Fernando Luis Vazquez Cao
    Tested-by: Ryusuke Konishi
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ryusuke Konishi
     

17 Mar, 2012

2 commits

  • According to the report from Slicky Devil, nilfs caused kernel oops at
    nilfs_load_super_block function during mount after he shrank the
    partition without resizing the filesystem:

    BUG: unable to handle kernel NULL pointer dereference at 00000048
    IP: [] nilfs_load_super_block+0x17e/0x280 [nilfs2]
    *pde = 00000000
    Oops: 0000 [#1] PREEMPT SMP
    ...
    Call Trace:
    [] init_nilfs+0x4b/0x2e0 [nilfs2]
    [] nilfs_mount+0x447/0x5b0 [nilfs2]
    [] mount_fs+0x36/0x180
    [] vfs_kern_mount+0x51/0xa0
    [] do_kern_mount+0x3e/0xe0
    [] do_mount+0x169/0x700
    [] sys_mount+0x6b/0xa0
    [] sysenter_do_call+0x12/0x28
    Code: 53 18 8b 43 20 89 4b 18 8b 4b 24 89 53 1c 89 43 24 89 4b 20 8b 43
    20 c7 43 2c 00 00 00 00 23 75 e8 8b 50 68 89 53 28 8b 54 b3 20 72
    48 8b 7a 4c 8b 55 08 89 b3 84 00 00 00 89 bb 88 00 00 00
    EIP: [] nilfs_load_super_block+0x17e/0x280 [nilfs2] SS:ESP 0068:ca9bbdcc
    CR2: 0000000000000048

    This turned out due to a defect in an error path which runs if the
    calculated location of the secondary super block was invalid.

    This patch fixes it and eliminates the reported oops.

    Reported-by: Slicky Devil
    Signed-off-by: Ryusuke Konishi
    Tested-by: Slicky Devil
    Cc: [2.6.30+]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ryusuke Konishi
     
  • ns_r_segments_percentage is read from the disk. Bogus or malicious
    value could cause integer overflow and malfunction due to meaningless
    disk usage calculation. This patch reports error when mounting such
    bogus volumes.

    Signed-off-by: Haogang Chen
    Signed-off-by: Ryusuke Konishi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Haogang Chen
     

10 May, 2011

1 commit


09 Mar, 2011

4 commits


08 Mar, 2011

1 commit

  • At present, the same warning message can be output twice when nilfs
    detected a problem on super blocks:

    NILFS warning: broken superblock. using spare superblock.
    NILFS warning: broken superblock. using spare superblock.
    ...

    This is because these super blocks are reloaded with the block size
    written in a super block if it differs from the first block size, but
    this repetition looks somewhat confusing. So, we hint at what is
    going on by appending block size information to those messages.

    Reported-by: Wakko Warner
    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     

10 Jan, 2011

2 commits


23 Oct, 2010

12 commits

  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ryusuke/nilfs2: (36 commits)
    nilfs2: eliminate sparse warning - "context imbalance"
    nilfs2: eliminate sparse warnings - "symbol not declared"
    nilfs2: get rid of bdi from nilfs object
    nilfs2: change license of exported header file
    nilfs2: add bdev freeze/thaw support
    nilfs2: accept 64-bit checkpoint numbers in cp mount option
    nilfs2: remove own inode allocator and destructor for metadata files
    nilfs2: get rid of back pointer to writable sb instance
    nilfs2: get rid of mi_nilfs back pointer to nilfs object
    nilfs2: see state of root dentry for mount check of snapshots
    nilfs2: use iget for all metadata files
    nilfs2: get rid of GCDAT inode
    nilfs2: add routines to redirect access to buffers of DAT file
    nilfs2: add routines to roll back state of DAT file
    nilfs2: add routines to save and restore bmap state
    nilfs2: do not allocate nilfs_mdt_info structure to gc-inodes
    nilfs2: allow nilfs_clear_inode to clear metadata file inodes
    nilfs2: get rid of snapshot mount flag
    nilfs2: simplify life cycle management of nilfs object
    nilfs2: do not allocate multiple super block instances for a device
    ...

    Linus Torvalds
     
  • Nilfs now can use sb->s_bdi to get backing_dev_info, so we use it
    instead of ns_bdi on the nilfs object and remove ns_bdi.

    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     
  • Nilfs object holds a back pointer to a writable super block instance
    in nilfs->ns_writer, and this became eliminable since sb is now made
    per device and all inodes have a valid pointer to it.

    This deletes the ns_writer pointer and a reader/writer semaphore
    protecting it.

    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     
  • After applied the patch that unified sb instances, root dentry of
    snapshots can be left in dcache even after their trees are unmounted.

    The orphan root dentry/inode keeps a root object, and this causes
    false positive of nilfs_checkpoint_is_mounted function.

    This resolves the issue by having nilfs_checkpoint_is_mounted test
    whether the root dentry is busy or not.

    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     
  • This makes use of iget5_locked to allocate or get inode for metadata
    files to stop using own inode allocator.

    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     
  • 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
     
  • This stops pre-allocating nilfs object in nilfs_get_sb routine, and
    stops managing its life cycle by reference counting.

    nilfs_find_or_create_nilfs() function, nilfs->ns_mount_mutex,
    nilfs_objects list, and the reference counter will be removed through
    the simplification.

    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     
  • This stops allocating multiple super block instances for a device.

    All snapshots and a current mode mount (i.e. latest tree) will be
    controlled with nilfs_root objects that are kept within an sb
    instance.

    nilfs_get_sb() is rewritten so that it always has a root object for
    the latest tree and snapshots make additional root objects.

    The root dentry of the latest tree is binded to sb->s_root even if it
    isn't attached on a directory. Root dentries of snapshots or the
    latest tree are binded to mnt->mnt_root on which they are mounted.

    With this patch, nilfs_find_sbinfo() function, nilfs->ns_supers list,
    and nilfs->ns_current back pointer, are deleted. In addition,
    init_nilfs() and load_nilfs() are simplified since they will be called
    once for a device, not repeatedly called for mount points.

    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     
  • This rewrites nilfs_checkpoint_is_mounted() function so that it
    decides whether a checkpoint is mounted by whether the corresponding
    root object is found in checkpoint tree.

    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     
  • To hold multiple versions of a filesystem in one sb instance, a new
    on-memory structure is necessary to handle one or more checkpoints.

    This adds a red-black tree of checkpoints to nilfs object, and adds
    lookup and create functions for them.

    Each checkpoint is represented by "nilfs_root" structure, and this
    structure has rb_node to configure the rb-tree.

    The nilfs_root object is identified with a checkpoint number. For
    each snapshot, a nilfs_root object is allocated and the checkpoint
    number of snapshot is assigned to it. For a regular mount
    (i.e. current mode mount), NILFS_CPTREE_CURRENT_CNO constant is
    assigned to the corresponding nilfs_root object.

    Each nilfs_root object has an ifile inode and some counters. These
    items will displace those of nilfs_sb_info structure in successive
    patches.

    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     
  • This uses inode hash function that vfs provides instead of the own
    hash table for caching gc inodes. This finally removes the own inode
    hash from nilfs.

    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     
  • Compatibility of nilfs partitions is now managed with three feature
    sets. This changes old compatibility check with revision number so
    that it can accept future revisions.

    Note that we can stop support of experimental versions of nilfs that
    doesn't know the feature sets by incrementing NILFS_CURRENT_REV. We
    don't have to do it soon, but it would be a possible option whenever
    the need arises.

    Signed-off-by: Ryusuke Konishi

    Ryusuke Konishi
     

19 Oct, 2010

1 commit


17 Sep, 2010

1 commit

  • All the blkdev_issue_* helpers can only sanely be used for synchronous
    caller. To issue cache flushes or barriers asynchronously the caller needs
    to set up a bio by itself with a completion callback to move the asynchronous
    state machine ahead. So drop the BLKDEV_IFL_WAIT flag that is always
    specified when calling blkdev_issue_* and also remove the now unused flags
    argument to blkdev_issue_flush and blkdev_issue_zeroout. For
    blkdev_issue_discard we need to keep it for the secure discard flag, which
    gains a more descriptive name and loses the bitops vs flag confusion.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     

10 Sep, 2010

1 commit

  • Switch to the WRITE_FLUSH_FUA flag for log writes, remove the EOPNOTSUPP
    detection for barriers and stop setting the barrier flag for discards.

    tj: nilfs is now fixed to wait for discard completion. Updated this
    patch accordingly and dropped warning about it.

    Signed-off-by: Christoph Hellwig
    Acked-by: Ryusuke Konishi
    Signed-off-by: Tejun Heo
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     

30 Aug, 2010

1 commit


18 Aug, 2010

1 commit

  • nilfs_discard_segment() doesn't wait for completion of discard
    requests. This specifies BLKDEV_IFL_WAIT flag when calling
    blkdev_issue_discard() in order to fix the sync failure.

    Reported-by: Christoph Hellwig
    Signed-off-by: Ryusuke Konishi
    Cc: Christoph Hellwig

    Ryusuke Konishi