1. 02 May, 2016 25 commits
    • Al Viro's avatar
      cifs: switch to ->iterate_shared() · 3125d265
      Al Viro authored
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      3125d265
    • Al Viro's avatar
      fuse: switch to ->iterate_shared() · d9b3dbdc
      Al Viro authored
      Switch dcache pre-seeding on readdir to d_alloc_parallel();
      nothing else is needed.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      d9b3dbdc
    • Al Viro's avatar
      f50752ea
    • Al Viro's avatar
      proc_sys_fill_cache(): switch to d_alloc_parallel() · 76aab3ab
      Al Viro authored
      make it usable with directory locked shared
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      76aab3ab
    • Al Viro's avatar
      proc_fill_cache(): switch to d_alloc_parallel() · 3781764b
      Al Viro authored
      ... making it usable with directory locked shared
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      3781764b
    • Al Viro's avatar
      introduce a parallel variant of ->iterate() · 61922694
      Al Viro authored
      New method: ->iterate_shared().  Same arguments as in ->iterate(),
      called with the directory locked only shared.  Once all filesystems
      switch, the old one will be gone.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      61922694
    • Al Viro's avatar
      give readdir(2)/getdents(2)/etc. uniform exclusion with lseek() · 63b6df14
      Al Viro authored
      same as read() on regular files has, and for the same reason.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      63b6df14
    • Al Viro's avatar
      parallel lookups: actual switch to rwsem · 9902af79
      Al Viro authored
      ta-da!
      
      The main issue is the lack of down_write_killable(), so the places
      like readdir.c switched to plain inode_lock(); once killable
      variants of rwsem primitives appear, that'll be dealt with.
      
      lockdep side also might need more work
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      9902af79
    • Al Viro's avatar
      parallel lookups machinery, part 4 (and last) · d9171b93
      Al Viro authored
      If we *do* run into an in-lookup match, we need to wait for it to
      cease being in-lookup.  Fortunately, we do have unused space in
      in-lookup dentries - d_lru is never looked at until it stops being
      in-lookup.
      
      So we can stash a pointer to wait_queue_head from stack frame of
      the caller of ->lookup().  Some precautions are needed while
      waiting, but it's not that hard - we do hold a reference to dentry
      we are waiting for, so it can't go away.  If it's found to be
      in-lookup the wait_queue_head is still alive and will remain so
      at least while ->d_lock is held.  Moreover, the condition we
      are waiting for becomes true at the same point where everything
      on that wq gets woken up, so we can just add ourselves to the
      queue once.
      
      d_alloc_parallel() gets a pointer to wait_queue_head_t from its
      caller; lookup_slow() adjusted, d_add_ci() taught to use
      d_alloc_parallel() if the dentry passed to it happens to be
      in-lookup one (i.e. if it's been called from the parallel lookup).
      
      That's pretty much it - all that remains is to switch ->i_mutex
      to rwsem and have lookup_slow() take it shared.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      d9171b93
    • Al Viro's avatar
      parallel lookups machinery, part 3 · 94bdd655
      Al Viro authored
      We will need to be able to check if there is an in-lookup
      dentry with matching parent/name.  Right now it's impossible,
      but as soon as start locking directories shared such beasts
      will appear.
      
      Add a secondary hash for locating those.  Hash chains go through
      the same space where d_alias will be once it's not in-lookup anymore.
      Search is done under the same bitlock we use for modifications -
      with the primary hash we can rely on d_rehash() into the wrong
      chain being the worst that could happen, but here the pointers are
      buggered once it's removed from the chain.  On the other hand,
      the chains are not going to be long and normally we'll end up
      adding to the chain anyway.  That allows us to avoid bothering with
      ->d_lock when doing the comparisons - everything is stable until
      removed from chain.
      
      New helper: d_alloc_parallel().  Right now it allocates, verifies
      that no hashed and in-lookup matches exist and adds to in-lookup
      hash.
      
      Returns ERR_PTR() for error, hashed match (in the unlikely case it's
      been found) or new dentry.  In-lookup matches trigger BUG() for
      now; that will change in the next commit when we introduce waiting
      for ongoing lookup to finish.  Note that in-lookup matches won't be
      possible until we actually go for shared locking.
      
      lookup_slow() switched to use of d_alloc_parallel().
      
      Again, these commits are separated only for making it easier to
      review.  All this machinery will start doing something useful only
      when we go for shared locking; it's just that the combination is
      too large for my taste.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      94bdd655
    • Al Viro's avatar
      parallel lookups machinery, part 2 · 84e710da
      Al Viro authored
      We'll need to verify that there's neither a hashed nor in-lookup
      dentry with desired parent/name before adding to in-lookup set.
      
      One possible solution would be to hold the parent's ->d_lock through
      both checks, but while the in-lookup set is relatively small at any
      time, dcache is not.  And holding the parent's ->d_lock through
      something like __d_lookup_rcu() would suck too badly.
      
      So we leave the parent's ->d_lock alone, which means that we watch
      out for the following scenario:
      	* we verify that there's no hashed match
      	* existing in-lookup match gets hashed by another process
      	* we verify that there's no in-lookup matches and decide
      that everything's fine.
      
      Solution: per-directory kinda-sorta seqlock, bumped around the times
      we hash something that used to be in-lookup or move (and hash)
      something in place of in-lookup.  Then the above would turn into
      	* read the counter
      	* do dcache lookup
      	* if no matches found, check for in-lookup matches
      	* if there had been none of those either, check if the
      counter has changed; repeat if it has.
      
      The "kinda-sorta" part is due to the fact that we don't have much spare
      space in inode.  There is a spare word (shared with i_bdev/i_cdev/i_pipe),
      so the counter part is not a problem, but spinlock is a different story.
      
      We could use the parent's ->d_lock, and it would be less painful in
      terms of contention, for __d_add() it would be rather inconvenient to
      grab; we could do that (using lock_parent()), but...
      
      Fortunately, we can get serialization on the counter itself, and it
      might be a good idea in general; we can use cmpxchg() in a loop to
      get from even to odd and smp_store_release() from odd to even.
      
      This commit adds the counter and updating logics; the readers will be
      added in the next commit.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      84e710da
    • Al Viro's avatar
      beginning of transition to parallel lookups - marking in-lookup dentries · 85c7f810
      Al Viro authored
      marked as such when (would be) parallel lookup is about to pass them
      to actual ->lookup(); unmarked when
      	* __d_add() is about to make it hashed, positive or not.
      	* __d_move() (from d_splice_alias(), directly or via
      __d_unalias()) puts a preexisting dentry in its place
      	* in caller of ->lookup() if it has escaped all of the
      above.  Bug (WARN_ON, actually) if it reaches the final dput()
      or d_instantiate() while still marked such.
      
      As the result, we are guaranteed that for as long as the flag is
      set, dentry will
      	* remain negative unhashed with positive refcount
      	* never have its ->d_alias looked at
      	* never have its ->d_lru looked at
      	* never have its ->d_parent and ->d_name changed
      
      Right now we have at most one such for any given parent directory.
      With parallel lookups that restriction will weaken to
      	* only exist when parent is locked shared
      	* at most one with given (parent,name) pair (comparison of
      names is according to ->d_compare())
      	* only exist when there's no hashed dentry with the same
      (parent,name)
      
      Transition will take the next several commits; unfortunately, we'll
      only be able to switch to rwsem at the end of this series.  The
      reason for not making it a single patch is to simplify review.
      
      New primitives: d_in_lookup() (a predicate checking if dentry is in
      the in-lookup state) and d_lookup_done() (tells the system that
      we are done with lookup and if it's still marked as in-lookup, it
      should cease to be such).
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      85c7f810
    • Al Viro's avatar
      __d_add(): don't drop/regain ->d_lock · 0568d705
      Al Viro authored
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      0568d705
    • Al Viro's avatar
    • Al Viro's avatar
      nfs: missing wakeup in nfs_unblock_sillyrename() · d2caaa0a
      Al Viro authored
      will be needed as soon as lookups are not serialized by ->i_mutex
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      d2caaa0a
    • Al Viro's avatar
      make ext2_get_page() and friends work without external serialization · be5b82db
      Al Viro authored
      Right now ext2_get_page() (and its analogues in a bunch of other filesystems)
      relies upon the directory being locked - the way it sets and tests Checked and
      Error bits would be racy without that.  Switch to a slightly different scheme,
      _not_ setting Checked in case of failure.  That way the logics becomes
      	if Checked => OK
      	else if Error => fail
      	else if !validate => fail
      	else => OK
      with validation setting Checked or Error on success and failure resp. and
      returning which one had happened.  Equivalent to the current logics, but unlike
      the current logics not sensitive to the order of set_bit, test_bit getting
      reordered by CPU, etc.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      be5b82db
    • Al Viro's avatar
      b9e1d435
    • Al Viro's avatar
      reconnect_one(): use lookup_one_len_unlocked() · 383d4e8a
      Al Viro authored
      ... and explain the non-obvious logics in case when lookup yields
      a different dentry.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      383d4e8a
    • Al Viro's avatar
      reiserfs: open-code reiserfs_mutex_lock_safe() in reiserfs_unpack() · 1ae1f3f6
      Al Viro authored
      ... and have it use inode_lock()
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      1ae1f3f6
    • Al Viro's avatar
      5ecfcb26
    • Al Viro's avatar
      ocfs2: don't open-code inode_lock/inode_unlock · 7b9743eb
      Al Viro authored
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      7b9743eb
    • Al Viro's avatar
      configfs_detach_prep(): make sure that wait_mutex won't go away · 48f35b7b
      Al Viro authored
      grab a reference to dentry we'd got the sucker from, and return
      that dentry via *wait, rather than just returning the address of
      ->i_mutex.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      48f35b7b
    • Al Viro's avatar
      kernfs: use lookup_one_len_unlocked() · 779b8391
      Al Viro authored
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      779b8391
    • Al Viro's avatar
    • Al Viro's avatar
      Merge getxattr prototype change into work.lookups · 84695ffe
      Al Viro authored
      The rest of work.xattr stuff isn't needed for this branch
      84695ffe
  2. 11 Apr, 2016 6 commits
  3. 10 Apr, 2016 4 commits
    • Linus Torvalds's avatar
      Revert "ext4: allow readdir()'s of large empty directories to be interrupted" · 9f2394c9
      Linus Torvalds authored
      This reverts commit 1028b55b.
      
      It's broken: it makes ext4 return an error at an invalid point, causing
      the readdir wrappers to write the the position of the last successful
      directory entry into the position field, which means that the next
      readdir will now return that last successful entry _again_.
      
      You can only return fatal errors (that terminate the readdir directory
      walk) from within the filesystem readdir functions, the "normal" errors
      (that happen when the readdir buffer fills up, for example) happen in
      the iterorator where we know the position of the actual failing entry.
      
      I do have a very different patch that does the "signal_pending()"
      handling inside the iterator function where it is allowable, but while
      that one passes all the sanity checks, I screwed up something like four
      times while emailing it out, so I'm not going to commit it today.
      
      So my track record is not good enough, and the stars will have to align
      better before that one gets committed.  And it would be good to get some
      review too, of course, since celestial alignments are always an iffy
      debugging model.
      
      IOW, let's just revert the commit that caused the problem for now.
      Reported-by: default avatarGreg Thelen <gthelen@google.com>
      Cc: Theodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9f2394c9
    • Al Viro's avatar
      reiserfs: switch to generic_{get,set,remove}xattr() · 79a628d1
      Al Viro authored
      reiserfs_xattr_[sg]et() will fail with -EOPNOTSUPP for V1 inodes anyway,
      and all reiserfs instances of ->[sg]et() call it and so does ->set_acl().
      
      Checks for name length in the instances had been bogus; they should've
      been "bugger off if it's _exactly_ the prefix" (as generic would
      do on its own) and not "bugger off if it's shorter than the prefix" -
      that can't happen.
      
      xattr_full_name() is needed to adjust for the fact that generic instances
      will skip the prefix in the name passed to ->[gs]et(); reiserfs homegrown
      analogues didn't.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      79a628d1
    • Al Viro's avatar
      cifs: kill more bogus checks in ->...xattr() methods · 5fdccfef
      Al Viro authored
      none of that stuff can ever be called for NULL or negative
      dentry.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      5fdccfef
    • Al Viro's avatar
      don't bother with ->d_inode->i_sb - it's always equal to ->d_sb · fc64005c
      Al Viro authored
      ... and neither can ever be NULL
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      fc64005c
  4. 09 Apr, 2016 5 commits
    • Linus Torvalds's avatar
      Merge branch 'parisc-4.6-3' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux · 5b5b7fd1
      Linus Torvalds authored
      Pull parisc fixes from Helge Deller:
       "Since commit 0de79858 ("parisc: Use generic extable search and
        sort routines") module loading is boken on parisc, because the parisc
        module loader wasn't prepared for the new R_PARISC_PCREL32 relocations.
      
        In addition, due to that breakage, Mikulas Patocka noticed that
        handling exceptions from modules probably never worked on parisc.  It
        was just masked by the fact that exceptions from modules don't happen
        during normal use.
      
        This patch series fixes those issues and survives the tests of the
        lib/test_user_copy kernel module test.  Some patches are tagged for
        stable"
      
      * 'parisc-4.6-3' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux:
        parisc: Update comment regarding relative extable support
        parisc: Unbreak handling exceptions from kernel modules
        parisc: Fix kernel crash with reversed copy_from_user()
        parisc: Avoid function pointers for kernel exception routines
        parisc: Handle R_PARISC_PCREL32 relocations in kernel modules
      5b5b7fd1
    • Linus Torvalds's avatar
      Merge branch 'libnvdimm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm · 239467e8
      Linus Torvalds authored
      Pull libnvdimm fixes from Dan Williams:
       "Three fixes, the first two are tagged for -stable:
      
         - The ndctl utility/library gained expanded unit tests illuminating a
           long standing bug in the libnvdimm SMART data retrieval
           implementation.
      
           It has been broken since its initial implementation, now fixed.
      
         - Another one line fix for the detection of stale info blocks.
      
           Without this change userspace can get into a situation where it is
           unable to reconfigure a namespace.
      
         - Fix the badblock initialization path in the presence of the new (in
           v4.6-rc1) section alignment workarounds.
      
           Without this change badblocks will be reported at the wrong offset.
      
        These have received a build success report from the kbuild robot and
        have appeared in -next with no reported issues"
      
      * 'libnvdimm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
        libnvdimm, pfn: fix nvdimm_namespace_add_poison() vs section alignment
        libnvdimm, pfn: fix uuid validation
        libnvdimm: fix smart data retrieval
      239467e8
    • Linus Torvalds's avatar
      Merge tag 'gpio-v4.6-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio · 289b7bfd
      Linus Torvalds authored
      Pull GPIO fixes from Linus Walleij:
       "Here is a set of four GPIO fixes.  The two fixes to the core are
        serious as they are regressing minor architectures.
      
        Core fixes:
      
         - Defer GPIO device setup until after gpiolib is initialized.
      
           It turns out that a few very tightly integrated GPIO platform
           drivers initialize so early (befor core_initcall()) so that the
           gpiolib isn't even initialized itself.  That limits what the
           library can do, and we cannot reference uninitialized fields until
           later.
      
           Defer some of the initialization until right after the gpiolib is
           initialized in these (rare) cases.
      
         - As a consequence: do not use devm_* resources when allocating the
           states in the initial set-up of the gpiochip.
      
        Driver fixes:
      
         - In ACPI retrieveal: ignore GpioInt when looking for output GPIOs.
      
         - Fix legacy builds on the PXA without a backing pin controller.
      
         - Use correct datatype on pca953x register writes"
      
      * tag 'gpio-v4.6-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio:
        gpio: pca953x: Use correct u16 value for register word write
        gpiolib: Defer gpio device setup until after gpiolib initialization
        gpiolib: Do not use devm functions when registering gpio chip
        gpio: pxa: fix legacy non pinctrl aware builds
        gpio / ACPI: ignore GpioInt() GPIOs when requesting GPIO_OUT_*
      289b7bfd
    • Linus Torvalds's avatar
      Merge tag 'tty-4.6-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty · 183c948a
      Linus Torvalds authored
      Pull tty fixes from Greg KH:
       "Here are two tty fixes for issues found.
      
        One was due to a merge error in 4.6-rc1, and the other a regression
        fix for UML consoles that broke in 4.6-rc1.
      
        Both have been in linux-next for a while"
      
      * tag 'tty-4.6-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
        tty: Fix merge of "tty: Refactor tty_open()"
        tty: Fix UML console breakage
      183c948a
    • Linus Torvalds's avatar
      Merge tag 'usb-4.6-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb · ffb927d1
      Linus Torvalds authored
      Pull USB fixes from Greg KH:
       "Here are some USB fixes and new device ids for 4.6-rc3.
      
        Nothing major, the normal USB gadget fixes and usb-serial driver ids,
        along with some other fixes mixed in.  All except the USB serial ids
        have been tested in linux-next, the id additions should be fine as
        they are 'trivial'"
      
      * tag 'usb-4.6-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (25 commits)
        USB: option: add "D-Link DWM-221 B1" device id
        USB: serial: cp210x: Adding GE Healthcare Device ID
        USB: serial: ftdi_sio: Add support for ICP DAS I-756xU devices
        usb: dwc3: keystone: drop dma_mask configuration
        usb: gadget: udc-core: remove manual dma configuration
        usb: dwc3: pci: add ID for one more Intel Broxton platform
        usb: renesas_usbhs: fix to avoid using a disabled ep in usbhsg_queue_done()
        usb: dwc2: do not override forced dr_mode in gadget setup
        usb: gadget: f_midi: unlock on error
        USB: digi_acceleport: do sanity checking for the number of ports
        USB: cypress_m8: add endpoint sanity check
        USB: mct_u232: add sanity checking in probe
        usb: fix regression in SuperSpeed endpoint descriptor parsing
        USB: usbip: fix potential out-of-bounds write
        usb: renesas_usbhs: disable TX IRQ before starting TX DMAC transfer
        usb: renesas_usbhs: avoid NULL pointer derefernce in usbhsf_pkt_handler()
        usb: gadget: f_midi: Fixed a bug when buflen was smaller than wMaxPacketSize
        usb: phy: qcom-8x16: fix regulator API abuse
        usb: ch9: Fix SSP Device Cap wFunctionalitySupport type
        usb: gadget: composite: Access SSP Dev Cap fields properly
        ...
      ffb927d1