1. 24 3月, 2009 3 次提交
    • S
      GFS2: Fix deadlock on journal flush · d8348de0
      Steven Whitehouse 提交于
      This patch fixes a deadlock when the journal is flushed and there
      are dirty inodes other than the one which caused the journal flush.
      Originally the journal flushing code was trying to obtain the
      transaction glock while running the flush code for an inode glock.
      We no longer require the transaction glock at this point in time
      since we know that any attempt to get the transaction glock from
      another node will result in a journal flush. So if we are flushing
      the journal, we can be sure that the transaction lock is still
      cached from when the transaction was started.
      
      By inlining a version of gfs2_trans_begin() (minus the bit which
      gets the transaction glock) we can avoid the deadlock problems
      caused if there is a demote request queued up on the transaction
      glock.
      
      In addition I've also moved the umount rwsem so that it covers
      the glock workqueue, since it all demotions are done by this
      workqueue now. That fixes a bug on umount which I came across
      while fixing the original problem.
      Reported-by: NDavid Teigland <teigland@redhat.com>
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      d8348de0
    • S
      GFS2: Remove unused field from glock · ac2425e7
      Steven Whitehouse 提交于
      The time stamp field is unused in the glock now that we are
      using a shrinker, so that we can remove it and save sizeof(unsigned long)
      bytes in each glock.
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      ac2425e7
    • S
      GFS2: Merge lock_dlm module into GFS2 · f057f6cd
      Steven Whitehouse 提交于
      This is the big patch that I've been working on for some time
      now. There are many reasons for wanting to make this change
      such as:
       o Reducing overhead by eliminating duplicated fields between structures
       o Simplifcation of the code (reduces the code size by a fair bit)
       o The locking interface is now the DLM interface itself as proposed
         some time ago.
       o Fewer lookups of glocks when processing replies from the DLM
       o Fewer memory allocations/deallocations for each glock
       o Scope to do further optimisations in the future (but this patch is
         more than big enough for now!)
      
      Please note that (a) this patch relates to the lock_dlm module and
      not the DLM itself, that is still a separate module; and (b) that
      we retain the ability to build GFS2 as a standalone single node
      filesystem with out requiring the DLM.
      
      This patch needs a lot of testing, hence my keeping it I restarted
      my -git tree after the last merge window. That way, this has the maximum
      exposure before its merged. This is (modulo a few minor bug fixes) the
      same patch that I've been posting on and off the the last three months
      and its passed a number of different tests so far.
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      f057f6cd
  2. 05 1月, 2009 7 次提交
    • J
      GFS2: Use DEFINE_SPINLOCK · eb8374e7
      Julia Lawall 提交于
      SPIN_LOCK_UNLOCKED is deprecated.  The following makes the change suggested
      in Documentation/spinlocks.txt
      
      The semantic patch that makes this change is as follows:
      (http://www.emn.fr/x-info/coccinelle/)
      
      // <smpl>
      @@
      declarer name DEFINE_SPINLOCK;
      identifier xxx_lock;
      @@
      
      - spinlock_t xxx_lock = SPIN_LOCK_UNLOCKED;
      + DEFINE_SPINLOCK(xxx_lock);
      // </smpl>
      Signed-off-by: NJulia Lawall <julia@diku.dk>
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      eb8374e7
    • S
      Revert "GFS2: Fix use-after-free bug on umount" · fefc03bf
      Steven Whitehouse 提交于
      This reverts commit 78802499912f1ba31ce83a94c55b5a980f250a43.
      
      The original patch is causing problems in relation to order of
      operations at umount in relation to jdata files. I need to fix
      this a different way.
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      fefc03bf
    • S
      GFS2: Fix use-after-free bug on umount · 3af165ac
      Steven Whitehouse 提交于
      There was a use-after-free with the GFS2 super block during
      umount. This patch moves almost all of the umount code from
      ->put_super into ->kill_sb, the only bit that cannot be moved
      being the glock hash clearing which has to remain as ->put_super
      due to umount ordering requirements. As a result its now obvious
      that the kfree is the final operation, whereas before it was
      hidden in ->put_super.
      
      Also gfs2_jindex_free is then only referenced from a single file
      so thats moved and marked static too.
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      3af165ac
    • S
      GFS2: Move four functions from super.c · 2bfb6449
      Steven Whitehouse 提交于
      The functions which are being moved can all be marked
      static in their new locations, since they only have
      a single caller each. Their new locations are more
      logical than before and some of the functions are
      small enough that the compiler might well inline them.
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      2bfb6449
    • S
      GFS2: Kill two daemons with one patch · 97cc1025
      Steven Whitehouse 提交于
      This patch removes the two daemons, gfs2_scand and gfs2_glockd
      and replaces them with a shrinker which is called from the VM.
      
      The net result is that GFS2 responds better when there is memory
      pressure, since it shrinks the glock cache at the same rate
      as the VFS shrinks the dcache and icache. There are no longer
      any time based criteria for shrinking glocks, they are kept
      until such time as the VM asks for more memory and then we
      demote just as many glocks as required.
      
      There are potential future changes to this code, including the
      possibility of sorting the glocks which are to be written back
      into inode number order, to get a better I/O ordering. It would
      be very useful to have an elevator based workqueue implementation
      for this, as that would automatically deal with the read I/O cases
      at the same time.
      
      This patch is my answer to Andrew Morton's remark, made during
      the initial review of GFS2, asking why GFS2 needs so many kernel
      threads, the answer being that it doesn't :-) This patch is a
      net loss of about 200 lines of code.
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      97cc1025
    • S
      GFS2: Fix "truncate in progress" hang · 813e0c46
      Steven Whitehouse 提交于
      Following on from the recent clean up of gfs2_quotad, this patch moves
      the processing of "truncate in progress" inodes from the glock workqueue
      into gfs2_quotad. This fixes a hang due to the "truncate in progress"
      processing requiring glocks in order to complete.
      
      It might seem odd to use gfs2_quotad for this particular item, but
      we have to use a pre-existing thread since creating a thread implies
      a GFP_KERNEL memory allocation which is not allowed from the glock
      workqueue context. Of the existing threads, gfs2_logd and gfs2_recoverd
      may deadlock if used for this operation. gfs2_scand and gfs2_glockd are
      both scheduled for removal at some (hopefully not too distant) future
      point. That leaves only gfs2_quotad whose workload is generally fairly
      light and is easily adapted for this extra task.
      
      Also, as a result of this change, it opens the way for a future patch to
      make the reading of the inode's information asynchronous with respect to
      the glock workqueue, which is another improvement that has been on the list
      for some time now.
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      813e0c46
    • H
      GFS2: sparse annotation of gl->gl_spin · 55ba474d
      Harvey Harrison 提交于
      fs/gfs2/glock.c:308:5: warning: context problem in 'do_promote': '_spin_unlock' expected different context
      fs/gfs2/glock.c:308:5:    context '*gl+28': wanted >= 1, got 0
      fs/gfs2/glock.c:529:2: warning: context problem in 'do_xmote': '_spin_unlock' expected different context
      fs/gfs2/glock.c:529:2:    context '*gl+28': wanted >= 1, got 0
      fs/gfs2/glock.c:925:3: warning: context problem in 'add_to_queue': '_spin_unlock' expected different context
      fs/gfs2/glock.c:925:3:    context '*gl+28': wanted >= 1, got 0
      Signed-off-by: NHarvey Harrison <harvey.harrison@gmail.com>
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      55ba474d
  3. 18 9月, 2008 1 次提交
    • S
      GFS2: high time to take some time over atime · 719ee344
      Steven Whitehouse 提交于
      Until now, we've used the same scheme as GFS1 for atime. This has failed
      since atime is a per vfsmnt flag, not a per fs flag and as such the
      "noatime" flag was not getting passed down to the filesystems. This
      patch removes all the "special casing" around atime updates and we
      simply use the VFS's atime code.
      
      The net result is that GFS2 will now support all the same atime related
      mount options of any other filesystem on a per-vfsmnt basis. We do lose
      the "lazy atime" updates, but we gain "relatime". We could add lazy
      atime to the VFS at a later date, if there is a requirement for that
      variant still - I suspect relatime will be enough.
      
      Also we lose about 100 lines of code after this patch has been applied,
      and I have a suspicion that it will speed things up a bit, even when
      atime is "on". So it seems like a nice clean up as well.
      
      From a user perspective, everything stays the same except the loss of
      the per-fs atime quantum tweekable (ought to be per-vfsmnt at the very
      least, and to be honest I don't think anybody ever used it) and that a
      number of options which were ignored before now work correctly.
      
      Please let me know if you've got any comments. I'm pushing this out
      early so that you can all see what my plans are.
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      719ee344
  4. 05 9月, 2008 1 次提交
    • S
      GFS2: Fix race relating to glock min-hold time · dff52574
      Steven Whitehouse 提交于
      In the case that a request for a glock arrives right after the
      grant reply has arrived, it sometimes means that the gl_tstamp
      field hasn't been updated recently enough. The net result is that
      the min-hold time for the glock is ignored. If this happens
      often enough, it leads to poor performance.
      
      This patch adds an additional test, so that if the reply pending
      bit is set on a glock, then it will select the maximum length of
      time for the min-hold time, rather than looking at gl_tstamp.
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      dff52574
  5. 13 8月, 2008 1 次提交
  6. 07 7月, 2008 2 次提交
    • S
      [GFS2] Allow local DF locks when holding a cached EX glock · 209806ab
      Steven Whitehouse 提交于
      We already allow local SH locks while we hold a cached EX glock, so here
      we allow DF locks as well. This works only because we rely on the VFS's
      invalidation for locally cached data, and because if we hold an EX lock,
      then we know that no other node can be caching data relating to this
      file.
      
      It dramatically speeds up initial writes to O_DIRECT files since we fall
      back to buffered I/O for this and would otherwise bounce between DF and
      EX modes on each and every write call. The lessons to be learned from
      that are to ensure that (for the time being anyway) O_DIRECT files are
      preallocated and that they are written to using reasonably large I/O
      sizes. Even so this change fixes that corner case nicely
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      209806ab
    • S
      [GFS2] Fix delayed demote race · 265d529c
      Steven Whitehouse 提交于
      There is a race in the delayed demote code where it does the wrong thing
      if a demotion to UN has occurred for other reasons before the delay has
      expired. This patch adds an assert to catch that condition as well as
      fixing the root cause by adding an additional check for the UN state.
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      Cc: Bob Peterson <rpeterso@redhat.com>
      265d529c
  7. 27 6月, 2008 3 次提交
    • S
      [GFS2] Remove remote lock dropping code · 1bdad606
      Steven Whitehouse 提交于
      There are several reasons why this is undesirable:
      
       1. It never happens during normal operation anyway
       2. If it does happen it causes performance to be very, very poor
       3. It isn't likely to solve the original problem (memory shortage
          on remote DLM node) it was supposed to solve
       4. It uses a bunch of arbitrary constants which are unlikely to be
          correct for any particular situation and for which the tuning seems
          to be a black art.
       5. In an N node cluster, only 1/N of the dropped locked will actually
          contribute to solving the problem on average.
      
      So all in all we are better off without it. This also makes merging
      the lock_dlm module into GFS2 a bit easier.
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      1bdad606
    • S
      [GFS2] No lock_nolock · 048bca22
      Steven Whitehouse 提交于
      This patch merges the lock_nolock module into GFS2 itself. As well as removing
      some of the overhead of the module, it also means that its now impossible to
      build GFS2 without a lock module (which would be a pointless thing to do
      anyway).
      
      We also plan to merge lock_dlm into GFS2 in the future, but that is a more
      tricky task, and will therefore be a separate patch.
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      Cc: David Teigland <teigland@redhat.com>
      048bca22
    • S
      [GFS2] Clean up the glock core · 6802e340
      Steven Whitehouse 提交于
      This patch implements a number of cleanups to the core of the
      GFS2 glock code. As a result a lot of code is removed. It looks
      like a really big change, but actually a large part of this patch
      is either removing or moving existing code.
      
      There are some new bits too though, such as the new run_queue()
      function which is considerably streamlined. Highlights of this
      patch include:
      
       o Fixes a cluster coherency bug during SH -> EX lock conversions
       o Removes the "glmutex" code in favour of a single bit lock
       o Removes the ->go_xmote_bh() for inodes since it was duplicating
         ->go_lock()
       o We now only use the ->lm_lock() function for both locks and
         unlocks (i.e. unlock is a lock with target mode LM_ST_UNLOCKED)
       o The fast path is considerably shortly, giving performance gains
         especially with lock_nolock
       o The glock_workqueue is now used for all the callbacks from the DLM
         which allows us to simplify the lock_dlm module (see following patch)
       o The way is now open to make further changes such as eliminating the two
         threads (gfs2_glockd and gfs2_scand) in favour of a more efficient
         scheme.
      
      This patch has undergone extensive testing with various test suites
      so it should be pretty stable by now.
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      Cc: Bob Peterson <rpeterso@redhat.com>
      6802e340
  8. 31 3月, 2008 8 次提交
  9. 08 2月, 2008 2 次提交
  10. 25 1月, 2008 7 次提交
    • B
      [GFS2] Reorganize function gfs2_glmutex_lock · 398bbe68
      Bob Peterson 提交于
      This patch optimizes the function gfs2_glmutex_lock.
      The basic theory is: Why bother initializing a holder, setting up
      wait bits and then waiting on them, if you know the glock can be
      yours.  So the holder stuff is placed inside the if checking if the
      glock is locked.  This one needs careful scrutiny because changing
      anything to do with locking should strike terror into one's heart.
      Signed-off-by: NBob Peterson <rpeterso@redhat.com>
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      398bbe68
    • F
      [GFS2] Fix runtime issue with UP kernels · 1a2781cf
      Fabio Massimo Di Nitto 提交于
      The issue is indeed UP vs SMP and it is totally random.
      
      spin_is_locked() is a bad assertion because there is no correct answer on UP.
      on UP spin_is_locked() has to return either one value or another, always.
      
      This means that in my setup I am lucky enough to trigger the issue and your you
      are lucky enough not to.
      
      the patch in attachment removes the bogus calls to BUG_ON and according to David
      (in CC and thanks for the long explanation on the problem) we can rely upon
      things like lockdep to find problem that might be trying to catch.
      Signed-off-by: NFabio M. Di Nitto <fabbione@ubuntu.com>
      Cc: David S. Miller <davem@davemloft.net>
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      1a2781cf
    • S
      [GFS2] Don't add glocks to the journal · 2bcd610d
      Steven Whitehouse 提交于
      The only reason for adding glocks to the journal was to keep track
      of which locks required a log flush prior to release. We add a
      flag to the glock to allow this check to be made in a simpler way.
      
      This reduces the size of a glock (by 12 bytes on i386, 24 on x86_64)
      and means that we can avoid extra work during the journal flush.
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      2bcd610d
    • S
      [GFS2] Remove flags no longer required · e589665e
      Steven Whitehouse 提交于
      The HIF_MUTEX and HIF_PROMOTE flags were set on the glock holders
      depending upon which of the two waiters lists they were going to
      be queued upon. They were then tested when the holders were taken
      off the lists to ensure that the right type of holder was being
      dequeued.
      
      Since we are already using separate lists, there doesn't seem a
      lot of point having these flags as well, and since setting them
      and testing them is in the fast path for locking and unlocking
      glock, this patch removes them.
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      e589665e
    • S
      [GFS2] Reorder writeback for glock sync · 3042a2cc
      Steven Whitehouse 提交于
      Previously we were doing (write data, wait for data, write metadata, wait
      for metadata). After this patch we so (write metadata, write data, wait for
      data, wait for metadata) which should be more efficient.
      
      Also I noticed that the drop_bh and xmote_bh functions were almost
      identical. In fact the only difference was a single test, and that
      test is such that in the drop_bh case, it would always evaluate to
      the correct result. As such we can use the xmote_bh functions in
      all the places where we were using the drop_bh function and remove
      the drop_bh functions.
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      3042a2cc
    • S
      [GFS2] Remove "reclaim limit" · c2932e03
      Steven Whitehouse 提交于
      This call to reclaim glocks is not needed, and in particular we don't want it
      in the fast path for locking glocks. The limit was entirely arbitrary anyway
      and we can't expect users to adjust things like this, the remaining code will
      do the right thing on its own.
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      c2932e03
    • W
      [GFS2] Handle multiple glock demote requests · cc7e79b1
      Wendy Cheng 提交于
      Fix a race condition where multiple glock demote requests are sent to
      a node back-to-back. This patch does a check inside handle_callback()
      to see whether a demote request is in progress. If true, it sets a flag
      to make sure run_queue() will loop again to handle the new request,
      instead of erronously setting gl_demote_state to a different state.
      Signed-off-by: NS. Wendy Cheng <wcheng@redhat.com>
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      cc7e79b1
  11. 10 10月, 2007 5 次提交
    • W
      [GFS2] Move inode deletion out of blocking_cb · 49e61f2e
      Wendy Cheng 提交于
      Move inode deletion code out of blocking_cb handle_callback route to
      avoid racy conditions that end up blocking lock_dlm1 thread. Fix
      bugzilla 286821.
      Signed-off-by: NWendy Cheng <wcheng@redhat.com>
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      49e61f2e
    • A
      [GFS2] flocks from same process trip kernel BUG at fs/gfs2/glock.c:1118! · b4c20166
      Abhijith Das 提交于
      This patch adds a new flag to the gfs2_holder structure GL_FLOCK.
      It is set on holders of glocks representing flocks. This flag is
      checked in add_to_queue() and a process is permitted to queue more
      than one holder onto a glock if it is set. This solves the issue
      of a process not being able to do multiple flocks on the same file.
      Through a single descriptor, a process can now promote and demote
      flocks. Through multiple descriptors a process can now queue
      multiple flocks on the same file. There's still the problem of
      a process deadlocking itself (because gfs2 blocking locks are not
      interruptible) by queueing incompatible deadlock.
      Signed-off-by: NAbhijith Das <adas@redhat.com>
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      b4c20166
    • B
      [GFS2] delay glock demote for a minimum hold time · c4f68a13
      Benjamin Marzinski 提交于
      When a lot of IO, with some distributed mmap IO, is run on a GFS2 filesystem in
      a cluster, it will deadlock. The reason is that do_no_page() will repeatedly
      call gfs2_sharewrite_nopage(), because each node keeps giving up the glock
      too early, and is forced to call unmap_mapping_range(). This bumps the
      mapping->truncate_count sequence count, forcing do_no_page() to retry. This
      patch institutes a minimum glock hold time a tenth a second.  This insures
      that even in heavy contention cases, the node has enough time to get some
      useful work done before it gives up the glock.
      
      A second issue is that when gfs2_glock_dq() is called from within a page fault
      to demote a lock, and the associated page needs to be written out, it will
      try to acqire a lock on it, but it has already been locked at a higher level.
      This patch puts makes gfs2_glock_dq() use the work queue as well, to avoid this
      issue. This is the same patch as Steve Whitehouse originally proposed to fix
      this issue, execpt that gfs2_glock_dq() now grabs a reference to the glock
      before it queues up the work on it.
      Signed-off-by: NBenjamin E. Marzinski <bmarzins@redhat.com>
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      c4f68a13
    • A
      [GFS2] Wendy's dump lockname in hex & fix glock dump · a947e033
      Abhijith Das 提交于
      With this patch, gfs2 glockdump through the debugfs filesystem will only
      dump glocks for the specified filesystem instead of all glocks. Also, to
      aid debugging, the glock number is dumped in hex instead of decimal.
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      Signed-off-by: NS. Wendy Cheng <wcheng@redhat.com>
      Signed-off-by: NAbhijith Das <adas@redhat.com>
      a947e033
    • S
      [GFS2] Reduce number of gfs2_scand processes to one · 8fbbfd21
      Steven Whitehouse 提交于
      We only need a single gfs2_scand process rather than the one
      per filesystem which we had previously. As a result the parameter
      determining the frequency of gfs2_scand runs becomes a module
      parameter rather than a mount parameter as it was before.
      Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
      8fbbfd21