Skip to content

Commit 243f40d

Browse files
author
Christoph Hellwig
committed
xfs: contain more sysfs code in xfs_sysfs.c
Extend the error sysfs initialization helper to include the neighbouring attributes as well. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
1 parent 5443041 commit 243f40d

3 files changed

Lines changed: 36 additions & 33 deletions

File tree

fs/xfs/xfs_mount.c

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -765,27 +765,15 @@ xfs_mountfs(
765765
/* enable fail_at_unmount as default */
766766
mp->m_fail_unmount = true;
767767

768-
super_set_sysfs_name_id(mp->m_super);
769-
770-
error = xfs_sysfs_init(&mp->m_kobj, &xfs_mp_ktype,
771-
NULL, mp->m_super->s_id);
772-
if (error)
773-
goto out;
774-
775-
error = xfs_sysfs_init(&mp->m_stats.xs_kobj, &xfs_stats_ktype,
776-
&mp->m_kobj, "stats");
768+
error = xfs_mount_sysfs_init(mp);
777769
if (error)
778-
goto out_remove_sysfs;
770+
goto out_remove_scrub_stats;
779771

780772
xchk_stats_register(mp->m_scrub_stats, mp->m_debugfs);
781773

782-
error = xfs_error_sysfs_init(mp);
783-
if (error)
784-
goto out_remove_scrub_stats;
785-
786774
error = xfs_errortag_init(mp);
787775
if (error)
788-
goto out_remove_error_sysfs;
776+
goto out_remove_sysfs;
789777

790778
error = xfs_uuid_mount(mp);
791779
if (error)
@@ -1148,13 +1136,10 @@ xfs_mountfs(
11481136
xfs_uuid_unmount(mp);
11491137
out_remove_errortag:
11501138
xfs_errortag_del(mp);
1151-
out_remove_error_sysfs:
1152-
xfs_error_sysfs_del(mp);
1139+
out_remove_sysfs:
1140+
xfs_mount_sysfs_del(mp);
11531141
out_remove_scrub_stats:
11541142
xchk_stats_unregister(mp->m_scrub_stats);
1155-
xfs_sysfs_del(&mp->m_stats.xs_kobj);
1156-
out_remove_sysfs:
1157-
xfs_sysfs_del(&mp->m_kobj);
11581143
out:
11591144
return error;
11601145
}
@@ -1231,10 +1216,8 @@ xfs_unmountfs(
12311216
xfs_free_rtgroups(mp, 0, mp->m_sb.sb_rgcount);
12321217
xfs_free_perag_range(mp, 0, mp->m_sb.sb_agcount);
12331218
xfs_errortag_del(mp);
1234-
xfs_error_sysfs_del(mp);
12351219
xchk_stats_unregister(mp->m_scrub_stats);
1236-
xfs_sysfs_del(&mp->m_stats.xs_kobj);
1237-
xfs_sysfs_del(&mp->m_kobj);
1220+
xfs_mount_sysfs_del(mp);
12381221
}
12391222

12401223
/*

fs/xfs/xfs_sysfs.c

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static struct attribute *xfs_mp_attrs[] = {
6969
};
7070
ATTRIBUTE_GROUPS(xfs_mp);
7171

72-
const struct kobj_type xfs_mp_ktype = {
72+
static const struct kobj_type xfs_mp_ktype = {
7373
.release = xfs_sysfs_release,
7474
.sysfs_ops = &xfs_sysfs_ops,
7575
.default_groups = xfs_mp_groups,
@@ -702,39 +702,58 @@ xfs_error_sysfs_init_class(
702702
}
703703

704704
int
705-
xfs_error_sysfs_init(
705+
xfs_mount_sysfs_init(
706706
struct xfs_mount *mp)
707707
{
708708
int error;
709709

710+
super_set_sysfs_name_id(mp->m_super);
711+
712+
/* .../xfs/<dev>/ */
713+
error = xfs_sysfs_init(&mp->m_kobj, &xfs_mp_ktype,
714+
NULL, mp->m_super->s_id);
715+
if (error)
716+
return error;
717+
718+
/* .../xfs/<dev>/stats/ */
719+
error = xfs_sysfs_init(&mp->m_stats.xs_kobj, &xfs_stats_ktype,
720+
&mp->m_kobj, "stats");
721+
if (error)
722+
goto out_remove_fsdir;
723+
710724
/* .../xfs/<dev>/error/ */
711725
error = xfs_sysfs_init(&mp->m_error_kobj, &xfs_error_ktype,
712726
&mp->m_kobj, "error");
713727
if (error)
714-
return error;
728+
goto out_remove_stats_dir;
715729

730+
/* .../xfs/<dev>/error/fail_at_unmount */
716731
error = sysfs_create_file(&mp->m_error_kobj.kobject,
717732
ATTR_LIST(fail_at_unmount));
718733

719734
if (error)
720-
goto out_error;
735+
goto out_remove_error_dir;
721736

722737
/* .../xfs/<dev>/error/metadata/ */
723738
error = xfs_error_sysfs_init_class(mp, XFS_ERR_METADATA,
724739
"metadata", &mp->m_error_meta_kobj,
725740
xfs_error_meta_init);
726741
if (error)
727-
goto out_error;
742+
goto out_remove_error_dir;
728743

729744
return 0;
730745

731-
out_error:
746+
out_remove_error_dir:
732747
xfs_sysfs_del(&mp->m_error_kobj);
748+
out_remove_stats_dir:
749+
xfs_sysfs_del(&mp->m_stats.xs_kobj);
750+
out_remove_fsdir:
751+
xfs_sysfs_del(&mp->m_kobj);
733752
return error;
734753
}
735754

736755
void
737-
xfs_error_sysfs_del(
756+
xfs_mount_sysfs_del(
738757
struct xfs_mount *mp)
739758
{
740759
struct xfs_error_cfg *cfg;
@@ -749,6 +768,8 @@ xfs_error_sysfs_del(
749768
}
750769
xfs_sysfs_del(&mp->m_error_meta_kobj);
751770
xfs_sysfs_del(&mp->m_error_kobj);
771+
xfs_sysfs_del(&mp->m_stats.xs_kobj);
772+
xfs_sysfs_del(&mp->m_kobj);
752773
}
753774

754775
struct xfs_error_cfg *

fs/xfs/xfs_sysfs.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#ifndef __XFS_SYSFS_H__
88
#define __XFS_SYSFS_H__
99

10-
extern const struct kobj_type xfs_mp_ktype; /* xfs_mount */
1110
extern const struct kobj_type xfs_dbg_ktype; /* debug */
1211
extern const struct kobj_type xfs_log_ktype; /* xlog */
1312
extern const struct kobj_type xfs_stats_ktype; /* stats */
@@ -53,7 +52,7 @@ xfs_sysfs_del(
5352
wait_for_completion(&kobj->complete);
5453
}
5554

56-
int xfs_error_sysfs_init(struct xfs_mount *mp);
57-
void xfs_error_sysfs_del(struct xfs_mount *mp);
55+
int xfs_mount_sysfs_init(struct xfs_mount *mp);
56+
void xfs_mount_sysfs_del(struct xfs_mount *mp);
5857

5958
#endif /* __XFS_SYSFS_H__ */

0 commit comments

Comments
 (0)