|
@@ -26,6 +26,36 @@
|
|
#include "util.h"
|
|
#include "util.h"
|
|
#include "glops.h"
|
|
#include "glops.h"
|
|
|
|
|
|
|
|
+struct gfs2_attr {
|
|
|
|
+ struct attribute attr;
|
|
|
|
+ ssize_t (*show)(struct gfs2_sbd *, char *);
|
|
|
|
+ ssize_t (*store)(struct gfs2_sbd *, const char *, size_t);
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+static ssize_t gfs2_attr_show(struct kobject *kobj, struct attribute *attr,
|
|
|
|
+ char *buf)
|
|
|
|
+{
|
|
|
|
+ struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
|
|
|
|
+ struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr);
|
|
|
|
+ return a->show ? a->show(sdp, buf) : 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static ssize_t gfs2_attr_store(struct kobject *kobj, struct attribute *attr,
|
|
|
|
+ const char *buf, size_t len)
|
|
|
|
+{
|
|
|
|
+ struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
|
|
|
|
+ struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr);
|
|
|
|
+ return a->store ? a->store(sdp, buf, len) : len;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static struct sysfs_ops gfs2_attr_ops = {
|
|
|
|
+ .show = gfs2_attr_show,
|
|
|
|
+ .store = gfs2_attr_store,
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+static struct kset *gfs2_kset;
|
|
|
|
+
|
|
static ssize_t id_show(struct gfs2_sbd *sdp, char *buf)
|
|
static ssize_t id_show(struct gfs2_sbd *sdp, char *buf)
|
|
{
|
|
{
|
|
return snprintf(buf, PAGE_SIZE, "%u:%u\n",
|
|
return snprintf(buf, PAGE_SIZE, "%u:%u\n",
|
|
@@ -212,11 +242,6 @@ static ssize_t demote_rq_store(struct gfs2_sbd *sdp, const char *buf, size_t len
|
|
return len;
|
|
return len;
|
|
}
|
|
}
|
|
|
|
|
|
-struct gfs2_attr {
|
|
|
|
- struct attribute attr;
|
|
|
|
- ssize_t (*show)(struct gfs2_sbd *, char *);
|
|
|
|
- ssize_t (*store)(struct gfs2_sbd *, const char *, size_t);
|
|
|
|
-};
|
|
|
|
|
|
|
|
#define GFS2_ATTR(name, mode, show, store) \
|
|
#define GFS2_ATTR(name, mode, show, store) \
|
|
static struct gfs2_attr gfs2_attr_##name = __ATTR(name, mode, show, store)
|
|
static struct gfs2_attr gfs2_attr_##name = __ATTR(name, mode, show, store)
|
|
@@ -246,49 +271,21 @@ static struct attribute *gfs2_attrs[] = {
|
|
NULL,
|
|
NULL,
|
|
};
|
|
};
|
|
|
|
|
|
-static ssize_t gfs2_attr_show(struct kobject *kobj, struct attribute *attr,
|
|
|
|
- char *buf)
|
|
|
|
-{
|
|
|
|
- struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
|
|
|
|
- struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr);
|
|
|
|
- return a->show ? a->show(sdp, buf) : 0;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static ssize_t gfs2_attr_store(struct kobject *kobj, struct attribute *attr,
|
|
|
|
- const char *buf, size_t len)
|
|
|
|
-{
|
|
|
|
- struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
|
|
|
|
- struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr);
|
|
|
|
- return a->store ? a->store(sdp, buf, len) : len;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static struct sysfs_ops gfs2_attr_ops = {
|
|
|
|
- .show = gfs2_attr_show,
|
|
|
|
- .store = gfs2_attr_store,
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
static struct kobj_type gfs2_ktype = {
|
|
static struct kobj_type gfs2_ktype = {
|
|
.default_attrs = gfs2_attrs,
|
|
.default_attrs = gfs2_attrs,
|
|
.sysfs_ops = &gfs2_attr_ops,
|
|
.sysfs_ops = &gfs2_attr_ops,
|
|
};
|
|
};
|
|
|
|
|
|
-static struct kset *gfs2_kset;
|
|
|
|
-
|
|
|
|
/*
|
|
/*
|
|
* display struct lm_lockstruct fields
|
|
* display struct lm_lockstruct fields
|
|
*/
|
|
*/
|
|
|
|
|
|
-struct lockstruct_attr {
|
|
|
|
- struct attribute attr;
|
|
|
|
- ssize_t (*show)(struct gfs2_sbd *, char *);
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
#define LOCKSTRUCT_ATTR(name, fmt) \
|
|
#define LOCKSTRUCT_ATTR(name, fmt) \
|
|
static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
|
|
static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
|
|
{ \
|
|
{ \
|
|
return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_lockstruct.ls_##name); \
|
|
return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_lockstruct.ls_##name); \
|
|
} \
|
|
} \
|
|
-static struct lockstruct_attr lockstruct_attr_##name = __ATTR_RO(name)
|
|
|
|
|
|
+static struct gfs2_attr lockstruct_attr_##name = __ATTR_RO(name)
|
|
|
|
|
|
LOCKSTRUCT_ATTR(jid, "%u\n");
|
|
LOCKSTRUCT_ATTR(jid, "%u\n");
|
|
LOCKSTRUCT_ATTR(first, "%u\n");
|
|
LOCKSTRUCT_ATTR(first, "%u\n");
|
|
@@ -401,14 +398,8 @@ static ssize_t recover_status_show(struct gfs2_sbd *sdp, char *buf)
|
|
return sprintf(buf, "%d\n", ls->ls_recover_jid_status);
|
|
return sprintf(buf, "%d\n", ls->ls_recover_jid_status);
|
|
}
|
|
}
|
|
|
|
|
|
-struct gdlm_attr {
|
|
|
|
- struct attribute attr;
|
|
|
|
- ssize_t (*show)(struct gfs2_sbd *sdp, char *);
|
|
|
|
- ssize_t (*store)(struct gfs2_sbd *sdp, const char *, size_t);
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
#define GDLM_ATTR(_name,_mode,_show,_store) \
|
|
#define GDLM_ATTR(_name,_mode,_show,_store) \
|
|
-static struct gdlm_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store)
|
|
|
|
|
|
+static struct gfs2_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store)
|
|
|
|
|
|
GDLM_ATTR(proto_name, 0444, proto_name_show, NULL);
|
|
GDLM_ATTR(proto_name, 0444, proto_name_show, NULL);
|
|
GDLM_ATTR(block, 0644, block_show, block_store);
|
|
GDLM_ATTR(block, 0644, block_show, block_store);
|
|
@@ -434,21 +425,12 @@ static struct attribute *lock_module_attrs[] = {
|
|
NULL,
|
|
NULL,
|
|
};
|
|
};
|
|
|
|
|
|
-/*
|
|
|
|
- * display struct gfs2_args fields
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
-struct args_attr {
|
|
|
|
- struct attribute attr;
|
|
|
|
- ssize_t (*show)(struct gfs2_sbd *, char *);
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
#define ARGS_ATTR(name, fmt) \
|
|
#define ARGS_ATTR(name, fmt) \
|
|
static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
|
|
static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
|
|
{ \
|
|
{ \
|
|
return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_args.ar_##name); \
|
|
return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_args.ar_##name); \
|
|
} \
|
|
} \
|
|
-static struct args_attr args_attr_##name = __ATTR_RO(name)
|
|
|
|
|
|
+static struct gfs2_attr args_attr_##name = __ATTR_RO(name)
|
|
|
|
|
|
ARGS_ATTR(lockproto, "%s\n");
|
|
ARGS_ATTR(lockproto, "%s\n");
|
|
ARGS_ATTR(locktable, "%s\n");
|
|
ARGS_ATTR(locktable, "%s\n");
|
|
@@ -531,14 +513,8 @@ static ssize_t tune_set(struct gfs2_sbd *sdp, unsigned int *field,
|
|
return len;
|
|
return len;
|
|
}
|
|
}
|
|
|
|
|
|
-struct tune_attr {
|
|
|
|
- struct attribute attr;
|
|
|
|
- ssize_t (*show)(struct gfs2_sbd *, char *);
|
|
|
|
- ssize_t (*store)(struct gfs2_sbd *, const char *, size_t);
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
#define TUNE_ATTR_3(name, show, store) \
|
|
#define TUNE_ATTR_3(name, show, store) \
|
|
-static struct tune_attr tune_attr_##name = __ATTR(name, 0644, show, store)
|
|
|
|
|
|
+static struct gfs2_attr tune_attr_##name = __ATTR(name, 0644, show, store)
|
|
|
|
|
|
#define TUNE_ATTR_2(name, store) \
|
|
#define TUNE_ATTR_2(name, store) \
|
|
static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
|
|
static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
|