19 Aug, 2011

1 commit

  • With
    $ grep -e UBIFS_FS_DEBUG -e DYNAMIC_DEBUG .config
    # CONFIG_UBIFS_FS_DEBUG is not set
    CONFIG_DYNAMIC_DEBUG=y

    Debug messages are kept in the object files due to the
    dynamic_pr_debug() macro, even if they are never going to be printed:
    $ make fs/ubifs/super.o
    $ strings fs/ubifs/super.o | grep 'compiled on'
    compiled on: Aug 11 2011 at 12:21:38

    Use plain printk to fix this.

    Signed-off-by: Michal Marek
    Signed-off-by: Artem Bityutskiy

    Michal Marek
     

23 Jul, 2011

1 commit

  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6: (107 commits)
    vfs: use ERR_CAST for err-ptr tossing in lookup_instantiate_filp
    isofs: Remove global fs lock
    jffs2: fix IN_DELETE_SELF on overwriting rename() killing a directory
    fix IN_DELETE_SELF on overwriting rename() on ramfs et.al.
    mm/truncate.c: fix build for CONFIG_BLOCK not enabled
    fs:update the NOTE of the file_operations structure
    Remove dead code in dget_parent()
    AFS: Fix silly characters in a comment
    switch d_add_ci() to d_splice_alias() in "found negative" case as well
    simplify gfs2_lookup()
    jfs_lookup(): don't bother with . or ..
    get rid of useless dget_parent() in btrfs rename() and link()
    get rid of useless dget_parent() in fs/btrfs/ioctl.c
    fs: push i_mutex and filemap_write_and_wait down into ->fsync() handlers
    drivers: fix up various ->llseek() implementations
    fs: handle SEEK_HOLE/SEEK_DATA properly in all fs's that define their own llseek
    Ext4: handle SEEK_HOLE/SEEK_DATA generically
    Btrfs: implement our own ->llseek
    fs: add SEEK_HOLE and SEEK_DATA flags
    reiserfs: make reiserfs default to barrier=flush
    ...

    Fix up trivial conflicts in fs/xfs/linux-2.6/xfs_super.c due to the new
    shrinker callout for the inode cache, that clashed with the xfs code to
    start the periodic workers later.

    Linus Torvalds
     

21 Jul, 2011

1 commit

  • Btrfs needs to be able to control how filemap_write_and_wait_range() is called
    in fsync to make it less of a painful operation, so push down taking i_mutex and
    the calling of filemap_write_and_wait() down into the ->fsync() handlers. Some
    file systems can drop taking the i_mutex altogether it seems, like ext3 and
    ocfs2. For correctness sake I just pushed everything down in all cases to make
    sure that we keep the current behavior the same for everybody, and then each
    individual fs maintainer can make up their mind about what to do from there.
    Thanks,

    Acked-by: Jan Kara
    Signed-off-by: Josef Bacik
    Signed-off-by: Al Viro

    Josef Bacik
     

08 Jul, 2011

1 commit

  • When the 1st LEB was unmapped and written but 2nd LEB not,
    the master node recovery doesn't succeed after power cut.
    We see following error when mounting UBIFS partition on NOR
    flash:

    UBIFS error (pid 1137): ubifs_recover_master_node: failed to recover master node

    Correct 2nd master node offset check is needed to fix the
    problem. If the 2nd master node is at the end in the 2nd LEB,
    first master node is used for recovery. When checking for this
    condition we should check whether the master node is exactly at
    the end of the LEB (without remaining empty space) or whether
    it is followed by an empty space less than the master node size.

    Artem: when the error happened, offs2 = 261120, sz = 512, c->leb_size = 262016.

    Signed-off-by: Anatolij Gustschin
    Signed-off-by: Artem Bityutskiy

    Anatolij Gustschin
     

04 Jul, 2011

30 commits

  • This patch cleans-up and improves the power cut testing:

    1. Kill custom 'simple_random()' function and use 'random32()' instead.
    2. Make timeout larger
    3. When cutting the buffer - fill the end with random data sometimes, not
    only with 0xFFs.
    4. Some times cut in the middle of the buffer, not always at the end.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Since the recovery testing is effectively about emulating power cuts by UBIFS,
    use "power cut" as the base term for all the related variables and name them
    correspondingly. This is just a minor clean-up for the sake of readability.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • This is a clean-up of the power-cut emulation code - remove the custom list of
    superblocks which we maintained to find the superblock by the UBI volume
    descriptor. We do not need that crud any longer, because now we can get the
    superblock as a function argument.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Now when we use UBIFS helpers for all the I/O, we can remove the horrible hack
    of re-defining UBI I/O functions.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Switch the rest of direct UBI calls to UBIFS helper functions.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Stop using 'ubi_leb_write()' directly and switch to the 'ubifs_leb_write()'
    helper.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Instead of using 'ubi_read()' function directly, used the 'ubifs_leb_read()'
    helper function instead. This allows to get rid of several redundant error
    messages and make sure that we always have a stack dump on read errors.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Introduce the following I/O helper functions: 'ubifs_leb_read()',
    'ubifs_leb_write()', 'ubifs_leb_change()', 'ubifs_leb_unmap()',
    'ubifs_leb_map()', 'ubifs_is_mapped().

    The idea is to wrap all UBI I/O functions in order to encapsulate various
    assertions and error path handling (error message, stack dump, switching to R/O
    mode). And there are some other benefits of this which will be used in the
    following patches.

    This patch does not switch whole UBIFS to use these functions yet.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • When switching to R/O mode due to an I/O error, always dump the stack, not only
    when debugging is enabled.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • This patch contains several minor clean-up and preparational cahnges.

    1. Remove 'dbg_read()', 'dbg_write()', 'dbg_change()', and 'dbg_leb_erase()'
    functions as they are not used.
    2. Remove 'dbg_leb_read()' and 'dbg_is_mapped()' as they are not really needed,
    it is fine to let reads go through in failure mode.
    3. Rename 'offset' argument to 'offs' to be consistent with the rest of UBIFS
    code.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Now we have per-FS (superblock) debugfs knobs, but they have one drawback - you
    have to first mount the FS and only after this you can switch self-checks
    on/off. But often we want to have the checks enabled during the mount.
    Introduce global debugging knobs for this purpose.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Separate out pieces of code from the debugfs file read/write functions and
    create separate 'interpret_user_input()'/'provide_user_output()' helpers. These
    helpers will be needed in one of the following patches, so this is just a
    preparational change.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Move 'dbg_debugfs_init()' and 'dbg_debugfs_exit()' functions which initialize
    debugfs for whole UBIFS subsystem below the code which initializes debugfs for
    a particular UBIFS instance. And do the same for 'ubifs_debugging_init()' and
    'ubifs_debugging_exit()' functions. This layout is a bit better for the next
    patches, so this is just a preparation.

    Also, rename 'open_debugfs_file()' into 'dfs_file_open()' for consistency.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • When we are testing UBIFS recovery, it is better to print in which eraseblock
    we are going to fail. Currently UBIFS prints it only if recovery debugging
    messages are enabled, but this is not very practical. So change 'dbg_rcvry()'
    messages to 'ubifs_warn()' messages.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • UBIFS has many built-in self-check functions which can be enabled using the
    debug_chks module parameter or the corresponding sysfs file
    (/sys/module/ubifs/parameters/debug_chks). However, this is not flexible enough
    because it is not per-filesystem. This patch moves this to debugfs interfaces.

    We already have debugfs support, so this patch just adds more debugfs files.
    While looking at debugfs support I've noticed that it is racy WRT file-system
    unmount, and added a TODO entry for that. This problem has been there for long
    time and it is quite standard debugfs PITA. The plan is to fix this later.

    This patch is simple, but it is large because it changes many places where we
    check if a particular type of checks is enabled or disabled.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • We have too many different debugging checks - lessen the amount by merging all
    index-related checks into one. At the same time, move the "force in-the-gap"
    test to the "index checks" class, because it is too heavy for the "general"
    class.

    This patch merges TNC, Old index, and Index size check and calles this just
    "index checks".

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • This patch introduces helper functions for all debugging checks, so instead of
    doing

    if (!(ubifs_chk_flags & UBIFS_CHK_GEN))

    we now do

    if (!dbg_is_chk_gen(c))

    This is a preparation to further changes where the flags will go away, and
    we'll need to only change the helper functions, but the code which utilizes
    them won't be touched.

    At the same time this patch removes 'dbg_force_in_the_gaps()',
    'dbg_force_in_the_gaps_enabled()', and dbg_failure_mode helpers for
    consistency.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Add 'const struct ubifs_info *c' parameter to 'dbg_check_synced_i_size()'
    function because we'll need it in the next patch when we switch to debugfs.
    So this patch is just a preparation.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Add 'struct ubifs_info *c' parameter to the 'dbg_check_name()' debugging
    function - it will be needed in one of the following commits where we switch to
    debugfs. So this is just a preparation.

    Mark parameters as 'const' while on it.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Add a couple of comments - while looking into TNC I could not easily figure out
    few facts, so it is a good idea to document them in the code.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • The UBIFS lpt tree is in many aspects similar to the TNC tree, and we have
    similar flags for these trees. And by mistake we use the COW_ZNODE flag for
    LPT in some places, instead of the right flag COW_CNODE. And this works
    only because these two constants have the same value.

    This patch makes all the LPT code to use COW_CNODE and also changes COW_CNODE
    constant value to make sure we do not misuse the flags any more.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • We have 3 znode flags: cow, obsolete, dirty. For the last flag we have a
    'ubifs_zn_dirty()' helper function, but for the other 2 flags we use
    'test_bit()' directly.

    This patch makes the situation more consistent and introduces helpers for the
    other 2 flags: 'ubifs_zn_cow()' and 'ubifs_zn_obsolete()'.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Remove dead pieces of code under "if (c->min_io_size == 1)" statement -
    we never execute it because in UBIFS 'c->min_io_size' is always at least 8.
    This are leftovers from old pre-mainline prototype.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Remove unnecessary brackets in "inode->i_flags |= (S_NOCMTIME)" statement to
    make the code not look silly.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Instead of using long "(inode->i_mode & S_IFMT) != S_IFREG" expression, use
    shorted "!S_ISREG(inode->i_mode)".

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Since this function is not only about size checking, rename it to
    'dbg_check_dir()'.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Teach 'dbg_dump_inode()' dump directory entries for directory inodes.
    This requires few additional changes:
    1. The 'c' argument of 'dbg_dump_inode()' cannot be const any more.
    2. Users of 'dbg_dump_inode()' should not have 'tnc_mutex' locked.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • When we fail to read a pnode or nnode - print stacktrace if debugging is enabled.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • This patch lessens the 'struct ubifs_debug_info' size by 90 bytes by
    allocating less bytes for the debugfs root directory name. It introduces macros
    for the name patter an length instead of hard-coding 100 bytes. It also makes
    UBIFS use 'snprintf()' and teaches it to gracefully catch situations when the
    name array is too short.

    Additionally, this patch makes 2 unrelated changes - I just thought they do not
    deserve separate commits: simplifies 'ubifs_assert()' for non-debugging case
    and makes 'dbg_debugfs_init()' properly verify debugfs return code which may be
    an error code or NULL, so we should you 'IS_ERR_OR_NULL()' instead of
    'IS_ERR()'.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • If commit failed and it is in broken state, UBIFS switches to R/O mode. Most
    operations return -EROFS in this case, except of commit which returns -EINVAL.
    Make it return -EROFS too for consistency. This is also important for our power
    cut emulation testing.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     

20 Jun, 2011

1 commit


13 Jun, 2011

2 commits

  • * allocate ubifs_info in ->mount(), fill it enough for sb_test() and
    set ->s_fs_info to it in set() callback passed to sget().
    * do *not* free it in ->put_super(); do that in ->kill_sb() after we'd
    done kill_anon_super().
    * don't free it in ubifs_fill_super() either - deactivate_locked_super()
    done by caller when ubifs_fill_super() returns an error will take care
    of that sucker.
    * get rid of kludge with passing ubi to ubifs_fill_super() in ->s_fs_info;
    we only need it in alloc_ubifs_info(), so ubifs_fill_super() will need
    only ubifs_info. Which it will find in ->s_fs_info just fine, no need to
    reassign anything...

    As the result, sb_test() becomes safe to apply to all superblocks that
    can be found by sget() (and a kludge with temporary use of ->s_fs_info
    to store a pointer to very different structure goes away).

    Signed-off-by: Al Viro

    Al Viro
     
  • preparation to ubifs sget() race fixes

    Signed-off-by: Al Viro

    Al Viro
     

03 Jun, 2011

3 commits

  • The free space fixup is currently initiated during mount after the call to
    ubifs_write_master() which results in a write to PEBs; this has been observed
    with the patch 'assert no fixup when writing a node' applied:

    Move the free space fixup on mount to before the calls to
    ubifs_recover_inl_heads() and ubifs_write_master(). This results in no
    assertions with the previously mentioned patch applied.

    Artem: tweaked the patch a bit

    Signed-off-by: Ben Gardiner
    Reviewed-by: Matthew L. Creech
    Signed-off-by: Artem Bityutskiy

    Ben Gardiner
     
  • The current 'mount_ubifs()' implementation does not initialize the LPT until the
    the master node is marked dirty. Move the LPT initialization to before marking
    the master node dirty. This is a preparation for the next patch which will move
    the free-space-fixup check to before marking the master node dirty, because we
    have to fix-up the free space before doing any writes.

    Artem: massaged the patch and commit message.

    Signed-off-by: Ben Gardiner
    Reviewed-by: Matthew L. Creech
    Signed-off-by: Artem Bityutskiy

    Ben Gardiner
     
  • The current free space fixup can result in some writing to the UBI volume
    when the space_fixup flag is set.

    To catch instances where UBIFS is writing to the NAND while the space_fixup
    flag is set, add an assert to ubifs_write_node().

    Artem: tweaked the patch, added similar assertion to the write buffer
    write path.

    Signed-off-by: Ben Gardiner
    Reviewed-by: Matthew L. Creech
    Signed-off-by: Artem Bityutskiy

    Ben Gardiner