X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fmdc%2Flproc_mdc.c;h=a2ca754b25255bbc54e1e450bb2022a501939115;hp=0242cd581a40c33dcd171d2330dc7f745005c326;hb=023a9e4cde5498aae89971028dc35c1e3279da5b;hpb=4031b885c1dd6b9f8af724b1b4ddf9f638b2b834 diff --git a/lustre/mdc/lproc_mdc.c b/lustre/mdc/lproc_mdc.c index 0242cd5..a2ca754 100644 --- a/lustre/mdc/lproc_mdc.c +++ b/lustre/mdc/lproc_mdc.c @@ -41,20 +41,20 @@ static ssize_t active_show(struct kobject *kobj, struct attribute *attr, char *buf) { - struct obd_device *dev = container_of(kobj, struct obd_device, + struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); + struct obd_import *imp; ssize_t len; - LPROCFS_CLIMP_CHECK(dev); - len = sprintf(buf, "%d\n", !dev->u.cli.cl_import->imp_deactive); - LPROCFS_CLIMP_EXIT(dev); + with_imp_locked(obd, imp, len) + len = sprintf(buf, "%d\n", !imp->imp_deactive); return len; } static ssize_t active_store(struct kobject *kobj, struct attribute *attr, const char *buffer, size_t count) { - struct obd_device *dev = container_of(kobj, struct obd_device, + struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); bool val; int rc; @@ -64,8 +64,8 @@ static ssize_t active_store(struct kobject *kobj, struct attribute *attr, return rc; /* opposite senses */ - if (dev->u.cli.cl_import->imp_deactive == val) - rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val); + if (obd->u.cli.cl_import->imp_deactive == val) + rc = ptlrpc_set_import_active(obd->u.cli.cl_import, val); else CDEBUG(D_CONFIG, "activate %u: ignoring repeat request\n", val); @@ -78,12 +78,12 @@ static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, struct attribute *attr, char *buf) { - struct obd_device *dev = container_of(kobj, struct obd_device, + struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); ssize_t len; u32 max; - max = obd_get_max_rpcs_in_flight(&dev->u.cli); + max = obd_get_max_rpcs_in_flight(&obd->u.cli); len = sprintf(buf, "%u\n", max); return len; @@ -94,7 +94,7 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, const char *buffer, size_t count) { - struct obd_device *dev = container_of(kobj, struct obd_device, + struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); unsigned int val; int rc; @@ -103,7 +103,7 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, if (rc) return rc; - rc = obd_set_max_rpcs_in_flight(&dev->u.cli, val); + rc = obd_set_max_rpcs_in_flight(&obd->u.cli, val); if (rc) count = rc; @@ -115,11 +115,11 @@ static ssize_t max_mod_rpcs_in_flight_show(struct kobject *kobj, struct attribute *attr, char *buf) { - struct obd_device *dev = container_of(kobj, struct obd_device, + struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); u16 max; - max = obd_get_max_mod_rpcs_in_flight(&dev->u.cli); + max = obd_get_max_mod_rpcs_in_flight(&obd->u.cli); return sprintf(buf, "%hu\n", max); } @@ -128,7 +128,7 @@ static ssize_t max_mod_rpcs_in_flight_store(struct kobject *kobj, const char *buffer, size_t count) { - struct obd_device *dev = container_of(kobj, struct obd_device, + struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); u16 val; int rc; @@ -137,7 +137,7 @@ static ssize_t max_mod_rpcs_in_flight_store(struct kobject *kobj, if (rc) return rc; - rc = obd_set_max_mod_rpcs_in_flight(&dev->u.cli, val); + rc = obd_set_max_mod_rpcs_in_flight(&obd->u.cli, val); if (rc) count = rc; @@ -147,17 +147,11 @@ LUSTRE_RW_ATTR(max_mod_rpcs_in_flight); static int mdc_max_dirty_mb_seq_show(struct seq_file *m, void *v) { - struct obd_device *dev = m->private; - struct client_obd *cli = &dev->u.cli; - long val; - int mult; + struct obd_device *obd = m->private; + struct client_obd *cli = &obd->u.cli; - spin_lock(&cli->cl_loi_list_lock); - val = cli->cl_dirty_max_pages; - spin_unlock(&cli->cl_loi_list_lock); - - mult = 1 << (20 - PAGE_SHIFT); - return lprocfs_seq_read_frac_helper(m, val, mult); + seq_printf(m, "%lu\n", PAGES_TO_MiB(cli->cl_dirty_max_pages)); + return 0; } static ssize_t mdc_max_dirty_mb_seq_write(struct file *file, @@ -165,20 +159,28 @@ static ssize_t mdc_max_dirty_mb_seq_write(struct file *file, size_t count, loff_t *off) { struct seq_file *sfl = file->private_data; - struct obd_device *dev = sfl->private; - struct client_obd *cli = &dev->u.cli; - s64 pages_number; + struct obd_device *obd = sfl->private; + struct client_obd *cli = &obd->u.cli; + char kernbuf[22] = ""; + u64 pages_number; int rc; - rc = lprocfs_str_with_units_to_s64(buffer, count, &pages_number, 'M'); - if (rc) - return rc; + if (count >= sizeof(kernbuf)) + return -EINVAL; - pages_number >>= PAGE_SHIFT; + if (copy_from_user(kernbuf, buffer, count)) + return -EFAULT; + kernbuf[count] = 0; + rc = sysfs_memparse(kernbuf, count, &pages_number, "MiB"); + if (rc < 0) + return rc; + + /* MB -> pages */ + pages_number = round_up(pages_number, 1024 * 1024) >> PAGE_SHIFT; if (pages_number <= 0 || - pages_number >= OSC_MAX_DIRTY_MB_MAX << (20 - PAGE_SHIFT) || - pages_number > totalram_pages / 4) /* 1/4 of RAM */ + pages_number >= MiB_TO_PAGES(OSC_MAX_DIRTY_MB_MAX) || + pages_number > cfs_totalram_pages() / 4) /* 1/4 of RAM */ return -ERANGE; spin_lock(&cli->cl_loi_list_lock); @@ -222,14 +224,15 @@ static ssize_t contention_seconds_store(struct kobject *kobj, } LUSTRE_RW_ATTR(contention_seconds); +LUSTRE_ATTR(mds_conn_uuid, 0444, conn_uuid_show, NULL); LUSTRE_RO_ATTR(conn_uuid); -LUSTRE_WO_ATTR(ping); +LUSTRE_RW_ATTR(ping); static int mdc_cached_mb_seq_show(struct seq_file *m, void *v) { - struct obd_device *dev = m->private; - struct client_obd *cli = &dev->u.cli; + struct obd_device *obd = m->private; + struct client_obd *cli = &obd->u.cli; int shift = 20 - PAGE_SHIFT; seq_printf(m, "used_mb: %ld\n" @@ -249,9 +252,10 @@ mdc_cached_mb_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { struct seq_file *sfl = file->private_data; - struct obd_device *dev = sfl->private; - struct client_obd *cli = &dev->u.cli; - __s64 pages_number; + struct obd_device *obd = sfl->private; + struct client_obd *cli = &obd->u.cli; + u64 pages_number; + const char *tmp; long rc; char kernbuf[128]; @@ -262,17 +266,13 @@ mdc_cached_mb_seq_write(struct file *file, const char __user *buffer, return -EFAULT; kernbuf[count] = 0; - buffer += lprocfs_find_named_value(kernbuf, "used_mb:", &count) - - kernbuf; - rc = lprocfs_str_with_units_to_s64(buffer, count, &pages_number, 'M'); - if (rc) + tmp = lprocfs_find_named_value(kernbuf, "used_mb:", &count); + rc = sysfs_memparse(tmp, count, &pages_number, "MiB"); + if (rc < 0) return rc; pages_number >>= PAGE_SHIFT; - if (pages_number < 0) - return -ERANGE; - rc = atomic_long_read(&cli->cl_lru_in_list) - pages_number; if (rc > 0) { struct lu_env *env; @@ -291,8 +291,8 @@ LPROC_SEQ_FOPS(mdc_cached_mb); static int mdc_unstable_stats_seq_show(struct seq_file *m, void *v) { - struct obd_device *dev = m->private; - struct client_obd *cli = &dev->u.cli; + struct obd_device *obd = m->private; + struct client_obd *cli = &obd->u.cli; long pages; int mb; @@ -310,8 +310,8 @@ static ssize_t mdc_rpc_stats_seq_write(struct file *file, size_t len, loff_t *off) { struct seq_file *seq = file->private_data; - struct obd_device *dev = seq->private; - struct client_obd *cli = &dev->u.cli; + struct obd_device *obd = seq->private; + struct client_obd *cli = &obd->u.cli; lprocfs_oh_clear(&cli->cl_mod_rpcs_hist); @@ -325,15 +325,14 @@ static ssize_t mdc_rpc_stats_seq_write(struct file *file, return len; } -#define pct(a, b) (b ? a * 100 / b : 0) static int mdc_rpc_stats_seq_show(struct seq_file *seq, void *v) { - struct obd_device *dev = seq->private; - struct client_obd *cli = &dev->u.cli; + struct obd_device *obd = seq->private; + struct client_obd *cli = &obd->u.cli; unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum; int i; - obd_mod_rpc_stats_seq_show(&dev->u.cli, seq); + obd_mod_rpc_stats_seq_show(cli, seq); spin_lock(&cli->cl_loi_list_lock); @@ -361,7 +360,7 @@ static int mdc_rpc_stats_seq_show(struct seq_file *seq, void *v) read_cum += r; write_cum += w; - seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n", + seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n", 1 << i, r, pct(r, read_tot), pct(read_cum, read_tot), w, pct(w, write_tot), @@ -385,7 +384,7 @@ static int mdc_rpc_stats_seq_show(struct seq_file *seq, void *v) read_cum += r; write_cum += w; - seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n", + seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n", i, r, pct(r, read_tot), pct(read_cum, read_tot), w, pct(w, write_tot), pct(write_cum, write_tot)); if (read_cum == read_tot && write_cum == write_tot) @@ -407,7 +406,7 @@ static int mdc_rpc_stats_seq_show(struct seq_file *seq, void *v) read_cum += r; write_cum += w; - seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n", + seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n", (i == 0) ? 0 : 1 << (i - 1), r, pct(r, read_tot), pct(read_cum, read_tot), w, pct(w, write_tot), pct(write_cum, write_tot)); @@ -418,14 +417,13 @@ static int mdc_rpc_stats_seq_show(struct seq_file *seq, void *v) return 0; } -#undef pct LPROC_SEQ_FOPS(mdc_rpc_stats); static int mdc_stats_seq_show(struct seq_file *seq, void *v) { struct timespec64 now; - struct obd_device *dev = seq->private; - struct osc_stats *stats = &obd2osc_dev(dev)->od_stats; + struct obd_device *obd = seq->private; + struct osc_stats *stats = &obd2osc_dev(obd)->od_stats; ktime_get_real_ts64(&now); @@ -445,14 +443,44 @@ static ssize_t mdc_stats_seq_write(struct file *file, size_t len, loff_t *off) { struct seq_file *seq = file->private_data; - struct obd_device *dev = seq->private; - struct osc_stats *stats = &obd2osc_dev(dev)->od_stats; + struct obd_device *obd = seq->private; + struct osc_stats *stats = &obd2osc_dev(obd)->od_stats; memset(stats, 0, sizeof(*stats)); return len; } LPROC_SEQ_FOPS(mdc_stats); +static int mdc_dom_min_repsize_seq_show(struct seq_file *m, void *v) +{ + struct obd_device *obd = m->private; + + seq_printf(m, "%u\n", obd->u.cli.cl_dom_min_inline_repsize); + + return 0; +} + +static ssize_t mdc_dom_min_repsize_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; + unsigned int val; + int rc; + + rc = kstrtouint_from_user(buffer, count, 0, &val); + if (rc) + return rc; + + if (val > MDC_DOM_MAX_INLINE_REPSIZE) + return -ERANGE; + + obd->u.cli.cl_dom_min_inline_repsize = val; + return count; +} +LPROC_SEQ_FOPS(mdc_dom_min_repsize); + LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags); LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid); LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts); @@ -486,6 +514,8 @@ struct lprocfs_vars lprocfs_mdc_obd_vars[] = { .fops = &mdc_unstable_stats_fops }, { .name = "mdc_stats", .fops = &mdc_stats_fops }, + { .name = "mdc_dom_min_repsize", + .fops = &mdc_dom_min_repsize_fops }, { NULL } }; @@ -494,6 +524,7 @@ static struct attribute *mdc_attrs[] = { &lustre_attr_max_rpcs_in_flight.attr, &lustre_attr_max_mod_rpcs_in_flight.attr, &lustre_attr_contention_seconds.attr, + &lustre_attr_mds_conn_uuid.attr, &lustre_attr_conn_uuid.attr, &lustre_attr_ping.attr, NULL,