ssize_t
lprocfs_checksum_dump_seq_write(struct file *file, const char __user *buffer,
size_t count, loff_t *off);
+ssize_t checksum_type_show(struct kobject *kobj, struct attribute *attr,
+ char *buf);
+ssize_t checksum_type_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count);
extern int lprocfs_single_release(struct inode *i, struct file *f);
extern int lprocfs_seq_release(struct inode *i, struct file *f);
}
/* Checksum algorithm names. Must be defined in the same order as the
- * OBD_CKSUM_* flags. */
-#define DECLARE_CKSUM_NAME const char *const cksum_name[] = {"crc32", "adler", \
- "crc32c", "reserved", "t10ip512", "t10ip4K", "t10crc512", "t10crc4K"}
+ * OBD_CKSUM_* flags.
+ */
+extern const char *const cksum_name[];
typedef __be16 (obd_dif_csum_fn) (void *, unsigned int);
}
LPROC_SEQ_FOPS(mdc_max_dirty_mb);
-DECLARE_CKSUM_NAME;
-
-static int mdc_checksum_type_seq_show(struct seq_file *m, void *v)
-{
- struct obd_device *obd = m->private;
- int i;
-
- if (obd == NULL)
- return 0;
-
- for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
- if ((BIT(i) & obd->u.cli.cl_supp_cksum_types) == 0)
- continue;
- if (obd->u.cli.cl_cksum_type == BIT(i))
- seq_printf(m, "[%s] ", cksum_name[i]);
- else
- seq_printf(m, "%s ", cksum_name[i]);
- }
- seq_puts(m, "\n");
-
- return 0;
-}
-
-static ssize_t mdc_checksum_type_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
-{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
- char kernbuf[10];
- int rc = -EINVAL;
- int i;
-
- if (obd == NULL)
- return 0;
-
- if (count > sizeof(kernbuf) - 1)
- return -EINVAL;
- if (copy_from_user(kernbuf, buffer, count))
- return -EFAULT;
-
- if (count > 0 && kernbuf[count - 1] == '\n')
- kernbuf[count - 1] = '\0';
- else
- kernbuf[count] = '\0';
-
- for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
- if (strcasecmp(kernbuf, cksum_name[i]) == 0) {
- obd->u.cli.cl_preferred_cksum_type = BIT(i);
- if (obd->u.cli.cl_supp_cksum_types & BIT(i)) {
- obd->u.cli.cl_cksum_type = BIT(i);
- rc = count;
- } else {
- rc = -EOPNOTSUPP;
- }
- break;
- }
- }
-
- return rc;
-}
-LPROC_SEQ_FOPS(mdc_checksum_type);
-
static ssize_t checksums_show(struct kobject *kobj,
struct attribute *attr, char *buf)
{
}
LUSTRE_RW_ATTR(checksums);
+LUSTRE_RW_ATTR(checksum_type);
+
static ssize_t checksum_dump_show(struct kobject *kobj,
struct attribute *attr, char *buf)
{
.fops = &mdc_max_dirty_mb_fops },
{ .name = "mdc_cached_mb",
.fops = &mdc_cached_mb_fops },
- { .name = "checksum_type",
- .fops = &mdc_checksum_type_fops },
{ .name = "timeouts",
.fops = &mdc_timeouts_fops },
{ .name = "import",
static struct attribute *mdc_attrs[] = {
&lustre_attr_active.attr,
&lustre_attr_checksums.attr,
+ &lustre_attr_checksum_type.attr,
&lustre_attr_checksum_dump.attr,
&lustre_attr_max_rpcs_in_flight.attr,
&lustre_attr_max_mod_rpcs_in_flight.attr,
#include <lustre_export.h>
/* struct obd_device */
#include <obd.h>
+#include <obd_cksum.h>
#include <obd_class.h>
#include <lustre_mds.h>
#include <lprocfs_status.h>
/*
* mdt_checksum_type(server) proc handling
*/
-DECLARE_CKSUM_NAME;
-
static int mdt_checksum_type_seq_show(struct seq_file *m, void *data)
{
struct obd_device *obd = m->private;
lut->lut_cksum_types_supported,
lut->lut_dt_conf.ddp_t10_cksum_type);
- for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
+ for (i = 0; cksum_name[i] != NULL; i++) {
if ((BIT(i) & lut->lut_cksum_types_supported) == 0)
continue;
static const char *obd_t10_cksum_name(enum obd_t10_cksum_type index)
{
- DECLARE_CKSUM_NAME;
-
/* Need to skip "crc32", "adler", "crc32c", "reserved" */
return cksum_name[3 + index];
}
}
EXPORT_SYMBOL(short_io_bytes_store);
+const char *const cksum_name[] = {
+ "crc32", "adler", "crc32c", "reserved", "t10ip512", "t10ip4K",
+ "t10crc512", "t10crc4K", NULL
+};
+EXPORT_SYMBOL(cksum_name);
+
+ssize_t checksum_type_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
+{
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
+ ssize_t len = 0;
+ int i;
+
+ if (!obd)
+ return 0;
+
+ for (i = 0; cksum_name[i] != NULL; i++) {
+ if ((BIT(i) & obd->u.cli.cl_supp_cksum_types) == 0)
+ continue;
+ if (obd->u.cli.cl_cksum_type == BIT(i))
+ len += scnprintf(buf + len, PAGE_SIZE, "[%s] ",
+ cksum_name[i]);
+ else
+ len += scnprintf(buf + len, PAGE_SIZE, "%s ",
+ cksum_name[i]);
+ }
+ len += scnprintf(buf + len, PAGE_SIZE, "\n");
+
+ return len;
+}
+EXPORT_SYMBOL(checksum_type_show);
+
+ssize_t checksum_type_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
+{
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
+ int rc = -EINVAL;
+ int i;
+
+ if (!obd)
+ return 0;
+
+ for (i = 0; cksum_name[i] != NULL; i++) {
+ if (strcasecmp(buffer, cksum_name[i]) == 0) {
+ obd->u.cli.cl_preferred_cksum_type = BIT(i);
+ if (obd->u.cli.cl_supp_cksum_types & BIT(i)) {
+ obd->u.cli.cl_cksum_type = BIT(i);
+ rc = count;
+ } else {
+ rc = -EOPNOTSUPP;
+ }
+ break;
+ }
+ }
+ return rc;
+}
+EXPORT_SYMBOL(checksum_type_store);
+
int lprocfs_wr_root_squash(const char __user *buffer, unsigned long count,
struct root_squash_info *squash, char *name)
{
/*
* ofd_checksum_type(server) proc handling
*/
-DECLARE_CKSUM_NAME;
-
static int ofd_checksum_type_seq_show(struct seq_file *m, void *data)
{
struct obd_device *obd = m->private;
lut->lut_cksum_types_supported,
lut->lut_dt_conf.ddp_t10_cksum_type);
- for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
+ for (i = 0; cksum_name[i] != NULL; i++) {
if ((BIT(i) & lut->lut_cksum_types_supported) == 0)
continue;
}
LUSTRE_RW_ATTR(checksums);
-DECLARE_CKSUM_NAME;
-
-static int osc_checksum_type_seq_show(struct seq_file *m, void *v)
-{
- struct obd_device *obd = m->private;
- int i;
-
- if (obd == NULL)
- return 0;
-
- for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
- if ((BIT(i) & obd->u.cli.cl_supp_cksum_types) == 0)
- continue;
- if (obd->u.cli.cl_cksum_type == BIT(i))
- seq_printf(m, "[%s] ", cksum_name[i]);
- else
- seq_printf(m, "%s ", cksum_name[i]);
- }
- seq_puts(m, "\n");
-
- return 0;
-}
-
-static ssize_t osc_checksum_type_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
-{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
- char kernbuf[10];
- int rc = -EINVAL;
- int i;
-
- if (obd == NULL)
- return 0;
-
- if (count > sizeof(kernbuf) - 1)
- return -EINVAL;
- if (copy_from_user(kernbuf, buffer, count))
- return -EFAULT;
-
- if (count > 0 && kernbuf[count - 1] == '\n')
- kernbuf[count - 1] = '\0';
- else
- kernbuf[count] = '\0';
-
- for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
- if (strcasecmp(kernbuf, cksum_name[i]) == 0) {
- obd->u.cli.cl_preferred_cksum_type = BIT(i);
- if (obd->u.cli.cl_supp_cksum_types & BIT(i)) {
- obd->u.cli.cl_cksum_type = BIT(i);
- rc = count;
- } else {
- rc = -EOPNOTSUPP;
- }
- break;
- }
- }
- return rc;
-}
-LPROC_SEQ_FOPS(osc_checksum_type);
+LUSTRE_RW_ATTR(checksum_type);
static ssize_t resend_count_show(struct kobject *kobj,
struct attribute *attr,
.fops = &osc_unevict_cached_mb_fops },
{ .name = "cur_grant_bytes",
.fops = &osc_cur_grant_bytes_fops },
- { .name = "checksum_type",
- .fops = &osc_checksum_type_fops },
{ .name = "timeouts",
.fops = &osc_timeouts_fops },
{ .name = "import",
&lustre_attr_active.attr,
&lustre_attr_enable_page_cache_shrink.attr,
&lustre_attr_checksums.attr,
+ &lustre_attr_checksum_type.attr,
&lustre_attr_checksum_dump.attr,
&lustre_attr_cur_dirty_bytes.attr,
&lustre_attr_cur_lost_grant_bytes.attr,