X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fobdfilter%2Flproc_obdfilter.c;h=b13fa91b4bcd48b3b4d8a2927511692e4c380634;hb=40ca6010734f52bd01fae48035040b1bce76519e;hp=5e5f1c7dfb2b8c076bb57da710032f63a0313c8f;hpb=90d8e7fd28746a572c8de488222f5312fe927fc3;p=fs%2Flustre-release.git diff --git a/lustre/obdfilter/lproc_obdfilter.c b/lustre/obdfilter/lproc_obdfilter.c index 5e5f1c7..b13fa91 100644 --- a/lustre/obdfilter/lproc_obdfilter.c +++ b/lustre/obdfilter/lproc_obdfilter.c @@ -26,7 +26,7 @@ * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. */ /* @@ -82,18 +82,6 @@ static int lprocfs_filter_rd_tot_pending(char *page, char **start, off_t off, return snprintf(page, count, LPU64"\n", obd->u.filter.fo_tot_pending); } -static int lprocfs_filter_rd_mntdev(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - - LASSERT(obd != NULL); - LASSERT(obd->u.filter.fo_vfsmnt->mnt_devname); - *eof = 1; - return snprintf(page, count, "%s\n", - obd->u.filter.fo_vfsmnt->mnt_devname); -} - static int lprocfs_filter_rd_last_id(char *page, char **start, off_t off, int count, int *eof, void *data) { @@ -101,7 +89,7 @@ static int lprocfs_filter_rd_last_id(char *page, char **start, off_t off, struct filter_obd *filter = &obd->u.filter; int retval = 0, rc, i; - if (obd == NULL) + if (obd == NULL || !obd->obd_set_up || obd->obd_stopping) return 0; rc = snprintf(page, count, LPU64"\n",filter_last_id(filter, 0)); if (rc < 0) @@ -110,7 +98,7 @@ static int lprocfs_filter_rd_last_id(char *page, char **start, off_t off, count -= rc; retval += rc; - for (i = FILTER_GROUP_MDS1_N_BASE + 1; i < filter->fo_group_count; i++) { + for (i = FID_SEQ_OST_MDT1; i < filter->fo_group_count; i++) { rc = snprintf(page, count, LPU64"\n",filter_last_id(filter, i)); if (rc < 0) { retval = rc; @@ -183,7 +171,8 @@ int lprocfs_filter_rd_fmd_max_age(char *page, char **start, off_t off, struct obd_device *obd = data; int rc; - rc = snprintf(page, count, "%u\n", obd->u.filter.fo_fmd_max_age / HZ); + rc = snprintf(page, count, "%u\n", + obd->u.filter.fo_fmd_max_age / CFS_HZ); return rc; } @@ -201,7 +190,7 @@ int lprocfs_filter_wr_fmd_max_age(struct file *file, const char *buffer, if (val > 65536 || val < 1) return -EINVAL; - obd->u.filter.fo_fmd_max_age = val * HZ; + obd->u.filter.fo_fmd_max_age = val * CFS_HZ; return count; } @@ -299,7 +288,9 @@ static int lprocfs_filter_wr_cache(struct file *file, const char *buffer, if (rc) return rc; - obd->u.filter.fo_read_cache = val; + cfs_spin_lock_bh(&obd->u.filter.fo_flags_lock); + obd->u.filter.fo_read_cache = !!val; + cfs_spin_unlock_bh(&obd->u.filter.fo_flags_lock); return count; } @@ -324,7 +315,115 @@ static int lprocfs_filter_wr_wcache(struct file *file, const char *buffer, if (rc) return rc; - obd->u.filter.fo_writethrough_cache = val; + cfs_spin_lock(&obd->u.filter.fo_flags_lock); + obd->u.filter.fo_writethrough_cache = !!val; + cfs_spin_unlock(&obd->u.filter.fo_flags_lock); + return count; +} + +static int lprocfs_filter_rd_mds_sync(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + struct obd_device *obd = (struct obd_device *)data; + LASSERT(obd != NULL); + + return snprintf(page, count, "%u\n", obd->u.filter.fo_mds_ost_sync); +} + +int lprocfs_filter_rd_degraded(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + struct obd_device *obd = data; + + return snprintf(page, count, "%u\n", obd->u.filter.fo_raid_degraded); +} + +int lprocfs_filter_wr_degraded(struct file *file, const char *buffer, + unsigned long count, void *data) +{ + struct obd_device *obd = data; + int val, rc; + + rc = lprocfs_write_helper(buffer, count, &val); + if (rc) + return rc; + + cfs_spin_lock(&obd->u.filter.fo_flags_lock); + obd->u.filter.fo_raid_degraded = !!val; + cfs_spin_unlock(&obd->u.filter.fo_flags_lock); + return count; +} + +int lprocfs_filter_rd_syncjournal(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + struct obd_device *obd = data; + int rc; + + rc = snprintf(page, count, "%u\n", obd->u.filter.fo_syncjournal); + return rc; +} + +int lprocfs_filter_wr_syncjournal(struct file *file, const char *buffer, + unsigned long count, void *data) +{ + struct obd_device *obd = data; + int val; + int rc; + + rc = lprocfs_write_helper(buffer, count, &val); + if (rc) + return rc; + + if (val < 0) + return -EINVAL; + + obd->u.filter.fo_syncjournal = !!val; + filter_slc_set(&obd->u.filter); + + return count; +} + +static char *sync_on_cancel_states[] = {"never", + "blocking", + "always" }; + +int lprocfs_filter_rd_sync_lock_cancel(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + struct obd_device *obd = data; + int rc; + + rc = snprintf(page, count, "%s\n", + sync_on_cancel_states[obd->u.filter.fo_sync_lock_cancel]); + return rc; +} + +int lprocfs_filter_wr_sync_lock_cancel(struct file *file, const char *buffer, + unsigned long count, void *data) +{ + struct obd_device *obd = data; + int val = -1; + int i; + + for (i = 0 ; i < NUM_SYNC_ON_CANCEL_STATES; i++) { + if (memcmp(buffer, sync_on_cancel_states[i], + strlen(sync_on_cancel_states[i])) == 0) { + val = i; + break; + } + } + if (val == -1) { + int rc; + rc = lprocfs_write_helper(buffer, count, &val); + if (rc) + return rc; + } + + if (val < 0 || val > 2) + return -EINVAL; + + obd->u.filter.fo_sync_lock_cancel = val; return count; } @@ -338,15 +437,17 @@ static struct lprocfs_vars lprocfs_filter_obd_vars[] = { { "filesfree", lprocfs_rd_filesfree, 0, 0 }, { "filegroups", lprocfs_filter_rd_groups, 0, 0 }, { "fstype", lprocfs_rd_fstype, 0, 0 }, - { "mntdev", lprocfs_filter_rd_mntdev, 0, 0 }, + { "mntdev", lprocfs_obd_rd_mntdev, 0, 0 }, { "last_id", lprocfs_filter_rd_last_id,0, 0 }, { "tot_dirty", lprocfs_filter_rd_tot_dirty, 0, 0 }, { "tot_pending", lprocfs_filter_rd_tot_pending, 0, 0 }, { "tot_granted", lprocfs_filter_rd_tot_granted, 0, 0 }, { "hash_stats", lprocfs_obd_rd_hash, 0, 0 }, - { "recovery_status", lprocfs_obd_rd_recovery_status, 0, 0 }, - { "recovery_maxtime", lprocfs_obd_rd_recovery_maxtime, - lprocfs_obd_wr_recovery_maxtime, 0}, + { "recovery_status", lprocfs_obd_rd_recovery_status, 0, 0 }, + { "recovery_time_soft", lprocfs_obd_rd_recovery_time_soft, + lprocfs_obd_wr_recovery_time_soft, 0}, + { "recovery_time_hard", lprocfs_obd_rd_recovery_time_hard, + lprocfs_obd_wr_recovery_time_hard, 0}, { "evict_client", 0, lprocfs_wr_evict_client, 0, &lprocfs_evict_client_fops}, { "num_exports", lprocfs_rd_num_exports, 0, 0 }, @@ -369,6 +470,13 @@ static struct lprocfs_vars lprocfs_filter_obd_vars[] = { { "read_cache_enable", lprocfs_filter_rd_cache, lprocfs_filter_wr_cache, 0}, { "writethrough_cache_enable", lprocfs_filter_rd_wcache, lprocfs_filter_wr_wcache, 0}, + { "mds_sync", lprocfs_filter_rd_mds_sync, 0, 0}, + { "degraded", lprocfs_filter_rd_degraded, + lprocfs_filter_wr_degraded, 0 }, + { "sync_journal", lprocfs_filter_rd_syncjournal, + lprocfs_filter_wr_syncjournal, 0 }, + { "sync_on_lock_cancel", lprocfs_filter_rd_sync_lock_cancel, + lprocfs_filter_wr_sync_lock_cancel, 0 }, { 0 } }; @@ -381,7 +489,6 @@ void filter_tally(struct obd_export *exp, struct page **pages, int nr_pages, unsigned long *blocks, int blocks_per_page, int wr) { struct filter_obd *filter = &exp->exp_obd->u.filter; - struct filter_export_data *fed = &exp->exp_filter_data; struct page *last_page = NULL; unsigned long *last_block = NULL; unsigned long discont_pages = 0; @@ -393,8 +500,6 @@ void filter_tally(struct obd_export *exp, struct page **pages, int nr_pages, lprocfs_oh_tally_log2(&filter->fo_filter_stats.hist[BRW_R_PAGES + wr], nr_pages); - lprocfs_oh_tally_log2(&fed->fed_brw_stats.hist[BRW_R_PAGES + wr], - nr_pages); if (exp->exp_nid_stats && exp->exp_nid_stats->nid_brw_stats) lprocfs_oh_tally_log2(&exp->exp_nid_stats->nid_brw_stats-> hist[BRW_R_PAGES + wr], nr_pages); @@ -413,12 +518,8 @@ void filter_tally(struct obd_export *exp, struct page **pages, int nr_pages, lprocfs_oh_tally(&filter->fo_filter_stats.hist[BRW_R_DISCONT_PAGES +wr], discont_pages); - lprocfs_oh_tally(&fed->fed_brw_stats.hist[BRW_R_DISCONT_PAGES + wr], - discont_pages); lprocfs_oh_tally(&filter->fo_filter_stats.hist[BRW_R_DISCONT_BLOCKS+wr], discont_blocks); - lprocfs_oh_tally(&fed->fed_brw_stats.hist[BRW_R_DISCONT_BLOCKS + wr], - discont_blocks); if (exp->exp_nid_stats && exp->exp_nid_stats->nid_brw_stats) { lprocfs_oh_tally_log2(&exp->exp_nid_stats->nid_brw_stats-> @@ -475,7 +576,7 @@ static void brw_stats_show(struct seq_file *seq, struct brw_stats *brw_stats) struct timeval now; /* this sampling races with updates */ - do_gettimeofday(&now); + cfs_gettimeofday(&now); seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", now.tv_sec, now.tv_usec); @@ -501,7 +602,7 @@ static void brw_stats_show(struct seq_file *seq, struct brw_stats *brw_stats) { char title[24]; - sprintf(title, "I/O time (1/%ds)", HZ); + sprintf(title, "I/O time (1/%ds)", CFS_HZ); display_brw_stats(seq, title, "ios", &brw_stats->hist[BRW_R_IO_TIME], &brw_stats->hist[BRW_W_IO_TIME], 1); @@ -546,30 +647,6 @@ int lproc_filter_attach_seqstat(struct obd_device *dev) &filter_brw_stats_fops, dev); } -static int filter_per_export_stats_seq_show(struct seq_file *seq, void *v) -{ - struct filter_export_data *fed = seq->private; - - brw_stats_show(seq, &fed->fed_brw_stats); - - return 0; -} - -static ssize_t filter_per_export_stats_seq_write(struct file *file, - const char *buf, size_t len, loff_t *off) -{ - struct seq_file *seq = file->private_data; - struct filter_export_data *fed = seq->private; - int i; - - for (i = 0; i < BRW_LAST; i++) - lprocfs_oh_clear(&fed->fed_brw_stats.hist[i]); - - return len; -} - -LPROC_SEQ_FOPS(filter_per_export_stats); - void lprocfs_filter_init_vars(struct lprocfs_static_vars *lvars) { lvars->module_vars = lprocfs_filter_module_vars; @@ -578,10 +655,10 @@ void lprocfs_filter_init_vars(struct lprocfs_static_vars *lvars) static int filter_per_nid_stats_seq_show(struct seq_file *seq, void *v) { - nid_stat_t *tmp = seq->private; + nid_stat_t * stat = seq->private; - if (tmp->nid_brw_stats) - brw_stats_show(seq, tmp->nid_brw_stats); + if (stat->nid_brw_stats) + brw_stats_show(seq, stat->nid_brw_stats); return 0; } @@ -590,13 +667,13 @@ static ssize_t filter_per_nid_stats_seq_write(struct file *file, const char *buf, size_t len, loff_t *off) { - struct seq_file *seq = file->private_data; - nid_stat_t *tmp = seq->private; + struct seq_file *seq = file->private_data; + nid_stat_t *stat = seq->private; int i; - if (tmp->nid_brw_stats) + if (stat->nid_brw_stats) for (i = 0; i < BRW_LAST; i++) - lprocfs_oh_clear(&tmp->nid_brw_stats->hist[i]); + lprocfs_oh_clear(&stat->nid_brw_stats->hist[i]); return len; }