28 Mar, 2020

2 commits

  • Before this patch, multiple users called gfs2_qa_alloc which allocated
    a qadata structure to the inode, if quotas are turned on. Later, in
    file close or evict, the structure was deleted with gfs2_qa_delete.
    But there can be several competing processes who need access to the
    structure. There were races between file close (release) and the others.
    Thus, a release could delete the structure out from under a process
    that relied upon its existence. For example, chown.

    This patch changes the management of the qadata structures to be
    a get/put scheme. Function gfs2_qa_alloc has been changed to gfs2_qa_get
    and if the structure is allocated, the count essentially starts out at
    1. Function gfs2_qa_delete has been renamed to gfs2_qa_put, and the
    last guy to decrement the count to 0 frees the memory.

    Signed-off-by: Bob Peterson

    Bob Peterson
     
  • Before this patch, multiple callers called gfs2_rsqa_alloc to force
    the existence of a reservations structure and a quota data structure
    if needed. However, now the reservations are handled separately, so
    the quota data is only the quota data. So we eliminate the one in
    favor of just calling gfs2_qa_alloc directly.

    Signed-off-by: Bob Peterson

    Bob Peterson
     

05 Jun, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this copyrighted material is made available to anyone wishing to use
    modify copy or redistribute it subject to the terms and conditions
    of the gnu general public license version 2

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 44 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Kate Stewart
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190531081038.653000175@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

08 May, 2019

1 commit


12 Oct, 2018

2 commits

  • Function rgblk_free can only deal with one resource group at a time, so
    pass that resource group is as a parameter. Several of the callers
    already have the resource group at hand, so we only need additional
    lookup code in a few places.

    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Bob Peterson
    Reviewed-by: Steven Whitehouse

    Andreas Gruenbacher
     
  • The state parameter of gfs2_rlist_alloc is set to LM_ST_EXCLUSIVE in all
    calls, so remove it and hardcode that state in gfs2_rlist_alloc instead.

    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Bob Peterson
    Reviewed-by: Steven Whitehouse

    Bob Peterson
     

03 Aug, 2018

1 commit

  • Function gfs2_ea_strlen is only called from ea_list_i, so inline it
    there. Remove the duplicate switch statement and the creative use of
    memcpy to set a null byte.

    Signed-off-by: Andreas Gruenbacher
    Reviewed-by: Andrew Price
    Reviewed-by: Bob Peterson

    Andreas Gruenbacher
     

28 Mar, 2018

1 commit


31 Oct, 2017

2 commits

  • On the following call path:

    gfs2_setattr -> setattr_prepare -> ... ->
    cap_inode_killpriv -> ... ->
    gfs2_xattr_set

    the glock is locked in gfs2_setattr, so check for recursive locking in
    gfs2_xattr_set as gfs2_xattr_get already does. While at it, get rid of
    need_unlock in gfs2_xattr_get.

    Fixes xfstest generic/093.

    Signed-off-by: Andreas Gruenbacher
    Acked-by: Abhijith Das
    Signed-off-by: Bob Peterson

    Andreas Gruenbacher
     
  • Make sure that changing xattrs marks the corresponding inode dirty so
    that a subsequent fsync will sync those changes to disk. We set
    I_DIRTY_SYNC as well as I_DIRTY_DATASYNC so that both fsync and
    fdatasync will sync xattr changes: xattrs can contain information
    critical to how the data can be accessed, so we don't want fdatasync
    to skip them.

    Fixes xfstest generic/066.

    Signed-off-by: Andreas Gruenbacher
    Reviewed-by: Andrew Price
    Signed-off-by: Bob Peterson

    Andreas Gruenbacher
     

31 Aug, 2017

1 commit

  • The function __gfs2_xattr_set() will return -ENODATA when called to
    remove a xattr that does not exist. The result is that setfacl will
    show an exit status of 1 when called to set only a file's mode bits
    (on a file with no ACLs), despite succeeding. A "No data available"
    error will be printed as well.

    To fix this return 0 instead, except when the XATTR_REPLACE flag is
    set, in which case -ENODATA is appropriate. This is consistent with
    how most other xattr setting functions work, in other filesystems.

    Signed-off-by: Ernesto A. Fernández
    Signed-off-by: Bob Peterson

    Ernesto A. Fernández
     

26 Aug, 2017

1 commit

  • This patch cleans up various pieces of GFS2 to avoid sparse errors.
    This doesn't fix them all, but it fixes several. The first error,
    in function glock_hash_walk was a genuine bug where the rhashtable
    could be started and not stopped.

    Signed-off-by: Bob Peterson

    Bob Peterson
     

05 Jul, 2017

1 commit


25 Dec, 2016

1 commit


28 Sep, 2016

1 commit

  • CURRENT_TIME macro is not appropriate for filesystems as it
    doesn't use the right granularity for filesystem timestamps.
    Use current_time() instead.

    CURRENT_TIME is also not y2038 safe.

    This is also in preparation for the patch that transitions
    vfs timestamps to use 64 bit time and hence make them
    y2038 safe. As part of the effort current_time() will be
    extended to do range checks. Hence, it is necessary for all
    file system timestamps to use current_time(). Also,
    current_time() will be transitioned along with vfs to be
    y2038 safe.

    Note that whenever a single call to current_time() is used
    to change timestamps in different inodes, it is because they
    share the same time granularity.

    Signed-off-by: Deepa Dinamani
    Reviewed-by: Arnd Bergmann
    Acked-by: Felipe Balbi
    Acked-by: Steven Whitehouse
    Acked-by: Ryusuke Konishi
    Acked-by: David Sterba
    Signed-off-by: Al Viro

    Deepa Dinamani
     

28 May, 2016

1 commit


13 May, 2016

1 commit

  • Switch to the generic xattr handlers and take the necessary glocks at
    the layer below. The following are the new xattr "entry points"; they
    are called with the glock held already in the following cases:

    gfs2_xattr_get: From SELinux, during lookups.
    gfs2_xattr_set: The glock is never held.
    gfs2_get_acl: From gfs2_create_inode -> posix_acl_create and
    gfs2_setattr -> posix_acl_chmod.
    gfs2_set_acl: From gfs2_setattr -> posix_acl_chmod.

    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Al Viro

    Al Viro
     

11 Apr, 2016

1 commit


13 Jan, 2016

1 commit

  • Pull GFS2 updates from Bob Peterson:
    "Here is a list of patches we've accumulated for GFS2 for the current
    upstream merge window. Last window's set was short, but I warned that
    this one would be bigger, and so it is. We've got 19 patches:

    - A patch from Abhi Das to propagate the GFS2_DIF_SYSTEM bit so that
    newly added journals don't get flagged, deleted, and recreated by
    fsck.gfs2.

    - Two patches from Andreas Gruenbacher to improve GFS2 performance
    where extended attributes are involved.

    - A patch from Andy Price to fix a suspicious rcu dereference error.

    - Two patches from Ben Marzinski that rework how GFS2's NFS cookies
    are managed. This fixes readdir problems with nfs-over-gfs2.

    - A patch from Ben Marzinski that fixes a race in unmounting GFS2.

    - A set of four patches from me to move the resource group
    reservations inside the gfs2 inode to improve performance and fix a
    bug whereby get_write_access improperly prevented some operations
    like chown.

    - A patch from me to spinlock-protect the setting of system statfs
    file data. This was causing small discrepancies between df and du.

    - A patch from me to reintroduce a timeout while clearing glocks
    which was accidentally dropped some time ago.

    - A patch from me to wait for iopen glock dequeues in order to
    improve deleting of files that were unlinked from a different
    cluster node.

    - A patch from me to ensure metadata address spaces get truncated
    when an inode is evicted.

    - A patch from me to fix a bug in which a memory leak could occur in
    some error cases when inodes were trying to be created.

    - A patch to consistently use iopen glocks to transition from the
    unlinked state to the deleted state.

    - A patch to fix a glock reference count error when inode creation
    fails.

    - A patch from Junxiao Bi to fix an flock panic.

    - A patch from Markus Elfring that removes an unnecessary if"

    * tag 'gfs2-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2:
    gfs2: fix flock panic issue
    GFS2: Don't do glock put on when inode creation fails
    GFS2: Always use iopen glock for gl_deletes
    GFS2: Release iopen glock in gfs2_create_inode error cases
    GFS2: Truncate address space mapping when deleting an inode
    GFS2: Wait for iopen glock dequeues
    gfs2: clear journal live bit in gfs2_log_flush
    gfs2: change gfs2 readdir cookie
    gfs2: keep offset when splitting dir leaf blocks
    GFS2: Reintroduce a timeout in function gfs2_gl_hash_clear
    GFS2: Update master statfs buffer with sd_statfs_spin locked
    GFS2: Reduce size of incore inode
    GFS2: Make rgrp reservations part of the gfs2_inode structure
    GFS2: Extract quota data from reservations structure (revert 5407e24)
    gfs2: Extended attribute readahead optimization
    gfs2: Extended attribute readahead
    GFS2: Use rht_for_each_entry_rcu in glock_hash_walk
    GFS2: Delete an unnecessary check before the function call "iput"
    gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files

    Linus Torvalds
     

07 Dec, 2015

1 commit


17 Nov, 2015

1 commit

  • When gfs2 allocates an inode and its extended attribute block next to
    each other at inode create time, the inode's directory entry indicates
    that in de_rahead. In that case, we can readahead the extended
    attribute block when we read in the inode.

    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Bob Peterson

    Andreas Gruenbacher
     

14 Nov, 2015

1 commit

  • The xattr_handler operations are currently all passed a file system
    specific flags value which the operations can use to disambiguate between
    different handlers; some file systems use that to distinguish the xattr
    namespace, for example. In some oprations, it would be useful to also have
    access to the handler prefix. To allow that, pass a pointer to the handler
    to operations instead of the flags value alone.

    Signed-off-by: Andreas Gruenbacher
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Al Viro

    Andreas Gruenbacher
     

27 Apr, 2015

1 commit

  • Pull fourth vfs update from Al Viro:
    "d_inode() annotations from David Howells (sat in for-next since before
    the beginning of merge window) + four assorted fixes"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    RCU pathwalk breakage when running into a symlink overmounting something
    fix I_DIO_WAKEUP definition
    direct-io: only inc/dec inode->i_dio_count for file systems
    fs/9p: fix readdir()
    VFS: assorted d_backing_inode() annotations
    VFS: fs/inode.c helpers: d_inode() annotations
    VFS: fs/cachefiles: d_backing_inode() annotations
    VFS: fs library helpers: d_inode() annotations
    VFS: assorted weird filesystems: d_inode() annotations
    VFS: normal filesystems (and lustre): d_inode() annotations
    VFS: security/: d_inode() annotations
    VFS: security/: d_backing_inode() annotations
    VFS: net/: d_inode() annotations
    VFS: net/unix: d_backing_inode() annotations
    VFS: kernel/: d_inode() annotations
    VFS: audit: d_backing_inode() annotations
    VFS: Fix up some ->d_inode accesses in the chelsio driver
    VFS: Cachefiles should perform fs modifications on the top layer only
    VFS: AF_UNIX sockets should call mknod on the top layer only

    Linus Torvalds
     

16 Apr, 2015

1 commit


19 Mar, 2015

1 commit

  • Use struct gfs2_alloc_parms as an argument to gfs2_quota_check()
    and gfs2_quota_lock_check() to check for quota violations while
    accounting for the new blocks requested by the current operation
    in ap->target.

    Previously, the number of new blocks requested during an operation
    were not accounted for during quota_check and would allow these
    operations to exceed quota. This was not very apparent since most
    operations allocated only 1 block at a time and quotas would get
    violated in the next operation. i.e. quota excess would only be by
    1 block or so. With fallocate, (where we allocate a bunch of blocks
    at once) the quota excess is non-trivial and is addressed by this
    patch.

    Signed-off-by: Abhi Das
    Signed-off-by: Bob Peterson
    Acked-by: Steven Whitehouse

    Abhi Das
     

26 Jan, 2014

1 commit


02 Oct, 2013

1 commit

  • This patch adds a structure to contain allocation parameters with
    the intention of future expansion of this structure. The idea is
    that we should be able to add more information about the allocation
    in the future in order to allow the allocator to make a better job
    of placing the requests on-disk.

    There is no functional difference from applying this patch.

    Signed-off-by: Steven Whitehouse

    Steven Whitehouse
     

26 Feb, 2013

1 commit

  • Pull user namespace and namespace infrastructure changes from Eric W Biederman:
    "This set of changes starts with a few small enhnacements to the user
    namespace. reboot support, allowing more arbitrary mappings, and
    support for mounting devpts, ramfs, tmpfs, and mqueuefs as just the
    user namespace root.

    I do my best to document that if you care about limiting your
    unprivileged users that when you have the user namespace support
    enabled you will need to enable memory control groups.

    There is a minor bug fix to prevent overflowing the stack if someone
    creates way too many user namespaces.

    The bulk of the changes are a continuation of the kuid/kgid push down
    work through the filesystems. These changes make using uids and gids
    typesafe which ensures that these filesystems are safe to use when
    multiple user namespaces are in use. The filesystems converted for
    3.9 are ceph, 9p, afs, ocfs2, gfs2, ncpfs, nfs, nfsd, and cifs. The
    changes for these filesystems were a little more involved so I split
    the changes into smaller hopefully obviously correct changes.

    XFS is the only filesystem that remains. I was hoping I could get
    that in this release so that user namespace support would be enabled
    with an allyesconfig or an allmodconfig but it looks like the xfs
    changes need another couple of days before it they are ready."

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: (93 commits)
    cifs: Enable building with user namespaces enabled.
    cifs: Convert struct cifs_ses to use a kuid_t and a kgid_t
    cifs: Convert struct cifs_sb_info to use kuids and kgids
    cifs: Modify struct smb_vol to use kuids and kgids
    cifs: Convert struct cifsFileInfo to use a kuid
    cifs: Convert struct cifs_fattr to use kuid and kgids
    cifs: Convert struct tcon_link to use a kuid.
    cifs: Modify struct cifs_unix_set_info_args to hold a kuid_t and a kgid_t
    cifs: Convert from a kuid before printing current_fsuid
    cifs: Use kuids and kgids SID to uid/gid mapping
    cifs: Pass GLOBAL_ROOT_UID and GLOBAL_ROOT_GID to keyring_alloc
    cifs: Use BUILD_BUG_ON to validate uids and gids are the same size
    cifs: Override unmappable incoming uids and gids
    nfsd: Enable building with user namespaces enabled.
    nfsd: Properly compare and initialize kuids and kgids
    nfsd: Store ex_anon_uid and ex_anon_gid as kuids and kgids
    nfsd: Modify nfsd4_cb_sec to use kuids and kgids
    nfsd: Handle kuids and kgids in the nfs4acl to posix_acl conversion
    nfsd: Convert nfsxdr to use kuids and kgids
    nfsd: Convert nfs3xdr to use kuids and kgids
    ...

    Linus Torvalds
     

13 Feb, 2013

1 commit


29 Jan, 2013

1 commit

  • There is little common content in gfs2_trans_add_bh() between the data
    and meta classes by the time that the functions which it calls are
    taken into account. The intent here is to split this into two
    separate functions. Stage one is to introduce gfs2_trans_add_data()
    and gfs2_trans_add_meta() and update the callers accordingly.

    Later patches will then pull in the content of gfs2_trans_add_bh()
    and its dependent functions in order to clean up the code in this
    area.

    Signed-off-by: Steven Whitehouse

    Steven Whitehouse
     

07 Nov, 2012

1 commit

  • Just like ext3, this works on the root directory and any directory
    with the +T flag set. Also, just like ext3, any subdirectory created
    in one of the just mentioned cases will be allocated to a random
    resource group (GFS2 equivalent of a block group).

    If you are creating a set of directories, each of which will contain a
    job running on a different node, then by setting +T on the parent
    directory before creating the subdirectories, each will land up in a
    different resource group, and thus resource group contention between
    nodes will be kept to a minimum.

    Signed-off-by: Steven Whitehouse

    Steven Whitehouse
     

24 Sep, 2012

2 commits

  • The rs_requested field is left over from the original allocation
    code, however this should have been a parameter passed to the
    various functions from gfs2_inplace_reserve() and not a member of the
    reservation structure as the value is not required after the
    initial allocation.

    This also helps simplify the code since we no longer need to set
    the rs_requested to zero. Also the gfs2_inplace_release()
    function can also be simplified since the reservation structure
    will always be defined when it is called, and the only remaining
    task is to unlock the rgrp if required. It can also now be
    called unconditionally too, resulting in a further simplification.

    Signed-off-by: Steven Whitehouse

    Steven Whitehouse
     
  • There were two functions in the xattr code which were nearly
    identical, the only difference being that one was copy data into
    the unstuffed xattrs and the other was copying data out from it.

    This patch merges the two functions such that the code which deal
    with iteration over the unstuffed xattrs is no longer duplicated.

    Signed-off-by: Steven Whitehouse

    Steven Whitehouse
     

19 Jul, 2012

1 commit

  • This patch reduces GFS2 file fragmentation by pre-reserving blocks. The
    resulting improved on disk layout greatly speeds up operations in cases
    which would have resulted in interlaced allocation of blocks previously.
    A typical example of this is 10 parallel dd processes, each writing to a
    file in a common dirctory.

    The implementation uses an rbtree of reservations attached to each
    resource group (and each inode).

    Signed-off-by: Bob Peterson
    Signed-off-by: Steven Whitehouse

    Bob Peterson
     

06 Jun, 2012

1 commit


05 Apr, 2012

1 commit


29 Feb, 2012

1 commit

  • The FITRIM ioctl provides an alternative way to send discard requests to
    the underlying device. Using the discard mount option results in every
    freed block generating a discard request to the block device. This can
    be slow, since many block devices can only process discard requests of
    larger sizes, and also such operations can be time consuming.

    Rather than using the discard mount option, FITRIM allows a sweep of the
    filesystem on an occasional basis, and also to optionally avoid sending
    down discard requests for smaller regions.

    In GFS2 FITRIM will work at resource group granularity. There is a flag
    for each resource group which keeps track of which resource groups have
    been trimmed. This flag is reset whenever a deallocation occurs in the
    resource group, and set whenever a successful FITRIM of that resource
    group has taken place. This helps to reduce repeated discard requests
    for the same block ranges, again improving performance.

    Signed-off-by: Steven Whitehouse

    Steven Whitehouse
     

22 Nov, 2011

1 commit

  • This patch separates the code pertaining to allocations into two
    parts: quota-related information and block reservations.
    This patch also moves all the block reservation structure allocations to
    function gfs2_inplace_reserve to simplify the code, and moves
    the frees to function gfs2_inplace_release.

    Signed-off-by: Bob Peterson
    Signed-off-by: Steven Whitehouse

    Bob Peterson
     

21 Nov, 2011

1 commit

  • This patch is a revision of the one I previously posted.
    I tried to integrate all the suggestions Steve gave.
    The purpose of the patch is to change function gfs2_alloc_block
    (allocate either a dinode block or an extent of data blocks)
    to a more generic gfs2_alloc_blocks function that can
    allocate both a dinode _and_ an extent of data blocks in the
    same call. This will ultimately help us create a multi-block
    reservation scheme to reduce file fragmentation.

    This patch moves more toward a generic multi-block allocator that
    takes a pointer to the number of data blocks to allocate, plus whether
    or not to allocate a dinode. In theory, it could be called to allocate
    (1) a single dinode block, (2) a group of one or more data blocks, or
    (3) a dinode plus several data blocks.

    Signed-off-by: Bob Peterson
    Signed-off-by: Steven Whitehouse

    Bob Peterson
     

15 Nov, 2011

1 commit

  • GFS2 functions gfs2_alloc_block and gfs2_alloc_di do basically
    the same things, with a few exceptions. This patch combines
    the two functions into a slightly more generic gfs2_alloc_block.
    Having one centralized block allocation function will reduce
    code redundancy and make it easier to implement multi-block
    reservations to reduce file fragmentation in the future.

    Signed-off-by: Bob Peterson
    Signed-off-by: Steven Whitehouse

    Bob Peterson