01 Nov, 2011

1 commit


05 Oct, 2011

1 commit


17 Aug, 2011

1 commit

  • Delete nontrivial initialization that is immediately overwritten by the
    result of an allocation function.

    The semantic match that makes this change is as follows:
    (http://coccinelle.lip6.fr/)

    //
    @@
    type T;
    identifier i;
    expression e;
    @@

    (
    T i = \(0\|NULL\|ERR_PTR(...)\);
    |
    -T i = e;
    +T i;
    )
    ... when != i
    i = \(kzalloc\|kcalloc\|kmalloc\)(...);

    //

    Signed-off-by: Julia Lawall
    Signed-off-by: Jan Kara

    Julia Lawall
     

25 Jun, 2011

2 commits

  • We should return -EINVAL when the FITRIM parameters are not sane, but
    currently we are exiting silently if start is beyond the end of the
    file system. This commit fixes this so we return -EINVAL as other file
    systems do.

    Signed-off-by: Lukas Czerner
    CC: Jan Kara
    Signed-off-by: Jan Kara

    Lukas Czerner
     
  • This commit adds fixed tracepoints to the ext3 code. It is based on ext4
    tracepoints, however due to the differences of both file systems, there
    are some tracepoints missing (those for delaloc and for multi-block
    allocator) and there are some ext3 specific as well (for reservation
    windows).

    Here is a list:

    ext3_free_inode
    ext3_request_inode
    ext3_allocate_inode
    ext3_evict_inode
    ext3_drop_inode
    ext3_mark_inode_dirty
    ext3_write_begin
    ext3_ordered_write_end
    ext3_writeback_write_end
    ext3_journalled_write_end
    ext3_ordered_writepage
    ext3_writeback_writepage
    ext3_journalled_writepage
    ext3_readpage
    ext3_releasepage
    ext3_invalidatepage
    ext3_discard_blocks
    ext3_request_blocks
    ext3_allocate_blocks
    ext3_free_blocks
    ext3_sync_file_enter
    ext3_sync_file_exit
    ext3_sync_fs
    ext3_rsv_window_add
    ext3_discard_reservation
    ext3_alloc_new_reservation
    ext3_reserved
    ext3_forget
    ext3_read_block_bitmap
    ext3_direct_IO_enter
    ext3_direct_IO_exit
    ext3_unlink_enter
    ext3_unlink_exit
    ext3_truncate_enter
    ext3_truncate_exit
    ext3_get_blocks_enter
    ext3_get_blocks_exit
    ext3_load_inode

    Signed-off-by: Lukas Czerner
    Cc: Jan Kara
    Signed-off-by: Jan Kara

    Lukas Czerner
     

31 Mar, 2011

1 commit


04 Mar, 2011

1 commit

  • In a bs=4096 volume, if we call FITRIM with the following parameter as
    fstrim_range(start = 102400, len = 134144000, minlen = 10240), with the
    following code:
    if (len >= EXT3_BLOCKS_PER_GROUP(sb))
    len -= (EXT3_BLOCKS_PER_GROUP(sb) - first_block);
    else
    last_block = first_block + len;

    So if len < EXT3_BLOCKS_PER_GROUP while first_block + len >
    EXT3_BLOCKS_PER_GROUP, last_block will be set to an overflow value
    which exceeds EXT3_BLOCKS_PER_GROUP.

    This patch fixes it and adjusts len and last_block accordingly.

    Cc: Lukas Czerner
    Cc: Jan Kara
    Signed-off-by: Tao Ma
    Signed-off-by: Jan Kara

    Tao Ma
     

24 Feb, 2011

2 commits

  • When we trim some free blocks in a group of ext3, we should
    calculate the free blocks properly and check whether there are
    enough freed blocks left for us to trim. Current solution will
    only calculate free spaces if they are large for a trim which
    is wrong.

    Let us see a small example:
    a group has 1.5M free which are 300k, 300k, 300k, 300k, 300k.
    And minblocks is 1M. With current solution, we have to iterate
    the whole group since these 300k will never be subtracted from
    1.5M. But actually we should exit after we find the first 2
    free spaces since the left 3 chunks only sum up to 900K if we
    subtract the first 600K although they can't be trimed.

    Cc: Jan Kara
    Cc: Lukas Czerner
    Signed-off-by: Tao Ma
    Signed-off-by: Jan Kara

    Tao Ma
     
  • As we have make the consense in the e-mail[1], the trim start should
    be added with first_data_block. So this patch fulfill it and remove
    the check for start < first_data_block.

    [1] http://www.spinics.net/lists/linux-ext4/msg22737.html

    Cc: Jan Kara
    Cc: Lukas Czerner
    Signed-off-by: Tao Ma
    Signed-off-by: Jan Kara

    Tao Ma
     

11 Jan, 2011

1 commit

  • Walk through allocation groups and trim all free extents. It can be
    invoked through FITRIM ioctl on the file system. The main idea is to
    provide a way to trim the whole file system if needed, since some SSD's
    may suffer from performance loss after the whole device was filled (it
    does not mean that fs is full!).

    It search for free extents in allocation groups specified by Byte range
    start -> start+len. When the free extent is within this range, blocks are
    marked as used and then trimmed. Afterwards these blocks are marked as
    free in per-group bitmap.

    [JK: Fixed up error handling and trimming of a single group]

    Signed-off-by: Lukas Czerner
    Reviewed-by: Jan Kara
    Reviewed-by: Dmitry Monakhov
    Signed-off-by: Jan Kara

    Lukas Czerner
     

28 Oct, 2010

2 commits


22 May, 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
     

05 Mar, 2010

1 commit

  • Get rid of the alloc_space, free_space, reserve_space, claim_space and
    release_rsv dquot operations - they are always called from the filesystem
    and if a filesystem really needs their own (which none currently does)
    it can just call into it's own routine directly.

    Move shared logic into the common __dquot_alloc_space,
    dquot_claim_space_nodirty and __dquot_free_space low-level methods,
    and rationalize the wrappers around it to move as much as possible
    code into the common block for CONFIG_QUOTA vs not. Also rename
    all these helpers to be named dquot_* instead of vfs_dq_*.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Christoph Hellwig
     

12 Jun, 2009

1 commit


26 Mar, 2009

1 commit


14 Nov, 2008

1 commit

  • Wrap access to task credentials so that they can be separated more easily from
    the task_struct during the introduction of COW creds.

    Change most current->(|e|s|fs)[ug]id to current_(|e|s|fs)[ug]id().

    Change some task->e?[ug]id to task_e?[ug]id(). In some places it makes more
    sense to use RCU directly rather than a convenient wrapper; these will be
    addressed by later patches.

    Signed-off-by: David Howells
    Reviewed-by: James Morris
    Acked-by: Serge Hallyn
    Cc: Stephen Tweedie
    Cc: Andrew Morton
    Cc: adilger@sun.com
    Cc: linux-ext4@vger.kernel.org
    Signed-off-by: James Morris

    David Howells
     

20 Oct, 2008

1 commit

  • We could run into ENOSPC error on ext3, even when there is free blocks on
    the filesystem.

    The problem is triggered in the case the goal block group has 0 free
    blocks , and the rest block groups are skipped due to the check of
    "free_blocks < windowsz/2". Current code could fall back to non
    reservation allocation to prevent early ENOSPC after examing all the block
    groups with reservation on , but this code was bypassed if the reservation
    window is turned off already, which is true in this case.

    This patch fixed two issues:
    1) We don't need to turn off block reservation if the goal block group has
    0 free blocks left and continue search for the rest of block groups.

    Current code the intention is to turn off the block reservation if the
    goal allocation group has a few (some) free blocks left (not enough for
    make the desired reservation window),to try to allocation in the goal
    block group, to get better locality. But if the goal blocks have 0 free
    blocks, it should leave the block reservation on, and continues search for
    the next block groups,rather than turn off block reservation completely.

    2) we don't need to check the window size if the block reservation is off.

    The problem was originally found and fixed in ext4.

    Signed-off-by: Mingming Cao
    Cc: Theodore Ts'o
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mingming Cao
     

28 Apr, 2008

3 commits

  • __FUNCTION__ is gcc-specific, use __func__

    Signed-off-by: Harvey Harrison
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Harvey Harrison
     
  • If the block allocator gets blocks out of system zone ext3 calls ext3_error.
    But if the file system is mounted with errors=continue retry block allocation.
    We need to mark the system zone blocks as in use to make sure retry don't
    pick them again

    System zone is the block range mapping block bitmap, inode bitmap and inode
    table.

    [akpm@linux-foundation.org: fix typo in comment]
    Signed-off-by: Aneesh Kumar K.V
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Aneesh Kumar K.V
     
  • if (...) BUG(); should be replaced with BUG_ON(...) when the test has no
    side-effects to allow a definition of BUG_ON that drops the code completely.

    The semantic patch that makes this change is as follows:
    (http://www.emn.fr/x-info/coccinelle/)

    //
    @ disable unlikely @ expression E,f; @@

    (
    if () { BUG(); }
    |
    - if (unlikely(E)) { BUG(); }
    + BUG_ON(E);
    )

    @@ expression E,f; @@

    (
    if () { BUG(); }
    |
    - if (E) { BUG(); }
    + BUG_ON(E);
    )
    //

    Signed-off-by: Julia Lawall
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Julia Lawall
     

09 Feb, 2008

1 commit

  • replace all:
    little_endian_variable = cpu_to_leX(leX_to_cpu(little_endian_variable) +
    expression_in_cpu_byteorder);
    with:
    leX_add_cpu(&little_endian_variable, expression_in_cpu_byteorder);
    sparse didn't generate any new warning with this patch

    Signed-off-by: Marcin Slusarz
    Cc: Mark Fasheh
    Cc: David Chinner
    Cc: Timothy Shimmin
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Marcin Slusarz
     

07 Feb, 2008

4 commits

  • Use ext[234]_bg_has_super() to remove duplicate code.

    Signed-off-by: Akinobu Mita
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Akinobu Mita
     
  • The comment in ext[234]_new_blocks() describes about "i". But there is no
    local variable called "i" in that scope. I guess it has been renamed to
    group_no.

    Cc:
    Signed-off-by: Akinobu Mita
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Akinobu Mita
     
  • This fixes some instances where we were continuing after calling
    ext3_error. ext3_error calls panic only if errors=panic mount option is
    set. So we need to make sure we return correctly after ext3_error call

    Signed-off-by: Aneesh Kumar K.V
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Aneesh Kumar K.V
     
  • When a new block bitmap is read from disk in read_block_bitmap() there are a
    few bits that should ALWAYS be set. In particular, the blocks given
    corresponding to block bitmap, inode bitmap and inode tables. Validate the
    block bitmap against these blocks.

    Signed-off-by: Aneesh Kumar K.V
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Aneesh Kumar K.V
     

14 Nov, 2007

1 commit

  • This reverts commit 7c9e69faa28027913ee059c285a5ea8382e24b5d, fixing up
    conflicts in fs/ext4/balloc.c manually.

    The cost of doing the bitmap validation on each lookup - even when the
    bitmap is cached - is absolutely prohibitive. We could, and probably
    should, do it only when adding the bitmap to the buffer cache. However,
    right now we are better off just reverting it.

    Peter Zijlstra measured the cost of this extra validation as a 85%
    decrease in cached iozone, and while I had a patch that took it down to
    just 17% by not being _quite_ so stupid in the validation, it was still
    a big slowdown that could have been avoided by just doing it right.

    Cc: Peter Zijlstra
    Cc: Andrew Morton
    Cc: Aneesh Kumar
    Cc: Andreas Dilger
    Cc: Mingming Cao
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

17 Oct, 2007

3 commits

  • When a new block bitmap is read from disk in read_block_bitmap() there are
    a few bits that should ALWAYS be set. In particular, the blocks given by
    ext4_blk_bitmap, ext4_inode_bitmap and ext4_inode_table. Validate the
    block bitmap against these blocks.

    [akpm@linux-foundation.org: cleanups]
    Signed-off-by: Aneesh Kumar K.V
    Signed-off-by: Andreas Dilger
    Acked-by: Mingming Cao
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Aneesh Kumar K.V
     
  • Hugh spotted that some code does:
    percpu_counter_add(&counter, -unsignedlong)

    which, when the amount argument is of type s32, sort-of works thanks to
    two's-complement. However when we'd change the type to s64 this breaks on 32bit
    machines, because the promotion rules zero extend the unsigned number.

    Provide percpu_counter_sub() to hide the s64 cast. That is:
    percpu_counter_sub(&counter, foo)
    is equal to:
    percpu_counter_add(&counter, -(s64)foo);

    Signed-off-by: Peter Zijlstra
    Cc: Hugh Dickins
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Peter Zijlstra
     
  • s/percpu_counter_mod/percpu_counter_add/

    Because its a better name, _mod implies modulo.

    Signed-off-by: Peter Zijlstra
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Peter Zijlstra
     

21 Feb, 2007

1 commit


08 Dec, 2006

7 commits

  • Port fix to the off-by-one in find_next_usable_block's memscan from ext2 to
    ext3; but it didn't cause a serious problem for ext3 because the additional
    ext3_test_allocatable check rescued it from the error.

    Signed-off-by: Mingming Cao
    Signed-off-by: Hugh Dickins
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Hugh Dickins
     
  • ext3_new_blocks has a nice io_error label for setting -EIO, so goto that in
    the one place that doesn't already use it.

    Signed-off-by: Mingming Cao
    Signed-off-by: Hugh Dickins
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Hugh Dickins
     
  • The reservations tree is an rb_tree not a list, so it's less confusing to use
    rb_entry() than list_entry() - though they're both just container_of().

    Signed-off-by: Mingming Cao
    Signed-off-by: Hugh Dickins
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Hugh Dickins
     
  • rsv_end is the last block within the reservation, so alloc_new_reservation
    should accept start_block == rsv_end as success.

    Signed-off-by: Mingming Cao
    Signed-off-by: Hugh Dickins
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Hugh Dickins
     
  • grp_goal 0 is a genuine goal (unlike -1), so ext3_try_to_allocate_with_rsv
    should treat it as such.

    Signed-off-by: Mingming Cao
    Signed-off-by: Hugh Dickins
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Hugh Dickins
     
  • ext3_new_blocks should reset the reservation window size to 0 when squeezing
    the last blocks out of an almost full filesystem, so the retry doesn't skip
    any groups with less than half that free, reporting ENOSPC too soon.

    Signed-off-by: Mingming Cao
    Signed-off-by: Hugh Dickins
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Hugh Dickins
     
  • Hugh Dickins wrote:
    > Not found anything relevant, but I keep noticing these lines
    > in ext2_try_to_allocate_with_rsv(), ext3 and ext4 similar:
    >
    > } else if (grp_goal > 0 &&
    > (my_rsv->rsv_end - grp_goal + 1) < *count)
    > try_to_extend_reservation(my_rsv, sb,
    > *count-my_rsv->rsv_end + grp_goal - 1);
    >
    > They're wrong, a no-op in most groups, aren't they? rsv_end is an
    > absolute block number, whereas grp_goal is group-relative, so the
    > calculation ought to bring in group_first_block? Or I'm confused.
    >

    Signed-off-by: Mingming Cao
    Cc: "linux-ext4@vger.kernel.org"
    Cc: Hugh Dickins
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mingming Cao
     

27 Sep, 2006

1 commit

  • Some of the changes in balloc.c are just cosmetic, as Andreas pointed out -
    if they overflow they'll then underflow and things are fine.

    5th hunk actually fixes an overflow problem.

    Also check for potential overflows in inode & block counts when resizing.

    Signed-off-by: Eric Sandeen
    Cc: Mingming Cao
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Sandeen