18 Aug, 2018

1 commit

  • get_seconds() is deprecated because of the 32-bit overflow and will be
    removed. All callers in ufs also truncate to a 32-bit number, so
    nothing changes during the conversion, but this should be harmless as
    the superblock and cylinder group timestamps are not visible to user
    space, except for checking the fs-dirty state, wich works fine across
    the overflow.

    This moves the call to get_seconds() into a new inline function, with a
    comment explaining the constraints, while converting it to
    ktime_get_real_seconds().

    Link: http://lkml.kernel.org/r/20180718115017.742609-1-arnd@arndb.de
    Signed-off-by: Arnd Bergmann
    Acked-by: Thomas Gleixner
    Cc: Al Viro
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arnd Bergmann
     

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
     

18 Jun, 2017

1 commit

  • * original hysteresis loop got broken by typo back in 2002; now
    it never switches out of OPTTIME state. Fixed.
    * critical levels for switching from OPTTIME to OPTSPACE and back
    ought to be calculated once, at mount time.
    * we should use mul_u64_u32_div() for those calculations, now that
    ->s_dsize is 64bit.
    * to quote Kirk McKusick (in 1995 FreeBSD commit message):
    The threshold for switching from time-space and space-time is too small
    when minfree is 5%...so make it stay at space in this case.

    Signed-off-by: Al Viro

    Al Viro
     

15 Jun, 2017

4 commits

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

10 Jun, 2017

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


08 Jun, 2016

1 commit


05 Apr, 2016

1 commit

  • PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
    ago with promise that one day it will be possible to implement page
    cache with bigger chunks than PAGE_SIZE.

    This promise never materialized. And unlikely will.

    We have many places where PAGE_CACHE_SIZE assumed to be equal to
    PAGE_SIZE. And it's constant source of confusion on whether
    PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
    especially on the border between fs and mm.

    Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
    breakage to be doable.

    Let's stop pretending that pages in page cache are special. They are
    not.

    The changes are pretty straight-forward:

    - << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> ;

    - >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> ;

    - PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};

    - page_cache_get() -> get_page();

    - page_cache_release() -> put_page();

    This patch contains automated changes generated with coccinelle using
    script below. For some reason, coccinelle doesn't patch header files.
    I've called spatch for them manually.

    The only adjustment after coccinelle is revert of changes to
    PAGE_CAHCE_ALIGN definition: we are going to drop it later.

    There are few places in the code where coccinelle didn't reach. I'll
    fix them manually in a separate patch. Comments and documentation also
    will be addressed with the separate patch.

    virtual patch

    @@
    expression E;
    @@
    - E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
    + E

    @@
    expression E;
    @@
    - E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
    + E

    @@
    @@
    - PAGE_CACHE_SHIFT
    + PAGE_SHIFT

    @@
    @@
    - PAGE_CACHE_SIZE
    + PAGE_SIZE

    @@
    @@
    - PAGE_CACHE_MASK
    + PAGE_MASK

    @@
    expression E;
    @@
    - PAGE_CACHE_ALIGN(E)
    + PAGE_ALIGN(E)

    @@
    expression E;
    @@
    - page_cache_get(E)
    + get_page(E)

    @@
    expression E;
    @@
    - page_cache_release(E)
    + put_page(E)

    Signed-off-by: Kirill A. Shutemov
    Acked-by: Michal Hocko
    Signed-off-by: Linus Torvalds

    Kirill A. Shutemov
     

10 Sep, 2015

1 commit

  • Followup to the UFS series - with the way we clear the new blocks (via
    buffer cache, possibly on more than a page worth of file) we really
    should not insert a reference to new block into inode block tree until
    after we'd cleared it.

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

    Al Viro
     

07 Jul, 2015

1 commit

  • * stores to block pointers are under per-inode seqlock (meta_lock) and
    mutex (truncate_mutex)
    * fetches of block pointers are either under truncate_mutex, or wrapped
    into seqretry loop on meta_lock
    * all changes of ->i_size are under truncate_mutex and i_mutex
    * all changes of ->i_lastfrag are under truncate_mutex

    It's similar to what ext2 is doing; the main difference is that unlike
    ext2 we can't rely upon the atomicity of stores into block pointers -
    on UFS2 they are 64bit. So we can't cut the corner when switching
    a pointer from NULL to non-NULL as we could in ext2_splice_branch()
    and need to use meta_lock on all modifications.

    We use seqlock where ext2 uses rwlock; ext2 could probably also benefit
    from such change...

    Another non-trivial difference is that with UFS we *cannot* have reader
    grab truncate_mutex in case of race - it has to keep retrying. That
    might be possible to change, but not until we lift tail unpacking
    several levels up in call chain.

    After that commit we do *NOT* hold fs-wide serialization on accesses
    to block pointers anymore. Moreover, lock_ufs() can become a normal
    mutex now - it's only used on statfs, remount and sync_fs and none
    of those uses are recursive. As the matter of fact, *now* it can be
    collapsed with ->s_lock, and be eventually replaced with saner
    per-cylinder-group spinlocks, but that's a separate story.

    Signed-off-by: Al Viro

    Al Viro
     

16 Jun, 2015

1 commit

  • Commit 0244756edc4b98c ("ufs: sb mutex merge + mutex_destroy") generated
    deadlocks in read/write mode on mkdir.

    This patch partially reverts it keeping fixes by Andrew Morton and
    mutex_destroy()

    [AV: fixed a missing bit in ufs_remount()]

    Signed-off-by: Fabian Frederick
    Reported-by: Ian Campbell
    Suggested-by: Jan Kara
    Cc: Ian Campbell
    Cc: Evgeniy Dushistov
    Cc: Alexey Khoroshilov
    Cc: Roger Pau Monne
    Cc: Ian Jackson
    Cc: Al Viro
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Al Viro

    Fabian Frederick
     

14 Oct, 2014

1 commit


07 Jun, 2014

2 commits

  • Commit 788257d6101d ("ufs: remove the BKL") replaced BKL with mutex
    protection using functions lock_ufs, unlock_ufs and struct mutex 'mutex'
    in sb_info.

    Commit b6963327e052 ("ufs: drop lock/unlock super") removed lock/unlock
    super and added struct mutex 's_lock' in sb_info.

    Those 2 mutexes are generally locked/unlocked at the same time except in
    allocation (balloc, ialloc).

    This patch merges the 2 mutexes and propagates first commit solution.
    It also adds mutex destruction before kfree during ufs_fill_super
    failure and ufs_put_super.

    [akpm@linux-foundation.org: avoid ifdefs, return -EROFS not -EINVAL]
    Signed-off-by: Fabian Frederick
    Cc: Evgeniy Dushistov
    Cc: "Chen, Jet"
    Cc: Wu Fengguang
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Fabian Frederick
     
  • err is used in ufs_new_fragments (ufs_add_fragments only callsite)
    not in ufs_add_fragments.

    Signed-off-by: Fabian Frederick
    Cc: Evgeniy Dushistov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Fabian Frederick
     

08 Apr, 2014

1 commit


10 Oct, 2012

1 commit


23 Jul, 2012

1 commit

  • This patch makes UFS stop using the VFS '->write_super()' method along with
    the 's_dirt' superblock flag, because they are on their way out.

    The way we implement this is that we schedule a delay job instead relying on
    's_dirt' and '->write_super()'.

    The whole "superblock write-out" VFS infrastructure is served by the
    'sync_supers()' kernel thread, which wakes up every 5 (by default) seconds and
    writes out all dirty superblocks using the '->write_super()' call-back. But the
    problem with this thread is that it wastes power by waking up the system every
    5 seconds, even if there are no diry superblocks, or there are no client
    file-systems which would need this (e.g., btrfs does not use
    '->write_super()'). So we want to kill it completely and thus, we need to make
    file-systems to stop using the '->write_super()' VFS service, and then remove
    it together with the kernel thread.

    Tested using fsstress from the LTP project.

    Signed-off-by: Artem Bityutskiy
    Signed-off-by: Al Viro

    Artem Bityutskiy
     

27 May, 2011

1 commit

  • Originally i_lastfrag was 32 bits but then we added support for handling
    64 bit metadata and it became a 64 bit variable. That was during 2007, in
    54fb996ac15c "[PATCH] ufs2 write: block allocation update". Unfortunately
    these casts got left behind so the value got truncated to 32 bit again.

    [akpm@linux-foundation.org: remove now-unneeded min_t/max_t casting]
    Signed-off-by: Dan Carpenter
    Cc: Evgeniy Dushistov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dan Carpenter
     

18 Aug, 2010

1 commit

  • These flags aren't real I/O types, but tell ll_rw_block to always
    lock the buffer instead of giving up on a failed trylock.

    Instead add a new write_dirty_buffer helper that implements this semantic
    and use it from the existing SWRITE* callers. Note that the ll_rw_block
    code had a bug where it didn't promote WRITE_SYNC_PLUG properly, which
    this patch fixes.

    In the ufs code clean up the helper that used to call ll_rw_block
    to mirror sync_dirty_buffer, which is the function it implements for
    compound buffers.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Al Viro

    Christoph Hellwig
     

24 May, 2010

1 commit

  • UFS quota is non-functional at least since 2.6.12 because dq_op was set
    to NULL. Since the filesystem exists mainly to allow cooperation with Solaris
    and quota format isn't standard, just remove the dead code.

    CC: Evgeniy Dushistov
    Signed-off-by: Jan Kara

    Jan Kara
     

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


28 Apr, 2008

1 commit


20 Mar, 2008

1 commit

  • fs/ufs/balloc.c: In function `ufs_change_blocknr':
    fs/ufs/balloc.c:317: warning: long long unsigned int format, long unsigned int arg (arg 2)
    fs/ufs/balloc.c:317: warning: long long unsigned int format, long unsigned int arg (arg 3)

    sector_t is u64 and we don't know what type the architecture uses to implement
    u64.

    Cc: Evgeniy Dushistov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

09 Feb, 2008

1 commit

  • Per previous discussions about cleaning up ufs_fs.h, people just want
    this straight up dropped from userspace export. The only remaining
    consumer (silo) has been fixed a while ago to not rely on this header.
    This allows use to move it completely from include/linux/ to fs/ufs/
    seeing as how the only in-kernel consumer is fs/ufs/.

    Signed-off-by: Mike Frysinger
    Cc: Jan Kara
    Cc: Christoph Hellwig
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mike Frysinger
     

17 Oct, 2007

1 commit

  • Move prototypes and in-core structures to fs/ufs/ similar to what most
    other filesystems already do.

    I made little modifications: move also ufs debug macros and
    mount options constants into fs/ufs/ufs.h, this stuff
    also private for ufs.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Evgeniy Dushistov
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Hellwig
     

17 Mar, 2007

2 commits

  • This patch fix behaviour in such test scenario:

    lseek(fd, BIG_OFFSET)
    write(fd, buf, sizeof(buf))
    truncate(BIG_OFFSET)
    truncate(BIG_OFFSET + sizeof(buf))
    read(fd, buf...)

    Because of if file big enough(BIG_OFFSET) we start allocate space by block,
    ordinary block size > page size, so we should zeroize the rest of block in
    truncate(except last framgnet, about which VFS should care), to not get
    garbage, when we extend file.

    Also patch corrects conversion from pointer to block to physical block number,
    this helps in case of not common used UFS types.

    And add to debug output inode number.

    Signed-off-by: Evgeniy Dushistov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Evgeniy Dushistov
     
  • This fixes "change blocks numbers on the fly" in case when "prepare
    write page" is in the call chain, in this case some buffers may be not
    uptodate and not mapped, we should care to map them and load from disk.

    This patch was tested with:
    - ufs regressions simple tests
    - fsx-linux
    - ltp(20060306)
    - untar and build kernel

    Signed-off-by: Evgeniy Dushistov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Evgeniy Dushistov
     

15 Feb, 2007

1 commit

  • After Al Viro (finally) succeeded in removing the sched.h #include in module.h
    recently, it makes sense again to remove other superfluous sched.h includes.
    There are quite a lot of files which include it but don't actually need
    anything defined in there. Presumably these includes were once needed for
    macros that used to live in sched.h, but moved to other header files in the
    course of cleaning it up.

    To ease the pain, this time I did not fiddle with any header files and only
    removed #includes from .c-files, which tend to cause less trouble.

    Compile tested against 2.6.20-rc2 and 2.6.20-rc2-mm2 (with offsets) on alpha,
    arm, i386, ia64, mips, powerpc, and x86_64 with allnoconfig, defconfig,
    allmodconfig, and allyesconfig as well as a few randconfigs on x86_64 and all
    configs in arch/arm/configs on arm. I also checked that no new warnings were
    introduced by the patch (actually, some warnings are removed that were emitted
    by unnecessarily included header files).

    Signed-off-by: Tim Schmielau
    Acked-by: Russell King
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tim Schmielau
     

13 Feb, 2007

1 commit


31 Jan, 2007

2 commits

  • In blocks reallocation function sometimes does not update some of
    buffer_head::b_blocknr, which may and cause data damage.

    Signed-off-by: Evgeniy Dushistov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Evgeniy Dushistov
     
  • These series of patches result of UFS1 write support stress testing, like
    running fsx-linux, untar and build linux kernel etc

    We pass from ufs::get_block_t to levels below: pointer to the current page, to
    make possible things like reallocation of blocks on the fly, and we also uses
    this pointer for indication, what actually we allocate data block or meta data
    block, but currently we make decision about what we allocate on the wrong
    level, this may and cause oops if we allocate blocks in some special order.

    Signed-off-by: Evgeniy Dushistov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Evgeniy Dushistov
     

06 Jan, 2007

1 commit

  • Looks like this is the problem, which point Al Viro some time ago:

    ufs's get_block callback allocates 16k of disk at a time, and links that
    entire 16k into the file's metadata. But because get_block is called for only
    a single buffer_head (a 2k buffer_head in this case?) we are only able to tell
    the VFS that this 2k is buffer_new().

    So when ufs_getfrag_block() is later called to map some more data in the file,
    and when that data resides within the remaining 14k of this fragment,
    ufs_getfrag_block() will incorrectly return a !buffer_new() buffer_head.

    I don't see _right_ way to do nullification of whole block, if use inode
    page cache, some pages may be outside of inode limits (inode size), and
    will be lost; if use blockdev page cache it is possible to zero real data,
    if later inode page cache will be used.

    The simpliest way, as can I see usage of block device page cache, but not only
    mark dirty, but also sync it during "nullification". I use my simple tests
    collection, which I used for check that create,open,write,read,close works on
    ufs, and I see that this patch makes ufs code 18% slower then before.

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

    Evgeniy Dushistov
     

06 Aug, 2006

1 commit

  • ufs_get_locked_page is called twice in ufs code, one time in ufs_truncate
    path(we allocated last block), and another time when fragments are
    reallocated. In ideal world in the second case on allocation/free block
    layer we should not know that things like `truncate' exists, but now with
    such crutch like ufs_get_locked_page we can (or should?) skip truncated
    pages.

    Signed-off-by: Evgeniy Dushistov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Evgeniy Dushistov
     

02 Jul, 2006

1 commit

  • This patch fixes buggy behaviour of UFS
    in such kind of scenario:
    open(, O_TRUNC...)
    ftruncate(, 1024)
    ftruncate(, 0)

    Such a scenario causes ufs_panic and remount read-only. This happen
    because of according to specification UFS should always allocate block for
    last byte, and many parts of our implementation rely on this, but
    `ufs_truncate' doesn't care about this.

    To make possible return error code and to know about old size, this patch
    removes `truncate' from ufs inode_operations and uses `setattr' method to
    call ufs_truncate.

    Signed-off-by: Evgeniy Dushistov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Evgeniy Dushistov