1. 12 10月, 2010 1 次提交
    • N
      sunrpc: Simplify cache_defer_req and related functions. · d29068c4
      NeilBrown 提交于
      The return value from cache_defer_req is somewhat confusing.
      Various different error codes are returned, but the single caller is
      only interested in success or failure.
      
      In fact it can measure this success or failure itself by checking
      CACHE_PENDING, which makes the point of the code more explicit.
      
      So change cache_defer_req to return 'void' and test CACHE_PENDING
      after it completes, to see if the request was actually deferred or
      not.
      
      Similarly setup_deferral and cache_wait_req don't need a return value,
      so make them void and remove some code.
      
      The call to cache_revisit_request (to guard against a race) is only
      needed for the second call to setup_deferral, so move it out of
      setup_deferral to after that second call.  With the first call the
      race is handled differently (by explicitly calling
      'wait_for_completion').
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      d29068c4
  2. 02 10月, 2010 1 次提交
    • N
      sunrpc: fix race in new cache_wait code. · 277f68db
      NeilBrown 提交于
      If we set up to wait for a cache item to be filled in, and then find
      that it is no longer pending, it could be that some other thread is
      in 'cache_revisit_request' and has moved our request to its 'pending' list.
      So when our setup_deferral calls cache_revisit_request it will find nothing to
      put on the pending list, and do nothing.
      
      We then return from cache_wait_req, thus leaving the 'sleeper'
      on-stack structure open to being corrupted by subsequent stack usage.
      
      However that 'sleeper' could still be on the 'pending' list that the
      other thread is looking at and so any corruption could cause it to behave badly.
      
      To avoid this race we simply take the same path as if the
      'wait_for_completion_interruptible_timeout' was interrupted and if the
      sleeper is no longer on the list (which it won't be) we wait on the
      completion - which will ensure that any other cache_revisit_request
      will have let go of the sleeper.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      277f68db
  3. 27 9月, 2010 2 次提交
  4. 23 9月, 2010 1 次提交
  5. 22 9月, 2010 2 次提交
  6. 20 9月, 2010 1 次提交
    • J
      nfsd4: fix hang on fast-booting nfs servers · 06497524
      J. Bruce Fields 提交于
      The last_close field of a cache_detail is initialized to zero, so the
      condition
      
      	detail->last_close < seconds_since_boot() - 30
      
      may be false even for a cache that was never opened.
      
      However, we want to immediately fail upcalls to caches that were never
      opened: in the case of the auth_unix_gid cache, especially, which may
      never be opened by mountd (if the --manage-gids option is not set), we
      want to fail the upcall immediately.  Otherwise client requests will be
      dropped unnecessarily on reboot.
      
      Also document these conditions.
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      06497524
  7. 08 9月, 2010 4 次提交
    • J
      svcrpc: cache deferral cleanup · 3211af11
      J. Bruce Fields 提交于
      Attempt to make obvious the first-try-sleeping-then-try-deferral logic
      by putting that logic into a top-level function that calls helpers.
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      3211af11
    • J
      svcrpc: minor cache cleanup · 6610f720
      J. Bruce Fields 提交于
      Pull out some code into helper functions, fix a typo.
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      6610f720
    • N
      sunrpc/cache: allow threads to block while waiting for cache update. · f16b6e8d
      NeilBrown 提交于
      The current practice of waiting for cache updates by queueing the
      whole request to be retried has (at least) two problems.
      
      1/ With NFSv4, requests can be quite complex and re-trying a whole
        request when a later part fails should only be a last-resort, not a
        normal practice.
      
      2/ Large requests, and in particular any 'write' request, will not be
        queued by the current code and doing so would be undesirable.
      
      In many cases only a very sort wait is needed before the cache gets
      valid data.
      
      So, providing the underlying transport permits it by setting
       ->thread_wait,
      arrange to wait briefly for an upcall to be completed (as reflected in
      the clearing of CACHE_PENDING).
      If the short wait was not long enough and CACHE_PENDING is still set,
      fall back on the old approach.
      
      The 'thread_wait' value is set to 5 seconds when there are spare
      threads, and 1 second when there are no spare threads.
      
      These values are probably much higher than needed, but will ensure
      some forward progress.
      
      Note that as we only request an update for a non-valid item, and as
      non-valid items are updated in place it is extremely unlikely that
      cache_check will return -ETIMEDOUT.  Normally cache_defer_req will
      sleep for a short while and then find that the item is_valid.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      f16b6e8d
    • N
      sunrpc: use seconds since boot in expiry cache · c5b29f88
      NeilBrown 提交于
      This protects us from confusion when the wallclock time changes.
      
      We convert to and from wallclock when  setting or reading expiry
      times.
      
      Also use seconds since boot for last_clost time.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      c5b29f88
  8. 07 8月, 2010 1 次提交
  9. 07 7月, 2010 1 次提交
    • A
      sunrpc: make the cache cleaner workqueue deferrable · 8eab945c
      Artem Bityutskiy 提交于
      This patch makes the cache_cleaner workqueue deferrable, to prevent
      unnecessary system wake-ups, which is very important for embedded
      battery-powered devices.
      
      do_cache_clean() is called every 30 seconds at the moment, and often
      makes the system wake up from its power-save sleep state. With this
      change, when the workqueue uses a deferrable timer, the
      do_cache_clean() invocation will be delayed and combined with the
      closest "real" wake-up. This improves the power consumption situation.
      
      Note, I tried to create a DECLARE_DELAYED_WORK_DEFERRABLE() helper
      macro, similar to DECLARE_DELAYED_WORK(), but failed because of the
      way the timer wheel core stores the deferrable flag (it is the
      LSBit in the time->base pointer). My attempt to define a static
      variable with this bit set ended up with the "initializer element is
      not constant" error.
      
      Thus, I have to use run-time initialization, so I created a new
      cache_initialize() function which is called once when sunrpc is
      being initialized.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      Signed-off-by: NJ. Bruce Fields <bfields@citi.umich.edu>
      8eab945c
  10. 06 7月, 2010 1 次提交
  11. 22 5月, 2010 1 次提交
  12. 17 5月, 2010 2 次提交
    • F
      sunrpc: Include missing smp_lock.h · 99df95a2
      Frederic Weisbecker 提交于
      Now that cache_ioctl_procfs() calls the bkl explicitly, we need to
      include the relevant header as well.
      
      This fixes the following build error:
      
      	net/sunrpc/cache.c: In function 'cache_ioctl_procfs':
      	net/sunrpc/cache.c:1355: error: implicit declaration of function 'lock_kernel'
      	net/sunrpc/cache.c:1359: error: implicit declaration of function 'unlock_kernel'
      Reported-by: NStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      99df95a2
    • F
      procfs: Push down the bkl from ioctl · d79b6f4d
      Frederic Weisbecker 提交于
      Push down the bkl from procfs's ioctl main handler to its users.
      Only three procfs users implement an ioctl (non unlocked) handler.
      Turn them into unlocked_ioctl and push down the Devil inside.
      
      v2: PDE(inode)->data doesn't need to be under bkl
      v3: And don't forget to git-add the result
      v4: Use wrappers to pushdown instead of an invasive and error prone
          handlers surgery.
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: John Kacur <jkacur@redhat.com>
      Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Cc: Al Viro <viro@ZenIV.linux.org.uk>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      d79b6f4d
  13. 24 3月, 2010 1 次提交
  14. 15 3月, 2010 3 次提交
    • N
      sunrpc: never return expired entries in sunrpc_cache_lookup · d202cce8
      NeilBrown 提交于
      If sunrpc_cache_lookup finds an expired entry, remove it from
      the cache and return a freshly created non-VALID entry instead.
      This ensures that we only ever get a usable entry, or an
      entry that will become usable once an update arrives.
      i.e. we will never need to repeat the lookup.
      
      This allows us to remove the 'is_expired' test from cache_check
      (i.e. from cache_is_valid).  cache_check should never get an expired
      entry as 'lookup' will never return one.  If it does happen - due to
      inconvenient timing - then just accept it as still valid, it won't be
      very much past it's use-by date.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NJ. Bruce Fields <bfields@citi.umich.edu>
      d202cce8
    • N
      sunrpc/cache: factor out cache_is_expired · 2f50d8b6
      NeilBrown 提交于
      This removes a tiny bit of code duplication, but more important
      prepares for following patch which will perform the expiry check in
      cache_lookup and the rest of the validity check in cache_check.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NJ. Bruce Fields <bfields@citi.umich.edu>
      2f50d8b6
    • N
      sunrpc: don't keep expired entries in the auth caches. · 3af4974e
      NeilBrown 提交于
      currently expired entries remain in the auth caches as long
      as there is a reference.
      This was needed long ago when the auth_domain cache used the same
      cache infrastructure.  But since that (being a very different sort
      of cache) was separated, this test is no longer needed.
      
      So remove the test on refcnt and tidy up the surrounding code.
      
      This allows the cache_dequeue call (which needed to be there to
      drop a potentially awkward reference) can be moved outside of the
      spinlock which is a better place for it.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NJ. Bruce Fields <bfields@citi.umich.edu>
      3af4974e
  15. 30 11月, 2009 1 次提交
  16. 19 9月, 2009 1 次提交
  17. 18 9月, 2009 1 次提交
  18. 12 9月, 2009 2 次提交
  19. 20 8月, 2009 1 次提交
  20. 10 8月, 2009 6 次提交
  21. 05 8月, 2009 1 次提交
  22. 04 8月, 2009 2 次提交
  23. 16 6月, 2009 1 次提交
  24. 31 3月, 2009 1 次提交
    • A
      proc 2/2: remove struct proc_dir_entry::owner · 99b76233
      Alexey Dobriyan 提交于
      Setting ->owner as done currently (pde->owner = THIS_MODULE) is racy
      as correctly noted at bug #12454. Someone can lookup entry with NULL
      ->owner, thus not pinning enything, and release it later resulting
      in module refcount underflow.
      
      We can keep ->owner and supply it at registration time like ->proc_fops
      and ->data.
      
      But this leaves ->owner as easy-manipulative field (just one C assignment)
      and somebody will forget to unpin previous/pin current module when
      switching ->owner. ->proc_fops is declared as "const" which should give
      some thoughts.
      
      ->read_proc/->write_proc were just fixed to not require ->owner for
      protection.
      
      rmmod'ed directories will be empty and return "." and ".." -- no harm.
      And directories with tricky enough readdir and lookup shouldn't be modular.
      We definitely don't want such modular code.
      
      Removing ->owner will also make PDE smaller.
      
      So, let's nuke it.
      
      Kudos to Jeff Layton for reminding about this, let's say, oversight.
      
      http://bugzilla.kernel.org/show_bug.cgi?id=12454Signed-off-by: NAlexey Dobriyan <adobriyan@gmail.com>
      99b76233
  25. 08 1月, 2009 1 次提交