26 Oct, 2010

7 commits

  • d_validate does a purely read lookup in the dentry hash, so use RCU read side
    locking instead of dcache_lock. Split out from a larget patch by
    Nick Piggin .

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Al Viro

    Christoph Hellwig
     
  • Always do a list_del_init on the LRU to make sure the list_empty invariant for
    not beeing on the LRU always holds true, and fold dentry_lru_del_init into
    dentry_lru_del. Replace the dentry_lru_add_tail primitive with a
    dentry_lru_move_tail operations that simpler when the dentry already is one
    the list, which is always is. Move the list_empty into dentry_lru_add to
    fit the scheme of the other lru helpers, and simplify locking once we
    move to a separate LRU lock.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Al Viro

    Christoph Hellwig
     
  • Currently __shrink_dcache_sb has an extremly awkward calling convention
    because it tries to please very different callers. Split out the
    main loop into a shrink_dentry_list helper, which gets called directly
    from shrink_dcache_sb for the cases where all dentries need to be pruned,
    or from __shrink_dcache_sb for pruning only a certain number of dentries.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Al Viro

    Christoph Hellwig
     
  • dentry referenced bit is only set when installing the dentry back
    onto the LRU. However with lazy LRU, the dentry can already be on
    the LRU list at dput time, thus missing out on setting the referenced
    bit. Fix this.

    Signed-off-by: Nick Piggin
    Signed-off-by: Christoph Hellwig
    Signed-off-by: Al Viro

    Nick Piggin
     
  • The nr_dentry stat is a globally touched cacheline and atomic operation
    twice over the lifetime of a dentry. It is used for the benfit of userspace
    only. Turn it into a per-cpu counter and always decrement it in d_free instead
    of doing various batching operations to reduce lock hold times in the callers.

    Based on an earlier patch from Nick Piggin .

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Al Viro

    Christoph Hellwig
     
  • Remove d_callback and always call __d_free with a RCU head.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Al Viro

    Christoph Hellwig
     
  • All callers take dcache_lock just around the call to __d_path, so
    take the lock into it in preparation of getting rid of dcache_lock.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Al Viro

    Christoph Hellwig
     

18 Aug, 2010

2 commits

  • fs: brlock vfsmount_lock

    Use a brlock for the vfsmount lock. It must be taken for write whenever
    modifying the mount hash or associated fields, and may be taken for read when
    performing mount hash lookups.

    A new lock is added for the mnt-id allocator, so it doesn't need to take
    the heavy vfsmount write-lock.

    The number of atomics should remain the same for fastpath rlock cases, though
    code would be slightly slower due to per-cpu access. Scalability is not not be
    much improved in common cases yet, due to other locks (ie. dcache_lock) getting
    in the way. However path lookups crossing mountpoints should be one case where
    scalability is improved (currently requiring the global lock).

    The slowpath is slower due to use of brlock. On a 64 core, 64 socket, 32 node
    Altix system (high latency to remote nodes), a simple umount microbenchmark
    (mount --bind mnt mnt2 ; umount mnt2 loop 1000 times), before this patch it
    took 6.8s, afterwards took 7.1s, about 5% slower.

    Cc: Al Viro
    Signed-off-by: Nick Piggin
    Signed-off-by: Al Viro

    Nick Piggin
     
  • fs: remove extra lookup in __lookup_hash

    Optimize lookup for create operations, where no dentry should often be
    common-case. In cases where it is not, such as unlink, the added overhead
    is much smaller than the removed.

    Also, move comments about __d_lookup racyness to the __d_lookup call site.
    d_lookup is intuitive; __d_lookup is what needs commenting. So in that same
    vein, add kerneldoc comments to __d_lookup and clean up some of the comments:

    - We are interested in how the RCU lookup works here, particularly with
    renames. Make that explicit, and point to the document where it is explained
    in more detail.
    - RCU is pretty standard now, and macros make implementations pretty mindless.
    If we want to know about RCU barrier details, we look in RCU code.
    - Delete some boring legacy comments because we don't care much about how the
    code used to work, more about the interesting parts of how it works now. So
    comments about lazy LRU may be interesting, but would better be done in the
    LRU or refcount management code.

    Signed-off-by: Nick Piggin
    Signed-off-by: Al Viro

    Nick Piggin
     

15 Aug, 2010

1 commit


11 Aug, 2010

5 commits

  • Prepend "(unreachable)" to path strings if the path is not reachable
    from the current root.

    Two places updated are
    - the return string from getcwd()
    - and symlinks under /proc/$PID.

    Other uses of d_path() are left unchanged (we know that some old
    software crashes if /proc/mounts is changed).

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Al Viro

    Miklos Szeredi
     
  • __d_path() has 4 callers:

    d_path()
    sys_getcwd()
    seq_path_root()
    tomoyo_realpath_from_path2()

    Of these the only one which needs the " (deleted)" ending is d_path().

    sys_getcwd() checks for existence before calling __d_path().

    seq_path_root() is used to show the mountpoint path in
    /proc/PID/mountinfo, which is always a positive.

    And tomoyo doesn't want the deleted ending.

    Create a helper "path_with_deleted()" as subsequent patches will need
    this in multiple places.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Al Viro

    Miklos Szeredi
     
  • Split off prepend_path() from __d_path(). This new helper takes an
    end-of-buffer pointer and buffer-length pointer just like the other
    prepend_* functions. Move the " (deleted)" postfix out to __d_path().

    This patch doesn't change any functionality but paves the way for the
    following patches.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Al Viro

    Miklos Szeredi
     
  • In the old times pseudo-filesystems set the name of theroot dentry to
    some prefix like "pipe:" and the name of the child dentry to "[123]"
    and relied on a hack in __d_path() to replace the preceding slash with
    the root's name to get "pipe:[123]".

    Then the d_dname() dentry operation was introduced which solved the
    same problem without having to pre-fill the name in each dentry.

    Currently the following pseudo filesystems exist in the kernel:

    perfmon
    mtd
    anon_inode
    bdev
    pipe
    socket

    Of these only perfmon, anon_inode, pipe and socket create
    sub-dentries, all of which have now been switched to using d_dname().

    bdev and mtd only create inodes.

    This means that now the hack to overwrite the slash can be removed, so
    for unreachable paths (e.g. within a detached mount) the path string
    won't be polluted with garbage. For these cases a subsequent patch
    will add a prefix, indicating that the path is unreachable.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Al Viro

    Miklos Szeredi
     
  • Add three helpers that retrieve a refcounted copy of the root and cwd
    from the supplied fs_struct.

    get_fs_root()
    get_fs_pwd()
    get_fs_root_and_pwd()

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Al Viro

    Miklos Szeredi
     

10 Aug, 2010

2 commits


19 Jul, 2010

1 commit

  • The current shrinker implementation requires the registered callback
    to have global state to work from. This makes it difficult to shrink
    caches that are not global (e.g. per-filesystem caches). Pass the shrinker
    structure to the callback so that users can embed the shrinker structure
    in the context the shrinker needs to operate on and get back to it in the
    callback via container_of().

    Signed-off-by: Dave Chinner
    Reviewed-by: Christoph Hellwig

    Dave Chinner
     

30 Jun, 2010

1 commit

  • list_for_each_entry_safe is not suitable to protect against concurrent
    modification of the list. 6754af6 introduced a race in sb walking.

    list_for_each_entry can use the trick of pinning the current entry in
    the list before we drop and retake the lock because it subsequently
    follows cur->next. However list_for_each_entry_safe saves n=cur->next
    for following before entering the loop body, so when the lock is
    dropped, n may be deleted.

    Signed-off-by: Nick Piggin
    Cc: Christoph Hellwig
    Cc: John Stultz
    Cc: Frank Mayhar
    Cc: Al Viro
    Signed-off-by: Linus Torvalds

    npiggin@suse.de
     

22 May, 2010

3 commits

  • ... and get rid of the last __put_super_and_need_restart() caller

    Signed-off-by: Al Viro

    Al Viro
     
  • We used to remove from s_list and s_instances at the same
    time. So let's *not* do the former and skip superblocks
    that have empty s_instances in the loops over s_list.

    The next step, of course, will be to get rid of rescan logics
    in those loops.

    Signed-off-by: Al Viro

    Al Viro
     
  • We set the "it's dead, don't mount on it" flag _and_ do not remove it if
    we turn the damn thing negative and leave it around. And if it goes
    positive afterwards, well...

    Fortunately, there's only one place where that needs to be caught:
    only d_delete() can turn the sucker negative without immediately freeing
    it; all other places that can lead to ->d_iput() call are followed by
    unconditionally freeing struct dentry in question. So the fix is obvious:

    Addresses https://bugzilla.kernel.org/show_bug.cgi?id=16014
    Reported-by: Adam Tkac
    Tested-by: Adam Tkac
    Cc: [2.6.34.x]

    Signed-off-by: Al Viro

    Al Viro
     

04 Mar, 2010

3 commits


17 Dec, 2009

1 commit

  • The EXPORT_SYMBOL for d_alloc_name is in fs/libfs.c but the function
    is in fs/dcache.c. Move the EXPORT_SYMBOL to the line immediately
    after the closing function brace line in fs/dcache.c as mentioned
    in Documentation/CodingStyle.

    Signed-off-by: H Hartley Sweeten
    Signed-off-by: Al Viro

    H Hartley Sweeten
     

18 Jul, 2009

1 commit

  • might_sleep() is called late-ish in cond_resched(), after the
    need_resched()/preempt enabled/system running tests are
    checked.

    It's better to check the sleeps while atomic earlier and not
    depend on some environment datas that reduce the chances to
    detect a problem.

    Also define cond_resched_*() helpers as macros, so that the
    FILE/LINE reported in the sleeping while atomic warning
    displays the real origin and not sched.h

    Changes in v2:

    - Call __might_sleep() directly instead of might_sleep() which
    may call cond_resched()

    - Turn cond_resched() into a macro so that the file:line
    couple reported refers to the caller of cond_resched() and
    not __cond_resched() itself.

    Changes in v3:

    - Also propagate this __might_sleep() pull up to
    cond_resched_lock() and cond_resched_softirq()

    Signed-off-by: Frederic Weisbecker
    Signed-off-by: Peter Zijlstra
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Frederic Weisbecker
     

12 Jun, 2009

1 commit


09 May, 2009

1 commit

  • Fix ordering of LRU when moving referenced dentries to the head of the list
    (they should go to the head of the list in the same order as they were found
    from the tail, rather than reverse order).

    Signed-off-by: Nick Piggin
    Signed-off-by: Al Viro

    npiggin@suse.de
     

21 Apr, 2009

1 commit


01 Apr, 2009

2 commits


28 Mar, 2009

1 commit

  • Make sure that comments describe what's going on and not how, and always
    use __d_instantiate instead of two separate branches, one with
    d_instantiate and one with __d_instantiate.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Al Viro

    Christoph Hellwig
     

28 Feb, 2009

1 commit

  • Commit 4ea3ada2955e4519befa98ff55dd62d6dfbd1705 declares d_obtain_alias()
    as EXPORT_SYMBOL_GPL where it's supposed to replace d_alloc_anon which was
    previously declared as EXPORT_SYMBOL and thus available to any loadable
    module.

    This patch reverts that.

    Signed-off-by: Benny Halevy
    Acked-by: Linus Torvalds
    Cc: Christoph Hellwig
    Cc: "J. Bruce Fields"
    Cc: Trond Myklebust
    Acked-by: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Benny Halevy
     

14 Jan, 2009

1 commit


09 Jan, 2009

1 commit


01 Jan, 2009

4 commits