From: Andreas Gruenbacher <agruenba@redhat.com>
To: gfs2@lists.linux.dev
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Subject: [PATCH 14/15] gfs2: Get rid of demote_ok checks
Date: Tue, 9 Apr 2024 18:45:04 +0200 [thread overview]
Message-ID: <20240409164508.79570-15-agruenba@redhat.com> (raw)
In-Reply-To: <20240409164508.79570-1-agruenba@redhat.com>
The demote_ok glock operation is only still used to prevent the inode
glocks of the "jindex" and "rindex" directories from getting recycled
while they are still referenced by sdp->sd_jindex and sdp->sd_rindex.
However, the LRU walking code will no longer recycle glocks which are
referenced, so the demote_ok glock operation is obsolete and can be
removed.
Each of a glock's holders in the gl_holders list is holding a reference
on the glock, so when the list of holders isn't empty in demote_ok(),
the existing reference count check will already prevent the glock from
getting released. This means that demote_ok() is obsolete as well.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
Documentation/filesystems/gfs2-glocks.rst | 3 ---
fs/gfs2/glock.c | 25 ++---------------------
fs/gfs2/glops.c | 18 ----------------
fs/gfs2/incore.h | 1 -
4 files changed, 2 insertions(+), 45 deletions(-)
diff --git a/Documentation/filesystems/gfs2-glocks.rst b/Documentation/filesystems/gfs2-glocks.rst
index 8a5842929b60..fd3bf0f157fb 100644
--- a/Documentation/filesystems/gfs2-glocks.rst
+++ b/Documentation/filesystems/gfs2-glocks.rst
@@ -61,8 +61,6 @@ Field Purpose
go_xmote_th Called before remote state change (e.g. to sync dirty data)
go_xmote_bh Called after remote state change (e.g. to refill cache)
go_inval Called if remote state change requires invalidating the cache
-go_demote_ok Returns boolean value of whether its ok to demote a glock
- (e.g. checks timeout, and that there is no cached data)
go_lock Called for the first local holder of a lock
go_unlock Called on the final local unlock of a lock
go_dump Called to print content of object for debugfs file, or on
@@ -96,7 +94,6 @@ Operation GLF_LOCK bit lock held gl_lockref.lock spinlock held
go_xmote_th Yes No
go_xmote_bh Yes No
go_inval Yes No
-go_demote_ok Sometimes Yes
go_lock Yes No
go_unlock Yes No
go_dump Sometimes Yes
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 04e0a8ac61d7..5b2fd5994cfc 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -192,27 +192,6 @@ struct gfs2_glock *gfs2_glock_hold(struct gfs2_glock *gl)
return gl;
}
-/**
- * demote_ok - Check to see if it's ok to unlock a glock
- * @gl: the glock
- *
- * Returns: 1 if it's ok
- */
-
-static int demote_ok(const struct gfs2_glock *gl)
-{
- const struct gfs2_glock_operations *glops = gl->gl_ops;
-
- if (gl->gl_state == LM_ST_UNLOCKED)
- return 0;
- if (!list_empty(&gl->gl_holders))
- return 0;
- if (glops->go_demote_ok)
- return glops->go_demote_ok(gl);
- return 1;
-}
-
-
void gfs2_glock_add_to_lru(struct gfs2_glock *gl)
{
if (!(gl->gl_ops->go_flags & GLOF_LRU))
@@ -1674,7 +1653,7 @@ static void __gfs2_glock_dq(struct gfs2_holder *gh)
fast_path = 1;
}
- if (!test_bit(GLF_LFLUSH, &gl->gl_flags) && demote_ok(gl))
+ if (!test_bit(GLF_LFLUSH, &gl->gl_flags))
gfs2_glock_add_to_lru(gl);
if (unlikely(!fast_path)) {
@@ -2033,7 +2012,7 @@ __acquires(&lru_lock)
goto add_back_to_lru;
}
gl->gl_lockref.count++;
- if (demote_ok(gl))
+ if (gl->gl_state != LM_ST_UNLOCKED)
handle_callback(gl, LM_ST_UNLOCKED, 0, false);
__gfs2_glock_queue_work(gl, 0);
spin_unlock(&gl->gl_lockref.lock);
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index 68677fb69a73..7013bccb67e8 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -385,23 +385,6 @@ static void inode_go_inval(struct gfs2_glock *gl, int flags)
gfs2_clear_glop_pending(ip);
}
-/**
- * inode_go_demote_ok - Check to see if it's ok to unlock an inode glock
- * @gl: the glock
- *
- * Returns: 1 if it's ok
- */
-
-static int inode_go_demote_ok(const struct gfs2_glock *gl)
-{
- struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
-
- if (sdp->sd_jindex == gl->gl_object || sdp->sd_rindex == gl->gl_object)
- return 0;
-
- return 1;
-}
-
static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
{
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
@@ -722,7 +705,6 @@ const struct gfs2_glock_operations gfs2_meta_glops = {
const struct gfs2_glock_operations gfs2_inode_glops = {
.go_sync = inode_go_sync,
.go_inval = inode_go_inval,
- .go_demote_ok = inode_go_demote_ok,
.go_instantiate = inode_go_instantiate,
.go_held = inode_go_held,
.go_dump = inode_go_dump,
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index 95a334d64da2..2c4c0ee2c014 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -218,7 +218,6 @@ struct gfs2_glock_operations {
int (*go_sync) (struct gfs2_glock *gl);
int (*go_xmote_bh)(struct gfs2_glock *gl);
void (*go_inval) (struct gfs2_glock *gl, int flags);
- int (*go_demote_ok) (const struct gfs2_glock *gl);
int (*go_instantiate) (struct gfs2_glock *gl);
int (*go_held)(struct gfs2_holder *gh);
void (*go_dump)(struct seq_file *seq, const struct gfs2_glock *gl,
--
2.44.0
next prev parent reply other threads:[~2024-04-09 16:45 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-09 16:44 [PATCH 00/15] gfs2 cleanups and fixes Andreas Gruenbacher
2024-04-09 16:44 ` [PATCH 01/15] gfs2: Get rid of newlines in log messages Andreas Gruenbacher
2024-04-09 16:44 ` [PATCH 02/15] gfs2: Remove unnecessary gfs2_meta_check_ii argument Andreas Gruenbacher
2024-04-09 16:44 ` [PATCH 03/15] gfs2: Follow-up to flag rename in sysfs status file Andreas Gruenbacher
2024-04-09 16:44 ` [PATCH 04/15] gfs2: Use [NO_]CREATE consistently for gfs2_glock_get Andreas Gruenbacher
2024-04-09 16:44 ` [PATCH 05/15] gfs2: Don't forget to complete delayed withdraw Andreas Gruenbacher
2024-04-09 16:44 ` [PATCH 06/15] gfs2: Fix NULL pointer dereference in gfs2_log_flush Andreas Gruenbacher
2024-04-09 16:44 ` [PATCH 07/15] gfs2: Get rid of gfs2_glock_queue_put in signal_our_withdraw Andreas Gruenbacher
2024-04-09 16:44 ` [PATCH 08/15] gfs2: Replace gfs2_glock_queue_put with gfs2_glock_put_async Andreas Gruenbacher
2024-04-09 16:44 ` [PATCH 09/15] gfs2: Don't set GLF_LOCK in gfs2_dispose_glock_lru Andreas Gruenbacher
2024-04-09 16:45 ` [PATCH 10/15] gfs2: Get rid of unnecessary test_and_set_bit Andreas Gruenbacher
2024-04-09 16:45 ` [PATCH 11/15] gfs2: Fix "ignore unlock failures after withdraw" Andreas Gruenbacher
2024-04-09 16:45 ` [PATCH 12/15] Revert "gfs2: fix glock shrinker ref issues" Andreas Gruenbacher
2024-04-09 16:45 ` [PATCH 13/15] gfs2: Fix "Make glock lru list scanning safer" Andreas Gruenbacher
2024-04-16 16:55 ` Andrew Price
2024-04-17 7:55 ` Andreas Gruenbacher
2024-04-09 16:45 ` Andreas Gruenbacher [this message]
2024-04-12 6:00 ` [PATCH 14/15] gfs2: Get rid of demote_ok checks Andreas Gruenbacher
2024-04-09 16:45 ` [PATCH 15/15] gfs2: Fix lru_count accounting Andreas Gruenbacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240409164508.79570-15-agruenba@redhat.com \
--to=agruenba@redhat.com \
--cc=gfs2@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).