Commit 5f483c4a authored by Gang He's avatar Gang He Committed by Linus Torvalds

ocfs2: add kobject for online file check

Use embedded kobject mechanism for online file check feature, this will
avoid to use a global list to save/search per-device online file check
related data, meanwhile, reduce the code lines and make the code logic
clear.  The changed code is based on Goldwyn Rodrigues's patches and
ext4 fs code.

Link: http://lkml.kernel.org/r/1495611866-27360-4-git-send-email-ghe@suse.comSigned-off-by: default avatarGang He <ghe@suse.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Joseph Qi <jiangqi903@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8fc2cb4b
This diff is collapsed.
...@@ -51,15 +51,6 @@ struct ocfs2_filecheck { ...@@ -51,15 +51,6 @@ struct ocfs2_filecheck {
unsigned int fc_done; /* Finished entry count in list */ unsigned int fc_done; /* Finished entry count in list */
}; };
struct ocfs2_filecheck_sysfs_entry { /* sysfs entry per mounting */
struct list_head fs_list;
atomic_t fs_count;
struct super_block *fs_sb;
struct kset *fs_devicekset;
struct kset *fs_fcheckkset;
struct ocfs2_filecheck *fs_fcheck;
};
#define OCFS2_FILECHECK_MAXSIZE 100 #define OCFS2_FILECHECK_MAXSIZE 100
#define OCFS2_FILECHECK_MINSIZE 10 #define OCFS2_FILECHECK_MINSIZE 10
...@@ -70,7 +61,14 @@ enum { ...@@ -70,7 +61,14 @@ enum {
OCFS2_FILECHECK_TYPE_SET = 100 /* Set entry list maximum size */ OCFS2_FILECHECK_TYPE_SET = 100 /* Set entry list maximum size */
}; };
int ocfs2_filecheck_create_sysfs(struct super_block *sb); struct ocfs2_filecheck_sysfs_entry { /* sysfs entry per partition */
int ocfs2_filecheck_remove_sysfs(struct super_block *sb); struct kobject fs_kobj;
struct completion fs_kobj_unregister;
struct ocfs2_filecheck *fs_fcheck;
};
int ocfs2_filecheck_create_sysfs(struct ocfs2_super *osb);
void ocfs2_filecheck_remove_sysfs(struct ocfs2_super *osb);
#endif /* FILECHECK_H */ #endif /* FILECHECK_H */
...@@ -50,6 +50,8 @@ ...@@ -50,6 +50,8 @@
#include "reservations.h" #include "reservations.h"
#include "filecheck.h"
/* Caching of metadata buffers */ /* Caching of metadata buffers */
/* Most user visible OCFS2 inodes will have very few pieces of /* Most user visible OCFS2 inodes will have very few pieces of
...@@ -472,6 +474,12 @@ struct ocfs2_super ...@@ -472,6 +474,12 @@ struct ocfs2_super
* workqueue and schedule on our own. * workqueue and schedule on our own.
*/ */
struct workqueue_struct *ocfs2_wq; struct workqueue_struct *ocfs2_wq;
/* sysfs directory per partition */
struct kset *osb_dev_kset;
/* file check related stuff */
struct ocfs2_filecheck_sysfs_entry osb_fc_ent;
}; };
#define OCFS2_SB(sb) ((struct ocfs2_super *)(sb)->s_fs_info) #define OCFS2_SB(sb) ((struct ocfs2_super *)(sb)->s_fs_info)
......
...@@ -1161,6 +1161,23 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1161,6 +1161,23 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
ocfs2_complete_mount_recovery(osb); ocfs2_complete_mount_recovery(osb);
osb->osb_dev_kset = kset_create_and_add(sb->s_id, NULL,
&ocfs2_kset->kobj);
if (!osb->osb_dev_kset) {
status = -ENOMEM;
mlog(ML_ERROR, "Unable to create device kset %s.\n", sb->s_id);
goto read_super_error;
}
/* Create filecheck sysfs related directories/files at
* /sys/fs/ocfs2/<devname>/filecheck */
if (ocfs2_filecheck_create_sysfs(osb)) {
status = -ENOMEM;
mlog(ML_ERROR, "Unable to create filecheck sysfs directory at "
"/sys/fs/ocfs2/%s/filecheck.\n", sb->s_id);
goto read_super_error;
}
if (ocfs2_mount_local(osb)) if (ocfs2_mount_local(osb))
snprintf(nodestr, sizeof(nodestr), "local"); snprintf(nodestr, sizeof(nodestr), "local");
else else
...@@ -1199,9 +1216,6 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1199,9 +1216,6 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
/* Start this when the mount is almost sure of being successful */ /* Start this when the mount is almost sure of being successful */
ocfs2_orphan_scan_start(osb); ocfs2_orphan_scan_start(osb);
/* Create filecheck sysfile /sys/fs/ocfs2/<devname>/filecheck */
ocfs2_filecheck_create_sysfs(sb);
return status; return status;
read_super_error: read_super_error:
...@@ -1653,7 +1667,6 @@ static void ocfs2_put_super(struct super_block *sb) ...@@ -1653,7 +1667,6 @@ static void ocfs2_put_super(struct super_block *sb)
ocfs2_sync_blockdev(sb); ocfs2_sync_blockdev(sb);
ocfs2_dismount_volume(sb, 0); ocfs2_dismount_volume(sb, 0);
ocfs2_filecheck_remove_sysfs(sb);
} }
static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf) static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf)
...@@ -1893,6 +1906,12 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err) ...@@ -1893,6 +1906,12 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)
osb = OCFS2_SB(sb); osb = OCFS2_SB(sb);
BUG_ON(!osb); BUG_ON(!osb);
/* Remove file check sysfs related directores/files,
* and wait for the pending file check operations */
ocfs2_filecheck_remove_sysfs(osb);
kset_unregister(osb->osb_dev_kset);
debugfs_remove(osb->osb_ctxt); debugfs_remove(osb->osb_ctxt);
/* Orphan scan should be stopped as early as possible */ /* Orphan scan should be stopped as early as possible */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment