20 Jun, 2018

2 commits


09 Apr, 2018

1 commit

  • dquot_init() is never called in atomic context.
    This function is only set as a parameter of fs_initcall().

    Despite never getting called from atomic context,
    dquot_init() calls __get_free_pages() with GFP_ATOMIC,
    which waits busily for allocation.
    GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL,
    to avoid busy waiting and improve the possibility of sucessful allocation.

    This is found by a static analysis tool named DCNS written by myself.
    And I also manually check it.

    Signed-off-by: Jia-Ju Bai
    Signed-off-by: Jan Kara

    Jia-Ju Bai
     

03 Apr, 2018

2 commits


29 Nov, 2017

1 commit

  • register_shrinker() might return -ENOMEM error since Linux 3.12.
    Call panic() as with other failure checks in this function if
    register_shrinker() failed.

    Fixes: 1d3d4437eae1 ("vmscan: per-node deferred work")
    Signed-off-by: Tetsuo Handa
    Cc: Jan Kara
    Cc: Michal Hocko
    Reviewed-by: Michal Hocko
    Signed-off-by: Jan Kara

    Tetsuo Handa
     

28 Nov, 2017

1 commit

  • In commit 6184fc0b8dd7 ("quota: Propagate error from ->acquire_dquot()"),
    we have propagated error from __dquot_initialize to caller, but we forgot
    to handle such error in add_dquot_ref(), so, currently, during quota
    accounting information initialization flow, if we failed for some of
    inodes, we just ignore such error, and do account for others, which is
    not a good implementation.

    In this patch, we choose to let user be aware of such error, so after
    turning on quota successfully, we can make sure all inodes disk usage
    can be accounted, which will be more reasonable.

    Suggested-by: Jan Kara
    Signed-off-by: Chao Yu
    Signed-off-by: Jan Kara

    Chao Yu
     

15 Nov, 2017

1 commit

  • Pull quota, ext2, isofs and udf fixes from Jan Kara:

    - two small quota error handling fixes

    - two isofs fixes for architectures with signed char

    - several udf block number overflow and signedness fixes

    - ext2 rework of mount option handling to avoid GFP_KERNEL allocation
    with spinlock held

    - ... it also contains a patch to implement auditing of responses to
    fanotify permission events. That should have been in the fanotify
    pull request but I mistakenly merged that patch into a wrong branch
    and noticed only now at which point I don't think it's worth rebasing
    and redoing.

    * 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
    quota: be aware of error from dquot_initialize
    quota: fix potential infinite loop
    isofs: use unsigned char types consistently
    isofs: fix timestamps beyond 2027
    udf: Fix some sign-conversion warnings
    udf: Fix signed/unsigned format specifiers
    udf: Fix 64-bit sign extension issues affecting blocks > 0x7FFFFFFF
    udf: Remove some outdate references from documentation
    udf: Avoid overflow when session starts at large offset
    ext2: Fix possible sleep in atomic during mount option parsing
    ext2: Parse mount options into a dedicated structure
    audit: Record fanotify access control decisions

    Linus Torvalds
     

14 Nov, 2017

1 commit


13 Nov, 2017

1 commit


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
     

01 Nov, 2017

1 commit

  • In dquot_writeback_dquots(), we write back dquot from dirty dquots
    list. There is a potential infinite loop if ->write_dquot() failure
    and forget remove dquot from the list. This patch clear dirty bit
    anyway to avoid it.

    Signed-off-by: zhangyi (F)
    Signed-off-by: Jan Kara

    zhangyi (F)
     

10 Oct, 2017

1 commit

  • Eryu has reported that since commit 7b9ca4c61bc2 "quota: Reduce
    contention on dq_data_lock" test generic/233 occasionally fails. This is
    caused by the fact that since that commit we don't generate warning and
    set grace time for quota allocations that have DQUOT_SPACE_NOFAIL set
    (these are for example some metadata allocations in ext4). We need these
    allocations to behave regularly wrt warning generation and grace time
    setting so fix the code to return to the original behavior.

    Reported-and-tested-by: Eryu Guan
    CC: stable@vger.kernel.org
    Fixes: 7b9ca4c61bc278b771fb57d6290a31ab1fc7fdac
    Signed-off-by: Jan Kara

    Jan Kara
     

27 Sep, 2017

1 commit

  • Eric has reported that since commit d2faa415166b "quota: Do not acquire
    dqio_sem for dquot overwrites in v2 format" test generic/232
    occasionally fails due to quota information being incorrect. Indeed that
    commit was too eager to remove dqio_sem completely from the path that
    just overwrites quota structure with updated information. Although that
    is innocent on its own, another process that inserts new quota structure
    to the same block can perform read-modify-write cycle of that block thus
    effectively discarding quota information update if they race in a wrong
    way.

    Fix the problem by acquiring dqio_sem for reading for overwrites of
    quota structure. Note that it *is* possible to completely avoid taking
    dqio_sem in the overwrite path however that will require modifying path
    inserting / deleting quota structures to avoid RMW cycles of the full
    block and for now it is not clear whether it is worth the hassle.

    Fixes: d2faa415166b2883428efa92f451774ef44373ac
    Reported-and-tested-by: Eric Whitney
    Signed-off-by: Jan Kara

    Jan Kara
     

18 Sep, 2017

1 commit


15 Sep, 2017

1 commit

  • Pull mount flag updates from Al Viro:
    "Another chunk of fmount preparations from dhowells; only trivial
    conflicts for that part. It separates MS_... bits (very grotty
    mount(2) ABI) from the struct super_block ->s_flags (kernel-internal,
    only a small subset of MS_... stuff).

    This does *not* convert the filesystems to new constants; only the
    infrastructure is done here. The next step in that series is where the
    conflicts would be; that's the conversion of filesystems. It's purely
    mechanical and it's better done after the merge, so if you could run
    something like

    list=$(for i in MS_RDONLY MS_NOSUID MS_NODEV MS_NOEXEC MS_SYNCHRONOUS MS_MANDLOCK MS_DIRSYNC MS_NOATIME MS_NODIRATIME MS_SILENT MS_POSIXACL MS_KERNMOUNT MS_I_VERSION MS_LAZYTIME; do git grep -l $i fs drivers/staging/lustre drivers/mtd ipc mm include/linux; done|sort|uniq|grep -v '^fs/namespace.c$')

    sed -i -e 's/\/SB_RDONLY/g' \
    -e 's/\/SB_NOSUID/g' \
    -e 's/\/SB_NODEV/g' \
    -e 's/\/SB_NOEXEC/g' \
    -e 's/\/SB_SYNCHRONOUS/g' \
    -e 's/\/SB_MANDLOCK/g' \
    -e 's/\/SB_DIRSYNC/g' \
    -e 's/\/SB_NOATIME/g' \
    -e 's/\/SB_NODIRATIME/g' \
    -e 's/\/SB_SILENT/g' \
    -e 's/\/SB_POSIXACL/g' \
    -e 's/\/SB_KERNMOUNT/g' \
    -e 's/\/SB_I_VERSION/g' \
    -e 's/\/SB_LAZYTIME/g' \
    $list

    and commit it with something along the lines of 'convert filesystems
    away from use of MS_... constants' as commit message, it would save a
    quite a bit of headache next cycle"

    * 'work.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    VFS: Differentiate mount flags (MS_*) from internal superblock flags
    VFS: Convert sb->s_flags & MS_RDONLY to sb_rdonly(sb)
    vfs: Add sb_rdonly(sb) to query the MS_RDONLY flag on s_flags

    Linus Torvalds
     

08 Sep, 2017

1 commit

  • Pull quota scaling updates from Jan Kara:
    "This contains changes to make the quota subsystem more scalable.

    Reportedly it improves number of files created per second on ext4
    filesystem on fast storage by about a factor of 2x"

    * 'quota_scaling' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: (28 commits)
    quota: Add lock annotations to struct members
    quota: Reduce contention on dq_data_lock
    fs: Provide __inode_get_bytes()
    quota: Inline dquot_[re]claim_reserved_space() into callsite
    quota: Inline inode_{incr,decr}_space() into callsites
    quota: Inline functions into their callsites
    ext4: Disable dirty list tracking of dquots when journalling quotas
    quota: Allow disabling tracking of dirty dquots in a list
    quota: Remove dq_wait_unused from dquot
    quota: Move locking into clear_dquot_dirty()
    quota: Do not dirty bad dquots
    quota: Fix possible corruption of dqi_flags
    quota: Propagate ->quota_read errors from v2_read_file_info()
    quota: Fix error codes in v2_read_file_info()
    quota: Push dqio_sem down to ->read_file_info()
    quota: Push dqio_sem down to ->write_file_info()
    quota: Push dqio_sem down to ->get_next_id()
    quota: Push dqio_sem down to ->release_dqblk()
    quota: Remove locking for writing to the old quota format
    quota: Do not acquire dqio_sem for dquot overwrites in v2 format
    ...

    Linus Torvalds
     

21 Aug, 2017

1 commit


18 Aug, 2017

22 commits

  • dq_data_lock is currently used to protect all modifications of quota
    accounting information, consistency of quota accounting on the inode,
    and dquot pointers from inode. As a result contention on the lock can be
    pretty heavy.

    Reduce the contention on the lock by protecting quota accounting
    information by a new dquot->dq_dqb_lock and consistency of quota
    accounting with inode usage by inode->i_lock.

    This change reduces time to create 500000 files on ext4 on ramdisk by 50
    different processes in separate directories by 6% when user quota is
    turned on. When those 50 processes belong to 50 different users, the
    improvement is about 9%.

    Signed-off-by: Jan Kara

    Jan Kara
     
  • dquot_claim_reserved_space() and dquot_reclaim_reserved_space() have
    only a single callsite. Inline them there.

    Signed-off-by: Jan Kara

    Jan Kara
     
  • inode_incr_space() and inode_decr_space() have only two callsites.
    Inline them there as that will make locking changes simpler.

    Signed-off-by: Jan Kara

    Jan Kara
     
  • inode_add_rsv_space() and inode_sub_rsv_space() had only one callsite.
    Inline them there directly. inode_claim_rsv_space() and
    inode_reclaim_rsv_space() had two callsites so inline them there as
    well. This will simplify further locking changes.

    Signed-off-by: Jan Kara

    Jan Kara
     
  • Filesystems that are journalling quotas generally don't need tracking of
    dirty dquots in a list since forcing a transaction commit flushes all
    quotas anyway. Allow filesystem to say it doesn't want dquots to be
    tracked as it reduces contention on the dq_list_lock.

    Signed-off-by: Jan Kara

    Jan Kara
     
  • Currently every dquot carries a wait_queue_head_t used only when we are
    turning quotas off to wait for last users to drop dquot references.
    Since such rare case is not performance sensitive in any means, just use
    a global waitqueue for this and save space in struct dquot. Also convert
    the logic to use wait_event() instead of open-coding it.

    Signed-off-by: Jan Kara

    Jan Kara
     
  • Move locking of dq_list_lock into clear_dquot_dirty(). It makes the
    function more self-contained and will simplify our life later.

    Reviewed-by: Andreas Dilger
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Currently we mark dirty even dquots that are not active (i.e.,
    initialization or reading failed for them). Thus later we have to check
    whether dirty dquot is really active and just clear the dirty bit if
    not. Avoid this complication by just never marking non-active dquot as
    dirty.

    Signed-off-by: Jan Kara

    Jan Kara
     
  • dqi_flags modifications are protected by dq_data_lock. However the
    modifications in vfs_load_quota_inode() and in mark_info_dirty() were
    not which could lead to corruption of dqi_flags. Since modifications to
    dqi_flags are rare, this is hard to observe in practice but in theory it
    could happen. Fix the problem by always using dq_data_lock for
    protection.

    Signed-off-by: Jan Kara

    Jan Kara
     
  • Currently we return -EIO on any error (or short read) from
    ->quota_read() while reading quota info. Propagate the error code
    instead.

    Suggested-by: Andreas Dilger
    Signed-off-by: Jan Kara

    Jan Kara
     
  • v2_read_file_info() returned -1 instead of proper error codes on error.
    Luckily this is not easily visible from userspace as we have called
    ->check_quota_file shortly before and thus already verified the quota
    file is sane. Still set the error codes to proper values.

    Reviewed-by: Andreas Dilger
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Push down acquisition of dqio_sem into ->read_file_info() callback. This
    is for consistency with other operations and it also allows us to get
    rid of an ugliness in OCFS2.

    Reviewed-by: Andreas Dilger
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Push down acquisition of dqio_sem into ->write_file_info() callback.
    Mostly for consistency with other operations.

    Reviewed-by: Andreas Dilger
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Push down acquisition of dqio_sem into ->get_next_id() callback. Mostly
    for consistency with other operations.

    Reviewed-by: Andreas Dilger
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Push down acquisition of dqio_sem into ->release_dqblk() callback. It
    will allow quota formats to decide whether they need it or not.

    Reviewed-by: Andreas Dilger
    Signed-off-by: Jan Kara

    Jan Kara
     
  • The old quota quota format has fixed offset in quota file based on ID so
    there's no locking needed against concurrent modifications of the file
    (locking against concurrent IO on the same dquot is still provided by
    dq_lock).

    Reviewed-by: Andreas Dilger
    Signed-off-by: Jan Kara

    Jan Kara
     
  • When dquot has space already allocated in a quota file, we just
    overwrite that place when writing dquot. So we don't need any protection
    against other modifications of quota file as these keep dquot in place.

    Reviewed-by: Andreas Dilger
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Push down acquisition of dqio_sem into ->write_dqblk() callback. It will
    allow quota formats to decide whether they need it or not.

    Reviewed-by: Andreas Dilger
    Signed-off-by: Jan Kara

    Jan Kara
     
  • The old quota format has fixed offset in quota file based on ID so
    there's no locking needed against concurrent modifications of the file
    (locking against concurrent IO on the same dquot is still provided by
    dq_lock).

    Reviewed-by: Andreas Dilger
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Push down acquisition of dqio_sem into ->read_dqblk() callback. It will
    allow quota formats to decide whether they need it or not.

    Reviewed-by: Andreas Dilger
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Currently dquot writeout is only protected by dqio_sem held for writing.
    As we transition to a finer grained locking we will use dquot->dq_lock
    instead. So acquire it in dquot_commit() and move dqio_sem just around
    ->commit_dqblk() call as it is still needed to serialize quota file
    changes.

    Reviewed-by: Andreas Dilger
    Signed-off-by: Jan Kara

    Jan Kara
     
  • vfs_load_quota_inode() needs dqio_sem only for reading. In fact dqio_sem
    is not needed there at all since the function can be called only during
    quota on when quota file cannot be modified but let's leave the
    protection there since it is logical and the path is in no way
    performance critical.

    Reviewed-by: Andreas Dilger
    Signed-off-by: Jan Kara

    Jan Kara