1. 04 1月, 2012 11 次提交
  2. 27 7月, 2011 1 次提交
  3. 17 1月, 2011 1 次提交
    • A
      sanitize vfsmount refcounting changes · f03c6599
      Al Viro 提交于
      Instead of splitting refcount between (per-cpu) mnt_count
      and (SMP-only) mnt_longrefs, make all references contribute
      to mnt_count again and keep track of how many are longterm
      ones.
      
      Accounting rules for longterm count:
      	* 1 for each fs_struct.root.mnt
      	* 1 for each fs_struct.pwd.mnt
      	* 1 for having non-NULL ->mnt_ns
      	* decrement to 0 happens only under vfsmount lock exclusive
      
      That allows nice common case for mntput() - since we can't drop the
      final reference until after mnt_longterm has reached 0 due to the rules
      above, mntput() can grab vfsmount lock shared and check mnt_longterm.
      If it turns out to be non-zero (which is the common case), we know
      that this is not the final mntput() and can just blindly decrement
      percpu mnt_count.  Otherwise we grab vfsmount lock exclusive and
      do usual decrement-and-check of percpu mnt_count.
      
      For fs_struct.c we have mnt_make_longterm() and mnt_make_shortterm();
      namespace.c uses the latter in places where we don't already hold
      vfsmount lock exclusive and opencodes a few remaining spots where
      we need to manipulate mnt_longterm.
      
      Note that we mostly revert the code outside of fs/namespace.c back
      to what we used to have; in particular, normal code doesn't need
      to care about two kinds of references, etc.  And we get to keep
      the optimization Nick's variant had bought us...
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      f03c6599
  4. 16 1月, 2011 1 次提交
    • D
      Unexport do_add_mount() and add in follow_automount(), not ->d_automount() · ea5b778a
      David Howells 提交于
      Unexport do_add_mount() and make ->d_automount() return the vfsmount to be
      added rather than calling do_add_mount() itself.  follow_automount() will then
      do the addition.
      
      This slightly complicates things as ->d_automount() normally wants to add the
      new vfsmount to an expiration list and start an expiration timer.  The problem
      with that is that the vfsmount will be deleted if it has a refcount of 1 and
      the timer will not repeat if the expiration list is empty.
      
      To this end, we require the vfsmount to be returned from d_automount() with a
      refcount of (at least) 2.  One of these refs will be dropped unconditionally.
      In addition, follow_automount() must get a 3rd ref around the call to
      do_add_mount() lest it eat a ref and return an error, leaving the mount we
      have open to being expired as we would otherwise have only 1 ref on it.
      
      d_automount() should also add the the vfsmount to the expiration list (by
      calling mnt_set_expiry()) and start the expiration timer before returning, if
      this mechanism is to be used.  The vfsmount will be unlinked from the
      expiration list by follow_automount() if do_add_mount() fails.
      
      This patch also fixes the call to do_add_mount() for AFS to propagate the mount
      flags from the parent vfsmount.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      ea5b778a
  5. 07 1月, 2011 1 次提交
    • N
      fs: scale mntget/mntput · b3e19d92
      Nick Piggin 提交于
      The problem that this patch aims to fix is vfsmount refcounting scalability.
      We need to take a reference on the vfsmount for every successful path lookup,
      which often go to the same mount point.
      
      The fundamental difficulty is that a "simple" reference count can never be made
      scalable, because any time a reference is dropped, we must check whether that
      was the last reference. To do that requires communication with all other CPUs
      that may have taken a reference count.
      
      We can make refcounts more scalable in a couple of ways, involving keeping
      distributed counters, and checking for the global-zero condition less
      frequently.
      
      - check the global sum once every interval (this will delay zero detection
        for some interval, so it's probably a showstopper for vfsmounts).
      
      - keep a local count and only taking the global sum when local reaches 0 (this
        is difficult for vfsmounts, because we can't hold preempt off for the life of
        a reference, so a counter would need to be per-thread or tied strongly to a
        particular CPU which requires more locking).
      
      - keep a local difference of increments and decrements, which allows us to sum
        the total difference and hence find the refcount when summing all CPUs. Then,
        keep a single integer "long" refcount for slow and long lasting references,
        and only take the global sum of local counters when the long refcount is 0.
      
      This last scheme is what I implemented here. Attached mounts and process root
      and working directory references are "long" references, and everything else is
      a short reference.
      
      This allows scalable vfsmount references during path walking over mounted
      subtrees and unattached (lazy umounted) mounts with processes still running
      in them.
      
      This results in one fewer atomic op in the fastpath: mntget is now just a
      per-CPU inc, rather than an atomic inc; and mntput just requires a spinlock
      and non-atomic decrement in the common case. However code is otherwise bigger
      and heavier, so single threaded performance is basically a wash.
      Signed-off-by: NNick Piggin <npiggin@kernel.dk>
      b3e19d92
  6. 11 8月, 2010 1 次提交
  7. 28 7月, 2010 1 次提交
  8. 04 3月, 2010 3 次提交
  9. 17 2月, 2010 1 次提交
    • T
      percpu: add __percpu sparse annotations to fs · 003cb608
      Tejun Heo 提交于
      Add __percpu sparse annotations to fs.
      
      These annotations are to make sparse consider percpu variables to be
      in a different address space and warn if accessed without going
      through percpu accessors.  This patch doesn't affect normal builds.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
      Cc: Alex Elder <aelder@sgi.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      003cb608
  10. 12 6月, 2009 2 次提交
    • N
      fs: introduce mnt_clone_write · 96029c4e
      npiggin@suse.de 提交于
      This patch speeds up lmbench lat_mmap test by about another 2% after the
      first patch.
      
      Before:
       avg = 462.286
       std = 5.46106
      
      After:
       avg = 453.12
       std = 9.58257
      
      (50 runs of each, stddev gives a reasonable confidence)
      
      It does this by introducing mnt_clone_write, which avoids some heavyweight
      operations of mnt_want_write if called on a vfsmount which we know already
      has a write count; and mnt_want_write_file, which can call mnt_clone_write
      if the file is open for write.
      
      After these two patches, mnt_want_write and mnt_drop_write go from 7% on
      the profile down to 1.3% (including mnt_clone_write).
      
      [AV: mnt_want_write_file() should take file alone and derive mnt from it;
      not only all callers have that form, but that's the only mnt about which
      we know that it's already held for write if file is opened for write]
      
      Cc: Dave Hansen <haveblue@us.ibm.com>
      Signed-off-by: NNick Piggin <npiggin@suse.de>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      96029c4e
    • N
      fs: mnt_want_write speedup · d3ef3d73
      npiggin@suse.de 提交于
      This patch speeds up lmbench lat_mmap test by about 8%. lat_mmap is set up
      basically to mmap a 64MB file on tmpfs, fault in its pages, then unmap it.
      A microbenchmark yes, but it exercises some important paths in the mm.
      
      Before:
       avg = 501.9
       std = 14.7773
      
      After:
       avg = 462.286
       std = 5.46106
      
      (50 runs of each, stddev gives a reasonable confidence, but there is quite
      a bit of variation there still)
      
      It does this by removing the complex per-cpu locking and counter-cache and
      replaces it with a percpu counter in struct vfsmount. This makes the code
      much simpler, and avoids spinlocks (although the msync is still pretty
      costly, unfortunately). It results in about 900 bytes smaller code too. It
      does increase the size of a vfsmount, however.
      
      It should also give a speedup on large systems if CPUs are frequently operating
      on different mounts (because the existing scheme has to operate on an atomic in
      the struct vfsmount when switching between mounts). But I'm most interested in
      the single threaded path performance for the moment.
      
      [AV: minor cleanup]
      
      Cc: Dave Hansen <haveblue@us.ibm.com>
      Signed-off-by: NNick Piggin <npiggin@suse.de>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      d3ef3d73
  11. 27 3月, 2009 1 次提交
  12. 17 10月, 2008 1 次提交
  13. 01 8月, 2008 1 次提交
  14. 27 7月, 2008 1 次提交
  15. 30 4月, 2008 1 次提交
  16. 23 4月, 2008 2 次提交
    • M
      [patch 4/7] vfs: mountinfo: add mount peer group ID · 719f5d7f
      Miklos Szeredi 提交于
      Add a unique ID to each peer group using the IDR infrastructure.  The
      identifiers are reused after the peer group dissolves.
      
      The IDR structures are protected by holding namepspace_sem for write
      while allocating or deallocating IDs.
      
      IDs are allocated when a previously unshared vfsmount becomes the
      first member of a peer group.  When a new member is added to an
      existing group, the ID is copied from one of the old members.
      
      IDs are freed when the last member of a peer group is unshared.
      
      Setting the MNT_SHARED flag on members of a subtree is done as a
      separate step, after all the IDs have been allocated.  This way an
      allocation failure can be cleaned up easilty, without affecting the
      propagation state.
      
      Based on design sketch by Al Viro.
      Signed-off-by: NMiklos Szeredi <mszeredi@suse.cz>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      719f5d7f
    • M
      [patch 3/7] vfs: mountinfo: add mount ID · 73cd49ec
      Miklos Szeredi 提交于
      Add a unique ID to each vfsmount using the IDR infrastructure.  The
      identifiers are reused after the vfsmount is freed.
      Signed-off-by: NMiklos Szeredi <mszeredi@suse.cz>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      73cd49ec
  17. 22 4月, 2008 1 次提交
  18. 19 4月, 2008 3 次提交
    • D
      [PATCH] r/o bind mounts: honor mount writer counts at remount · 2e4b7fcd
      Dave Hansen 提交于
      Originally from: Herbert Poetzl <herbert@13thfloor.at>
      
      This is the core of the read-only bind mount patch set.
      
      Note that this does _not_ add a "ro" option directly to the bind mount
      operation.  If you require such a mount, you must first do the bind, then
      follow it up with a 'mount -o remount,ro' operation:
      
      If you wish to have a r/o bind mount of /foo on bar:
      
      	mount --bind /foo /bar
      	mount -o remount,ro /bar
      Acked-by: NAl Viro <viro@ZenIV.linux.org.uk>
      Signed-off-by: NChristoph Hellwig <hch@infradead.org>
      Signed-off-by: NDave Hansen <haveblue@us.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      2e4b7fcd
    • D
      [PATCH] r/o bind mounts: track numbers of writers to mounts · 3d733633
      Dave Hansen 提交于
      This is the real meat of the entire series.  It actually
      implements the tracking of the number of writers to a mount.
      However, it causes scalability problems because there can be
      hundreds of cpus doing open()/close() on files on the same mnt at
      the same time.  Even an atomic_t in the mnt has massive scalaing
      problems because the cacheline gets so terribly contended.
      
      This uses a statically-allocated percpu variable.  All want/drop
      operations are local to a cpu as long that cpu operates on the same
      mount, and there are no writer count imbalances.  Writer count
      imbalances happen when a write is taken on one cpu, and released
      on another, like when an open/close pair is performed on two
      
      Upon a remount,ro request, all of the data from the percpu
      variables is collected (expensive, but very rare) and we determine
      if there are any outstanding writers to the mount.
      
      I've written a little benchmark to sit in a loop for a couple of
      seconds in several cpus in parallel doing open/write/close loops.
      
      http://sr71.net/~dave/linux/openbench.c
      
      The code in here is a a worst-possible case for this patch.  It
      does opens on a _pair_ of files in two different mounts in parallel.
      This should cause my code to lose its "operate on the same mount"
      optimization completely.  This worst-case scenario causes a 3%
      degredation in the benchmark.
      
      I could probably get rid of even this 3%, but it would be more
      complex than what I have here, and I think this is getting into
      acceptable territory.  In practice, I expect writing more than 3
      bytes to a file, as well as disk I/O to mask any effects that this
      has.
      
      (To get rid of that 3%, we could have an #defined number of mounts
      in the percpu variable.  So, instead of a CPU getting operate only
      on percpu data when it accesses only one mount, it could stay on
      percpu data when it only accesses N or fewer mounts.)
      
      [AV] merged fix for __clear_mnt_mount() stepping on freed vfsmount
      Acked-by: NAl Viro <viro@ZenIV.linux.org.uk>
      Signed-off-by: NChristoph Hellwig <hch@infradead.org>
      Signed-off-by: NDave Hansen <haveblue@us.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      3d733633
    • D
      [PATCH] r/o bind mounts: stub functions · 8366025e
      Dave Hansen 提交于
      This patch adds two function mnt_want_write() and mnt_drop_write().  These are
      used like a lock pair around and fs operations that might cause a write to the
      filesystem.
      
      Before these can become useful, we must first cover each place in the VFS
      where writes are performed with a want/drop pair.  When that is complete, we
      can actually introduce code that will safely check the counts before allowing
      r/w<->r/o transitions to occur.
      Acked-by: NSerge Hallyn <serue@us.ibm.com>
      Acked-by: NAl Viro <viro@ZenIV.linux.org.uk>
      Signed-off-by: NChristoph Hellwig <hch@infradead.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NDave Hansen <haveblue@us.ibm.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      8366025e
  19. 28 3月, 2008 2 次提交
  20. 09 5月, 2007 1 次提交
  21. 12 2月, 2007 1 次提交
    • E
      [PATCH] struct vfsmount: keep mnt_count & mnt_expiry_mark away from mnt_flags · 4ba4d4c0
      Eric Dumazet 提交于
      I noticed cache misses in touch_atime() that can be avoided if we keep
      mnt_count & mnt_expiry_mark in a different cache line than mnt_flags
      (mostly read)
      
      mnt_count & mnt_expiry_mark are modified each time a file is opened/closed
      in a file system.
      
      touch_atime() is called each time a file is read, and generally needs to
      read mnt_flags.
      
      Other fields of struct vfsmount are mostly read so I chose to move
      mnt_count & mnt_expiry_mark at the end of struct vfsmount.  And adding a
      comment so that nobody tries to re-arrange fields to fill the holes :)
      
      On 64bits platforms, the new offsetof(mnt_count) is 0xC0
      On 32bits platforms, it is 0x60, so I didnot add a
      ____cacheline_aligned_in_smp because it would have a too big impact on the
      size of this object (in particular if CONFIG_X86_L1_CACHE_SHIFT=7)
      Signed-off-by: NEric Dumazet <dada1@cosmosbay.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4ba4d4c0
  22. 14 12月, 2006 1 次提交
  23. 09 12月, 2006 1 次提交