Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Brian Foster and committed by
Dave Chinner
baff4e44 a31b1d3d

+64
+9
fs/xfs/xfs_log.c
··· 34 34 #include "xfs_trace.h" 35 35 #include "xfs_fsops.h" 36 36 #include "xfs_cksum.h" 37 + #include "xfs_sysfs.h" 37 38 38 39 kmem_zone_t *xfs_log_ticket_zone; 39 40 ··· 708 707 } 709 708 } 710 709 710 + error = xfs_sysfs_init(&mp->m_log->l_kobj, &xfs_log_ktype, &mp->m_kobj, 711 + "log"); 712 + if (error) 713 + goto out_destroy_ail; 714 + 711 715 /* Normal transactions can now occur */ 712 716 mp->m_log->l_flags &= ~XLOG_ACTIVE_RECOVERY; 713 717 ··· 953 947 xfs_log_quiesce(mp); 954 948 955 949 xfs_trans_ail_destroy(mp); 950 + 951 + xfs_sysfs_del(&mp->m_log->l_kobj); 952 + 956 953 xlog_dealloc_log(mp->m_log); 957 954 } 958 955
+2
fs/xfs/xfs_log_priv.h
··· 405 405 struct xlog_grant_head l_reserve_head; 406 406 struct xlog_grant_head l_write_head; 407 407 408 + struct xfs_kobj l_kobj; 409 + 408 410 /* The following field are used for debugging; need to hold icloglock */ 409 411 #ifdef DEBUG 410 412 char *l_iclog_bak[XLOG_MAX_ICLOGS];
+52
fs/xfs/xfs_sysfs.c
··· 18 18 19 19 #include "xfs.h" 20 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 25 struct xfs_sysfs_attr { 23 26 struct attribute attr; ··· 49 46 50 47 struct kobj_type xfs_mp_ktype = { 51 48 .release = xfs_sysfs_release, 49 + }; 50 + 51 + /* xlog */ 52 + 53 + static struct attribute *xfs_log_attrs[] = { 54 + NULL, 55 + }; 56 + 57 + static inline struct xlog * 58 + to_xlog(struct kobject *kobject) 59 + { 60 + struct xfs_kobj *kobj = to_kobj(kobject); 61 + return container_of(kobj, struct xlog, l_kobj); 62 + } 63 + 64 + STATIC ssize_t 65 + xfs_log_show( 66 + struct kobject *kobject, 67 + struct attribute *attr, 68 + char *buf) 69 + { 70 + struct xlog *log = to_xlog(kobject); 71 + struct xfs_sysfs_attr *xfs_attr = to_attr(attr); 72 + 73 + return xfs_attr->show ? xfs_attr->show(buf, log) : 0; 74 + } 75 + 76 + STATIC ssize_t 77 + xfs_log_store( 78 + struct kobject *kobject, 79 + struct attribute *attr, 80 + const char *buf, 81 + size_t count) 82 + { 83 + struct xlog *log = to_xlog(kobject); 84 + struct xfs_sysfs_attr *xfs_attr = to_attr(attr); 85 + 86 + return xfs_attr->store ? xfs_attr->store(buf, count, log) : 0; 87 + } 88 + 89 + static struct sysfs_ops xfs_log_ops = { 90 + .show = xfs_log_show, 91 + .store = xfs_log_store, 92 + }; 93 + 94 + struct kobj_type xfs_log_ktype = { 95 + .release = xfs_sysfs_release, 96 + .sysfs_ops = &xfs_log_ops, 97 + .default_attrs = xfs_log_attrs, 52 98 };
+1
fs/xfs/xfs_sysfs.h
··· 20 20 #define __XFS_SYSFS_H__ 21 21 22 22 extern struct kobj_type xfs_mp_ktype; /* xfs_mount */ 23 + extern struct kobj_type xfs_log_ktype; /* xlog */ 23 24 24 25 static inline struct xfs_kobj * 25 26 to_kobj(struct kobject *kobject)