aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2014-07-14 18:07:48 -0400
committerDave Chinner <david@fromorbit.com>2014-07-14 18:07:48 -0400
commit80d6d69821a27c3cd4687c2eefe409cbd1b7f458 (patch)
treed28f9bc82bf793fd1c0152ab82f4d6db12e9d102 /fs/xfs
parentbaff4e44b92aad363dcce176b907a369ee8b348e (diff)
xfs: add log attributes for log lsn and grant head data
Create log attributes to export the current runtime state of the log to sysfs. Note that the filesystem should be frozen for consistency across attributes. The following per-mount attributes are created: log_head_lsn, log_tail_lsn, reserve_grant_head and write_grant_head. These represent the physical log head, tail and reserve and write grant heads respectively. Attribute values are exported in the following format: "cycle:[block,byte]" ... where cycle represents the log cycle and [block,bytes] represents either the basic block or byte offset of the log, depending on the attribute. Log sequence number (LSN) values are encoded in basic blocks and grant heads are encoded in bytes. All values are in decimal format. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_sysfs.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
index 88361d76f73a..9835139ce1ec 100644
--- a/fs/xfs/xfs_sysfs.c
+++ b/fs/xfs/xfs_sysfs.c
@@ -53,7 +53,71 @@ struct kobj_type xfs_mp_ktype = {
53 53
54/* xlog */ 54/* xlog */
55 55
56STATIC ssize_t
57log_head_lsn_show(
58 char *buf,
59 void *data)
60{
61 struct xlog *log = data;
62 int cycle;
63 int block;
64
65 spin_lock(&log->l_icloglock);
66 cycle = log->l_curr_cycle;
67 block = log->l_curr_block;
68 spin_unlock(&log->l_icloglock);
69
70 return snprintf(buf, PAGE_SIZE, "%d:%d\n", cycle, block);
71}
72XFS_SYSFS_ATTR_RO(log_head_lsn);
73
74STATIC ssize_t
75log_tail_lsn_show(
76 char *buf,
77 void *data)
78{
79 struct xlog *log = data;
80 int cycle;
81 int block;
82
83 xlog_crack_atomic_lsn(&log->l_tail_lsn, &cycle, &block);
84 return snprintf(buf, PAGE_SIZE, "%d:%d\n", cycle, block);
85}
86XFS_SYSFS_ATTR_RO(log_tail_lsn);
87
88STATIC ssize_t
89reserve_grant_head_show(
90 char *buf,
91 void *data)
92{
93 struct xlog *log = data;
94 int cycle;
95 int bytes;
96
97 xlog_crack_grant_head(&log->l_reserve_head.grant, &cycle, &bytes);
98 return snprintf(buf, PAGE_SIZE, "%d:%d\n", cycle, bytes);
99}
100XFS_SYSFS_ATTR_RO(reserve_grant_head);
101
102STATIC ssize_t
103write_grant_head_show(
104 char *buf,
105 void *data)
106{
107 struct xlog *log = data;
108 int cycle;
109 int bytes;
110
111 xlog_crack_grant_head(&log->l_write_head.grant, &cycle, &bytes);
112 return snprintf(buf, PAGE_SIZE, "%d:%d\n", cycle, bytes);
113}
114XFS_SYSFS_ATTR_RO(write_grant_head);
115
56static struct attribute *xfs_log_attrs[] = { 116static struct attribute *xfs_log_attrs[] = {
117 ATTR_LIST(log_head_lsn),
118 ATTR_LIST(log_tail_lsn),
119 ATTR_LIST(reserve_grant_head),
120 ATTR_LIST(write_grant_head),
57 NULL, 121 NULL,
58}; 122};
59 123