Skip to content

Commit ca68787

Browse files
committed
Merge tag 'gfs2-for-5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2
Pull gfs2 updates from Andreas Gruenbacher: - An iopen glock locking scheme rework that speeds up deletes of inodes accessed from multiple nodes - Various bug fixes and debugging improvements - Convert gfs2-glocks.txt to ReST * tag 'gfs2-for-5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2: gfs2: fix use-after-free on transaction ail lists gfs2: new slab for transactions gfs2: initialize transaction tr_ailX_lists earlier gfs2: Smarter iopen glock waiting gfs2: Wake up when setting GLF_DEMOTE gfs2: Check inode generation number in delete_work_func gfs2: Move inode generation number check into gfs2_inode_lookup gfs2: Minor gfs2_lookup_by_inum cleanup gfs2: Try harder to delete inodes locally gfs2: Give up the iopen glock on contention gfs2: Turn gl_delete into a delayed work gfs2: Keep track of deleted inode generations in LVBs gfs2: Allow ASPACE glocks to also have an lvb gfs2: instrumentation wrt log_flush stuck gfs2: introduce new gfs2_glock_assert_withdraw gfs2: print mapping->nrpages in glock dump for address space glocks gfs2: Only do glock put in gfs2_create_inode for free inodes gfs2: Allow lock_nolock mount to specify jid=X gfs2: Don't ignore inode write errors during inode_go_sync docs: filesystems: convert gfs2-glocks.txt to ReST
2 parents 23fc02e + 300e549 commit ca68787

20 files changed

Lines changed: 489 additions & 141 deletions

File tree

Lines changed: 85 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
Glock internal locking rules
2-
------------------------------
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
============================
4+
Glock internal locking rules
5+
============================
36

47
This documents the basic principles of the glock state machine
58
internals. Each glock (struct gfs2_glock in fs/gfs2/incore.h)
@@ -24,46 +27,52 @@ There are three lock states that users of the glock layer can request,
2427
namely shared (SH), deferred (DF) and exclusive (EX). Those translate
2528
to the following DLM lock modes:
2629

27-
Glock mode | DLM lock mode
28-
------------------------------
29-
UN | IV/NL Unlocked (no DLM lock associated with glock) or NL
30-
SH | PR (Protected read)
31-
DF | CW (Concurrent write)
32-
EX | EX (Exclusive)
30+
========== ====== =====================================================
31+
Glock mode DLM lock mode
32+
========== ====== =====================================================
33+
UN IV/NL Unlocked (no DLM lock associated with glock) or NL
34+
SH PR (Protected read)
35+
DF CW (Concurrent write)
36+
EX EX (Exclusive)
37+
========== ====== =====================================================
3338

3439
Thus DF is basically a shared mode which is incompatible with the "normal"
3540
shared lock mode, SH. In GFS2 the DF mode is used exclusively for direct I/O
3641
operations. The glocks are basically a lock plus some routines which deal
3742
with cache management. The following rules apply for the cache:
3843

39-
Glock mode | Cache data | Cache Metadata | Dirty Data | Dirty Metadata
40-
--------------------------------------------------------------------------
41-
UN | No | No | No | No
42-
SH | Yes | Yes | No | No
43-
DF | No | Yes | No | No
44-
EX | Yes | Yes | Yes | Yes
44+
========== ========== ============== ========== ==============
45+
Glock mode Cache data Cache Metadata Dirty Data Dirty Metadata
46+
========== ========== ============== ========== ==============
47+
UN No No No No
48+
SH Yes Yes No No
49+
DF No Yes No No
50+
EX Yes Yes Yes Yes
51+
========== ========== ============== ========== ==============
4552

4653
These rules are implemented using the various glock operations which
4754
are defined for each type of glock. Not all types of glocks use
4855
all the modes. Only inode glocks use the DF mode for example.
4956

5057
Table of glock operations and per type constants:
5158

52-
Field | Purpose
53-
----------------------------------------------------------------------------
54-
go_xmote_th | Called before remote state change (e.g. to sync dirty data)
55-
go_xmote_bh | Called after remote state change (e.g. to refill cache)
56-
go_inval | Called if remote state change requires invalidating the cache
57-
go_demote_ok | Returns boolean value of whether its ok to demote a glock
58-
| (e.g. checks timeout, and that there is no cached data)
59-
go_lock | Called for the first local holder of a lock
60-
go_unlock | Called on the final local unlock of a lock
61-
go_dump | Called to print content of object for debugfs file, or on
62-
| error to dump glock to the log.
63-
go_type | The type of the glock, LM_TYPE_.....
64-
go_callback | Called if the DLM sends a callback to drop this lock
65-
go_flags | GLOF_ASPACE is set, if the glock has an address space
66-
| associated with it
59+
============= =============================================================
60+
Field Purpose
61+
============= =============================================================
62+
go_xmote_th Called before remote state change (e.g. to sync dirty data)
63+
go_xmote_bh Called after remote state change (e.g. to refill cache)
64+
go_inval Called if remote state change requires invalidating the cache
65+
go_demote_ok Returns boolean value of whether its ok to demote a glock
66+
(e.g. checks timeout, and that there is no cached data)
67+
go_lock Called for the first local holder of a lock
68+
go_unlock Called on the final local unlock of a lock
69+
go_dump Called to print content of object for debugfs file, or on
70+
error to dump glock to the log.
71+
go_type The type of the glock, ``LM_TYPE_*``
72+
go_callback Called if the DLM sends a callback to drop this lock
73+
go_flags GLOF_ASPACE is set, if the glock has an address space
74+
associated with it
75+
============= =============================================================
6776

6877
The minimum hold time for each lock is the time after a remote lock
6978
grant for which we ignore remote demote requests. This is in order to
@@ -82,29 +91,33 @@ rather than via the glock.
8291

8392
Locking rules for glock operations:
8493

85-
Operation | GLF_LOCK bit lock held | gl_lockref.lock spinlock held
86-
-------------------------------------------------------------------------
87-
go_xmote_th | Yes | No
88-
go_xmote_bh | Yes | No
89-
go_inval | Yes | No
90-
go_demote_ok | Sometimes | Yes
91-
go_lock | Yes | No
92-
go_unlock | Yes | No
93-
go_dump | Sometimes | Yes
94-
go_callback | Sometimes (N/A) | Yes
95-
96-
N.B. Operations must not drop either the bit lock or the spinlock
97-
if its held on entry. go_dump and do_demote_ok must never block.
98-
Note that go_dump will only be called if the glock's state
99-
indicates that it is caching uptodate data.
94+
============= ====================== =============================
95+
Operation GLF_LOCK bit lock held gl_lockref.lock spinlock held
96+
============= ====================== =============================
97+
go_xmote_th Yes No
98+
go_xmote_bh Yes No
99+
go_inval Yes No
100+
go_demote_ok Sometimes Yes
101+
go_lock Yes No
102+
go_unlock Yes No
103+
go_dump Sometimes Yes
104+
go_callback Sometimes (N/A) Yes
105+
============= ====================== =============================
106+
107+
.. Note::
108+
109+
Operations must not drop either the bit lock or the spinlock
110+
if its held on entry. go_dump and do_demote_ok must never block.
111+
Note that go_dump will only be called if the glock's state
112+
indicates that it is caching uptodate data.
100113

101114
Glock locking order within GFS2:
102115

103116
1. i_rwsem (if required)
104117
2. Rename glock (for rename only)
105118
3. Inode glock(s)
106119
(Parents before children, inodes at "same level" with same parent in
107-
lock number order)
120+
lock number order)
108121
4. Rgrp glock(s) (for (de)allocation operations)
109122
5. Transaction glock (via gfs2_trans_begin) for non-read operations
110123
6. i_rw_mutex (if required)
@@ -117,8 +130,8 @@ determine the lifetime of the inode in question. Locking of inodes
117130
is on a per-inode basis. Locking of rgrps is on a per rgrp basis.
118131
In general we prefer to lock local locks prior to cluster locks.
119132

120-
Glock Statistics
121-
------------------
133+
Glock Statistics
134+
----------------
122135

123136
The stats are divided into two sets: those relating to the
124137
super block and those relating to an individual glock. The
@@ -173,8 +186,8 @@ we'd like to get a better idea of these timings:
173186
1. To be able to better set the glock "min hold time"
174187
2. To spot performance issues more easily
175188
3. To improve the algorithm for selecting resource groups for
176-
allocation (to base it on lock wait time, rather than blindly
177-
using a "try lock")
189+
allocation (to base it on lock wait time, rather than blindly
190+
using a "try lock")
178191

179192
Due to the smoothing action of the updates, a step change in
180193
some input quantity being sampled will only fully be taken
@@ -195,25 +208,30 @@ as possible. There are always inaccuracies in any
195208
measuring system, but I hope this is as accurate as we
196209
can reasonably make it.
197210

198-
Per sb stats can be found here:
199-
/sys/kernel/debug/gfs2/<fsname>/sbstats
200-
Per glock stats can be found here:
201-
/sys/kernel/debug/gfs2/<fsname>/glstats
211+
Per sb stats can be found here::
212+
213+
/sys/kernel/debug/gfs2/<fsname>/sbstats
214+
215+
Per glock stats can be found here::
216+
217+
/sys/kernel/debug/gfs2/<fsname>/glstats
202218

203219
Assuming that debugfs is mounted on /sys/kernel/debug and also
204220
that <fsname> is replaced with the name of the gfs2 filesystem
205221
in question.
206222

207223
The abbreviations used in the output as are follows:
208224

209-
srtt - Smoothed round trip time for non-blocking dlm requests
210-
srttvar - Variance estimate for srtt
211-
srttb - Smoothed round trip time for (potentially) blocking dlm requests
212-
srttvarb - Variance estimate for srttb
213-
sirt - Smoothed inter-request time (for dlm requests)
214-
sirtvar - Variance estimate for sirt
215-
dlm - Number of dlm requests made (dcnt in glstats file)
216-
queue - Number of glock requests queued (qcnt in glstats file)
225+
========= ================================================================
226+
srtt Smoothed round trip time for non blocking dlm requests
227+
srttvar Variance estimate for srtt
228+
srttb Smoothed round trip time for (potentially) blocking dlm requests
229+
srttvarb Variance estimate for srttb
230+
sirt Smoothed inter request time (for dlm requests)
231+
sirtvar Variance estimate for sirt
232+
dlm Number of dlm requests made (dcnt in glstats file)
233+
queue Number of glock requests queued (qcnt in glstats file)
234+
========= ================================================================
217235

218236
The sbstats file contains a set of these stats for each glock type (so 8 lines
219237
for each type) and for each cpu (one column per cpu). The glstats file contains
@@ -224,9 +242,12 @@ The gfs2_glock_lock_time tracepoint prints out the current values of the stats
224242
for the glock in question, along with some addition information on each dlm
225243
reply that is received:
226244

227-
status - The status of the dlm request
228-
flags - The dlm request flags
229-
tdiff - The time taken by this specific request
245+
====== =======================================
246+
status The status of the dlm request
247+
flags The dlm request flags
248+
tdiff The time taken by this specific request
249+
====== =======================================
250+
230251
(remaining fields as per above list)
231252

232253

‎Documentation/filesystems/index.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ Documentation for filesystem implementations.
8888
f2fs
8989
gfs2
9090
gfs2-uevents
91+
gfs2-glocks
9192
hfs
9293
hfsplus
9394
hpfs

‎MAINTAINERS‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7251,7 +7251,7 @@ L: cluster-devel@redhat.com
72517251
S: Supported
72527252
W: http://sources.redhat.com/cluster/
72537253
T: git git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git
7254-
F: Documentation/filesystems/gfs2*.txt
7254+
F: Documentation/filesystems/gfs2*
72557255
F: fs/gfs2/
72567256
F: include/uapi/linux/gfs2_ondisk.h
72577257

‎fs/gfs2/export.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ static struct dentry *gfs2_get_dentry(struct super_block *sb,
134134
struct gfs2_sbd *sdp = sb->s_fs_info;
135135
struct inode *inode;
136136

137-
inode = gfs2_lookup_by_inum(sdp, inum->no_addr, &inum->no_formal_ino,
137+
if (!inum->no_formal_ino)
138+
return ERR_PTR(-ESTALE);
139+
inode = gfs2_lookup_by_inum(sdp, inum->no_addr, inum->no_formal_ino,
138140
GFS2_BLKST_DINODE);
139141
if (IS_ERR(inode))
140142
return ERR_CAST(inode);

0 commit comments

Comments
 (0)