+ if (rc)
+ return rc;
+
+ spin_lock_bh(&obd->obd_processing_task_lock);
+ obd->u.filter.fo_read_cache = val;
+ spin_unlock_bh(&obd->obd_processing_task_lock);
+ return count;
+}
+
+static int lprocfs_filter_rd_wcache(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_writethrough_cache);
+}
+
+static int lprocfs_filter_wr_wcache(struct file *file, const char *buffer,
+ unsigned long count, void *data)
+{
+ struct obd_device *obd = (struct obd_device *)data;
+ int val, rc;
+ LASSERT(obd != NULL);
+
+ rc = lprocfs_write_helper(buffer, count, &val);
+
+ if (rc)
+ return rc;
+
+ spin_lock_bh(&obd->obd_processing_task_lock);
+ obd->u.filter.fo_writethrough_cache = val;
+ spin_unlock_bh(&obd->obd_processing_task_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;
+
+ spin_lock(&obd->obd_osfs_lock);
+ obd->u.filter.fo_raid_degraded = !!val;
+ spin_unlock(&obd->obd_osfs_lock);
+ return count;
+}
+
+static struct lprocfs_vars lprocfs_filter_obd_vars[] = {
+ { "uuid", lprocfs_rd_uuid, 0, 0 },
+ { "blocksize", lprocfs_rd_blksize, 0, 0 },
+ { "kbytestotal", lprocfs_rd_kbytestotal, 0, 0 },
+ { "kbytesfree", lprocfs_rd_kbytesfree, 0, 0 },
+ { "kbytesavail", lprocfs_rd_kbytesavail, 0, 0 },
+ { "filestotal", lprocfs_rd_filestotal, 0, 0 },
+ { "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 },
+ { "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},
+ { "evict_client", 0, lprocfs_wr_evict_client, 0,
+ &lprocfs_evict_client_fops},
+ { "num_exports", lprocfs_rd_num_exports, 0, 0 },
+ { "readcache_max_filesize",
+ lprocfs_filter_rd_readcache,
+ lprocfs_filter_wr_readcache, 0 },
+#ifdef HAVE_QUOTA_SUPPORT
+ { "quota_type", lprocfs_quota_rd_type,
+ lprocfs_quota_wr_type, 0},
+#endif
+ { "client_cache_count", lprocfs_filter_rd_fmd_max_num,
+ lprocfs_filter_wr_fmd_max_num, 0 },
+ { "client_cache_seconds", lprocfs_filter_rd_fmd_max_age,
+ lprocfs_filter_wr_fmd_max_age, 0 },
+ { "capa", lprocfs_filter_rd_capa,
+ lprocfs_filter_wr_capa, 0 },
+ { "capa_count", lprocfs_filter_rd_capa_count, 0, 0 },
+ { "sec_level", lprocfs_rd_sec_level,
+ lprocfs_wr_sec_level, 0 },
+ { "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 },
+ { 0 }
+};
+
+static struct lprocfs_vars lprocfs_filter_module_vars[] = {
+ { "num_refs", lprocfs_rd_numrefs, 0, 0 },
+ { 0 }
+};
+
+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 page *last_page = NULL;
+ unsigned long *last_block = NULL;
+ unsigned long discont_pages = 0;
+ unsigned long discont_blocks = 0;
+ int i;
+
+ if (nr_pages == 0)
+ return;
+
+ lprocfs_oh_tally_log2(&filter->fo_filter_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);
+
+ while (nr_pages-- > 0) {
+ if (last_page && (*pages)->index != (last_page->index + 1))
+ discont_pages++;
+ last_page = *pages;
+ pages++;
+ for (i = 0; i < blocks_per_page; i++) {
+ if (last_block && *blocks != (*last_block + 1))
+ discont_blocks++;
+ last_block = blocks++;
+ }
+ }
+
+ lprocfs_oh_tally(&filter->fo_filter_stats.hist[BRW_R_DISCONT_PAGES +wr],
+ discont_pages);
+ lprocfs_oh_tally(&filter->fo_filter_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->
+ hist[BRW_R_DISCONT_PAGES + wr],
+ discont_pages);
+ lprocfs_oh_tally_log2(&exp->exp_nid_stats->nid_brw_stats->
+ hist[BRW_R_DISCONT_BLOCKS + wr],
+ discont_blocks);