]> git.baikalelectronics.ru Git - kernel.git/commit
gfs2: Introduce flag for glock holder auto-demotion
authorBob Peterson <rpeterso@redhat.com>
Thu, 19 Aug 2021 18:51:23 +0000 (20:51 +0200)
committerAndreas Gruenbacher <agruenba@redhat.com>
Wed, 20 Oct 2021 17:33:08 +0000 (19:33 +0200)
commit5a0d19d44d32c3a5680860665ff3a7244e13e601
tree25a8e7ebcda582f2d387d5477b29b37b036e6eac
parent15cab4b9f28959c22e3b158bce34ee0b3479ff30
gfs2: Introduce flag for glock holder auto-demotion

This patch introduces a new HIF_MAY_DEMOTE flag and infrastructure that
will allow glocks to be demoted automatically on locking conflicts.
When a locking request comes in that isn't compatible with the locking
state of an active holder and that holder has the HIF_MAY_DEMOTE flag
set, the holder will be demoted before the incoming locking request is
granted.

Note that this mechanism demotes active holders (with the HIF_HOLDER
flag set), while before we were only demoting glocks without any active
holders.  This allows processes to keep hold of locks that may form a
cyclic locking dependency; the core glock logic will then break those
dependencies in case a conflicting locking request occurs.  We'll use
this to avoid giving up the inode glock proactively before faulting in
pages.

Processes that allow a glock holder to be taken away indicate this by
calling gfs2_holder_allow_demote(), which sets the HIF_MAY_DEMOTE flag.
Later, they call gfs2_holder_disallow_demote() to clear the flag again,
and then they check if their holder is still queued: if it is, they are
still holding the glock; if it isn't, they can re-acquire the glock (or
abort).

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/glock.c
fs/gfs2/glock.h
fs/gfs2/incore.h