⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lproc_mds.c

📁 lustre 1.6.5 source code
💻 C
📖 第 1 页 / 共 2 页
字号:
        kernbuf[count] = '\0';        uid = simple_strtoul(kernbuf, &tmp, 0);        if (kernbuf == tmp) {                if (tmp[0] != ':')                        return -EINVAL;                uid = mds->mds_squash_uid;        }        /* skip ':' */        tmp++;        gid = simple_strtoul(tmp, &end, 0);        if (tmp == end)                gid = mds->mds_squash_gid;        mds->mds_squash_uid = uid;        mds->mds_squash_gid = gid;        return count;}static int lprocfs_rd_rootsquash(char *page, char **start, off_t off,                                 int count, int *eof, void *data){        struct obd_device *obd = data;        struct mds_obd *mds = &obd->u.mds;        *eof = 1;        return snprintf(page, count, "%lu:%lu\n",                        (unsigned long)mds->mds_squash_uid,                        (unsigned long)mds->mds_squash_gid);}static int lprocfs_wr_nosquash_nid(struct file *file, const char *buffer,                                   unsigned long count, void *data){        struct obd_device *obd = data;        struct mds_obd *mds = &obd->u.mds;        char kernbuf[30], *start, *end;        if (count > (sizeof(kernbuf) - 1))                return -EINVAL;        if (copy_from_user(kernbuf, buffer, count))                return -EFAULT;        kernbuf[count] = '\0';        /* strip frontal whitespaces */        start = kernbuf;        while (*start && isspace(*start))                start++;        /* EOL - string doesn't contain NID */        if (*start == '\0')                return -EINVAL;        /* strip backward whitespaces */        end = kernbuf + count - 1;        while (*end && isspace(*end))                end--;        *(end + 1) = '\0';        mds->mds_nosquash_nid = libcfs_str2nid(start);        return count;}static int lprocfs_rd_nosquash_nid(char *page, char **start, off_t off,                                   int count, int *eof, void *data){        struct obd_device *obd = data;        struct mds_obd *mds = &obd->u.mds;        *eof = 1;        return snprintf(page, count, "%s\n",                        libcfs_nid2str(mds->mds_nosquash_nid));}#ifdef HAVE_QUOTA_SUPPORTstatic int lprocfs_mds_rd_switch_qs(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, "changing qunit size is %s\n",                        obd->u.obt.obt_qctxt.lqc_switch_qs ?                        "enabled" : "disabled");}static int lprocfs_mds_rd_boundary_factor(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, "%lu\n",                        obd->u.obt.obt_qctxt.lqc_cqs_boundary_factor);}static int lprocfs_mds_rd_least_bunit(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, "%lu\n",                        obd->u.obt.obt_qctxt.lqc_cqs_least_bunit);}static int lprocfs_mds_rd_least_iunit(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, "%lu\n",                        obd->u.obt.obt_qctxt.lqc_cqs_least_iunit);}static int lprocfs_mds_rd_qs_factor(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, "%lu\n",                        obd->u.obt.obt_qctxt.lqc_cqs_qs_factor);}static int lprocfs_mds_wr_switch_qs(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;        if (val)            obd->u.obt.obt_qctxt.lqc_switch_qs = 1;        else            obd->u.obt.obt_qctxt.lqc_switch_qs = 0;        return count;}static int lprocfs_mds_wr_boundary_factor(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;        if (val < 2)                return -EINVAL;        obd->u.obt.obt_qctxt.lqc_cqs_boundary_factor = val;        return count;}static int lprocfs_mds_wr_least_bunit(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;        if (val < PTLRPC_MAX_BRW_SIZE ||            val >= obd->u.obt.obt_qctxt.lqc_bunit_sz)                return -EINVAL;        obd->u.obt.obt_qctxt.lqc_cqs_least_bunit = val;        return count;}static int lprocfs_mds_wr_least_iunit(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;        if (val < 1 || val >= obd->u.obt.obt_qctxt.lqc_iunit_sz)                return -EINVAL;        obd->u.obt.obt_qctxt.lqc_cqs_least_iunit = val;        return count;}static int lprocfs_mds_wr_qs_factor(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;        if (val < 2)                return -EINVAL;        obd->u.obt.obt_qctxt.lqc_cqs_qs_factor = val;        return count;}#endifstruct lprocfs_vars lprocfs_mds_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 },        { "fstype",          lprocfs_rd_fstype,      0, 0 },        { "mntdev",          lprocfs_mds_rd_mntdev,  0, 0 },        { "recovery_status", lprocfs_obd_rd_recovery_status, 0, 0 },        { "evict_client",    0,                lprocfs_mds_wr_evict_client, 0 },        { "evict_ost_nids",  lprocfs_mds_rd_evictostnids,                                               lprocfs_mds_wr_evictostnids, 0 },        { "num_exports",     lprocfs_rd_num_exports, 0, 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_qs", lprocfs_mds_rd_switch_qs,                             lprocfs_mds_wr_switch_qs, 0 },        { "quota_boundary_factor", lprocfs_mds_rd_boundary_factor,                                   lprocfs_mds_wr_boundary_factor, 0 },        { "quota_least_bunit", lprocfs_mds_rd_least_bunit,                               lprocfs_mds_wr_least_bunit, 0 },        { "quota_least_iunit", lprocfs_mds_rd_least_iunit,                               lprocfs_mds_wr_least_iunit, 0 },        { "quota_qs_factor",   lprocfs_mds_rd_qs_factor,                               lprocfs_mds_wr_qs_factor, 0 },        { "quota_switch_seconds",  lprocfs_quota_rd_switch_seconds,                                   lprocfs_quota_wr_switch_seconds, 0 },#endif        { "group_expire_interval", lprocfs_rd_group_expire,                             lprocfs_wr_group_expire, 0},        { "group_acquire_expire", lprocfs_rd_group_acquire_expire,                             lprocfs_wr_group_acquire_expire, 0},        { "group_upcall",    lprocfs_rd_group_upcall,                             lprocfs_wr_group_upcall, 0},        { "group_flush",     0, lprocfs_wr_group_flush, 0},        { "group_info",      0, lprocfs_wr_group_info, 0 },        { "atime_diff",      lprocfs_rd_atime_diff, lprocfs_wr_atime_diff, 0 },        { "rootsquash",      lprocfs_rd_rootsquash,                             lprocfs_wr_rootsquash, 0 },        { "nosquash_nid",    lprocfs_rd_nosquash_nid,                             lprocfs_wr_nosquash_nid, 0 },        { 0 }};struct lprocfs_vars lprocfs_mds_module_vars[] = {        { "num_refs",     lprocfs_rd_numrefs,     0, 0 },        { 0 }};struct lprocfs_vars lprocfs_mdt_obd_vars[] = {        { "uuid",         lprocfs_rd_uuid,        0, 0 },        { 0 }};struct lprocfs_vars lprocfs_mdt_module_vars[] = {        { "num_refs",     lprocfs_rd_numrefs,     0, 0 },        { 0 }};void mds_counter_incr(struct obd_export *exp, int opcode){        if (exp->exp_obd && exp->exp_obd->obd_stats)                lprocfs_counter_incr(exp->exp_obd->obd_stats, opcode);        if (exp->exp_nid_stats && exp->exp_nid_stats->nid_stats != NULL)                lprocfs_counter_incr(exp->exp_nid_stats->nid_stats, opcode);}void mds_stats_counter_init(struct lprocfs_stats *stats){        lprocfs_counter_init(stats, LPROC_MDS_OPEN, 0, "open", "reqs");        lprocfs_counter_init(stats, LPROC_MDS_CLOSE, 0, "close", "reqs");        lprocfs_counter_init(stats, LPROC_MDS_MKNOD, 0, "mknod", "reqs");        lprocfs_counter_init(stats, LPROC_MDS_LINK, 0, "link", "reqs");        lprocfs_counter_init(stats, LPROC_MDS_UNLINK, 0, "unlink", "reqs");        lprocfs_counter_init(stats, LPROC_MDS_MKDIR, 0, "mkdir", "reqs");        lprocfs_counter_init(stats, LPROC_MDS_RMDIR, 0, "rmdir", "reqs");        lprocfs_counter_init(stats, LPROC_MDS_RENAME, 0, "rename", "reqs");        lprocfs_counter_init(stats, LPROC_MDS_GETXATTR, 0, "getxattr", "reqs");        lprocfs_counter_init(stats, LPROC_MDS_SETXATTR, 0, "setxattr", "reqs");}void lprocfs_mds_init_vars(struct lprocfs_static_vars *lvars){    lvars->module_vars = lprocfs_mds_module_vars;    lvars->obd_vars = lprocfs_mds_obd_vars;}void lprocfs_mdt_init_vars(struct lprocfs_static_vars *lvars){    lvars->module_vars = lprocfs_mdt_module_vars;    lvars->obd_vars = lprocfs_mdt_obd_vars;}#endif

⌨️ 快捷键说明

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