30 May, 2018

1 commit

  • commit 1e2e547a93a00ebc21582c06ca3c6cfea2a309ee upstream.

    For anything NFS-exported we do _not_ want to unlock new inode
    before it has grown an alias; original set of fixes got the
    ordering right, but missed the nasty complication in case of
    lockdep being enabled - unlock_new_inode() does
    lockdep_annotate_inode_mutex_key(inode)
    which can only be done before anyone gets a chance to touch
    ->i_mutex. Unfortunately, flipping the order and doing
    unlock_new_inode() before d_instantiate() opens a window when
    mkdir can race with open-by-fhandle on a guessed fhandle, leading
    to multiple aliases for a directory inode and all the breakage
    that follows from that.

    Correct solution: a new primitive (d_instantiate_new())
    combining these two in the right order - lockdep annotate, then
    d_instantiate(), then the rest of unlock_new_inode(). All
    combinations of d_instantiate() with unlock_new_inode() should
    be converted to that.

    Cc: stable@kernel.org # 2.6.29 and later
    Tested-by: Mike Marshall
    Reviewed-by: Andreas Dilger
    Signed-off-by: Al Viro
    Signed-off-by: Greg Kroah-Hartman

    Al Viro
     

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
     

17 Jul, 2017

1 commit

  • Firstly by applying the following with coccinelle's spatch:

    @@ expression SB; @@
    -SB->s_flags & MS_RDONLY
    +sb_rdonly(SB)

    to effect the conversion to sb_rdonly(sb), then by applying:

    @@ expression A, SB; @@
    (
    -(!sb_rdonly(SB)) && A
    +!sb_rdonly(SB) && A
    |
    -A != (sb_rdonly(SB))
    +A != sb_rdonly(SB)
    |
    -A == (sb_rdonly(SB))
    +A == sb_rdonly(SB)
    |
    -!(sb_rdonly(SB))
    +!sb_rdonly(SB)
    |
    -A && (sb_rdonly(SB))
    +A && sb_rdonly(SB)
    |
    -A || (sb_rdonly(SB))
    +A || sb_rdonly(SB)
    |
    -(sb_rdonly(SB)) != A
    +sb_rdonly(SB) != A
    |
    -(sb_rdonly(SB)) == A
    +sb_rdonly(SB) == A
    |
    -(sb_rdonly(SB)) && A
    +sb_rdonly(SB) && A
    |
    -(sb_rdonly(SB)) || A
    +sb_rdonly(SB) || A
    )

    @@ expression A, B, SB; @@
    (
    -(sb_rdonly(SB)) ? 1 : 0
    +sb_rdonly(SB)
    |
    -(sb_rdonly(SB)) ? A : B
    +sb_rdonly(SB) ? A : B
    )

    to remove left over excess bracketage and finally by applying:

    @@ expression A, SB; @@
    (
    -(A & MS_RDONLY) != sb_rdonly(SB)
    +(bool)(A & MS_RDONLY) != sb_rdonly(SB)
    |
    -(A & MS_RDONLY) == sb_rdonly(SB)
    +(bool)(A & MS_RDONLY) == sb_rdonly(SB)
    )

    to make comparisons against the result of sb_rdonly() (which is a bool)
    work correctly.

    Signed-off-by: David Howells

    David Howells
     

08 Jul, 2017

1 commit

  • Pull Writeback error handling fixes from Jeff Layton:
    "The main rationale for all of these changes is to tighten up writeback
    error reporting to userland. There are many ways now that writeback
    errors can be lost, such that fsync/fdatasync/msync return 0 when
    writeback actually failed.

    This pile contains a small set of cleanups and writeback error
    handling fixes that I was able to break off from the main pile (#2).

    Two of the patches in this pile are trivial. The exceptions are the
    patch to fix up error handling in write_one_page, and the patch to
    make JFS pay attention to write_one_page errors"

    * tag 'for-linus-v4.13-1' of git://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux:
    fs: remove call_fsync helper function
    mm: clean up error handling in write_one_page
    JFS: do not ignore return code from write_one_page()
    mm: drop "wait" parameter from write_one_page()

    Linus Torvalds
     

06 Jul, 2017

1 commit

  • The callers all set it to 1.

    Also, make it clear that this function will not set any sort of AS_*
    error, and that the caller must do so if necessary. No existing caller
    uses this on normal files, so none of them need it.

    Also, add __must_check here since, in general, the callers need to handle
    an error here in some fashion.

    Link: http://lkml.kernel.org/r/20170525103303.6524-1-jlayton@redhat.com
    Signed-off-by: Jeff Layton
    Reviewed-by: Ross Zwisler
    Reviewed-by: Jan Kara
    Reviewed-by: Matthew Wilcox
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Andrew Morton

    Jeff Layton
     

22 Jun, 2017

1 commit

  • Pull more ufs fixes from Al Viro:
    "More UFS fixes, unfortunately including build regression fix for the
    64-bit s_dsize commit. Fixed in this pile:

    - trivial bug in signedness of 32bit timestamps on ufs1

    - ESTALE instead of ufs_error() when doing open-by-fhandle on
    something deleted

    - build regression on 32bit in ufs_new_fragments() - calculating that
    many percents of u64 pulls libgcc stuff on some of those. Mea
    culpa.

    - fix hysteresis loop broken by typo in 2.4.14.7 (right next to the
    location of previous bug).

    - fix the insane limits of said hysteresis loop on filesystems with
    very low percentage of reserved blocks. If it's 5% or less, just
    use the OPTSPACE policy.

    - calculate those limits once and mount time.

    This tree does pass xfstests clean (both ufs1 and ufs2) and it _does_
    survive cross-builds.

    Again, my apologies for missing that, especially since I have noticed
    a related percentage-of-64bit issue in earlier patches (when dealing
    with amount of reserved blocks). Self-LART applied..."

    * 'ufs-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    ufs: fix the logics for tail relocation
    ufs_iget(): fail with -ESTALE on deleted inode
    fix signedness of timestamps on ufs1

    Linus Torvalds
     

18 Jun, 2017

3 commits


17 Jun, 2017

1 commit

  • Pull ufs fixes from Al Viro:
    "Fix assorted ufs bugs: a couple of deadlocks, fs corruption in
    truncate(), oopsen on tail unpacking and truncate when racing with
    vmscan, mild fs corruption (free blocks stats summary buggered, *BSD
    fsck would complain and fix), several instances of broken logics
    around reserved blocks (starting with "check almost never triggers
    when it should" and then there are issues with sufficiently large
    UFS2)"

    [ Note: ufs hasn't gotten any loving in a long time, because nobody
    really seems to use it. These ufs fixes are triggered by people
    actually caring now, not some sudden influx of new bugs. - Linus ]

    * 'ufs-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    ufs_truncate_blocks(): fix the case when size is in the last direct block
    ufs: more deadlock prevention on tail unpacking
    ufs: avoid grabbing ->truncate_mutex if possible
    ufs_get_locked_page(): make sure we have buffer_heads
    ufs: fix s_size/s_dsize users
    ufs: fix reserved blocks check
    ufs: make ufs_freespace() return signed
    ufs: fix logics in "ufs: make fsck -f happy"

    Linus Torvalds
     

15 Jun, 2017

8 commits

  • The logics when deciding whether we need to do anything with direct blocks
    is broken when new size is within the last direct block. It's better to
    find the path to the last byte _not_ to be removed and use that instead
    of the path to the beginning of the first block to be freed...

    Signed-off-by: Al Viro

    Al Viro
     
  • ->s_lock is not needed for ufs_change_blocknr()

    Signed-off-by: Al Viro

    Al Viro
     
  • tail unpacking is done in a wrong place; the deadlocks galore
    is best dealt with by doing that in ->write_iter() (and switching
    to iomap, while we are at it), but that's rather painful to
    backport. The trouble comes from grabbing pages that cover
    the beginning of tail from inside of ufs_new_fragments(); ongoing
    pageout of any of those is going to deadlock on ->truncate_mutex
    with process that got around to extending the tail holding that
    and waiting for page to get unlocked, while ->writepage() on
    that page is waiting on ->truncate_mutex.

    The thing is, we don't need ->truncate_mutex when the fragment
    we are trying to map is within the tail - the damn thing is
    allocated (tail can't contain holes).

    Let's do a plain lookup and if the fragment is present, we can
    just pretend that we'd won the race in almost all cases. The
    only exception is a fragment between the end of tail and the
    end of block containing tail.

    Protect ->i_lastfrag with ->meta_lock - read_seqlock_excl() is
    sufficient.

    Signed-off-by: Al Viro

    Al Viro
     
  • callers rely upon that, but find_lock_page() racing with attempt of
    page eviction by memory pressure might have left us with
    * try_to_free_buffers() successfully done
    * __remove_mapping() failed, leaving the page in our mapping
    * find_lock_page() returning an uptodate page with no
    buffer_heads attached.

    Signed-off-by: Al Viro

    Al Viro
     
  • For UFS2 we need 64bit variants; we even store them in uspi, but
    use 32bit ones instead. One wrinkle is in handling of reserved
    space - recalculating it every time had been stupid all along, but
    now it would become really ugly. Just calculate it once...

    Signed-off-by: Al Viro

    Al Viro
     
  • a) honour ->s_minfree; don't just go with default (5)
    b) don't bother with capability checks until we know we'll need them

    Signed-off-by: Al Viro

    Al Viro
     
  • as it is, checking that its return value is

    Al Viro
     
  • Storing stats _only_ at new locations is wrong for UFS1; old
    locations should always be kept updated. The check for "has
    been converted to use of new locations" is also wrong - it
    should be "->fs_maxbsize is equal to ->fs_bsize".

    Signed-off-by: Al Viro

    Al Viro
     

11 Jun, 2017

2 commits

  • Pull UFS fixes from Al Viro:
    "This is just the obvious backport fodder; I'm pretty sure that there
    will be more - definitely so wrt performance and quite possibly
    correctness as well"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    ufs: we need to sync inode before freeing it
    excessive checks in ufs_write_failed() and ufs_evict_inode()
    ufs_getfrag_block(): we only grab ->truncate_mutex on block creation path
    ufs_extend_tail(): fix the braino in calling conventions of ufs_new_fragments()
    ufs: set correct ->s_maxsize
    ufs: restore maintaining ->i_blocks
    fix ufs_isblockset()
    ufs: restore proper tail allocation

    Linus Torvalds
     
  • Signed-off-by: Al Viro

    Al Viro
     

10 Jun, 2017

7 commits


05 Jun, 2017

1 commit

  • This fixes a problem with reading files larger than 2GB from a UFS-2
    file system:

    https://bugzilla.kernel.org/show_bug.cgi?id=195721

    The incorrect UFS s_maxsize limit became a problem as of commit
    c2a9737f45e2 ("vfs,mm: fix a dead loop in truncate_inode_pages_range()")
    which started using s_maxbytes to avoid a page index overflow in
    do_generic_file_read().

    That caused files to be truncated on UFS-2 file systems because the
    default maximum file size is 2GB (MAX_NON_LFS) and UFS didn't update it.

    Here I simply increase the default to a common value used by other file
    systems.

    Signed-off-by: Richard Narron
    Cc: Al Viro
    Cc: Will B
    Cc: Theodore Ts'o
    Cc: # v4.9 and backports of c2a9737f45e2
    Signed-off-by: Linus Torvalds

    Richard Narron
     

09 May, 2017

1 commit

  • CURRENT_TIME is not y2038 safe. Replace it with ktime_get_real_ts64().
    Inode time formats are already 64 bit long and accommodates time64_t.

    Link: http://lkml.kernel.org/r/1491613030-11599-6-git-send-email-deepa.kernel@gmail.com
    Signed-off-by: Deepa Dinamani
    Cc: Evgeniy Dushistov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Deepa Dinamani
     

25 Dec, 2016

1 commit


23 Dec, 2016

1 commit


05 Nov, 2016

1 commit

  • Add a helper function that clears buffer heads from a block device
    aliasing passed bh. Use this helper function from filesystems instead of
    the original unmap_underlying_metadata() to save some boiler plate code
    and also have a better name for the functionalily since it is not
    unmapping anything for a *long* time.

    Signed-off-by: Jan Kara
    Signed-off-by: Jens Axboe

    Jan Kara
     

01 Nov, 2016

1 commit


11 Oct, 2016

2 commits

  • Pull more vfs updates from Al Viro:
    ">rename2() work from Miklos + current_time() from Deepa"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    fs: Replace current_fs_time() with current_time()
    fs: Replace CURRENT_TIME_SEC with current_time() for inode timestamps
    fs: Replace CURRENT_TIME with current_time() for inode timestamps
    fs: proc: Delete inode time initializations in proc_alloc_inode()
    vfs: Add current_time() api
    vfs: add note about i_op->rename changes to porting
    fs: rename "rename2" i_op to "rename"
    vfs: remove unused i_op->rename
    fs: make remaining filesystems use .rename2
    libfs: support RENAME_NOREPLACE in simple_rename()
    fs: support RENAME_NOREPLACE for local filesystems
    ncpfs: fix unused variable warning

    Linus Torvalds
     
  • Al Viro
     

28 Sep, 2016

1 commit

  • CURRENT_TIME_SEC is not y2038 safe. current_time() will
    be transitioned to use 64 bit time along with vfs in a
    separate patch.
    There is no plan to transistion CURRENT_TIME_SEC to use
    y2038 safe time interfaces.

    current_time() will also be extended to use superblock
    range checking parameters when range checking is introduced.

    This works because alloc_super() fills in the the s_time_gran
    in super block to NSEC_PER_SEC.

    Signed-off-by: Deepa Dinamani
    Acked-by: Jan Kara
    Signed-off-by: Al Viro

    Deepa Dinamani
     

27 Sep, 2016

2 commits

  • Generated patch:

    sed -i "s/\.rename2\t/\.rename\t\t/" `git grep -wl rename2`
    sed -i "s/\brename2\b/rename/g" `git grep -wl rename2`

    Signed-off-by: Miklos Szeredi

    Miklos Szeredi
     
  • This is trivial to do:

    - add flags argument to foo_rename()
    - check if flags doesn't have any other than RENAME_NOREPLACE
    - assign foo_rename() to .rename2 instead of .rename

    Filesystems converted:

    affs, bfs, exofs, ext2, hfs, hfsplus, jffs2, jfs, logfs, minix, msdos,
    nilfs2, omfs, reiserfs, sysvfs, ubifs, udf, ufs, vfat.

    Signed-off-by: Miklos Szeredi
    Acked-by: Boaz Harrosh
    Acked-by: Richard Weinberger
    Acked-by: Bob Copeland
    Acked-by: Jan Kara
    Cc: Theodore Ts'o
    Cc: Jaegeuk Kim
    Cc: OGAWA Hirofumi
    Cc: Mikulas Patocka
    Cc: David Woodhouse
    Cc: Dave Kleikamp
    Cc: Ryusuke Konishi
    Cc: Christoph Hellwig

    Miklos Szeredi
     

22 Sep, 2016

1 commit

  • inode_change_ok() will be resposible for clearing capabilities and IMA
    extended attributes and as such will need dentry. Give it as an argument
    to inode_change_ok() instead of an inode. Also rename inode_change_ok()
    to setattr_prepare() to better relect that it does also some
    modifications in addition to checks.

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

    Jan Kara
     

29 Jul, 2016

1 commit

  • Pull vfs updates from Al Viro:
    "Assorted cleanups and fixes.

    Probably the most interesting part long-term is ->d_init() - that will
    have a bunch of followups in (at least) ceph and lustre, but we'll
    need to sort the barrier-related rules before it can get used for
    really non-trivial stuff.

    Another fun thing is the merge of ->d_iput() callers (dentry_iput()
    and dentry_unlink_inode()) and a bunch of ->d_compare() ones (all
    except the one in __d_lookup_lru())"

    * 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (26 commits)
    fs/dcache.c: avoid soft-lockup in dput()
    vfs: new d_init method
    vfs: Update lookup_dcache() comment
    bdev: get rid of ->bd_inodes
    Remove last traces of ->sync_page
    new helper: d_same_name()
    dentry_cmp(): use lockless_dereference() instead of smp_read_barrier_depends()
    vfs: clean up documentation
    vfs: document ->d_real()
    vfs: merge .d_select_inode() into .d_real()
    unify dentry_iput() and dentry_unlink_inode()
    binfmt_misc: ->s_root is not going anywhere
    drop redundant ->owner initializations
    ufs: get rid of redundant checks
    orangefs: constify inode_operations
    missed comment updates from ->direct_IO() prototype change
    file_inode(f)->i_mapping is f->f_mapping
    trim fsnotify hooks a bit
    9p: new helper - v9fs_parent_fid()
    debugfs: ->d_parent is never NULL or negative
    ...

    Linus Torvalds