Re: [Cluster-devel] [GFS2 PATCH] gfs2: Add new sysfs file for gfs2 status
- Original Message - > On 19/03/2021 12:06, Bob Peterson wrote: > > 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: > > > > Do non-root users need access to this? I'd be more comfortable with > 0400, following the principle of least privilege. > > Andy Hi Andy, Non-root users do not need access. I agree and I'll change it to 400. Bob
Re: [Cluster-devel] [GFS2 PATCH] gfs2: Add new sysfs file for gfs2 status
On 19/03/2021 12:06, Bob Peterson wrote: 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_lock held: 0 statfs_spin held: 0 sd_rindex_spin: 0 sd_jindex_spin: 0 sd_trunc_lock:0 sd_bitmap_lock: 0 sd_ordered_lock: 0 sd_ail_lock: 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 --- fs/gfs2/sys.c | 83 +++ 1 file changed, 83 insertions(+) diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index c3e72dba7418..57f53c13866e 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c @@ -63,6 +63,87 @@ static ssize_t id_show(struct gfs2_sbd *sdp, char *buf) MAJOR(sdp->sd_vfs->s_dev), MINOR(sdp->sd_vfs->s_dev)); } +static ssize_t status_show(struct gfs2_sbd *sdp, char *buf) +{ + unsigned long f = sdp->sd_flags; + ssize_t s; + + s = snprintf(buf, PAGE_SIZE, +"Journal Checked: %d\n" +"Journal Live: %d\n" +"Journal ID: %d\n" +"Spectator:%d\n" +"Withdrawn:%d\n" +"No barriers: %d\n" +"No recovery: %d\n" +"Demote: %d\n" +"No Journal ID:%d\n" +"Mounted RO: %d\n" +"RO Recovery: %d\n" +"Skip DLM Unlock: %d\n" +"Force AIL Flush: %d\n" +"FS Frozen:%d\n" +"Withdrawing: %d\n" +"Withdraw In Prog: %d\n" +"Remote Withdraw: %d\n" +"Withdraw Recovery:%d\n" +"sd_log_lock held: %d\n" +"statfs_spin held: %d\n" +"sd_rindex_spin: %d\n" +"sd_jindex_spin: %d\n" +"sd_trunc_lock:%d\n" +"sd_bitmap_lock: %d\n" +"sd_ordered_lock: %d\n" +"sd_ail_lock: %d\n" +"sd_log_error: %d\n" +"sd_log_flush_lock:%d\n" +"sd_log_num_revoke:%u\n" +"sd_log_in_flight: %d\n" +"sd_log_blks_needed: %d\n" +"sd_log_blks_free: %d\n" +"sd_log_flush_head:%d\n" +"sd_log_flush_tail:%d\n" +"sd_log_blks_reserved: %d\n" +"sd_log_revokes_available: %d\n", +test_bit(SDF_JOURNAL_CHECKED, ), +test_bit(SDF_JOURNAL_LIVE, ), +(sdp->sd_jdesc ? sdp->sd_jdesc->jd_jid : 0), +(sdp->sd_args.ar_spectator ? 1 : 0), +test_bit(SDF_WITHDRAWN, ), +test_bit(SDF_NOBARRIERS, ), +test_bit(SDF_NORECOVERY, ), +test_bit(SDF_DEMOTE, ), +test_bit(SDF_NOJOURNALID, ), +(sb_rdonly(sdp->sd_vfs) ? 1 : 0), +test_bit(SDF_RORECOVERY, ), +test_bit(SDF_SKIP_DLM_UNLOCK, ), +test_bit(SDF_FORCE_AIL_FLUSH, ), +test_bit(SDF_FS_FROZEN, ), +test_bit(SDF_WITHDRAWING, ), +test_bit(SDF_WITHDRAW_IN_PROG, ), +test_bit(SDF_REMOTE_WITHDRAW, ), +test_bit(SDF_WITHDRAW_RECOVERY, ), +spin_is_locked(>sd_log_lock), +spin_is_locked(>sd_statfs_spin), +spin_is_locked(>sd_rindex_spin), +spin_is_locked(>sd_jindex_spin), +
Re: [Cluster-devel] [GFS2 PATCH] gfs2: Add new sysfs file for gfs2 status
Hi, - Original Message - > On 19/03/2021 12:06, Bob Peterson wrote: > > 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: > > It looks like it might be missing some locking on some of those variables? > > Steve. Yes that's true, but the absence of locking is by design. The new sysfs file is only for debugging purposes, mostly to help us debug livelocks and deadlocks. But in deadlock situations, it's quite likely you won't be able to acquire the proper locks. Hopefully this new file may be captured by sos reports at some point, or checked by insights rules, and we can't have those things deadlocking. The way I see it, it's better to get possibly inaccurate values than to have your access of the sysfs file deadlock itself. Partial information is better than no information, if you see what I mean. At least we can tell if things are still changing and the status of the locks, and such. In previous incarnations of this patch, I dumped the ail lists, which is also valuable, but to do that, we absolutely need the locking to ensure we don't access freed memory and such. This version avoids all that possibility, so the locking isn't as important. Unless, of course, I'm failing to take something into account. Regards, Bob Peterson
Re: [Cluster-devel] [GFS2 PATCH] gfs2: Add new sysfs file for gfs2 status
On 19/03/2021 12:06, Bob Peterson wrote: 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_lock held: 0 statfs_spin held: 0 sd_rindex_spin: 0 sd_jindex_spin: 0 sd_trunc_lock:0 sd_bitmap_lock: 0 sd_ordered_lock: 0 sd_ail_lock: 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 It looks like it might be missing some locking on some of those variables? Steve. --- fs/gfs2/sys.c | 83 +++ 1 file changed, 83 insertions(+) diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index c3e72dba7418..57f53c13866e 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c @@ -63,6 +63,87 @@ static ssize_t id_show(struct gfs2_sbd *sdp, char *buf) MAJOR(sdp->sd_vfs->s_dev), MINOR(sdp->sd_vfs->s_dev)); } +static ssize_t status_show(struct gfs2_sbd *sdp, char *buf) +{ + unsigned long f = sdp->sd_flags; + ssize_t s; + + s = snprintf(buf, PAGE_SIZE, +"Journal Checked: %d\n" +"Journal Live: %d\n" +"Journal ID: %d\n" +"Spectator:%d\n" +"Withdrawn:%d\n" +"No barriers: %d\n" +"No recovery: %d\n" +"Demote: %d\n" +"No Journal ID:%d\n" +"Mounted RO: %d\n" +"RO Recovery: %d\n" +"Skip DLM Unlock: %d\n" +"Force AIL Flush: %d\n" +"FS Frozen:%d\n" +"Withdrawing: %d\n" +"Withdraw In Prog: %d\n" +"Remote Withdraw: %d\n" +"Withdraw Recovery:%d\n" +"sd_log_lock held: %d\n" +"statfs_spin held: %d\n" +"sd_rindex_spin: %d\n" +"sd_jindex_spin: %d\n" +"sd_trunc_lock:%d\n" +"sd_bitmap_lock: %d\n" +"sd_ordered_lock: %d\n" +"sd_ail_lock: %d\n" +"sd_log_error: %d\n" +"sd_log_flush_lock:%d\n" +"sd_log_num_revoke:%u\n" +"sd_log_in_flight: %d\n" +"sd_log_blks_needed: %d\n" +"sd_log_blks_free: %d\n" +"sd_log_flush_head:%d\n" +"sd_log_flush_tail:%d\n" +"sd_log_blks_reserved: %d\n" +"sd_log_revokes_available: %d\n", +test_bit(SDF_JOURNAL_CHECKED, ), +test_bit(SDF_JOURNAL_LIVE, ), +(sdp->sd_jdesc ? sdp->sd_jdesc->jd_jid : 0), +(sdp->sd_args.ar_spectator ? 1 : 0), +test_bit(SDF_WITHDRAWN, ), +test_bit(SDF_NOBARRIERS, ), +test_bit(SDF_NORECOVERY, ), +test_bit(SDF_DEMOTE, ), +test_bit(SDF_NOJOURNALID, ), +(sb_rdonly(sdp->sd_vfs) ? 1 : 0), +test_bit(SDF_RORECOVERY, ), +test_bit(SDF_SKIP_DLM_UNLOCK, ), +test_bit(SDF_FORCE_AIL_FLUSH, ), +test_bit(SDF_FS_FROZEN, ), +test_bit(SDF_WITHDRAWING, ), +test_bit(SDF_WITHDRAW_IN_PROG, ), +test_bit(SDF_REMOTE_WITHDRAW, ), +test_bit(SDF_WITHDRAW_RECOVERY, ), +spin_is_locked(>sd_log_lock), +spin_is_locked(>sd_statfs_spin), +