13 Jan, 2019

1 commit

  • commit 6ff9b09e00a441599f3aacdf577254455a048bc9 upstream.

    In gfs2_create_inode, after setting and releasing the acl / default_acl, the
    acl / default_acl pointers are not set to NULL as they should be. In that
    state, when the function reaches label fail_free_acls, gfs2_create_inode will
    try to release the same acls again.

    Fix that by setting the pointers to NULL after releasing the acls. Slightly
    simplify the logic. Also, posix_acl_release checks for NULL already, so
    there is no need to duplicate those checks here.

    Fixes: e01580bf9e4d ("gfs2: use generic posix ACL infrastructure")
    Reported-by: Pan Bian
    Cc: Christoph Hellwig
    Cc: stable@vger.kernel.org # v4.9+
    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Bob Peterson
    Signed-off-by: Greg Kroah-Hartman

    Andreas Gruenbacher
     

09 Aug, 2017

2 commits


21 Jul, 2017

2 commits

  • Before this patch, the inode glock's gl_object was set after a
    reference was acquired, but before the block type was verified.
    In cases where the block was unlinked, then freed and reused on
    another node, a residule delete callback (delete_work) would try
    to look up the inode, eventually failing the block check, but
    only after it overwrites gl_object with a pointer to the wrong
    inode. This patch moves the assignment of gl_object after the
    block check so it won't be improperly overwritten.

    Likewise, at the end of the function, gfs2_inode_lookup was
    clearing gl_object after it unlocked the glock, which meant
    another process might free the glock in the meantime. This
    patch guards against that case.

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

    Bob Peterson
     
  • This patch introduces a new helper function in glock.h that
    clears gl_object, with an added integrity check. An additional
    integrity check has been added to glock_set_object, plus comments.
    This is step 1 in a series to ensure gl_object integrity.

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

    Bob Peterson
     

20 Jul, 2017

1 commit

  • When commit 4fd1a57952 moved the call to flush_delayed_work from
    gfs2_evict_inode to gfs2_inode_lookup to avoid calling into DLM during
    evict, a similar call should have been added to gfs2_create_inode:
    that's another code path in which glocks of previous inodes may be
    reused.

    The flush of the iopen glock work queue added by 4fd1a57952, on the
    other hand, is unnecessary and can be removed.

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

    Andreas Gruenbacher
     

05 Jul, 2017

3 commits

  • On failure, keep the inode glock across the final iput of the new inode
    so that gfs2_evict_inode doesn't have to re-acquire the glock. That
    way, gfs2_evict_inode won't need to revalidate the block type.

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

    Andreas Gruenbacher
     
  • Put all remaining accesses to gl->gl_object under the
    gl->gl_lockref.lock spinlock to prevent races.

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

    Andreas Gruenbacher
     
  • So far, gfs2_evict_inode clears gl->gl_object and then flushes the glock
    work queue to make sure that inode glops which dereference gl->gl_object
    have finished running before the inode is destroyed. However, flushing
    the work queue may do more work than needed, and in particular, it may
    call into DLM, which we want to avoid here. Use a bit lock
    (GIF_GLOP_PENDING) to synchronize between the inode glops and
    gfs2_evict_inode instead to get rid of the flushing.

    In addition, flush the work queues of existing glocks before reusing
    them for new inodes to get those glocks into a known state: the glock
    state engine currently doesn't handle glock re-appropriation correctly.
    (We may be able to fix the glock state engine instead later.)

    Based on a patch by Steven Whitehouse .

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

    Andreas Gruenbacher
     

03 Apr, 2017

1 commit

  • Revert commit 86d067a797d4e8546a7c92b985f31e8cd3ec39ad: it turns out
    that waiting for iopen glock dequeues here isn't needed anymore because
    the bugs that commit was meant to fix have been fixed otherwise.

    In addition, we want to avoid waiting on glocks in gfs2_evict_inode in
    shrinker context because the shrinker may be invoked on behalf of DLM,
    in which case calling into DLM again would deadlock. This commit makes
    the described scenario less likely without completely avoiding it; it's
    still a step in the right direction, though.

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

    Andreas Gruenbacher
     

17 Mar, 2017

1 commit

  • Before this patch i_no_addr was not initialized until after the
    return from allocating its block. That meant the i_no_addr was
    temporarily uninitialized storage. Ordinarily that's not a concern,
    but if inplace_reserve can't find space, it can call try_rgrp_unlink
    which references i_no_addr as a block to avoid. That can result in
    unpredictable behavior. More importantly, the trace point in
    gfs2_alloc_blocks references ip->i_no_addr before it is set, which
    is misleading when reading the kernel traces. This patch makes it
    look like the new dinode block was assigned in the name of inode 0
    rather than a random inode that's completely unrelated.

    Signed-off-by: Bob Peterson

    Bob Peterson
     

04 Mar, 2017

1 commit

  • Pull vfs 'statx()' update from Al Viro.

    This adds the new extended stat() interface that internally subsumes our
    previous stat interfaces, and allows user mode to specify in more detail
    what kind of information it wants.

    It also allows for some explicit synchronization information to be
    passed to the filesystem, which can be relevant for network filesystems:
    is the cached value ok, or do you need open/close consistency, or what?

    From David Howells.

    Andreas Dilger points out that the first version of the extended statx
    interface was posted June 29, 2010:

    https://www.spinics.net/lists/linux-fsdevel/msg33831.html

    * 'rebased-statx' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    statx: Add a system call to make enhanced file info available

    Linus Torvalds
     

03 Mar, 2017

1 commit

  • Add a system call to make extended file information available, including
    file creation and some attribute flags where available through the
    underlying filesystem.

    The getattr inode operation is altered to take two additional arguments: a
    u32 request_mask and an unsigned int flags that indicate the
    synchronisation mode. This change is propagated to the vfs_getattr*()
    function.

    Functions like vfs_stat() are now inline wrappers around new functions
    vfs_statx() and vfs_statx_fd() to reduce stack usage.

    ========
    OVERVIEW
    ========

    The idea was initially proposed as a set of xattrs that could be retrieved
    with getxattr(), but the general preference proved to be for a new syscall
    with an extended stat structure.

    A number of requests were gathered for features to be included. The
    following have been included:

    (1) Make the fields a consistent size on all arches and make them large.

    (2) Spare space, request flags and information flags are provided for
    future expansion.

    (3) Better support for the y2038 problem [Arnd Bergmann] (tv_sec is an
    __s64).

    (4) Creation time: The SMB protocol carries the creation time, which could
    be exported by Samba, which will in turn help CIFS make use of
    FS-Cache as that can be used for coherency data (stx_btime).

    This is also specified in NFSv4 as a recommended attribute and could
    be exported by NFSD [Steve French].

    (5) Lightweight stat: Ask for just those details of interest, and allow a
    netfs (such as NFS) to approximate anything not of interest, possibly
    without going to the server [Trond Myklebust, Ulrich Drepper, Andreas
    Dilger] (AT_STATX_DONT_SYNC).

    (6) Heavyweight stat: Force a netfs to go to the server, even if it thinks
    its cached attributes are up to date [Trond Myklebust]
    (AT_STATX_FORCE_SYNC).

    And the following have been left out for future extension:

    (7) Data version number: Could be used by userspace NFS servers [Aneesh
    Kumar].

    Can also be used to modify fill_post_wcc() in NFSD which retrieves
    i_version directly, but has just called vfs_getattr(). It could get
    it from the kstat struct if it used vfs_xgetattr() instead.

    (There's disagreement on the exact semantics of a single field, since
    not all filesystems do this the same way).

    (8) BSD stat compatibility: Including more fields from the BSD stat such
    as creation time (st_btime) and inode generation number (st_gen)
    [Jeremy Allison, Bernd Schubert].

    (9) Inode generation number: Useful for FUSE and userspace NFS servers
    [Bernd Schubert].

    (This was asked for but later deemed unnecessary with the
    open-by-handle capability available and caused disagreement as to
    whether it's a security hole or not).

    (10) Extra coherency data may be useful in making backups [Andreas Dilger].

    (No particular data were offered, but things like last backup
    timestamp, the data version number and the DOS archive bit would come
    into this category).

    (11) Allow the filesystem to indicate what it can/cannot provide: A
    filesystem can now say it doesn't support a standard stat feature if
    that isn't available, so if, for instance, inode numbers or UIDs don't
    exist or are fabricated locally...

    (This requires a separate system call - I have an fsinfo() call idea
    for this).

    (12) Store a 16-byte volume ID in the superblock that can be returned in
    struct xstat [Steve French].

    (Deferred to fsinfo).

    (13) Include granularity fields in the time data to indicate the
    granularity of each of the times (NFSv4 time_delta) [Steve French].

    (Deferred to fsinfo).

    (14) FS_IOC_GETFLAGS value. These could be translated to BSD's st_flags.
    Note that the Linux IOC flags are a mess and filesystems such as Ext4
    define flags that aren't in linux/fs.h, so translation in the kernel
    may be a necessity (or, possibly, we provide the filesystem type too).

    (Some attributes are made available in stx_attributes, but the general
    feeling was that the IOC flags were to ext[234]-specific and shouldn't
    be exposed through statx this way).

    (15) Mask of features available on file (eg: ACLs, seclabel) [Brad Boyer,
    Michael Kerrisk].

    (Deferred, probably to fsinfo. Finding out if there's an ACL or
    seclabal might require extra filesystem operations).

    (16) Femtosecond-resolution timestamps [Dave Chinner].

    (A __reserved field has been left in the statx_timestamp struct for
    this - if there proves to be a need).

    (17) A set multiple attributes syscall to go with this.

    ===============
    NEW SYSTEM CALL
    ===============

    The new system call is:

    int ret = statx(int dfd,
    const char *filename,
    unsigned int flags,
    unsigned int mask,
    struct statx *buffer);

    The dfd, filename and flags parameters indicate the file to query, in a
    similar way to fstatat(). There is no equivalent of lstat() as that can be
    emulated with statx() by passing AT_SYMLINK_NOFOLLOW in flags. There is
    also no equivalent of fstat() as that can be emulated by passing a NULL
    filename to statx() with the fd of interest in dfd.

    Whether or not statx() synchronises the attributes with the backing store
    can be controlled by OR'ing a value into the flags argument (this typically
    only affects network filesystems):

    (1) AT_STATX_SYNC_AS_STAT tells statx() to behave as stat() does in this
    respect.

    (2) AT_STATX_FORCE_SYNC will require a network filesystem to synchronise
    its attributes with the server - which might require data writeback to
    occur to get the timestamps correct.

    (3) AT_STATX_DONT_SYNC will suppress synchronisation with the server in a
    network filesystem. The resulting values should be considered
    approximate.

    mask is a bitmask indicating the fields in struct statx that are of
    interest to the caller. The user should set this to STATX_BASIC_STATS to
    get the basic set returned by stat(). It should be noted that asking for
    more information may entail extra I/O operations.

    buffer points to the destination for the data. This must be 256 bytes in
    size.

    ======================
    MAIN ATTRIBUTES RECORD
    ======================

    The following structures are defined in which to return the main attribute
    set:

    struct statx_timestamp {
    __s64 tv_sec;
    __s32 tv_nsec;
    __s32 __reserved;
    };

    struct statx {
    __u32 stx_mask;
    __u32 stx_blksize;
    __u64 stx_attributes;
    __u32 stx_nlink;
    __u32 stx_uid;
    __u32 stx_gid;
    __u16 stx_mode;
    __u16 __spare0[1];
    __u64 stx_ino;
    __u64 stx_size;
    __u64 stx_blocks;
    __u64 __spare1[1];
    struct statx_timestamp stx_atime;
    struct statx_timestamp stx_btime;
    struct statx_timestamp stx_ctime;
    struct statx_timestamp stx_mtime;
    __u32 stx_rdev_major;
    __u32 stx_rdev_minor;
    __u32 stx_dev_major;
    __u32 stx_dev_minor;
    __u64 __spare2[14];
    };

    The defined bits in request_mask and stx_mask are:

    STATX_TYPE Want/got stx_mode & S_IFMT
    STATX_MODE Want/got stx_mode & ~S_IFMT
    STATX_NLINK Want/got stx_nlink
    STATX_UID Want/got stx_uid
    STATX_GID Want/got stx_gid
    STATX_ATIME Want/got stx_atime{,_ns}
    STATX_MTIME Want/got stx_mtime{,_ns}
    STATX_CTIME Want/got stx_ctime{,_ns}
    STATX_INO Want/got stx_ino
    STATX_SIZE Want/got stx_size
    STATX_BLOCKS Want/got stx_blocks
    STATX_BASIC_STATS [The stuff in the normal stat struct]
    STATX_BTIME Want/got stx_btime{,_ns}
    STATX_ALL [All currently available stuff]

    stx_btime is the file creation time, stx_mask is a bitmask indicating the
    data provided and __spares*[] are where as-yet undefined fields can be
    placed.

    Time fields are structures with separate seconds and nanoseconds fields
    plus a reserved field in case we want to add even finer resolution. Note
    that times will be negative if before 1970; in such a case, the nanosecond
    fields will also be negative if not zero.

    The bits defined in the stx_attributes field convey information about a
    file, how it is accessed, where it is and what it does. The following
    attributes map to FS_*_FL flags and are the same numerical value:

    STATX_ATTR_COMPRESSED File is compressed by the fs
    STATX_ATTR_IMMUTABLE File is marked immutable
    STATX_ATTR_APPEND File is append-only
    STATX_ATTR_NODUMP File is not to be dumped
    STATX_ATTR_ENCRYPTED File requires key to decrypt in fs

    Within the kernel, the supported flags are listed by:

    KSTAT_ATTR_FS_IOC_FLAGS

    [Are any other IOC flags of sufficient general interest to be exposed
    through this interface?]

    New flags include:

    STATX_ATTR_AUTOMOUNT Object is an automount trigger

    These are for the use of GUI tools that might want to mark files specially,
    depending on what they are.

    Fields in struct statx come in a number of classes:

    (0) stx_dev_*, stx_blksize.

    These are local system information and are always available.

    (1) stx_mode, stx_nlinks, stx_uid, stx_gid, stx_[amc]time, stx_ino,
    stx_size, stx_blocks.

    These will be returned whether the caller asks for them or not. The
    corresponding bits in stx_mask will be set to indicate whether they
    actually have valid values.

    If the caller didn't ask for them, then they may be approximated. For
    example, NFS won't waste any time updating them from the server,
    unless as a byproduct of updating something requested.

    If the values don't actually exist for the underlying object (such as
    UID or GID on a DOS file), then the bit won't be set in the stx_mask,
    even if the caller asked for the value. In such a case, the returned
    value will be a fabrication.

    Note that there are instances where the type might not be valid, for
    instance Windows reparse points.

    (2) stx_rdev_*.

    This will be set only if stx_mode indicates we're looking at a
    blockdev or a chardev, otherwise will be 0.

    (3) stx_btime.

    Similar to (1), except this will be set to 0 if it doesn't exist.

    =======
    TESTING
    =======

    The following test program can be used to test the statx system call:

    samples/statx/test-statx.c

    Just compile and run, passing it paths to the files you want to examine.
    The file is built automatically if CONFIG_SAMPLES is enabled.

    Here's some example output. Firstly, an NFS directory that crosses to
    another FSID. Note that the AUTOMOUNT attribute is set because transiting
    this directory will cause d_automount to be invoked by the VFS.

    [root@andromeda ~]# /tmp/test-statx -A /warthog/data
    statx(/warthog/data) = 0
    results=7ff
    Size: 4096 Blocks: 8 IO Block: 1048576 directory
    Device: 00:26 Inode: 1703937 Links: 125
    Access: (3777/drwxrwxrwx) Uid: 0 Gid: 4041
    Access: 2016-11-24 09:02:12.219699527+0000
    Modify: 2016-11-17 10:44:36.225653653+0000
    Change: 2016-11-17 10:44:36.225653653+0000
    Attributes: 0000000000001000 (-------- -------- -------- -------- -------- -------- ---m---- --------)

    Secondly, the result of automounting on that directory.

    [root@andromeda ~]# /tmp/test-statx /warthog/data
    statx(/warthog/data) = 0
    results=7ff
    Size: 4096 Blocks: 8 IO Block: 1048576 directory
    Device: 00:27 Inode: 2 Links: 125
    Access: (3777/drwxrwxrwx) Uid: 0 Gid: 4041
    Access: 2016-11-24 09:02:12.219699527+0000
    Modify: 2016-11-17 10:44:36.225653653+0000
    Change: 2016-11-17 10:44:36.225653653+0000

    Signed-off-by: David Howells
    Signed-off-by: Al Viro

    David Howells
     

02 Mar, 2017

1 commit


25 Dec, 2016

1 commit


09 Dec, 2016

1 commit


11 Oct, 2016

4 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
     
  • Pull vfs xattr updates from Al Viro:
    "xattr stuff from Andreas

    This completes the switch to xattr_handler ->get()/->set() from
    ->getxattr/->setxattr/->removexattr"

    * 'work.xattr' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    vfs: Remove {get,set,remove}xattr inode operations
    xattr: Stop calling {get,set,remove}xattr inode operations
    vfs: Check for the IOP_XATTR flag in listxattr
    xattr: Add __vfs_{get,set,remove}xattr helpers
    libfs: Use IOP_XATTR flag for empty directory handling
    vfs: Use IOP_XATTR flag for bad-inode handling
    vfs: Add IOP_XATTR inode operations flag
    vfs: Move xattr_resolve_name to the front of fs/xattr.c
    ecryptfs: Switch to generic xattr handlers
    sockfs: Get rid of getxattr iop
    sockfs: getxattr: Fail with -EOPNOTSUPP for invalid attribute names
    kernfs: Switch to generic xattr handlers
    hfs: Switch to generic xattr handlers
    jffs2: Remove jffs2_{get,set,remove}xattr macros
    xattr: Remove unnecessary NULL attribute name check

    Linus Torvalds
     
  • Pull misc vfs updates from Al Viro:
    "Assorted misc bits and pieces.

    There are several single-topic branches left after this (rename2
    series from Miklos, current_time series from Deepa Dinamani, xattr
    series from Andreas, uaccess stuff from from me) and I'd prefer to
    send those separately"

    * 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (39 commits)
    proc: switch auxv to use of __mem_open()
    hpfs: support FIEMAP
    cifs: get rid of unused arguments of CIFSSMBWrite()
    posix_acl: uapi header split
    posix_acl: xattr representation cleanups
    fs/aio.c: eliminate redundant loads in put_aio_ring_file
    fs/internal.h: add const to ns_dentry_operations declaration
    compat: remove compat_printk()
    fs/buffer.c: make __getblk_slow() static
    proc: unsigned file descriptors
    fs/file: more unsigned file descriptors
    fs: compat: remove redundant check of nr_segs
    cachefiles: Fix attempt to read i_blocks after deleting file [ver #2]
    cifs: don't use memcpy() to copy struct iov_iter
    get rid of separate multipage fault-in primitives
    fs: Avoid premature clearing of capabilities
    fs: Give dentry to inode_change_ok() instead of inode
    fuse: Propagate dentry down to inode_change_ok()
    ceph: Propagate dentry down to inode_change_ok()
    xfs: Propagate dentry down to inode_change_ok()
    ...

    Linus Torvalds
     

08 Oct, 2016

1 commit


05 Oct, 2016

1 commit

  • Pull gfs2 updates from Bob Peterson:
    "We've only got six GFS2 patches for this merge window. In patch
    order:

    - Fabian Frederick submitted a nice cleanup that uses the BIT macro
    rather than bit shifting.

    - Andreas Gruenbacher contributed a patch that fixes a long-standing
    annoyance whereby GFS2 warned about dirty pages.

    - Andreas also fixed a problem with the recent extended attribute
    readahead feature.

    - Chao Yu contributed a patch that checks the return code from
    function register_shrinker and reacts accordingly. Previously, it
    was not checked.

    - Andreas Gruenbacher also fixed a problem whereby incore file
    timestamps were forgotten if the file was invalidated. This merely
    moves the assignment inside the inode glock where it belongs.

    - Andreas also fixed a problem where incore timestamps were not
    initialized"

    * tag 'gfs2-4.8.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2:
    gfs2: Initialize atime of I_NEW inodes
    gfs2: Update file times after grabbing glock
    gfs2: fix to detect failure of register_shrinker
    gfs2: Fix extended attribute readahead optimization
    gfs2: Remove dirty buffer warning from gfs2_releasepage
    GFS2: use BIT() macro

    Linus Torvalds
     

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
     

27 Sep, 2016

2 commits


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
     

07 Aug, 2016

1 commit

  • In most cases, EPERM is returned on immutable inode, and there're only a
    few places returning EACCES. I noticed this when running LTP on
    overlayfs, setxattr03 failed due to unexpected EACCES on immutable
    inode.

    So converting all EACCES to EPERM on immutable inode.

    Acked-by: Dave Chinner
    Signed-off-by: Eryu Guan
    Signed-off-by: Al Viro
    Signed-off-by: Linus Torvalds

    Eryu Guan
     

25 Jul, 2016

1 commit

  • Pull gfs2 updates from Bob Peterson:
    "We've got ten patches this time, half of which are related to a
    plethora of nasty outcomes when inodes are transitioned from the
    unlinked state to the free state. Small file systems are particularly
    vulnerable to these problems, and it can manifest as mainly hangs, but
    also file system corruption. The patches have been tested for
    literally many weeks, with a very gruelling test, so I have a high
    level of confidence.

    - Andreas Gruenbacher wrote a series of five patches for various
    lockups during the transition of inodes from unlinked to free.

    The main patch is titled "Fix gfs2_lookup_by_inum lock inversion"
    and the other four are support and cleanup patches related to that.

    - Ben Marzinski contributed two patches with regard to a recreatable
    problem when gfs2 tries to write a page to a file that is being
    truncated, resulting in a BUG() in gfs2_remove_from_journal.

    Note that Ben had to export vfs function __block_write_full_page to
    get this to work properly. It's been posted a long time and he
    talked to various VFS people about it, and nobody seemed to mind.

    - I contributed 3 patches:
    o The first one fixes a memory corruptor: a race in which one
    process can overwrite the gl_object pointer set by another
    process, causing kernel panic and other symptoms.
    o The second patch fixes another race that resulted in a
    false-positive BUG_ON. This occurred when resource group
    reservations were freed by one process while another process
    was trying to grab a new reservation in the same resource
    group.
    o The third patch fixes a problem with doing journal replay when
    the journals are not all the same size"

    * tag 'gfs2-4.7.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2:
    GFS2: Fix gfs2_replay_incr_blk for multiple journal sizes
    GFS2: Check rs_free with rd_rsspin protection
    gfs2: writeout truncated pages
    fs: export __block_write_full_page
    gfs2: Lock holder cleanup
    gfs2: Large-filesystem fix for 32-bit systems
    gfs2: Get rid of gfs2_ilookup
    gfs2: Fix gfs2_lookup_by_inum lock inversion
    gfs2: Initialize iopen glock holder for new inodes
    GFS2: don't set rgrp gl_object until it's inserted into rgrp tree

    Linus Torvalds
     

06 Jul, 2016

1 commit


27 Jun, 2016

4 commits

  • Make the code more readable by cleaning up the different ways of
    initializing lock holders and checking for initialized lock holders:
    mark lock holders as uninitialized by setting the holder's glock to NULL
    (gfs2_holder_mark_uninitialized) instead of zeroing out the entire
    object or using a separate flag. Recognize initialized holders by their
    non-NULL glock (gfs2_holder_initialized). Don't zero out holder objects
    which are immeditiately initialized via gfs2_holder_init or
    gfs2_glock_nq_init.

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

    Andreas Gruenbacher
     
  • Commit ff34245d switched from iget5_locked to iget_locked among other
    things, but iget_locked doesn't work for filesystems larger than 2^32
    blocks on 32-bit systems. Switch back to iget5_locked. Filesystems
    larger than 2^32 blocks are unrealistic to work well on 32-bit systems,
    so this is mostly a code cleanliness fix.

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

    Andreas Gruenbacher
     
  • Now that gfs2_lookup_by_inum only takes the inode glock for new inodes
    (and not for cached inodes anymore), there no longer is a need to
    optimize the cached-inode case in gfs2_get_dentry or delete_work_func,
    and gfs2_ilookup can be removed.

    In addition, gfs2_get_dentry wasn't checking the GFS2_DIF_SYSTEM flag in
    i_diskflags in the gfs2_ilookup case (see gfs2_lookup_by_inum); this
    inconsistency goes away as well.

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

    Andreas Gruenbacher
     
  • The current gfs2_lookup_by_inum takes the glock of a presumed inode
    identified by block number, verifies that the block is indeed an inode,
    and then instantiates and reads the new inode via gfs2_inode_lookup.

    However, instantiating a new inode may block on freeing a previous
    instance of that inode (__wait_on_freeing_inode), and freeing an inode
    requires to take the glock already held, leading to lock inversion and
    deadlock.

    Fix this by first instantiating the new inode, then verifying that the
    block is an inode (if required), and then reading in the new inode, all
    in gfs2_inode_lookup.

    If the block we are looking for is not an inode, we discard the new
    inode via iget_failed, which marks inodes as bad and unhashes them.
    Other tasks waiting on that inode will get back a bad inode back from
    ilookup or iget_locked; in that case, retry the lookup.

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

    Andreas Gruenbacher
     

21 May, 2016

1 commit

  • Pull GFS2 updates from Bob Peterson:
    "We've got nine patches this time:

    - Abhi Das has two patches that fix a GFS2 splice issue (and an
    adjustment).

    - Ben Marzinski has a patch which allows the proper unmount of a GFS2
    file system after hitting a withdraw error.

    - I have a patch to fix a problem where GFS2 would dereference an
    error value, plus three cosmetic / refactoring patches.

    - Daniel DeFreez has a patch to fix two glock reference count
    problems, where GFS2 was not properly "uninitializing" its glock
    holder on error paths.

    - Denys Vlasenko has a patch to change a function to not be inlined,
    thus reducing the memory footprint of the GFS2 module"

    * tag 'gfs2-4.7.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2:
    GFS2: Refactor gfs2_remove_from_journal
    GFS2: Remove allocation parms from gfs2_rbm_find
    gfs2: use inode_lock/unlock instead of accessing i_mutex directly
    GFS2: Add calls to gfs2_holder_uninit in two error handlers
    GFS2: Don't dereference inode in gfs2_inode_lookup until it's valid
    GFS2: fs/gfs2/glock.c: Deinline do_error, save 1856 bytes
    gfs2: Use gfs2 wrapper to sync inode before calling generic_file_splice_read()
    GFS2: Get rid of dead code in inode_go_demote_ok
    GFS2: ignore unlock failures after withdraw

    Linus Torvalds
     

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
     

14 Apr, 2016

1 commit


11 Apr, 2016

1 commit


18 Mar, 2016

1 commit

  • Pull GFS2 updates from Bob Peterson:
    "We only have six patches ready for this merge window:

    - Arnd Bergmann contributed a patch that fixes an uninitialized
    variable warning.

    - The second patch avoids a kernel panic due to referencing an iopen
    glock that may not be held, in an error path.

    - The third patch fixes a rounding error that caused xfs_tests direct
    IO write "fsx" tests to fail on GFS2.

    - The fourth patch tidies up the code path when glocks are being
    reused to recreate a dinode that was recently deleted.

    - The fifth reverts an ages-old patch that should no longer be
    needed, and which interfered with the transition of dinodes from
    unlinked to free.

    - And lastly, a patch to eliminate a function parameter that's not
    needed"

    * tag 'gfs2-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2:
    GFS2: Eliminate parameter non_block on gfs2_inode_lookup
    GFS2: Don't filter out I_FREEING inodes anymore
    GFS2: Prevent delete work from occurring on glocks used for create
    GFS2: Fix direct IO write rounding error
    gfs2: avoid uninitialized variable warning
    GFS2: Check if iopen is held when deleting inode

    Linus Torvalds
     

15 Mar, 2016

2 commits

  • Now that we're not filtering out I_FREEING inodes from our lookups
    anymore, we can eliminate the non_block parameter from the lookup
    function.

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

    Bob Peterson
     
  • This patch basically reverts a very old patch from 2008,
    7a9f53b3c1875bef22ad4588e818bc046ef183da, with the title
    "Alternate gfs2_iget to avoid looking up inodes being freed".
    The original patch was designed to avoid a deadlock caused by lock
    ordering with try_rgrp_unlink. The patch forced the function to not
    find inodes that were being removed by VFS. The problem is, that
    made it impossible for nodes to delete their own unlinked dinodes
    after a certain point in time, because the inode needed was not found
    by this filtering process. There is no longer a need for the patch,
    since function try_rgrp_unlink no longer locks the inode: All it does
    is queue the glock onto the delete work_queue, so there should be no
    more deadlock.

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

    Bob Peterson