28 Sep, 2016

1 commit

  • current_fs_time() uses struct super_block* as an argument.
    As per Linus's suggestion, this is changed to take struct
    inode* as a parameter instead. This is because the function
    is primarily meant for vfs inode timestamps.
    Also the function was renamed as per Arnd's suggestion.

    Change all calls to current_fs_time() to use the new
    current_time() function instead. current_fs_time() will be
    deleted.

    Signed-off-by: Deepa Dinamani
    Signed-off-by: Al Viro

    Deepa Dinamani
     

08 Jun, 2016

1 commit


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

23 Jan, 2016

1 commit

  • parallel to mutex_{lock,unlock,trylock,is_locked,lock_nested},
    inode_foo(inode) being mutex_foo(&inode->i_mutex).

    Please, use those for access to ->i_mutex; over the coming cycle
    ->i_mutex will become rwsem, with ->lookup() done with it held
    only shared.

    Signed-off-by: Al Viro

    Al Viro
     

16 Jan, 2016

1 commit

  • Pull UDF fixes and quota cleanups from Jan Kara:
    "Several UDF fixes and some minor quota cleanups"

    * 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
    udf: Check output buffer length when converting name to CS0
    udf: Prevent buffer overrun with multi-byte characters
    quota: constify qtree_fmt_operations structures
    udf: avoid uninitialized variable use
    udf: Fix lost indirect extent block
    udf: Factor out code for creating indirect extent
    udf: limit the maximum number of indirect extents in a row
    udf: limit the maximum number of TD redirections
    fs: make quota/dquot.c explicitly non-modular
    fs: make quota/netlink.c explicitly non-modular

    Linus Torvalds
     

04 Jan, 2016

1 commit

  • A new warning has come up from a recent cleanup:

    fs/udf/inode.c: In function 'udf_setup_indirect_aext':
    fs/udf/inode.c:1927:28: warning: 'adsize' may be used uninitialized in this function [-Wmaybe-uninitialized]

    If the alloc_type is neither ICBTAG_FLAG_AD_SHORT nor
    ICBTAG_FLAG_AD_LONG, the value of adsize is undefined. Currently,
    callers of these functions make sure alloc_type is one of the two valid
    ones but for future proofing make sure we handle the case of invalid
    alloc type as well. This changes the code to return -EIOin that case.

    Signed-off-by: Arnd Bergmann
    Fixes: fcea62babc81 ("udf: Factor out code for creating indirect extent")
    Signed-off-by: Jan Kara

    Arnd Bergmann
     

24 Dec, 2015

2 commits

  • When inode ends with empty indirect extent block and we extended that
    file, udf_do_extend_file() ended up just overwriting pointer to it with
    another extent and thus effectively leaking the block and also
    corruptiong length of allocation descriptors.

    Fix the problem by properly following into next indirect extent when it
    is present.

    Signed-off-by: Jan Kara

    Jan Kara
     
  • Factor out code for creating indirect extent from udf_add_aext(). It was
    mostly duplicated in two places. Also remove some opencoded versions
    of udf_write_aext().

    Signed-off-by: Jan Kara

    Jan Kara
     

23 Dec, 2015

1 commit

  • udf_next_aext() just follows extent pointers while extents are marked as
    indirect. This can loop forever for corrupted filesystem. Limit number
    the of indirect extents we are willing to follow in a row.

    [JK: Updated changelog, limit, style]

    Signed-off-by: Vegard Nossum
    Cc: stable@vger.kernel.org
    Cc: Jan Kara
    Cc: Quentin Casasnovas
    Cc: Andrew Morton
    Signed-off-by: Jan Kara

    Vegard Nossum
     

09 Dec, 2015

1 commit

  • kmap() in page_follow_link_light() needed to go - allowing to hold
    an arbitrary number of kmaps for long is a great way to deadlocking
    the system.

    new helper (inode_nohighmem(inode)) needs to be used for pagecache
    symlinks inodes; done for all in-tree cases. page_follow_link_light()
    instrumented to yell about anything missed.

    Signed-off-by: Al Viro

    Al Viro
     

07 Dec, 2015

1 commit


09 Jul, 2015

1 commit

  • For a UDF filesystem configured with an Unallocated Space Table,
    a filesystem operation that triggers an update to the table results
    in on-disk corruption that prevents remounting:

    udf_read_tagged: tag version 0x0000 != 0x0002 || 0x0003, block 274

    For example:
    1. Create a filesystem
    $ mkudffs --media-type=hd --blocksize=512 --lvid=BUGTEST \
    --vid=BUGTEST --fsid=BUGTEST --space=unalloctable \
    /dev/mmcblk0

    2. Mount it
    # mount /dev/mmcblk0 /mnt

    3. Create a file
    $ echo "No corruption, please" > /mnt/new.file

    4. Umount
    # umount /mnt

    5. Attempt remount
    # mount /dev/mmcblk0 /mnt

    This appears to be a longstanding bug caused by zero-initialization of
    the Unallocated Space Entry block buffer and only partial repopulation
    of required fields before writing to disk.

    Commit 0adfb339fd64 ("udf: Fix unalloc space handling in udf_update_inode")
    addressed one such field, but several others are required.

    Signed-off-by: Steven J. Magnani
    Signed-off-by: Jan Kara

    Steven J. Magnani
     

17 Apr, 2015

2 commits

  • Pull third hunk of vfs changes from Al Viro:
    "This contains the ->direct_IO() changes from Omar + saner
    generic_write_checks() + dealing with fcntl()/{read,write}() races
    (mirroring O_APPEND/O_DIRECT into iocb->ki_flags and instead of
    repeatedly looking at ->f_flags, which can be changed by fcntl(2),
    check ->ki_flags - which cannot) + infrastructure bits for dhowells'
    d_inode annotations + Christophs switch of /dev/loop to
    vfs_iter_write()"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (30 commits)
    block: loop: switch to VFS ITER_BVEC
    configfs: Fix inconsistent use of file_inode() vs file->f_path.dentry->d_inode
    VFS: Make pathwalk use d_is_reg() rather than S_ISREG()
    VFS: Fix up debugfs to use d_is_dir() in place of S_ISDIR()
    VFS: Combine inode checks with d_is_negative() and d_is_positive() in pathwalk
    NFS: Don't use d_inode as a variable name
    VFS: Impose ordering on accesses of d_inode and d_flags
    VFS: Add owner-filesystem positive/negative dentry checks
    nfs: generic_write_checks() shouldn't be done on swapout...
    ocfs2: use __generic_file_write_iter()
    mirror O_APPEND and O_DIRECT into iocb->ki_flags
    switch generic_write_checks() to iocb and iter
    ocfs2: move generic_write_checks() before the alignment checks
    ocfs2_file_write_iter: stop messing with ppos
    udf_file_write_iter: reorder and simplify
    fuse: ->direct_IO() doesn't need generic_write_checks()
    ext4_file_write_iter: move generic_write_checks() up
    xfs_file_aio_write_checks: switch to iocb/iov_iter
    generic_write_checks(): drop isblk argument
    blkdev_write_iter: expand generic_file_checks() call in there
    ...

    Linus Torvalds
     
  • Pull quota and udf updates from Jan Kara:
    "The pull contains quota changes which complete unification of XFS and
    VFS quota interfaces (so tools can use either interface to manipulate
    any filesystem). There's also a patch to support project quotas in
    VFS quota subsystem from Li Xi.

    Finally there's a bunch of UDF fixes and cleanups and tiny cleanup in
    reiserfs & ext3"

    * 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: (21 commits)
    udf: Update ctime and mtime when directory is modified
    udf: return correct errno for udf_update_inode()
    ext3: Remove useless condition in if statement.
    vfs: Add general support to enforce project quota limits
    reiserfs: fix __RASSERT format string
    udf: use int for allocated blocks instead of sector_t
    udf: remove redundant buffer_head.h includes
    udf: remove else after return in __load_block_bitmap()
    udf: remove unused variable in udf_table_free_blocks()
    quota: Fix maximum quota limit settings
    quota: reorder flags in quota state
    quota: paranoia: check quota tree root
    quota: optimize i_dquot access
    quota: Hook up Q_XSETQLIM for id 0 to ->set_info
    xfs: Add support for Q_SETINFO
    quota: Make ->set_info use structure with neccesary info to VFS and XFS
    quota: Remove ->get_xstate and ->get_xstatev callbacks
    gfs2: Convert to using ->get_state callback
    xfs: Convert to using ->get_state callback
    quota: Wire up Q_GETXSTATE and Q_GETXSTATV calls to work with ->get_state
    ...

    Linus Torvalds
     

12 Apr, 2015

3 commits


01 Apr, 2015

1 commit


26 Mar, 2015

1 commit


14 Mar, 2015

1 commit


05 Feb, 2015

1 commit


07 Jan, 2015

2 commits


19 Dec, 2014

1 commit

  • Verify that inode size is sane when loading inode with data stored in
    ICB. Otherwise we may get confused later when working with the inode and
    inode size is too big.

    CC: stable@vger.kernel.org
    Reported-by: Carl Henrik Lunde
    Signed-off-by: Jan Kara

    Jan Kara
     

09 Oct, 2014

1 commit

  • Some UDF media have special inodes (like VAT or metadata partition
    inodes) whose link_count is 0. Thus commit 4071b9136223 (udf: Properly
    detect stale inodes) broke loading these inodes because udf_iget()
    started returning -ESTALE for them. Since we still need to properly
    detect stale inodes queried by NFS, create two variants of udf_iget() -
    one which is used for looking up special inodes (which ignores
    link_count == 0) and one which is used for other cases which return
    ESTALE when link_count == 0.

    Fixes: 4071b913622316970d0e1919f7d82b4403fec5f2
    CC: stable@vger.kernel.org
    Signed-off-by: Jan Kara

    Jan Kara
     

05 Sep, 2014

3 commits

  • Currently UDF doesn't initialize i_generation in any way and thus NFS
    can easily get reallocated inodes from stale file handles. Luckily UDF
    already has a unique object identifier associated with each inode -
    i_unique. Use that for initialization of i_generation.

    Signed-off-by: Jan Kara

    Jan Kara
     
  • NFS can easily ask for inodes that are already deleted. Currently UDF
    happily returns such inodes which is a bug. Return -ESTALE if
    udf_read_inode() is asked to read deleted inode.

    Signed-off-by: Jan Kara

    Jan Kara
     
  • Currently __udf_read_inode() wasn't returning anything and we found out
    whether we succeeded reading inode by checking whether inode is bad or
    not. udf_iget() returned NULL on failure and inode pointer otherwise.
    Make these two functions properly propagate errors up the call stack and
    use the return value in callers.

    Signed-off-by: Jan Kara

    Jan Kara
     

04 Sep, 2014

3 commits


07 May, 2014

3 commits


04 Apr, 2014

1 commit

  • Reclaim will be leaving shadow entries in the page cache radix tree upon
    evicting the real page. As those pages are found from the LRU, an
    iput() can lead to the inode being freed concurrently. At this point,
    reclaim must no longer install shadow pages because the inode freeing
    code needs to ensure the page tree is really empty.

    Add an address_space flag, AS_EXITING, that the inode freeing code sets
    under the tree lock before doing the final truncate. Reclaim will check
    for this flag before installing shadow pages.

    Signed-off-by: Johannes Weiner
    Reviewed-by: Rik van Riel
    Reviewed-by: Minchan Kim
    Cc: Andrea Arcangeli
    Cc: Bob Liu
    Cc: Christoph Hellwig
    Cc: Dave Chinner
    Cc: Greg Thelen
    Cc: Hugh Dickins
    Cc: Jan Kara
    Cc: KOSAKI Motohiro
    Cc: Luigi Semenzato
    Cc: Mel Gorman
    Cc: Metin Doslu
    Cc: Michel Lespinasse
    Cc: Ozgun Erdogan
    Cc: Peter Zijlstra
    Cc: Roman Gushchin
    Cc: Ryan Mallon
    Cc: Tejun Heo
    Cc: Vlastimil Babka
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Johannes Weiner
     

21 Feb, 2014

1 commit

  • UDF has two types of files - files with data stored in inode (ICB in
    UDF terminology) and files with data stored in external data blocks. We
    convert file from in-inode format to external format in
    udf_file_aio_write() when we find out data won't fit into inode any
    longer. However the following race between two O_APPEND writes can happen:

    CPU1 CPU2
    udf_file_aio_write() udf_file_aio_write()
    down_write(&iinfo->i_data_sem);
    checks that i_size + count1 fits within inode
    => no need to convert
    up_write(&iinfo->i_data_sem);
    down_write(&iinfo->i_data_sem);
    checks that i_size + count2 fits
    within inode => no need to convert
    up_write(&iinfo->i_data_sem);
    generic_file_aio_write()
    - extends file by count1 bytes
    generic_file_aio_write()
    - extends file by count2 bytes

    Clearly if count1 + count2 doesn't fit into the inode, we overwrite
    kernel buffers beyond inode, possibly corrupting the filesystem as well.

    Fix the problem by acquiring i_mutex before checking whether write fits
    into the inode and using __generic_file_aio_write() afterwards which
    puts check and write into one critical section.

    Reported-by: Al Viro
    Signed-off-by: Jan Kara

    Jan Kara
     

13 Sep, 2013

1 commit


08 May, 2013

1 commit

  • Faster kernel compiles by way of fewer unnecessary includes.

    [akpm@linux-foundation.org: fix fallout]
    [akpm@linux-foundation.org: fix build]
    Signed-off-by: Kent Overstreet
    Cc: Zach Brown
    Cc: Felipe Balbi
    Cc: Greg Kroah-Hartman
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Rusty Russell
    Cc: Jens Axboe
    Cc: Asai Thambi S P
    Cc: Selvan Mani
    Cc: Sam Bradshaw
    Cc: Jeff Moyer
    Cc: Al Viro
    Cc: Benjamin LaHaise
    Reviewed-by: "Theodore Ts'o"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kent Overstreet
     

22 Jan, 2013

1 commit

  • This patch implements extent caching in case of file reading.
    While reading a file, currently, UDF reads metadata serially
    which takes a lot of time depending on the number of extents present
    in the file. Caching last accessd extent improves metadata read time.
    Instead of reading file metadata from start, now we read from
    the cached extent.

    This patch considerably improves the time spent by CPU in kernel mode.
    For example, while reading a 10.9 GB file using dd:
    Time before applying patch:
    11677022208 bytes (10.9GB) copied, 1529.748921 seconds, 7.3MB/s
    real 25m 29.85s
    user 0m 12.41s
    sys 15m 34.75s

    Time after applying patch:
    11677022208 bytes (10.9GB) copied, 1469.338231 seconds, 7.6MB/s
    real 24m 29.44s
    user 0m 15.73s
    sys 3m 27.61s

    [JK: Fix bh refcounting issues, simplify initialization]

    Signed-off-by: Namjae Jeon
    Signed-off-by: Ashish Sangwan
    Signed-off-by: Bonggil Bak
    Signed-off-by: Jan Kara

    Namjae Jeon