gfs2: Add new sysfs file for gfs2 status
PATCH 1/1 gfs2: Add new sysfs file for gfs2 status
In reply to a message not in the archiveThis 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
--- fs/gfs2/sys.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+)
fs/gfs2/sys.c +83 -0
@@ -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 , &f), +test_bit (SDF_JOURNAL_LIVE , &f), + (sdp->sd_jdesc ? sdp->sd_jdesc->jd_jid :0 ), + (sdp->sd_args.ar_spectator ?1 :0 ), +test_bit (SDF_WITHDRAWN , &f), +test_bit (SDF_NOBARRIERS , &f), +test_bit (SDF_NORECOVERY , &f), +test_bit (SDF_DEMOTE , &f), +test_bit (SDF_NOJOURNALID , &f), + (sb_rdonly (sdp->sd_vfs) ?1 :0 ), +test_bit (SDF_RORECOVERY , &f), +test_bit (SDF_SKIP_DLM_UNLOCK , &f), +test_bit (SDF_FORCE_AIL_FLUSH , &f), +test_bit (SDF_FS_FROZEN , &f), +test_bit (SDF_WITHDRAWING , &f), +test_bit (SDF_WITHDRAW_IN_PROG , &f), +test_bit (SDF_REMOTE_WITHDRAW , &f), +test_bit (SDF_WITHDRAW_RECOVERY , &f), +spin_is_locked (&sdp->sd_log_lock), +spin_is_locked (&sdp->sd_statfs_spin), +spin_is_locked (&sdp->sd_rindex_spin), +spin_is_locked (&sdp->sd_jindex_spin), +spin_is_locked (&sdp->sd_trunc_lock), +spin_is_locked (&sdp->sd_bitmap_lock), +spin_is_locked (&sdp->sd_ordered_lock), +spin_is_locked (&sdp->sd_ail_lock), + sdp->sd_log_error, +rwsem_is_locked (&sdp->sd_log_flush_lock), + sdp->sd_log_num_revoke, +atomic_read (&sdp->sd_log_in_flight), +atomic_read (&sdp->sd_log_blks_needed), +atomic_read (&sdp->sd_log_blks_free), + sdp->sd_log_flush_head, + sdp->sd_log_flush_tail, + sdp->sd_log_blks_reserved, +atomic_read (&sdp->sd_log_revokes_available)); +return s; +} +static ssize_t fsname_show (struct gfs2_sbd *sdp,char *buf) {return snprintf (buf,PAGE_SIZE ,"%s\n" , sdp->sd_fsname);
@@ -283,6 +364,7 @@ GFS2_ATTR(quota_sync, 0200, NULL, quota_sync_store);GFS2_ATTR (quota_refresh_user,0200 ,NULL , quota_refresh_user_store);GFS2_ATTR (quota_refresh_group,0200 ,NULL , quota_refresh_group_store);GFS2_ATTR (demote_rq,0200 ,NULL , demote_rq_store); +GFS2_ATTR (status,0444 , status_show,NULL );static struct attribute *gfs2_attrs[] = { &gfs2_attr_id.attr,
@@ -295,6 +377,7 @@ static struct attribute *gfs2_attrs[] = { &gfs2_attr_quota_refresh_user.attr, &gfs2_attr_quota_refresh_group.attr, &gfs2_attr_demote_rq.attr, + &gfs2_attr_status.attr,NULL , };ATTRIBUTE_GROUPS (gfs2);
PATCH 1/1 gfs2: Add new sysfs file for gfs2 status
Quoted 42 lines · Bob Peterson
This patch adds a new file:
/sys/fs/gfs2/*/statuswhich 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
Quoted 1 line
Signed-off-by Bob Peterson <[email protected]>
It looks like it might be missing some locking on some of those variables?
Steve.
Quoted 113 lines
--- fs/gfs2/sys.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+)fs/gfs2/sys.c +83
-0@@ -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 , &f), +test_bit (SDF_JOURNAL_LIVE , &f), + (sdp->sd_jdesc ? sdp->sd_jdesc->jd_jid :0 ), + (sdp->sd_args.ar_spectator ?1 :0 ), +test_bit (SDF_WITHDRAWN , &f), +test_bit (SDF_NOBARRIERS , &f), +test_bit (SDF_NORECOVERY , &f), +test_bit (SDF_DEMOTE , &f), +test_bit (SDF_NOJOURNALID , &f), + (sb_rdonly (sdp->sd_vfs) ?1 :0 ), +test_bit (SDF_RORECOVERY , &f), +test_bit (SDF_SKIP_DLM_UNLOCK , &f), +test_bit (SDF_FORCE_AIL_FLUSH , &f), +test_bit (SDF_FS_FROZEN , &f), +test_bit (SDF_WITHDRAWING , &f), +test_bit (SDF_WITHDRAW_IN_PROG , &f), +test_bit (SDF_REMOTE_WITHDRAW , &f), +test_bit (SDF_WITHDRAW_RECOVERY , &f), +spin_is_locked (&sdp->sd_log_lock), +spin_is_locked (&sdp->sd_statfs_spin), +spin_is_locked (&sdp->sd_rindex_spin), +spin_is_locked (&sdp->sd_jindex_spin), +spin_is_locked (&sdp->sd_trunc_lock), +spin_is_locked (&sdp->sd_bitmap_lock), +spin_is_locked (&sdp->sd_ordered_lock), +spin_is_locked (&sdp->sd_ail_lock), + sdp->sd_log_error, +rwsem_is_locked (&sdp->sd_log_flush_lock), + sdp->sd_log_num_revoke, +atomic_read (&sdp->sd_log_in_flight), +atomic_read (&sdp->sd_log_blks_needed), +atomic_read (&sdp->sd_log_blks_free), + sdp->sd_log_flush_head, + sdp->sd_log_flush_tail, + sdp->sd_log_blks_reserved, +atomic_read (&sdp->sd_log_revokes_available)); +return s; +} +static ssize_t fsname_show (struct gfs2_sbd *sdp,char *buf) {return snprintf (buf,PAGE_SIZE ,"%s\n" , sdp->sd_fsname);@@ -283,6 +364,7 @@ GFS2_ATTR(quota_sync, 0200, NULL, quota_sync_store);GFS2_ATTR (quota_refresh_user,0200 ,NULL , quota_refresh_user_store);GFS2_ATTR (quota_refresh_group,0200 ,NULL , quota_refresh_group_store);GFS2_ATTR (demote_rq,0200 ,NULL , demote_rq_store); +GFS2_ATTR (status,0444 , status_show,NULL );static struct attribute *gfs2_attrs[] = { &gfs2_attr_id.attr,@@ -295,6 +377,7 @@ static struct attribute *gfs2_attrs[] = { &gfs2_attr_quota_refresh_user.attr, &gfs2_attr_quota_refresh_group.attr, &gfs2_attr_demote_rq.attr, + &gfs2_attr_status.attr,NULL , };ATTRIBUTE_GROUPS (gfs2);
PATCH 1/1 gfs2: Add new sysfs file for gfs2 status
Hi,
----- Original Message -----
Quoted 9 lines · Bob Peterson
Quoted 4 lines
This patch adds a new file:
/sys/fs/gfs2/*/statuswhich 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
PATCH 1/1 gfs2: Add new sysfs file for gfs2 status
In reply to Bob PetersonQuoted 140 lines · Bob Peterson
This patch adds a new file:
/sys/fs/gfs2/*/statuswhich 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: 503Signed-off-by Bob Peterson <[email protected]>--- fs/gfs2/sys.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+)fs/gfs2/sys.c +81
-0@@ -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 , &f), +test_bit (SDF_JOURNAL_LIVE , &f), + (sdp->sd_jdesc ? sdp->sd_jdesc->jd_jid :0 ), + (sdp->sd_args.ar_spectator ?1 :0 ), +test_bit (SDF_WITHDRAWN , &f), +test_bit (SDF_NOBARRIERS , &f), +test_bit (SDF_NORECOVERY , &f), +test_bit (SDF_DEMOTE , &f), +test_bit (SDF_NOJOURNALID , &f), + (sb_rdonly (sdp->sd_vfs) ?1 :0 ), +test_bit (SDF_RORECOVERY , &f), +test_bit (SDF_SKIP_DLM_UNLOCK , &f), +test_bit (SDF_FORCE_AIL_FLUSH , &f), +test_bit (SDF_FS_FROZEN , &f), +test_bit (SDF_WITHDRAWING , &f), +test_bit (SDF_WITHDRAW_IN_PROG , &f), +test_bit (SDF_REMOTE_WITHDRAW , &f), +test_bit (SDF_WITHDRAW_RECOVERY , &f), +spin_is_locked (&sdp->sd_log_lock), +spin_is_locked (&sdp->sd_statfs_spin), +spin_is_locked (&sdp->sd_rindex_spin), +spin_is_locked (&sdp->sd_jindex_spin), +spin_is_locked (&sdp->sd_trunc_lock), +spin_is_locked (&sdp->sd_bitmap_lock), +spin_is_locked (&sdp->sd_ordered_lock), +spin_is_locked (&sdp->sd_ail_lock), + sdp->sd_log_error, +rwsem_is_locked (&sdp->sd_log_flush_lock), + sdp->sd_log_num_revoke, +atomic_read (&sdp->sd_log_in_flight), +atomic_read (&sdp->sd_log_blks_needed), +atomic_read (&sdp->sd_log_blks_free), + sdp->sd_log_flush_head, + sdp->sd_log_flush_tail, + sdp->sd_log_blks_reserved, +atomic_read (&sdp->sd_log_revokes_available)); +return s; +} +static ssize_t fsname_show (struct gfs2_sbd *sdp,char *buf) {return snprintf (buf,PAGE_SIZE ,"%s\n" , sdp->sd_fsname);
fs/gfs2/sys.c GFS2_ATTR(quota_sync, 0200, NULL, quota_sync_store); · line 367
Quoted 4 lines
fs/gfs2/sys.c +1
-0@@ -283,6 +364,7 @@ GFS2_ATTR(quota_sync, 0200, NULL, quota_sync_store);GFS2_ATTR (quota_refresh_user,0200 ,NULL , quota_refresh_user_store);GFS2_ATTR (quota_refresh_group,0200 ,NULL , quota_refresh_group_store);GFS2_ATTR (demote_rq,0200 ,NULL , demote_rq_store); +GFS2_ATTR (status,0444 , status_show,NULL );
Do non-root users need access to this? I'd be more comfortable with 0400, following the principle of least privilege.
Andy
Quoted 12 lines
fs/gfs2/sys.c +1
-0static struct attribute *gfs2_attrs[] = { &gfs2_attr_id.attr,@@ -295,6 +377,7 @@ static struct attribute *gfs2_attrs[] = { &gfs2_attr_quota_refresh_user.attr, &gfs2_attr_quota_refresh_group.attr, &gfs2_attr_demote_rq.attr, + &gfs2_attr_status.attr,NULL , };ATTRIBUTE_GROUPS (gfs2);
PATCH 1/1 gfs2: Add new sysfs file for gfs2 status
----- Original Message -----
Quoted 11 lines · Bob Peterson
Quoted 5 lines
This patch adds a new file:
/sys/fs/gfs2/*/statuswhich 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