03 Mar, 2020

8 commits

  • Lift the common code to copy the cursor from and to user space into
    xfs_ioc_attr_list. Note that this means we copy in twice now as
    the cursor is in the middle of the conaining structure, but we never
    touch the memory for the original copy. Doing so keeps the cursor
    handling isolated in the common helper.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Dave Chinner
    Reviewed-by: Chandan Rajendra
    Reviewed-by: Darrick J. Wong
    Signed-off-by: Darrick J. Wong

    Christoph Hellwig
     
  • Lift the buffer allocation from the two callers into xfs_ioc_attr_list.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Dave Chinner
    Reviewed-by: Chandan Rajendra
    Reviewed-by: Darrick J. Wong
    Signed-off-by: Darrick J. Wong

    Christoph Hellwig
     
  • Lift the flags and bufsize checks from both callers into the common code
    in xfs_ioc_attr_list.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Dave Chinner
    Reviewed-by: Chandan Rajendra
    Reviewed-by: Darrick J. Wong
    Signed-off-by: Darrick J. Wong

    Christoph Hellwig
     
  • The old xfs_attr_list code is only used by the attrlist by handle
    ioctl. Move it to xfs_ioctl.c with its user. Also move the
    attrlist and attrlist_ent structure to xfs_fs.h, as they are exposed
    user ABIs. They are used through libattr headers with the same name
    by at least xfsdump. Also document this relation so that it doesn't
    require a research project to figure out.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Dave Chinner
    Reviewed-by: Chandan Rajendra
    Reviewed-by: Darrick J. Wong
    Signed-off-by: Darrick J. Wong

    Christoph Hellwig
     
  • Add a new helper to handle a single attr multi ioctl operation that
    can be shared between the native and compat ioctl implementation.

    There is a slight change in behaviour in that we don't break out of the
    loop when copying in the attribute name fails. The previous behaviour
    was rather inconsistent here as it continued for any other kind of
    error, and that we don't clear the flags in the structure returned
    to userspace, a behavior only introduced as a bug fix in the last
    merge window.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Dave Chinner
    Reviewed-by: Chandan Rajendra
    Reviewed-by: Darrick J. Wong
    Signed-off-by: Darrick J. Wong

    Christoph Hellwig
     
  • Simplify the user copy code by using strndup_user. This means that we
    now do one memory allocation per operation instead of one per ioctl,
    but memory allocations are cheap compared to the actual file system
    operations. Also the error for an invalid path is now EINVAL or EFAULT
    instead of the previous odd and undocumented ERANGE.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Dave Chinner
    Reviewed-by: Chandan Rajendra
    Reviewed-by: Darrick J. Wong
    Signed-off-by: Darrick J. Wong

    Christoph Hellwig
     
  • Merge the ioctl handlers just like the low-level xfs_attr_set function.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Dave Chinner
    Reviewed-by: Chandan Rajendra
    Reviewed-by: Darrick J. Wong
    Signed-off-by: Darrick J. Wong

    Christoph Hellwig
     
  • While the flags field in the ABI and the on-disk format allows for
    multiple namespace flags, an attribute can only exist in a single
    namespace at a time. Hence asking to list attributes that exist
    in multiple namespaces simultaneously is a logically invalid
    request and will return no results. Reject this case early with
    -EINVAL.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Dave Chinner
    Reviewed-by: Chandan Rajendra
    Reviewed-by: Darrick J. Wong
    Signed-off-by: Darrick J. Wong

    Christoph Hellwig
     

10 Jan, 2020

2 commits


07 Jan, 2020

1 commit

  • The compat_time_t type has been removed everywhere else,
    as most users rely on old_time32_t for both native and
    compat mode handling of 32-bit time_t.

    Remove the last one in xfs.

    Reviewed-by: Darrick J. Wong
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Darrick J. Wong

    Arnd Bergmann
     

14 Nov, 2019

1 commit

  • Thes ioctls set DMAPI specific flags in the on-disk inode, but there is
    no way to actually ever query those flags. The only known user is
    xfsrestore with the -D option, which is documented to be only useful
    inside a DMAPI enviroment, which isn't supported by upstream XFS.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Darrick J. Wong
    Signed-off-by: Darrick J. Wong

    Christoph Hellwig
     

28 Oct, 2019

2 commits


27 Aug, 2019

1 commit


17 Aug, 2019

2 commits

  • For 31-bit s390 user space, we have to pass pointer arguments through
    compat_ptr() in the compat_ioctl handler.

    Signed-off-by: Arnd Bergmann
    Signed-off-by: Christoph Hellwig
    Reviewed-by: Eric Sandeen
    Reviewed-by: Darrick J. Wong
    Signed-off-by: Darrick J. Wong

    Christoph Hellwig
     
  • Always try the native ioctl if we don't have a compat handler. This
    removes a lot of boilerplate code as 'modern' ioctls should generally
    be compat clean, and fixes the missing entries for the recently added
    FS_IOC_GETFSLABEL/FS_IOC_SETFSLABEL ioctls.

    Fixes: f7664b31975b ("xfs: implement online get/set fs label")
    Signed-off-by: Christoph Hellwig
    Reviewed-by: Eric Sandeen
    Reviewed-by: Darrick J. Wong
    Signed-off-by: Darrick J. Wong

    Christoph Hellwig
     

04 Jul, 2019

6 commits


03 Jul, 2019

3 commits


29 Jun, 2019

2 commits

  • There are many, many xfs header files which are included but
    unneeded (or included twice) in the xfs code, so remove them.

    nb: xfs_linux.h includes about 9 headers for everyone, so those
    explicit includes get removed by this. I'm not sure what the
    preference is, but if we wanted explicit includes everywhere,
    a followup patch could remove those xfs_*.h includes from
    xfs_linux.h and move them into the files that need them.
    Or it could be left as-is.

    Signed-off-by: Eric Sandeen
    Reviewed-by: Darrick J. Wong
    Signed-off-by: Darrick J. Wong

    Eric Sandeen
     
  • The inode geometry structure isn't related to ondisk format; it's
    support for the mount structure. Move it to xfs_shared.h.

    Signed-off-by: Darrick J. Wong
    Reviewed-by: Dave Chinner
    Reviewed-by: Christoph Hellwig

    Darrick J. Wong
     

02 May, 2019

1 commit

  • There are several functions which have no opportunity to return
    an error, and don't contain any ASSERTs which could be argued
    to be better constructed as error cases. So, make them voids
    to simplify the callers.

    Signed-off-by: Eric Sandeen
    Reviewed-by: Darrick J. Wong
    Signed-off-by: Darrick J. Wong
    Reviewed-by: Dave Chinner

    Eric Sandeen
     

15 Apr, 2019

2 commits

  • Add a new ioctl to describe an allocation group's geometry.

    Signed-off-by: Darrick J. Wong
    Reviewed-by: Brian Foster

    Darrick J. Wong
     
  • Unfortunately, the V4 XFS_IOC_FSGEOMETRY structure is out of space so we
    can't just add a new field to it. Hence we need to bump the definition
    to V5 and and treat the V4 ioctl and structure similar to v1 to v3.

    While doing this, clean up all the definitions associated with the
    XFS_IOC_FSGEOMETRY ioctl.

    Signed-Off-By: Dave Chinner
    Reviewed-by: Darrick J. Wong
    [darrick: forward port to 5.1, expand structure size to 256 bytes]
    Signed-off-by: Darrick J. Wong
    Reviewed-by: Brian Foster

    Dave Chinner
     

19 Dec, 2018

3 commits

  • Several ioctl structs change size between native 32-bit (ia32) and x32
    applications, because x32 follows the native 64-bit (amd64) integer
    alignment rules and uses 64-bit time_t. In these instances, the ioctl
    number changes so userspace simply gets -ENOTTY. This scenario can be
    handled by simply adding more cases.

    Looking at the different ioctls implemented here:

    - All the ones marked 'No size or alignment issue on any arch' should
    presumably all be fine.

    - All the ones under BROKEN_X86_ALIGNMENT are different under integer
    alignment rules. Since x32 matches amd64 here, we just need both
    sets of cases handled.

    - XFS_IOC_SWAPEXT has both integer alignment differences and time_t
    differences. Since x32 matches amd64 here, we need to add a case
    which calls the native implementation.

    - The remaining ioctls have neither 64-bit integers nor time_t, so
    x32 matches ia32 here and no change is required at this level. The
    bulkstat ioctl implementations have some pointer chasing which is
    handled separately.

    Signed-off-by: Nick Bowler
    Reviewed-by: Darrick J. Wong
    Signed-off-by: Darrick J. Wong

    Nick Bowler
     
  • The bulkstat family of ioctls are problematic on x32, because there is
    a mixup of native 32-bit and 64-bit conventions. The xfs_fsop_bulkreq
    struct contains pointers and 32-bit integers so that matches the native
    32-bit layout, and that means the ioctl implementation goes into the
    regular compat path on x32.

    However, the 'ubuffer' member of that struct in turn refers to either
    struct xfs_inogrp or xfs_bstat (or an array of these). On x32, those
    structures match the native 64-bit layout. The compat implementation
    writes out the 32-bit version of these structures. This is not the
    expected format for x32 userspace, causing problems.

    Fortunately the functions which actually output these xfs_inogrp and
    xfs_bstat structures have an easy way to select which output format
    is required, so we just need a little tweak to select the right format
    on x32.

    Signed-off-by: Nick Bowler
    Reviewed-by: Darrick J. Wong
    Signed-off-by: Darrick J. Wong

    Nick Bowler
     
  • While inspecting the ioctl implementations, I noticed that the compat
    implementation of XFS_IOC_ATTRLIST_BY_HANDLE does not do exactly the
    same thing as the native implementation. Specifically, the "cursor"
    does not appear to be written out to userspace on the compat path,
    like it is on the native path.

    This adjusts the compat implementation to copy out the cursor just
    like the native implementation does. The attrlist cursor does not
    require any special compat handling. This fixes xfstests xfs/269
    on both IA-32 and x32 userspace, when running on an amd64 kernel.

    Signed-off-by: Nick Bowler
    Fixes: 0facef7fb053b ("xfs: in _attrlist_by_handle, copy the cursor back to userspace")
    Reviewed-by: Darrick J. Wong
    Signed-off-by: Darrick J. Wong

    Nick Bowler
     

07 Jun, 2018

1 commit

  • Remove the verbose license text from XFS files and replace them
    with SPDX tags. This does not change the license of any of the code,
    merely refers to the common, up-to-date license files in LICENSES/

    This change was mostly scripted. fs/xfs/Makefile and
    fs/xfs/libxfs/xfs_fs.h were modified by hand, the rest were detected
    and modified by the following command:

    for f in `git grep -l "GNU General" fs/xfs/` ; do
    echo $f
    cat $f | awk -f hdr.awk > $f.new
    mv -f $f.new $f
    done

    And the hdr.awk script that did the modification (including
    detecting the difference between GPL-2.0 and GPL-2.0+ licenses)
    is as follows:

    $ cat hdr.awk
    BEGIN {
    hdr = 1.0
    tag = "GPL-2.0"
    str = ""
    }

    /^ \* This program is free software/ {
    hdr = 2.0;
    next
    }

    /any later version./ {
    tag = "GPL-2.0+"
    next
    }

    /^ \*\// {
    if (hdr > 0.0) {
    print "// SPDX-License-Identifier: " tag
    print str
    print $0
    str=""
    hdr = 0.0
    next
    }
    print $0
    next
    }

    /^ \* / {
    if (hdr > 1.0)
    next
    if (hdr > 0.0) {
    if (str != "")
    str = str "\n"
    str = str $0
    next
    }
    print $0
    next
    }

    /^ \*/ {
    if (hdr > 0.0)
    next
    print $0
    next
    }

    // {
    if (hdr > 0.0) {
    if (str != "")
    str = str "\n"
    str = str $0
    next
    }
    print $0
    }

    END { }
    $

    Signed-off-by: Dave Chinner
    Reviewed-by: Darrick J. Wong
    Signed-off-by: Darrick J. Wong

    Dave Chinner
     

09 Jan, 2018

2 commits


27 Oct, 2017

1 commit

  • Create an ioctl that can be used to scrub internal filesystem metadata.
    The new ioctl takes the metadata type, an (optional) AG number, an
    (optional) inode number and generation, and a flags argument. This will
    be used by the upcoming XFS online scrub tool.

    Signed-off-by: Darrick J. Wong
    Reviewed-by: Dave Chinner

    Darrick J. Wong
     

04 Apr, 2017

1 commit


25 Dec, 2016

1 commit