20 Mar, 2016

1 commit

  • Pull vfs updates from Al Viro:

    - Preparations of parallel lookups (the remaining main obstacle is the
    need to move security_d_instantiate(); once that becomes safe, the
    rest will be a matter of rather short series local to fs/*.c

    - preadv2/pwritev2 series from Christoph

    - assorted fixes

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (32 commits)
    splice: handle zero nr_pages in splice_to_pipe()
    vfs: show_vfsstat: do not ignore errors from show_devname method
    dcache.c: new helper: __d_add()
    don't bother with __d_instantiate(dentry, NULL)
    untangle fsnotify_d_instantiate() a bit
    uninline d_add()
    replace d_add_unique() with saner primitive
    quota: use lookup_one_len_unlocked()
    cifs_get_root(): use lookup_one_len_unlocked()
    nfs_lookup: don't bother with d_instantiate(dentry, NULL)
    kill dentry_unhash()
    ceph_fill_trace(): don't bother with d_instantiate(dn, NULL)
    autofs4: don't bother with d_instantiate(dentry, NULL) in ->lookup()
    configfs: move d_rehash() into configfs_create() for regular files
    ceph: don't bother with d_rehash() in splice_dentry()
    namei: teach lookup_slow() to skip revalidate
    namei: massage lookup_slow() to be usable by lookup_one_len_unlocked()
    lookup_one_len_unlocked(): use lookup_dcache()
    namei: simplify invalidation logics in lookup_dcache()
    namei: change calling conventions for lookup_{fast,slow} and follow_managed()
    ...

    Linus Torvalds
     

16 Mar, 2016

9 commits

  • Use the standard pr_xxx() log macros directly for log prints instead of
    the AUTOFS_XXX() macros.

    Signed-off-by: Ian Kent
    Cc: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • Common kernel coding practice is to include the newline of log prints
    within the log text rather than hidden away in a macro.

    To avoid introducing inconsistencies as changes are made change the log
    macros to not include the newline.

    Signed-off-by: Ian Kent
    Cc: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • Use the pr_*() print in AUTOFS_*() macros instead of printks and include
    the module name in log message macros. Also use the AUTOFS_*() macros
    everywhere instead of raw printks.

    Signed-off-by: Ian Kent
    Cc: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • Fix some white space format errors.

    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • The return from an ioctl if an invalid ioctl is passed in should be
    EINVAL not ENOSYS.

    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • The need for this is questionable but checkpatch.pl complains about the
    line length and it's a straightfoward change.

    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • Refactor autofs4_get_set_timeout() to eliminate coding style error.

    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • Try and make the coding style completely consistent throughtout the
    autofs module and inline with kernel coding style recommendations.

    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • This is required for CRIU (Checkpoint Restart In Userspace) to migrate a
    mount point when write end in user space is closed.

    Below is a brief description of the problem.

    To migrate a non-catatonic autofs mount point, one has to restore the
    control pipe between kernel and autofs master process.

    One of the autofs masters is systemd, which closes pipe write end after
    passing it to the kernel with mount call.

    To be able to restore the systemd control pipe one has to know which
    read pipe end in systemd corresponds to the write pipe end in the
    kernel. The pipe "fd" in mount options is not enough because it was
    closed and probably replaced by some other descriptor.

    Thus, some other attribute is required to be able to find the read pipe
    end. The best attribute to use to find the correct pipe end is inode
    number becuase it's unique for the whole system and can't be reused
    while the autofs mount exists.

    This attribute can also be used to recognize a situation where an autofs
    mount has no master (no process with specified "pgrp" or no file
    descriptor with "pipe_ino", specified in autofs mount options).

    Signed-off-by: Stanislav Kinsburskiy
    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stanislav Kinsburskiy
     

14 Mar, 2016

1 commit


31 Dec, 2015

1 commit


09 Dec, 2015

1 commit

  • new method: ->get_link(); replacement of ->follow_link(). The differences
    are:
    * inode and dentry are passed separately
    * might be called both in RCU and non-RCU mode;
    the former is indicated by passing it a NULL dentry.
    * when called that way it isn't allowed to block
    and should return ERR_PTR(-ECHILD) if it needs to be called
    in non-RCU mode.

    It's a flagday change - the old method is gone, all in-tree instances
    converted. Conversion isn't hard; said that, so far very few instances
    do not immediately bail out when called in RCU mode. That'll change
    in the next commits.

    Signed-off-by: Al Viro

    Al Viro
     

24 Jun, 2015

1 commit


11 May, 2015

2 commits

  • its only use is getting passed to nd_jump_link(), which can obtain
    it from current->nameidata

    Signed-off-by: Al Viro

    Al Viro
     
  • a) instead of storing the symlink body (via nd_set_link()) and returning
    an opaque pointer later passed to ->put_link(), ->follow_link() _stores_
    that opaque pointer (into void * passed by address by caller) and returns
    the symlink body. Returning ERR_PTR() on error, NULL on jump (procfs magic
    symlinks) and pointer to symlink body for normal symlinks. Stored pointer
    is ignored in all cases except the last one.

    Storing NULL for opaque pointer (or not storing it at all) means no call
    of ->put_link().

    b) the body used to be passed to ->put_link() implicitly (via nameidata).
    Now only the opaque pointer is. In the cases when we used the symlink body
    to free stuff, ->follow_link() now should store it as opaque pointer in addition
    to returning it.

    Signed-off-by: Al Viro

    Al Viro
     

16 Apr, 2015

1 commit


12 Apr, 2015

1 commit


23 Feb, 2015

2 commits

  • X-Coverup: just ask spender
    Cc: stable@vger.kernel.org
    Signed-off-by: Al Viro

    Al Viro
     
  • Convert the following where appropriate:

    (1) S_ISLNK(dentry->d_inode) to d_is_symlink(dentry).

    (2) S_ISREG(dentry->d_inode) to d_is_reg(dentry).

    (3) S_ISDIR(dentry->d_inode) to d_is_dir(dentry). This is actually more
    complicated than it appears as some calls should be converted to
    d_can_lookup() instead. The difference is whether the directory in
    question is a real dir with a ->lookup op or whether it's a fake dir with
    a ->d_automount op.

    In some circumstances, we can subsume checks for dentry->d_inode not being
    NULL into this, provided we the code isn't in a filesystem that expects
    d_inode to be NULL if the dirent really *is* negative (ie. if we're going to
    use d_inode() rather than d_backing_inode() to get the inode pointer).

    Note that the dentry type field may be set to something other than
    DCACHE_MISS_TYPE when d_inode is NULL in the case of unionmount, where the VFS
    manages the fall-through from a negative dentry to a lower layer. In such a
    case, the dentry type of the negative union dentry is set to the same as the
    type of the lower dentry.

    However, if you know d_inode is not NULL at the call site, then you can use
    the d_is_xxx() functions even in a filesystem.

    There is one further complication: a 0,0 chardev dentry may be labelled
    DCACHE_WHITEOUT_TYPE rather than DCACHE_SPECIAL_TYPE. Strictly, this was
    intended for special directory entry types that don't have attached inodes.

    The following perl+coccinelle script was used:

    use strict;

    my @callers;
    open($fd, 'git grep -l \'S_IS[A-Z].*->d_inode\' |') ||
    die "Can't grep for S_ISDIR and co. callers";
    @callers = ;
    close($fd);
    unless (@callers) {
    print "No matches\n";
    exit(0);
    }

    my @cocci = (
    '@@',
    'expression E;',
    '@@',
    '',
    '- S_ISLNK(E->d_inode->i_mode)',
    '+ d_is_symlink(E)',
    '',
    '@@',
    'expression E;',
    '@@',
    '',
    '- S_ISDIR(E->d_inode->i_mode)',
    '+ d_is_dir(E)',
    '',
    '@@',
    'expression E;',
    '@@',
    '',
    '- S_ISREG(E->d_inode->i_mode)',
    '+ d_is_reg(E)' );

    my $coccifile = "tmp.sp.cocci";
    open($fd, ">$coccifile") || die $coccifile;
    print($fd "$_\n") || die $coccifile foreach (@cocci);
    close($fd);

    foreach my $file (@callers) {
    chomp $file;
    print "Processing ", $file, "\n";
    system("spatch", "--sp-file", $coccifile, $file, "--in-place", "--no-show-diff") == 0 ||
    die "spatch failed";
    }

    [AV: overlayfs parts skipped]

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

    David Howells
     

20 Feb, 2015

1 commit


20 Nov, 2014

1 commit


04 Nov, 2014

1 commit


14 Oct, 2014

5 commits

  • If rcu-walk mode we don't *have* to return -EISDIR for non-mount-traps
    as we will simply drop into REF-walk and handling DCACHE_NEED_AUTOMOUNT
    dentrys the slow way. But it is better if we do when possible.

    In 'oz_mode', use the same condition as ref-walk: if not a mountpoint,
    then it must be -EISDIR.

    In regular mode there are most tests needed. Most of them can be
    performed without taking any spinlocks. If we find a directory that
    isn't obviously empty, and isn't mounted on, we need to call
    'simple_empty()' which does take a spinlock. If this turned out to hurt
    performance, some other approach could be found to signal when a
    directory is known to be empty.

    Signed-off-by: NeilBrown
    Reviewed-by: Ian Kent
    Tested-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    NeilBrown
     
  • ->fs_lock protects AUTOFS_INF_EXPIRING. We need to be sure that once
    the flag is set, no new references beneath the dentry are taken. So
    rcu-walk currently needs to take fs_lock before checking the flag. This
    hurts performance.

    Change the expiry to a two-stage process. First set AUTOFS_INF_NO_RCU
    which forces any path walk into ref-walk mode, then drop the lock and
    call synchronize_rcu(). Once that returns we can be sure no rcu-walk is
    active beneath the dentry and we can check reference counts again.

    Now during an RCU-walk we can test AUTOFS_INF_EXPIRING without taking
    the lock as along as we test AUTOFS_INF_NO_RCU too. If either are set,
    we must abort the RCU-walk If neither are set, we know that refcounts
    will be tested again after we finish the RCU-walk so we are safe to
    continue.

    ->fs_lock is still taken in d_manage() to check for a non-trap
    directory. That will be resolved in the next patch.

    Signed-off-by: NeilBrown
    Reviewed-by: Ian Kent
    Tested-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    NeilBrown
     
  • Have a "test" function change the value it is testing can be confusing,
    particularly as a future patch will be calling this function twice.

    So move the update for 'last_used' to avoid repeat expiry to the place
    where the final determination on what to expire is known.

    Signed-off-by: NeilBrown
    Reviewed-by: Ian Kent
    Tested-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    NeilBrown
     
  • Future patch will potentially call this twice, so make it separate.

    Signed-off-by: NeilBrown
    Reviewed-by: Ian Kent
    Tested-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    NeilBrown
     
  • This series teaches autofs about RCU-walk so that we don't drop straight
    into REF-walk when we hit an autofs directory, and so that we avoid
    spinlocks as much as possible when performing an RCU-walk.

    This is needed so that the benefits of the recent NFS support for
    RCU-walk are fully available when NFS filesystems are automounted.

    Patches have been carefully reviewed and tested both with test suites
    and in production - thanks a lot to Ian Kent for his support there.

    This patch (of 6):

    Any attempt to look up a pathname that passes though an autofs4 mount is
    currently forced out of RCU-walk into REF-walk.

    This can significantly hurt performance of many-thread work loads on
    many-core systems, especially if the automounted filesystem supports
    RCU-walk but doesn't get to benefit from it.

    So if autofs4_d_manage is called with rcu_walk set, only fail with -ECHILD
    if it is necessary to wait longer than a spinlock.

    Signed-off-by: NeilBrown
    Reviewed-by: Ian Kent
    Tested-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    NeilBrown
     

09 Oct, 2014

1 commit

  • Biederman's umount-on-rmdir series changes d_invalidate() to sumarily remove
    mounts under the passed in dentry regardless of whether they are busy
    or not. So calling this in fs/autofs4/expire.c:autofs4_tree_busy() is
    definitely the wrong thing to do becuase it will silently umount entries
    instead of just cleaning stale dentrys.

    But this call shouldn't be needed and testing shows that automounting
    continues to function without it.

    As Al Viro correctly surmises the original intent of the call was to
    perform what shrink_dcache_parent() does.

    If at some time in the future I see stale dentries accumulating
    following failed mounts I'll revisit the issue and possibly add a
    shrink_dcache_parent() call if needed.

    Signed-off-by: Ian Kent
    Cc: Al Viro
    Cc: Eric W. Biederman
    Signed-off-by: Al Viro

    Ian Kent
     

09 Aug, 2014

5 commits


04 Jul, 2014

1 commit

  • On strict build environments we can see:

    fs/autofs4/inode.c: In function 'autofs4_fill_super':
    fs/autofs4/inode.c:312: error: 'pgrp' may be used uninitialized in this function
    make[2]: *** [fs/autofs4/inode.o] Error 1
    make[1]: *** [fs/autofs4] Error 2
    make: *** [fs] Error 2
    make: *** Waiting for unfinished jobs....

    This is due to the use of pgrp_set being used to indicate pgrp has has
    been set rather than initializing pgrp itself.

    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     

05 Jun, 2014

1 commit


07 May, 2014

1 commit

  • autofs needs to be able to see private data dentry flags for its dentrys
    that are being created but not yet hashed and for its dentrys that have
    been rmdir()ed but not yet freed. It needs to do this so it can block
    processes in these states until a status has been returned to indicate
    the given operation is complete.

    It does this by keeping two lists, active and expring, of dentrys in
    this state and uses ->d_release() to keep them stable while it checks
    the reference count to determine if they should be used.

    But with the recent lockref changes dentrys being freed sometimes don't
    transition to a reference count of 0 before being freed so autofs can
    occassionally use a dentry that is invalid which can lead to a panic.

    Signed-off-by: Ian Kent
    Cc: Al Viro
    Cc: Linus Torvalds
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     

09 Apr, 2014

1 commit

  • There wasn't any check of the size passed from userspace before trying
    to allocate the memory required.

    This meant that userspace might request more space than allowed,
    triggering an OOM.

    Signed-off-by: Sasha Levin
    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sasha Levin
     

24 Jan, 2014

2 commits

  • The autofs4 module doesn't consider symlinks for expire as it did in the
    older autofs v3 module (so it's actually a long standing regression).

    The user space daemon has focused on the use of bind mounts instead of
    symlinks for a long time now and that's why this has not been noticed.
    But with the future addition of amd map parsing to automount(8), not to
    mention amd itself (of am-utils), symlink expiry will be needed.

    The direct and offset mount types can't be symlinks and the tree mounts of
    version 4 were always real mounts so only indirect mounts need expire
    symlinks.

    Since the current users of the autofs4 module haven't reported this as a
    problem to date this patch probably isn't a candidate for backport to
    stable.

    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • Use the helper macro !IS_ROOT to replace parent != dentry->d_parent. Just
    clean up.

    Signed-off-by: Rui Xiang
    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rui Xiang