31 Jul, 2019

2 commits


12 Jun, 2019

1 commit


28 Nov, 2017

1 commit

  • This is a pure automated search-and-replace of the internal kernel
    superblock flags.

    The s_flags are now called SB_*, with the names and the values for the
    moment mirroring the MS_* flags that they're equivalent to.

    Note how the MS_xyz flags are the ones passed to the mount system call,
    while the SB_xyz flags are what we then use in sb->s_flags.

    The script to do this was:

    # places to look in; re security/*: it generally should *not* be
    # touched (that stuff parses mount(2) arguments directly), but
    # there are two places where we really deal with superblock flags.
    FILES="drivers/mtd drivers/staging/lustre fs ipc mm \
    include/linux/fs.h include/uapi/linux/bfs_fs.h \
    security/apparmor/apparmorfs.c security/apparmor/include/lib.h"
    # the list of MS_... constants
    SYMS="RDONLY NOSUID NODEV NOEXEC SYNCHRONOUS REMOUNT MANDLOCK \
    DIRSYNC NOATIME NODIRATIME BIND MOVE REC VERBOSE SILENT \
    POSIXACL UNBINDABLE PRIVATE SLAVE SHARED RELATIME KERNMOUNT \
    I_VERSION STRICTATIME LAZYTIME SUBMOUNT NOREMOTELOCK NOSEC BORN \
    ACTIVE NOUSER"

    SED_PROG=
    for i in $SYMS; do SED_PROG="$SED_PROG -e s/MS_$i/SB_$i/g"; done

    # we want files that contain at least one of MS_...,
    # with fs/namespace.c and fs/pnode.c excluded.
    L=$(for i in $SYMS; do git grep -w -l MS_$i $FILES; done| sort|uniq|grep -v '^fs/namespace.c'|grep -v '^fs/pnode.c')

    for f in $L; do sed -i $f $SED_PROG; done

    Requested-by: Al Viro
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

02 Mar, 2017

1 commit


06 Jul, 2016

1 commit

  • This bug can be reproducible with fsfuzzer, although, I couldn't reproduce it
    100% of my tries, it is quite easily reproducible.

    During the deletion of an inode, ext2_xattr_delete_inode() does not check if the
    block pointed by EXT2_I(inode)->i_file_acl is a valid data block, this might
    lead to a deadlock, when i_file_acl == 1, and the filesystem block size is 1024.

    In that situation, ext2_xattr_delete_inode, will load the superblock's buffer
    head (instead of a valid i_file_acl block), and then lock that buffer head,
    which, ext2_sync_super will also try to lock, making the filesystem deadlock in
    the following stack trace:

    root 17180 0.0 0.0 113660 660 pts/0 D+ 07:08 0:00 rmdir
    /media/test/dir1

    [] __sync_dirty_buffer+0xaf/0x100
    [] sync_dirty_buffer+0x13/0x20
    [] ext2_sync_super+0xb7/0xc0 [ext2]
    [] ext2_error+0x119/0x130 [ext2]
    [] ext2_free_blocks+0x83/0x350 [ext2]
    [] ext2_xattr_delete_inode+0x173/0x190 [ext2]
    [] ext2_evict_inode+0xc9/0x130 [ext2]
    [] evict+0xb3/0x180
    [] iput+0x1b8/0x240
    [] d_delete+0x11c/0x150
    [] vfs_rmdir+0xfe/0x120
    [] do_rmdir+0x17e/0x1f0
    [] SyS_rmdir+0x16/0x20
    [] entry_SYSCALL_64_fastpath+0x1a/0xa4
    [] 0xffffffffffffffff

    Fix this by using the same approach ext4 uses to test data blocks validity,
    implementing ext2_data_block_valid.

    An another possibility when the superblock is very corrupted, is that i_file_acl
    is 1, block_count is 1 and first_data_block is 0. For such situations, we might
    have i_file_acl pointing to a 'valid' block, but still step over the superblock.
    The approach I used was to also test if the superblock is not in the range
    described by ext2_data_block_valid() arguments

    Signed-off-by: Carlos Maiolino
    Signed-off-by: Theodore Ts'o

    Carlos Maiolino
     

07 Feb, 2013

2 commits


06 Feb, 2013

1 commit


02 Oct, 2012

1 commit

  • Pull the trivial tree from Jiri Kosina:
    "Tiny usual fixes all over the place"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (34 commits)
    doc: fix old config name of kprobetrace
    fs/fs-writeback.c: cleanup riteback_sb_inodes kerneldoc
    btrfs: fix the commment for the action flags in delayed-ref.h
    btrfs: fix trivial typo for the comment of BTRFS_FREE_INO_OBJECTID
    vfs: fix kerneldoc for generic_fh_to_parent()
    treewide: fix comment/printk/variable typos
    ipr: fix small coding style issues
    doc: fix broken utf8 encoding
    nfs: comment fix
    platform/x86: fix asus_laptop.wled_type module parameter
    mfd: printk/comment fixes
    doc: getdelays.c: remember to close() socket on error in create_nl_socket()
    doc: aliasing-test: close fd on write error
    mmc: fix comment typos
    dma: fix comments
    spi: fix comment/printk typos in spi
    Coccinelle: fix typo in memdup_user.cocci
    tmiofb: missing NULL pointer checks
    tools: perf: Fix typo in tools/perf
    tools/testing: fix comment / output typos
    ...

    Linus Torvalds
     

02 Sep, 2012

1 commit


31 Jul, 2012

1 commit

  • Convert ext2_count_free() to use memweight() instead of table lookup
    based counting clear bits implementation. This change only affects the
    code segments enabled by EXT2FS_DEBUG.

    Note that this memweight() call can't be replaced with a single
    bitmap_weight() call, although the pointer to the memory area is aligned
    to long-word boundary. Because the size of the memory area may not be a
    multiple of BITS_PER_LONG, then it returns wrong value on big-endian
    architecture.

    This also includes the following changes.

    - Remove unnecessary map == NULL check in ext2_count_free() which
    always takes non-null pointer as the memory area.

    - Fix printk format warning that only reveals with EXT2FS_DEBUG.

    Signed-off-by: Akinobu Mita
    Acked-by: Jan Kara
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Akinobu Mita
     

25 May, 2012

1 commit

  • Pull ext2, ext3 and quota fixes from Jan Kara:
    "Interesting bits are:
    - removal of a special i_mutex locking subclass (I_MUTEX_QUOTA) since
    quota code does not need i_mutex anymore in any unusual way.
    - backport (from ext4) of a fix of a checkpointing bug (missing cache
    flush) that could lead to fs corruption on power failure

    The rest are just random small fixes & cleanups."

    * 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
    ext2: trivial fix to comment for ext2_free_blocks
    ext2: remove the redundant comment for ext2_export_ops
    ext3: return 32/64-bit dir name hash according to usage type
    quota: Get rid of nested I_MUTEX_QUOTA locking subclass
    quota: Use precomputed value of sb_dqopt in dquot_quota_sync
    ext2: Remove i_mutex use from ext2_quota_write()
    reiserfs: Remove i_mutex use from reiserfs_quota_write()
    ext4: Remove i_mutex use from ext4_quota_write()
    ext3: Remove i_mutex use from ext3_quota_write()
    quota: Fix double lock in add_dquot_ref() with CONFIG_QUOTA_DEBUG
    jbd: Write journal superblock with WRITE_FUA after checkpointing
    jbd: protect all log tail updates with j_checkpoint_mutex
    jbd: Split updating of journal superblock and marking journal empty
    ext2: do not register write_super within VFS
    ext2: Remove s_dirt handling
    ext2: write superblock only once on unmount
    ext3: update documentation with barrier=1 default
    ext3: remove max_debt in find_group_orlov()
    jbd: Refine commit writeout logic

    Linus Torvalds
     

18 May, 2012

1 commit


16 May, 2012

1 commit


11 Apr, 2012

1 commit

  • Places which modify superblock feature / state fields mark the superblock
    buffer dirty so it is written out by flusher thread. Thus there's no need to
    set s_dirt there.

    The only other fields changing in the superblock are the numbers of free
    blocks, free inodes and s_wtime. There's no real need to write (or even
    compute) these periodically. Free blocks / inodes counters are recomputed on
    every mount from group counters anyway and value of s_wtime is only
    informational and imprecise anyway. So it should be enough to write these
    opportunistically on mount, remount, umount, and sync_fs times.

    Signed-off-by: Jan Kara

    Jan Kara
     

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
     

31 Mar, 2011

1 commit


28 Oct, 2010

1 commit


10 Aug, 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
     

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: linux-ext4@vger.kernel.org
    Signed-off-by: James Morris

    David Howells
     

17 Oct, 2008

1 commit

  • We could run into ENOSPC error on ext2, 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

  • If the block allocator gets blocks out of system zone ext2 calls ext2_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
     
  • __FUNCTION__ is gcc-specific, use __func__

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

    Harvey Harrison
     
  • 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
     

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
     
  • 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
     
  • This fixes some instances where we were continuing after calling
    ext2_error. ext2_error call panic only if errors=panic mount option is
    set. So we need to make sure we return correctly after ext2_error call.

    Signed-off-by: Aneesh Kumar K.V
    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

4 commits

  • Val's cross-port of the ext3 reservations code into ext2.

    [mbligh@mbligh.org: Small type error for printk
    [akpm@linux-foundation.org: fix types, sync with ext3]
    [mbligh@mbligh.org: Bring ext2 reservations code in line with latest ext3]
    [akpm@linux-foundation.org: kill noisy printk]
    [akpm@linux-foundation.org: remember to dirty the gdp's block]
    [akpm@linux-foundation.org: cross-port the missed 5dea5176e5c32ef9f0d1a41d28427b3bf6881b3a]
    [akpm@linux-foundation.org: cross-port e6022603b9aa7d61d20b392e69edcdbbc1789969]
    [akpm@linux-foundation.org: Port the omitted 08fb306fe63d98eb86e3b16f4cc21816fa47f18e]
    [akpm@linux-foundation.org: Backport the missed 20acaa18d0c002fec180956f87adeb3f11f635a6]
    [akpm@linux-foundation.org: fixes]
    [cmm@us.ibm.com: fix reservation extension]
    [bunk@stusta.de: make ext2_get_blocks() static]
    [hugh@veritas.com: fix hang]
    [hugh@veritas.com: ext2_new_blocks should reset the reservation window size]
    [hugh@veritas.com: ext2 balloc: fix off-by-one against rsv_end]
    [hugh@veritas.com: grp_goal 0 is a genuine goal (unlike -1), so ext2_try_to_allocate_with_rsv should treat it as such]
    [hugh@veritas.com: rbtree usage cleanup]
    [pbadari@us.ibm.com: Fix for ext2 reservation]
    [bunk@kernel.org: remove fs/ext2/balloc.c:reserve_blocks()]
    [hugh@veritas.com: ext2 balloc: use io_error label]
    Cc: "Martin J. Bligh"
    Cc: Valerie Henson
    Cc: Mingming Cao
    Cc: Mel Gorman
    Cc: Hugh Dickins
    Signed-off-by: Adrian Bunk
    Signed-off-by: Hugh Dickins
    Signed-off-by: Badari Pulavarty
    Signed-off-by: Adrian Bunk
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Martin J. Bligh
     
  • 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
     
  • Signed-off-by: Philippe De Muyter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Philippe De Muyter
     
  • 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