1. 28 6月, 2021 1 次提交
  2. 31 5月, 2021 1 次提交
  3. 20 5月, 2021 2 次提交
    • B
      gfs2: fix a deadlock on withdraw-during-mount · 865cc3e9
      Bob Peterson 提交于
      Before this patch, gfs2 would deadlock because of the following
      sequence during mount:
      
      mount
         gfs2_fill_super
            gfs2_make_fs_rw <--- Detects IO error with glock
               kthread_stop(sdp->sd_quotad_process);
                  <--- Blocked waiting for quotad to finish
      
      logd
         Detects IO error and the need to withdraw
         calls gfs2_withdraw
            gfs2_make_fs_ro
               kthread_stop(sdp->sd_quotad_process);
                  <--- Blocked waiting for quotad to finish
      
      gfs2_quotad
         gfs2_statfs_sync
            gfs2_glock_wait <---- Blocked waiting for statfs glock to be granted
      
      glock_work_func
         do_xmote <---Detects IO error, can't release glock: blocked on withdraw
            glops->go_inval
            glock_blocked_by_withdraw
               requeue glock work & exit <--- work requeued, blocked by withdraw
      
      This patch makes a special exception for the statfs system inode glock,
      which allows the statfs glock UNLOCK to proceed normally. That allows the
      quotad daemon to exit during the withdraw, which allows the logd daemon
      to exit during the withdraw, which allows the mount to exit.
      Signed-off-by: NBob Peterson <rpeterso@redhat.com>
      Signed-off-by: NAndreas Gruenbacher <agruenba@redhat.com>
      865cc3e9
    • B
      gfs2: fix scheduling while atomic bug in glocks · 20265d9a
      Bob Peterson 提交于
      Before this patch, in the unlikely event that gfs2_glock_dq encountered
      a withdraw, it would do a wait_on_bit to wait for its journal to be
      recovered, but it never released the glock's spin_lock, which caused a
      scheduling-while-atomic error.
      
      This patch unlocks the lockref spin_lock before waiting for recovery.
      
      Fixes: 601ef0d5 ("gfs2: Force withdraw to replay journals and wait for it to finish")
      Cc: stable@vger.kernel.org # v5.7+
      Reported-by: NAlexander Aring <aahringo@redhat.com>
      Signed-off-by: NBob Peterson <rpeterso@redhat.com>
      Signed-off-by: NAndreas Gruenbacher <agruenba@redhat.com>
      20265d9a
  4. 06 5月, 2021 1 次提交
  5. 10 4月, 2021 1 次提交
  6. 09 4月, 2021 1 次提交
  7. 04 4月, 2021 1 次提交
  8. 18 2月, 2021 1 次提交
    • B
      gfs2: Allow node-wide exclusive glock sharing · 06e908cd
      Bob Peterson 提交于
      Introduce a new LM_FLAG_NODE_SCOPE glock holder flag: when taking a
      glock in LM_ST_EXCLUSIVE (EX) mode and with the LM_FLAG_NODE_SCOPE flag
      set, the exclusive lock is shared among all local processes who are
      holding the glock in EX mode and have the LM_FLAG_NODE_SCOPE flag set.
      From the point of view of other nodes, the lock is still held
      exclusively.
      
      A future patch will start using this flag to improve performance with
      rgrp sharing.
      Signed-off-by: NBob Peterson <rpeterso@redhat.com>
      Signed-off-by: NAndreas Gruenbacher <agruenba@redhat.com>
      06e908cd
  9. 01 12月, 2020 1 次提交
  10. 25 11月, 2020 1 次提交
    • A
      gfs2: set lockdep subclass for iopen glocks · 515b269d
      Alexander Aring 提交于
      This patch introduce a new globs attribute to define the subclass of the
      glock lockref spinlock. This avoid the following lockdep warning, which
      occurs when we lock an inode lock while an iopen lock is held:
      
      ============================================
      WARNING: possible recursive locking detected
      5.10.0-rc3+ #4990 Not tainted
      --------------------------------------------
      kworker/0:1/12 is trying to acquire lock:
      ffff9067d45672d8 (&gl->gl_lockref.lock){+.+.}-{3:3}, at: lockref_get+0x9/0x20
      
      but task is already holding lock:
      ffff9067da308588 (&gl->gl_lockref.lock){+.+.}-{3:3}, at: delete_work_func+0x164/0x260
      
      other info that might help us debug this:
       Possible unsafe locking scenario:
      
             CPU0
             ----
        lock(&gl->gl_lockref.lock);
        lock(&gl->gl_lockref.lock);
      
       *** DEADLOCK ***
      
       May be due to missing lock nesting notation
      
      3 locks held by kworker/0:1/12:
       #0: ffff9067c1bfdd38 ((wq_completion)delete_workqueue){+.+.}-{0:0}, at: process_one_work+0x1b7/0x540
       #1: ffffac594006be70 ((work_completion)(&(&gl->gl_delete)->work)){+.+.}-{0:0}, at: process_one_work+0x1b7/0x540
       #2: ffff9067da308588 (&gl->gl_lockref.lock){+.+.}-{3:3}, at: delete_work_func+0x164/0x260
      
      stack backtrace:
      CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.10.0-rc3+ #4990
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-2.fc32 04/01/2014
      Workqueue: delete_workqueue delete_work_func
      Call Trace:
       dump_stack+0x8b/0xb0
       __lock_acquire.cold+0x19e/0x2e3
       lock_acquire+0x150/0x410
       ? lockref_get+0x9/0x20
       _raw_spin_lock+0x27/0x40
       ? lockref_get+0x9/0x20
       lockref_get+0x9/0x20
       delete_work_func+0x188/0x260
       process_one_work+0x237/0x540
       worker_thread+0x4d/0x3b0
       ? process_one_work+0x540/0x540
       kthread+0x127/0x140
       ? __kthread_bind_mask+0x60/0x60
       ret_from_fork+0x22/0x30
      Suggested-by: NAndreas Gruenbacher <agruenba@redhat.com>
      Signed-off-by: NAlexander Aring <aahringo@redhat.com>
      Signed-off-by: NAndreas Gruenbacher <agruenba@redhat.com>
      515b269d
  11. 03 11月, 2020 1 次提交
  12. 21 10月, 2020 2 次提交
  13. 15 10月, 2020 3 次提交
  14. 03 8月, 2020 2 次提交
  15. 30 6月, 2020 1 次提交
    • A
      gfs2: Don't sleep during glock hash walk · 34244d71
      Andreas Gruenbacher 提交于
      In flush_delete_work, instead of flushing each individual pending
      delayed work item, cancel and re-queue them for immediate execution.
      The waiting isn't needed here because we're already waiting for all
      queued work items to complete in gfs2_flush_delete_work.  This makes the
      code more efficient, but more importantly, it avoids sleeping during a
      rhashtable walk, inside rcu_read_lock().
      Signed-off-by: NAndreas Gruenbacher <agruenba@redhat.com>
      34244d71
  16. 06 6月, 2020 8 次提交
  17. 05 6月, 2020 2 次提交
  18. 09 5月, 2020 2 次提交
    • B
      Revert "gfs2: Don't demote a glock until its revokes are written" · b14c9490
      Bob Peterson 提交于
      This reverts commit df5db5f9.
      
      This patch fixes a regression: patch df5db5f9 allowed function
      run_queue() to bypass its call to do_xmote() if revokes were queued for
      the glock. That's wrong because its call to do_xmote() is what is
      responsible for calling the go_sync() glops functions to sync both
      the ail list and any revokes queued for it. By bypassing the call,
      gfs2 could get into a stand-off where the glock could not be demoted
      until its revokes are written back, but the revokes would not be
      written back because do_xmote() was never called.
      
      It "sort of" works, however, because there are other mechanisms like
      the log flush daemon (logd) that can sync the ail items and revokes,
      if it deems it necessary. The problem is: without file system pressure,
      it might never deem it necessary.
      Signed-off-by: NBob Peterson <rpeterso@redhat.com>
      b14c9490
    • B
      gfs2: If go_sync returns error, withdraw but skip invalidate · b11e1a84
      Bob Peterson 提交于
      Before this patch, if the go_sync operation returned an error during
      the do_xmote process (such as unable to sync metadata to the journal)
      the code did goto out. That kept the glock locked, so it could not be
      given away, which correctly avoids file system corruption. However,
      it never set the withdraw bit or requeueing the glock work. So it would
      hang forever, unable to ever demote the glock.
      
      This patch changes to goto to a new label, skip_inval, so that errors
      from go_sync are treated the same way as errors from go_inval:
      The delayed withdraw bit is set and the work is requeued. That way,
      the logd should eventually figure out there's a problem and withdraw
      properly there.
      Signed-off-by: NBob Peterson <rpeterso@redhat.com>
      Signed-off-by: NAndreas Gruenbacher <agruenba@redhat.com>
      b11e1a84
  19. 08 5月, 2020 1 次提交
    • B
      gfs2: Fix error exit in do_xmote · a8b7528b
      Bob Peterson 提交于
      Before this patch, if an error was detected from glock function go_sync
      by function do_xmote, it would return.  But the function had temporarily
      unlocked the gl_lockref spin_lock, and it never re-locked it.  When the
      caller of do_xmote tried to unlock it again, it was already unlocked,
      which resulted in a corrupted spin_lock value.
      
      This patch makes sure the gl_lockref spin_lock is re-locked after it is
      unlocked.
      
      Thanks to Wu Bo <wubo40@huawei.com> for reporting this problem.
      Signed-off-by: NBob Peterson <rpeterso@redhat.com>
      Signed-off-by: NAndreas Gruenbacher <agruenba@redhat.com>
      a8b7528b
  20. 28 3月, 2020 1 次提交
  21. 27 2月, 2020 5 次提交
    • B
      gfs2: Do proper error checking for go_sync family of glops functions · 1c634f94
      Bob Peterson 提交于
      Before this patch, function do_xmote would try to sync out the glock
      dirty data by calling the appropriate glops function XXX_go_sync()
      but it did not check for a good return code. If the sync was not
      possible due to an io error or whatever, do_xmote would continue on
      and call go_inval and release the glock to other cluster nodes.
      When those nodes go to replay the journal, they may already be holding
      glocks for the journal records that should have been synced, but were
      not due to the ignored error.
      
      This patch introduces proper error code checking to the go_sync
      family of glops functions.
      Signed-off-by: NBob Peterson <rpeterso@redhat.com>
      Reviewed-by: NAndreas Gruenbacher <agruenba@redhat.com>
      1c634f94
    • B
      gfs2: Don't demote a glock until its revokes are written · df5db5f9
      Bob Peterson 提交于
      Before this patch, run_queue would demote glocks based on whether
      there are any more holders. But if the glock has pending revokes that
      haven't been written to the media, giving up the glock might end in
      file system corruption if the revokes never get written due to
      io errors, node crashes and fences, etc. In that case, another node
      will replay the metadata blocks associated with the glock, but
      because the revoke was never written, it could replay that block
      even though the glock had since been granted to another node who
      might have made changes.
      
      This patch changes the logic in run_queue so that it never demotes
      a glock until its count of pending revokes reaches zero.
      Signed-off-by: NBob Peterson <rpeterso@redhat.com>
      Reviewed-by: NAndreas Gruenbacher <agruenba@redhat.com>
      df5db5f9
    • B
      gfs2: Check for log write errors before telling dlm to unlock · d93ae386
      Bob Peterson 提交于
      Before this patch, function do_xmote just assumed all the writes
      submitted to the journal were finished and successful, and it
      called the go_unlock function to release the dlm lock. But if
      they're not, and a revoke failed to make its way to the journal,
      a journal replay on another node will cause corruption if we
      let the go_inval function continue and tell dlm to release the
      glock to another node. This patch adds a couple checks for errors
      in do_xmote after the calls to go_sync and go_inval. If an error
      is found, we cannot withdraw yet, because the withdraw itself
      uses glocks to make the file system read-only. Instead, we flag
      the error. Later, asserts should cause another node to replay
      the journal before continuing, thus protecting rgrp and dinode
      glocks and maintaining the integrity of the metadata. Note that
      we only need to do this for journaled glocks. System glocks
      should be able to progress even under withdrawn conditions.
      Signed-off-by: NBob Peterson <rpeterso@redhat.com>
      Reviewed-by: NAndreas Gruenbacher <agruenba@redhat.com>
      d93ae386
    • B
      gfs2: fix infinite loop when checking ail item count before go_inval · 33dbd1e4
      Bob Peterson 提交于
      Before this patch, the rgrp_go_inval and inode_go_inval functions each
      checked if there were any items left on the ail count (by way of a
      count), and if so, did a withdraw. But the withdraw code now uses
      glocks when changing the file system to read-only status. So we can
      not have glock functions withdrawing or a hang will likely result:
      The glocks can't be serviced by the work_func if the work_func is
      busy doing its own withdraw.
      
      This patch removes the checks from the go_inval functions and adds
      a centralized check in do_xmote to warn about the problem and not
      withdraw, but flag the error so it's eventually caught when the logd
      daemon eventually runs.
      Signed-off-by: NBob Peterson <rpeterso@redhat.com>
      Reviewed-by: NAndreas Gruenbacher <agruenba@redhat.com>
      33dbd1e4
    • B
      gfs2: Force withdraw to replay journals and wait for it to finish · 601ef0d5
      Bob Peterson 提交于
      When a node withdraws from a file system, it often leaves its journal
      in an incomplete state. This is especially true when the withdraw is
      caused by io errors writing to the journal. Before this patch, a
      withdraw would try to write a "shutdown" record to the journal, tell
      dlm it's done with the file system, and none of the other nodes
      know about the problem. Later, when the problem is fixed and the
      withdrawn node is rebooted, it would then discover that its own
      journal was incomplete, and replay it. However, replaying it at this
      point is almost guaranteed to introduce corruption because the other
      nodes are likely to have used affected resource groups that appeared
      in the journal since the time of the withdraw. Replaying the journal
      later will overwrite any changes made, and not through any fault of
      dlm, which was instructed during the withdraw to release those
      resources.
      
      This patch makes file system withdraws seen by the entire cluster.
      Withdrawing nodes dequeue their journal glock to allow recovery.
      
      The remaining nodes check all the journals to see if they are
      clean or in need of replay. They try to replay dirty journals, but
      only the journals of withdrawn nodes will be "not busy" and
      therefore available for replay.
      
      Until the journal replay is complete, no i/o related glocks may be
      given out, to ensure that the replay does not cause the
      aforementioned corruption: We cannot allow any journal replay to
      overwrite blocks associated with a glock once it is held.
      
      The "live" glock which is now used to signal when a withdraw
      occurs. When a withdraw occurs, the node signals its withdraw by
      dequeueing the "live" glock and trying to enqueue it in EX mode,
      thus forcing the other nodes to all see a demote request, by way
      of a "1CB" (one callback) try lock. The "live" glock is not
      granted in EX; the callback is only just used to indicate a
      withdraw has occurred.
      
      Note that all nodes in the cluster must wait for the recovering
      node to finish replaying the withdrawing node's journal before
      continuing. To this end, it checks that the journals are clean
      multiple times in a retry loop.
      
      Also note that the withdraw function may be called from a wide
      variety of situations, and therefore, we need to take extra
      precautions to make sure pointers are valid before using them in
      many circumstances.
      
      We also need to take care when glocks decide to withdraw, since
      the withdraw code now uses glocks.
      
      Also, before this patch, if a process encountered an error and
      decided to withdraw, if another process was already withdrawing,
      the second withdraw would be silently ignored, which set it free
      to unlock its glocks. That's correct behavior if the original
      withdrawer encounters further errors down the road. But if
      secondary waiters don't wait for the journal replay, unlocking
      glocks will allow other nodes to use them, despite the fact that
      the journal containing those blocks is being replayed. The
      replay needs to finish before our glocks are released to other
      nodes. IOW, secondary withdraws need to wait for the first
      withdraw to finish.
      
      For example, if an rgrp glock is unlocked by a process that didn't
      wait for the first withdraw, a journal replay could introduce file
      system corruption by replaying a rgrp block that has already been
      granted to a different cluster node.
      Signed-off-by: NBob Peterson <rpeterso@redhat.com>
      601ef0d5
  22. 21 2月, 2020 1 次提交
    • B
      gfs2: Allow some glocks to be used during withdraw · a72d2401
      Bob Peterson 提交于
      We need to allow some glocks to be enqueued, dequeued, promoted, and demoted
      when we're withdrawn. For example, to maintain metadata integrity, we should
      disallow the use of inode and rgrp glocks when withdrawn. Other glocks, like
      iopen or the transaction glocks may be safely used because none of their
      metadata goes through the journal. So in general, we should disallow all
      glocks with an address space, and allow all the others. One exception is:
      we need to allow our active journal to be demoted so others may recover it.
      
      Allowing glocks after withdraw gives us the ability to take appropriate
      action (in a following patch) to have our journal properly replayed by
      another node rather than just abandoning the current transactions and
      pretending nothing bad happened, leaving the other nodes free to modify
      the blocks we had in our journal, which may result in file system
      corruption.
      Signed-off-by: NBob Peterson <rpeterso@redhat.com>
      a72d2401