Skip to content

Commit 9f9eb5a

Browse files
AstralBobAndreas Gruenbacher
authored andcommitted
gfs2: Add new sysfs file for gfs2 status
This patch adds a new file: /sys/fs/gfs2/*/status which will report the status of the file system. Catting this file dumps the current status of the file system according to various superblock variables. For example: Journal Checked: 1 Journal Live: 1 Journal ID: 0 Spectator: 0 Withdrawn: 0 No barriers: 0 No recovery: 0 Demote: 0 No Journal ID: 1 Mounted RO: 0 RO Recovery: 0 Skip DLM Unlock: 0 Force AIL Flush: 0 FS Frozen: 0 Withdrawing: 0 Withdraw In Prog: 0 Remote Withdraw: 0 Withdraw Recovery: 0 sd_log_error: 0 sd_log_flush_lock: 0 sd_log_num_revoke: 0 sd_log_in_flight: 0 sd_log_blks_needed: 0 sd_log_blks_free: 32768 sd_log_flush_head: 0 sd_log_flush_tail: 5384 sd_log_blks_reserved: 0 sd_log_revokes_available: 503 Signed-off-by: Bob Peterson <[email protected]> Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent bea906e commit 9f9eb5a

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

fs/gfs2/sys.c

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,71 @@ static ssize_t id_show(struct gfs2_sbd *sdp, char *buf)
6363
MAJOR(sdp->sd_vfs->s_dev), MINOR(sdp->sd_vfs->s_dev));
6464
}
6565

66+
static ssize_t status_show(struct gfs2_sbd *sdp, char *buf)
67+
{
68+
unsigned long f = sdp->sd_flags;
69+
ssize_t s;
70+
71+
s = snprintf(buf, PAGE_SIZE,
72+
"Journal Checked: %d\n"
73+
"Journal Live: %d\n"
74+
"Journal ID: %d\n"
75+
"Spectator: %d\n"
76+
"Withdrawn: %d\n"
77+
"No barriers: %d\n"
78+
"No recovery: %d\n"
79+
"Demote: %d\n"
80+
"No Journal ID: %d\n"
81+
"Mounted RO: %d\n"
82+
"RO Recovery: %d\n"
83+
"Skip DLM Unlock: %d\n"
84+
"Force AIL Flush: %d\n"
85+
"FS Frozen: %d\n"
86+
"Withdrawing: %d\n"
87+
"Withdraw In Prog: %d\n"
88+
"Remote Withdraw: %d\n"
89+
"Withdraw Recovery: %d\n"
90+
"sd_log_error: %d\n"
91+
"sd_log_flush_lock: %d\n"
92+
"sd_log_num_revoke: %u\n"
93+
"sd_log_in_flight: %d\n"
94+
"sd_log_blks_needed: %d\n"
95+
"sd_log_blks_free: %d\n"
96+
"sd_log_flush_head: %d\n"
97+
"sd_log_flush_tail: %d\n"
98+
"sd_log_blks_reserved: %d\n"
99+
"sd_log_revokes_available: %d\n",
100+
test_bit(SDF_JOURNAL_CHECKED, &f),
101+
test_bit(SDF_JOURNAL_LIVE, &f),
102+
(sdp->sd_jdesc ? sdp->sd_jdesc->jd_jid : 0),
103+
(sdp->sd_args.ar_spectator ? 1 : 0),
104+
test_bit(SDF_WITHDRAWN, &f),
105+
test_bit(SDF_NOBARRIERS, &f),
106+
test_bit(SDF_NORECOVERY, &f),
107+
test_bit(SDF_DEMOTE, &f),
108+
test_bit(SDF_NOJOURNALID, &f),
109+
(sb_rdonly(sdp->sd_vfs) ? 1 : 0),
110+
test_bit(SDF_RORECOVERY, &f),
111+
test_bit(SDF_SKIP_DLM_UNLOCK, &f),
112+
test_bit(SDF_FORCE_AIL_FLUSH, &f),
113+
test_bit(SDF_FS_FROZEN, &f),
114+
test_bit(SDF_WITHDRAWING, &f),
115+
test_bit(SDF_WITHDRAW_IN_PROG, &f),
116+
test_bit(SDF_REMOTE_WITHDRAW, &f),
117+
test_bit(SDF_WITHDRAW_RECOVERY, &f),
118+
sdp->sd_log_error,
119+
rwsem_is_locked(&sdp->sd_log_flush_lock),
120+
sdp->sd_log_num_revoke,
121+
atomic_read(&sdp->sd_log_in_flight),
122+
atomic_read(&sdp->sd_log_blks_needed),
123+
atomic_read(&sdp->sd_log_blks_free),
124+
sdp->sd_log_flush_head,
125+
sdp->sd_log_flush_tail,
126+
sdp->sd_log_blks_reserved,
127+
atomic_read(&sdp->sd_log_revokes_available));
128+
return s;
129+
}
130+
66131
static ssize_t fsname_show(struct gfs2_sbd *sdp, char *buf)
67132
{
68133
return snprintf(buf, PAGE_SIZE, "%s\n", sdp->sd_fsname);
@@ -283,6 +348,7 @@ GFS2_ATTR(quota_sync, 0200, NULL, quota_sync_store);
283348
GFS2_ATTR(quota_refresh_user, 0200, NULL, quota_refresh_user_store);
284349
GFS2_ATTR(quota_refresh_group, 0200, NULL, quota_refresh_group_store);
285350
GFS2_ATTR(demote_rq, 0200, NULL, demote_rq_store);
351+
GFS2_ATTR(status, 0400, status_show, NULL);
286352

287353
static struct attribute *gfs2_attrs[] = {
288354
&gfs2_attr_id.attr,
@@ -295,6 +361,7 @@ static struct attribute *gfs2_attrs[] = {
295361
&gfs2_attr_quota_refresh_user.attr,
296362
&gfs2_attr_quota_refresh_group.attr,
297363
&gfs2_attr_demote_rq.attr,
364+
&gfs2_attr_status.attr,
298365
NULL,
299366
};
300367
ATTRIBUTE_GROUPS(gfs2);

0 commit comments

Comments
 (0)