lproc_osc.c

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

C
556
字号
/* -*- 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>#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))#include <asm/statfs.h>#endif#include <obd_class.h>#include <lprocfs_status.h>#include <linux/seq_file.h>#include "osc_internal.h"#ifdef LPROCFSstatic int osc_rd_active(char *page, char **start, off_t off,                         int count, int *eof, void *data){        struct obd_device *dev = data;        int rc;        LPROCFS_CLIMP_CHECK(dev);        rc = snprintf(page, count, "%d\n", !dev->u.cli.cl_import->imp_deactive);        LPROCFS_CLIMP_EXIT(dev);        return rc;}static int osc_wr_active(struct file *file, const char *buffer,                         unsigned long count, void *data){        struct obd_device *dev = data;        int val, rc;                rc = lprocfs_write_helper(buffer, count, &val);        if (rc)                return rc;        if (val < 0 || val > 1)                return -ERANGE;        LPROCFS_CLIMP_CHECK(dev);        /* opposite senses */        if (dev->u.cli.cl_import->imp_deactive == val)                 rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val);        else                CDEBUG(D_CONFIG, "activate %d: ignoring repeat request\n", val);                LPROCFS_CLIMP_EXIT(dev);        return count;}static int osc_rd_max_pages_per_rpc(char *page, char **start, off_t off,                                    int count, int *eof, void *data){        struct obd_device *dev = data;        struct client_obd *cli = &dev->u.cli;        int rc;        client_obd_list_lock(&cli->cl_loi_list_lock);        rc = snprintf(page, count, "%d\n", cli->cl_max_pages_per_rpc);        client_obd_list_unlock(&cli->cl_loi_list_lock);        return rc;}static int osc_wr_max_pages_per_rpc(struct file *file, const char *buffer,                                    unsigned long count, void *data){        struct obd_device *dev = data;        struct client_obd *cli = &dev->u.cli;        struct obd_connect_data *ocd;        int val, rc;        rc = lprocfs_write_helper(buffer, count, &val);        if (rc)                return rc;        LPROCFS_CLIMP_CHECK(dev);        ocd = &cli->cl_import->imp_connect_data;        if (val < 1 || val > ocd->ocd_brw_size >> CFS_PAGE_SHIFT) {                LPROCFS_CLIMP_EXIT(dev);                return -ERANGE;        }        client_obd_list_lock(&cli->cl_loi_list_lock);        cli->cl_max_pages_per_rpc = val;        client_obd_list_unlock(&cli->cl_loi_list_lock);        LPROCFS_CLIMP_EXIT(dev);        return count;}static int osc_rd_max_rpcs_in_flight(char *page, char **start, off_t off,                                     int count, int *eof, void *data){        struct obd_device *dev = data;        struct client_obd *cli = &dev->u.cli;        int rc;        client_obd_list_lock(&cli->cl_loi_list_lock);        rc = snprintf(page, count, "%u\n", cli->cl_max_rpcs_in_flight);        client_obd_list_unlock(&cli->cl_loi_list_lock);        return rc;}static int osc_wr_max_rpcs_in_flight(struct file *file, const char *buffer,                                     unsigned long count, void *data){        struct obd_device *dev = data;        struct client_obd *cli = &dev->u.cli;        struct ptlrpc_request_pool *pool;        int val, rc;        rc = lprocfs_write_helper(buffer, count, &val);        if (rc)                return rc;        if (val < 1 || val > OSC_MAX_RIF_MAX)                return -ERANGE;        LPROCFS_CLIMP_CHECK(dev);        pool = cli->cl_import->imp_rq_pool;        if (pool && val > cli->cl_max_rpcs_in_flight)                pool->prp_populate(pool, val-cli->cl_max_rpcs_in_flight);        client_obd_list_lock(&cli->cl_loi_list_lock);        cli->cl_max_rpcs_in_flight = val;        client_obd_list_unlock(&cli->cl_loi_list_lock);        LPROCFS_CLIMP_EXIT(dev);        return count;}static int osc_rd_max_dirty_mb(char *page, char **start, off_t off, int count,                               int *eof, void *data){        struct obd_device *dev = data;        struct client_obd *cli = &dev->u.cli;        long val;        int mult;        client_obd_list_lock(&cli->cl_loi_list_lock);        val = cli->cl_dirty_max;        client_obd_list_unlock(&cli->cl_loi_list_lock);        mult = 1 << 20;        return lprocfs_read_frac_helper(page, count, val, mult);}static int osc_wr_max_dirty_mb(struct file *file, const char *buffer,                               unsigned long count, void *data){        struct obd_device *dev = data;        struct client_obd *cli = &dev->u.cli;        int pages_number, mult, rc;        mult = 1 << (20 - CFS_PAGE_SHIFT);        rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);        if (rc)                return rc;        if (pages_number < 0 || pages_number > OSC_MAX_DIRTY_MB_MAX << (20 - CFS_PAGE_SHIFT) ||            pages_number > num_physpages / 4) /* 1/4 of RAM */                return -ERANGE;        client_obd_list_lock(&cli->cl_loi_list_lock);        cli->cl_dirty_max = (obd_count)(pages_number << CFS_PAGE_SHIFT);        osc_wake_cache_waiters(cli);        client_obd_list_unlock(&cli->cl_loi_list_lock);        return count;}static int osc_rd_cur_dirty_bytes(char *page, char **start, off_t off,                                  int count, int *eof, void *data){        struct obd_device *dev = data;        struct client_obd *cli = &dev->u.cli;        int rc;        client_obd_list_lock(&cli->cl_loi_list_lock);        rc = snprintf(page, count, "%lu\n", cli->cl_dirty);        client_obd_list_unlock(&cli->cl_loi_list_lock);        return rc;}static int osc_rd_cur_grant_bytes(char *page, char **start, off_t off,                                  int count, int *eof, void *data){        struct obd_device *dev = data;        struct client_obd *cli = &dev->u.cli;        int rc;        client_obd_list_lock(&cli->cl_loi_list_lock);        rc = snprintf(page, count, "%lu\n", cli->cl_avail_grant);        client_obd_list_unlock(&cli->cl_loi_list_lock);        return rc;}static int osc_rd_create_count(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, "%d\n",                        obd->u.cli.cl_oscc.oscc_grow_count);}static int osc_wr_create_count(struct file *file, const char *buffer,                               unsigned long count, void *data){        struct obd_device *obd = data;        int val, rc;        if (obd == NULL)                return 0;        rc = lprocfs_write_helper(buffer, count, &val);        if (rc)                return rc;        if (val < 0)                return -ERANGE;        if (val > OST_MAX_PRECREATE)                return -ERANGE;        obd->u.cli.cl_oscc.oscc_grow_count = val;        return count;}static int osc_rd_prealloc_next_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",                        obd->u.cli.cl_oscc.oscc_next_id);}static int osc_rd_prealloc_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",                        obd->u.cli.cl_oscc.oscc_last_id);}static int osc_rd_checksum(char *page, char **start, off_t off, int count,                           int *eof, void *data){

⌨️ 快捷键说明

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