lproc_obdfilter.c

来自「lustre 1.6.5 source code」· C语言 代码 · 共 459 行 · 第 1/2 页

C
459
字号
/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * *  Copyright (C) 2002, 2003 Cluster File Systems, Inc. * *   This file is part of the Lustre file system, http://www.lustre.org *   Lustre is a trademark of Cluster File Systems, Inc. * *   You may have signed or agreed to another license before downloading *   this software.  If so, you are bound by the terms and conditions *   of that agreement, and the following does not apply to you.  See the *   LICENSE file included with this distribution for more information. * *   If you did not agree to a different license, then this copy of Lustre *   is open source software; you can redistribute it and/or modify it *   under the terms of version 2 of the GNU General Public License as *   published by the Free Software Foundation. * *   In either case, Lustre is distributed in the hope that it will be *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *   license text for more details. * */#define DEBUG_SUBSYSTEM S_CLASS#include <linux/version.h>#include <lprocfs_status.h>#include <obd.h>#include <linux/seq_file.h>#include <linux/version.h>#include "filter_internal.h"#ifdef LPROCFSstatic int lprocfs_filter_rd_groups(char *page, char **start, off_t off,                                    int count, int *eof, void *data){        *eof = 1;        return snprintf(page, count, "%u\n", FILTER_GROUPS);}static int lprocfs_filter_rd_tot_dirty(char *page, char **start, off_t off,                                       int count, int *eof, void *data){        struct obd_device *obd = (struct obd_device *)data;        LASSERT(obd != NULL);        *eof = 1;        return snprintf(page, count, LPU64"\n", obd->u.filter.fo_tot_dirty);}static int lprocfs_filter_rd_tot_granted(char *page, char **start, off_t off,                                         int count, int *eof, void *data){        struct obd_device *obd = (struct obd_device *)data;        LASSERT(obd != NULL);        *eof = 1;        return snprintf(page, count, LPU64"\n", obd->u.filter.fo_tot_granted);}static int lprocfs_filter_rd_tot_pending(char *page, char **start, off_t off,                                         int count, int *eof, void *data){        struct obd_device *obd = (struct obd_device *)data;        LASSERT(obd != NULL);        *eof = 1;        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){        struct obd_device *obd = data;        if (obd == NULL)                return 0;        return snprintf(page, count, LPU64"\n",                        filter_last_id(&obd->u.filter, 0));}int lprocfs_filter_rd_readcache(char *page, char **start, off_t off, int count,                                int *eof, void *data){        struct obd_device *obd = data;        int rc;        rc = snprintf(page, count, LPU64"\n",                      obd->u.filter.fo_readcache_max_filesize);        return rc;}int lprocfs_filter_wr_readcache(struct file *file, const char *buffer,                                unsigned long count, void *data){        struct obd_device *obd = data;        __u64 val;        int rc;        rc = lprocfs_write_u64_helper(buffer, count, &val);        if (rc)                return rc;        obd->u.filter.fo_readcache_max_filesize = val;        return count;}int lprocfs_filter_rd_fmd_max_num(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_fmd_max_num);        return rc;}int lprocfs_filter_wr_fmd_max_num(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 > 65536 || val < 1)                return -EINVAL;        obd->u.filter.fo_fmd_max_num = val;        return count;}int lprocfs_filter_rd_fmd_max_age(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_fmd_max_age / HZ);        return rc;}int lprocfs_filter_wr_fmd_max_age(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 > 65536 || val < 1)                return -EINVAL;        obd->u.filter.fo_fmd_max_age = val * HZ;        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 },        { "recovery_status", lprocfs_obd_rd_recovery_status, 0, 0 },#ifdef CRAY_XT3        { "recovery_maxtime", lprocfs_obd_rd_recovery_maxtime,                              lprocfs_obd_wr_recovery_maxtime, 0},#endif        { "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_bunit_sz", lprocfs_quota_rd_bunit,                            lprocfs_quota_wr_bunit, 0},        { "quota_btune_sz", lprocfs_quota_rd_btune,                            lprocfs_quota_wr_btune, 0},        { "quota_iunit_sz", lprocfs_quota_rd_iunit,                            lprocfs_quota_wr_iunit, 0},        { "quota_itune_sz", lprocfs_quota_rd_itune,                            lprocfs_quota_wr_itune, 0},        { "quota_type",     lprocfs_quota_rd_type,                            lprocfs_quota_wr_type, 0},        { "quota_switch_seconds",  lprocfs_quota_rd_switch_seconds,                            lprocfs_quota_wr_switch_seconds, 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 },        { 0 }};static struct lprocfs_vars lprocfs_filter_module_vars[] = {        { "num_refs",     lprocfs_rd_numrefs,       0, 0 },        { 0 }};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?