diff options
author | Brian Foster <bfoster@redhat.com> | 2014-07-14 18:07:29 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2014-07-14 18:07:29 -0400 |
commit | baff4e44b92aad363dcce176b907a369ee8b348e (patch) | |
tree | 273b69069917ee59eeed0472b34a590a519c3b9b | |
parent | a31b1d3d89e40f585a1c6745b066774ee3263eb2 (diff) |
xfs: add xlog sysfs kobject and attribute handlers
Embed a kobject into the xfs log data structure (xlog). This creates a
'log' subdirectory for every XFS mount instance in sysfs. The lifecycle
of the log kobject is tied to the lifecycle of the log.
Also define a set of generic attribute handlers associated with the log
kobject in preparation for the addition of attributes.
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r-- | fs/xfs/xfs_log.c | 9 | ||||
-rw-r--r-- | fs/xfs/xfs_log_priv.h | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_sysfs.c | 52 | ||||
-rw-r--r-- | fs/xfs/xfs_sysfs.h | 1 |
4 files changed, 64 insertions, 0 deletions
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 7647818b8c8a..149a4a575a09 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include "xfs_trace.h" | 34 | #include "xfs_trace.h" |
35 | #include "xfs_fsops.h" | 35 | #include "xfs_fsops.h" |
36 | #include "xfs_cksum.h" | 36 | #include "xfs_cksum.h" |
37 | #include "xfs_sysfs.h" | ||
37 | 38 | ||
38 | kmem_zone_t *xfs_log_ticket_zone; | 39 | kmem_zone_t *xfs_log_ticket_zone; |
39 | 40 | ||
@@ -707,6 +708,11 @@ xfs_log_mount( | |||
707 | } | 708 | } |
708 | } | 709 | } |
709 | 710 | ||
711 | error = xfs_sysfs_init(&mp->m_log->l_kobj, &xfs_log_ktype, &mp->m_kobj, | ||
712 | "log"); | ||
713 | if (error) | ||
714 | goto out_destroy_ail; | ||
715 | |||
710 | /* Normal transactions can now occur */ | 716 | /* Normal transactions can now occur */ |
711 | mp->m_log->l_flags &= ~XLOG_ACTIVE_RECOVERY; | 717 | mp->m_log->l_flags &= ~XLOG_ACTIVE_RECOVERY; |
712 | 718 | ||
@@ -947,6 +953,9 @@ xfs_log_unmount( | |||
947 | xfs_log_quiesce(mp); | 953 | xfs_log_quiesce(mp); |
948 | 954 | ||
949 | xfs_trans_ail_destroy(mp); | 955 | xfs_trans_ail_destroy(mp); |
956 | |||
957 | xfs_sysfs_del(&mp->m_log->l_kobj); | ||
958 | |||
950 | xlog_dealloc_log(mp->m_log); | 959 | xlog_dealloc_log(mp->m_log); |
951 | } | 960 | } |
952 | 961 | ||
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index 9bc403a9e54f..db7cbdeb2b42 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h | |||
@@ -405,6 +405,8 @@ struct xlog { | |||
405 | struct xlog_grant_head l_reserve_head; | 405 | struct xlog_grant_head l_reserve_head; |
406 | struct xlog_grant_head l_write_head; | 406 | struct xlog_grant_head l_write_head; |
407 | 407 | ||
408 | struct xfs_kobj l_kobj; | ||
409 | |||
408 | /* The following field are used for debugging; need to hold icloglock */ | 410 | /* The following field are used for debugging; need to hold icloglock */ |
409 | #ifdef DEBUG | 411 | #ifdef DEBUG |
410 | char *l_iclog_bak[XLOG_MAX_ICLOGS]; | 412 | char *l_iclog_bak[XLOG_MAX_ICLOGS]; |
diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c index ae9aa7a1a06a..88361d76f73a 100644 --- a/fs/xfs/xfs_sysfs.c +++ b/fs/xfs/xfs_sysfs.c | |||
@@ -18,6 +18,9 @@ | |||
18 | 18 | ||
19 | #include "xfs.h" | 19 | #include "xfs.h" |
20 | #include "xfs_sysfs.h" | 20 | #include "xfs_sysfs.h" |
21 | #include "xfs_log_format.h" | ||
22 | #include "xfs_log.h" | ||
23 | #include "xfs_log_priv.h" | ||
21 | 24 | ||
22 | struct xfs_sysfs_attr { | 25 | struct xfs_sysfs_attr { |
23 | struct attribute attr; | 26 | struct attribute attr; |
@@ -47,3 +50,52 @@ to_attr(struct attribute *attr) | |||
47 | struct kobj_type xfs_mp_ktype = { | 50 | struct kobj_type xfs_mp_ktype = { |
48 | .release = xfs_sysfs_release, | 51 | .release = xfs_sysfs_release, |
49 | }; | 52 | }; |
53 | |||
54 | /* xlog */ | ||
55 | |||
56 | static struct attribute *xfs_log_attrs[] = { | ||
57 | NULL, | ||
58 | }; | ||
59 | |||
60 | static inline struct xlog * | ||
61 | to_xlog(struct kobject *kobject) | ||
62 | { | ||
63 | struct xfs_kobj *kobj = to_kobj(kobject); | ||
64 | return container_of(kobj, struct xlog, l_kobj); | ||
65 | } | ||
66 | |||
67 | STATIC ssize_t | ||
68 | xfs_log_show( | ||
69 | struct kobject *kobject, | ||
70 | struct attribute *attr, | ||
71 | char *buf) | ||
72 | { | ||
73 | struct xlog *log = to_xlog(kobject); | ||
74 | struct xfs_sysfs_attr *xfs_attr = to_attr(attr); | ||
75 | |||
76 | return xfs_attr->show ? xfs_attr->show(buf, log) : 0; | ||
77 | } | ||
78 | |||
79 | STATIC ssize_t | ||
80 | xfs_log_store( | ||
81 | struct kobject *kobject, | ||
82 | struct attribute *attr, | ||
83 | const char *buf, | ||
84 | size_t count) | ||
85 | { | ||
86 | struct xlog *log = to_xlog(kobject); | ||
87 | struct xfs_sysfs_attr *xfs_attr = to_attr(attr); | ||
88 | |||
89 | return xfs_attr->store ? xfs_attr->store(buf, count, log) : 0; | ||
90 | } | ||
91 | |||
92 | static struct sysfs_ops xfs_log_ops = { | ||
93 | .show = xfs_log_show, | ||
94 | .store = xfs_log_store, | ||
95 | }; | ||
96 | |||
97 | struct kobj_type xfs_log_ktype = { | ||
98 | .release = xfs_sysfs_release, | ||
99 | .sysfs_ops = &xfs_log_ops, | ||
100 | .default_attrs = xfs_log_attrs, | ||
101 | }; | ||
diff --git a/fs/xfs/xfs_sysfs.h b/fs/xfs/xfs_sysfs.h index 4bd5fff75d0f..54a2091183c0 100644 --- a/fs/xfs/xfs_sysfs.h +++ b/fs/xfs/xfs_sysfs.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #define __XFS_SYSFS_H__ | 20 | #define __XFS_SYSFS_H__ |
21 | 21 | ||
22 | extern struct kobj_type xfs_mp_ktype; /* xfs_mount */ | 22 | extern struct kobj_type xfs_mp_ktype; /* xfs_mount */ |
23 | extern struct kobj_type xfs_log_ktype; /* xlog */ | ||
23 | 24 | ||
24 | static inline struct xfs_kobj * | 25 | static inline struct xfs_kobj * |
25 | to_kobj(struct kobject *kobject) | 26 | to_kobj(struct kobject *kobject) |