📄 lproc_llite.c
字号:
/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * * Copyright (C) 2002 Cluster File Systems, Inc. * * This file is part of Lustre, http://www.lustre.org. * * Lustre is free 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. * * 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 * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Lustre; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */#define DEBUG_SUBSYSTEM S_LLITE#include <linux/version.h>#include <lustre_lite.h>#include <lprocfs_status.h>#include <linux/seq_file.h>#include <obd_support.h>#include "llite_internal.h"struct proc_dir_entry *proc_lustre_fs_root;#ifdef LPROCFS/* /proc/lustre/llite mount point registration */struct file_operations llite_dump_pgcache_fops;struct file_operations ll_ra_stats_fops;struct file_operations ll_rw_extents_stats_fops;struct file_operations ll_rw_extents_stats_pp_fops;struct file_operations ll_rw_offset_stats_fops;static int ll_rd_blksize(char *page, char **start, off_t off, int count, int *eof, void *data){ struct super_block *sb = (struct super_block *)data; struct obd_statfs osfs; int rc; LASSERT(sb != NULL); rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - HZ, OBD_STATFS_NODELAY); if (!rc) { *eof = 1; rc = snprintf(page, count, "%u\n", osfs.os_bsize); } return rc;}static int ll_rd_kbytestotal(char *page, char **start, off_t off, int count, int *eof, void *data){ struct super_block *sb = (struct super_block *)data; struct obd_statfs osfs; int rc; LASSERT(sb != NULL); rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - HZ, OBD_STATFS_NODELAY); if (!rc) { __u32 blk_size = osfs.os_bsize >> 10; __u64 result = osfs.os_blocks; while (blk_size >>= 1) result <<= 1; *eof = 1; rc = snprintf(page, count, LPU64"\n", result); } return rc;}static int ll_rd_kbytesfree(char *page, char **start, off_t off, int count, int *eof, void *data){ struct super_block *sb = (struct super_block *)data; struct obd_statfs osfs; int rc; LASSERT(sb != NULL); rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - HZ, OBD_STATFS_NODELAY); if (!rc) { __u32 blk_size = osfs.os_bsize >> 10; __u64 result = osfs.os_bfree; while (blk_size >>= 1) result <<= 1; *eof = 1; rc = snprintf(page, count, LPU64"\n", result); } return rc;}static int ll_rd_kbytesavail(char *page, char **start, off_t off, int count, int *eof, void *data){ struct super_block *sb = (struct super_block *)data; struct obd_statfs osfs; int rc; LASSERT(sb != NULL); rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - HZ, OBD_STATFS_NODELAY); if (!rc) { __u32 blk_size = osfs.os_bsize >> 10; __u64 result = osfs.os_bavail; while (blk_size >>= 1) result <<= 1; *eof = 1; rc = snprintf(page, count, LPU64"\n", result); } return rc;}static int ll_rd_filestotal(char *page, char **start, off_t off, int count, int *eof, void *data){ struct super_block *sb = (struct super_block *)data; struct obd_statfs osfs; int rc; LASSERT(sb != NULL); rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - HZ, OBD_STATFS_NODELAY); if (!rc) { *eof = 1; rc = snprintf(page, count, LPU64"\n", osfs.os_files); } return rc;}static int ll_rd_filesfree(char *page, char **start, off_t off, int count, int *eof, void *data){ struct super_block *sb = (struct super_block *)data; struct obd_statfs osfs; int rc; LASSERT(sb != NULL); rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - HZ, OBD_STATFS_NODELAY); if (!rc) { *eof = 1; rc = snprintf(page, count, LPU64"\n", osfs.os_ffree); } return rc;}static int ll_rd_fstype(char *page, char **start, off_t off, int count, int *eof, void *data){ struct super_block *sb = (struct super_block*)data; LASSERT(sb != NULL); *eof = 1; return snprintf(page, count, "%s\n", sb->s_type->name);}static int ll_rd_sb_uuid(char *page, char **start, off_t off, int count, int *eof, void *data){ struct super_block *sb = (struct super_block *)data; LASSERT(sb != NULL); *eof = 1; return snprintf(page, count, "%s\n", ll_s2sbi(sb)->ll_sb_uuid.uuid);}static int ll_rd_max_readahead_mb(char *page, char **start, off_t off, int count, int *eof, void *data){ struct super_block *sb = data; struct ll_sb_info *sbi = ll_s2sbi(sb); long pages_number; int mult; spin_lock(&sbi->ll_lock); pages_number = sbi->ll_ra_info.ra_max_pages; spin_unlock(&sbi->ll_lock); mult = 1 << (20 - CFS_PAGE_SHIFT); return lprocfs_read_frac_helper(page, count, pages_number, mult);}static int ll_wr_max_readahead_mb(struct file *file, const char *buffer, unsigned long count, void *data){ struct super_block *sb = data; struct ll_sb_info *sbi = ll_s2sbi(sb); int mult, rc, pages_number; 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 > num_physpages / 2) { CERROR("can't set file readahead more than %lu MB\n", num_physpages >> (20 - CFS_PAGE_SHIFT + 1)); /*1/2 of RAM*/ return -ERANGE; } spin_lock(&sbi->ll_lock); sbi->ll_ra_info.ra_max_pages = pages_number; spin_unlock(&sbi->ll_lock); return count;}static int ll_rd_max_read_ahead_whole_mb(char *page, char **start, off_t off, int count, int *eof, void *data){ struct super_block *sb = data; struct ll_sb_info *sbi = ll_s2sbi(sb); long pages_number; int mult; spin_lock(&sbi->ll_lock); pages_number = sbi->ll_ra_info.ra_max_read_ahead_whole_pages; spin_unlock(&sbi->ll_lock); mult = 1 << (20 - CFS_PAGE_SHIFT); return lprocfs_read_frac_helper(page, count, pages_number, mult);}static int ll_wr_max_read_ahead_whole_mb(struct file *file, const char *buffer, unsigned long count, void *data){ struct super_block *sb = data; struct ll_sb_info *sbi = ll_s2sbi(sb); int mult, rc, pages_number; mult = 1 << (20 - CFS_PAGE_SHIFT); rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult); if (rc) return rc; /* Cap this at the current max readahead window size, the readahead * algorithm does this anyway so it's pointless to set it larger. */ if (pages_number < 0 || pages_number > sbi->ll_ra_info.ra_max_pages) { CERROR("can't set max_read_ahead_whole_mb more than " "max_read_ahead_mb: %lu\n", sbi->ll_ra_info.ra_max_pages >> (20 - CFS_PAGE_SHIFT)); return -ERANGE; } spin_lock(&sbi->ll_lock); sbi->ll_ra_info.ra_max_read_ahead_whole_pages = pages_number; spin_unlock(&sbi->ll_lock); return count;}static int ll_rd_max_cached_mb(char *page, char **start, off_t off, int count, int *eof, void *data){ struct super_block *sb = data; struct ll_sb_info *sbi = ll_s2sbi(sb); long pages_number; int mult; spin_lock(&sbi->ll_lock); pages_number = sbi->ll_async_page_max; spin_unlock(&sbi->ll_lock); mult = 1 << (20 - CFS_PAGE_SHIFT); return lprocfs_read_frac_helper(page, count, pages_number, mult);;}static int ll_wr_max_cached_mb(struct file *file, const char *buffer, unsigned long count, void *data){ struct super_block *sb = data; struct ll_sb_info *sbi = ll_s2sbi(sb); int mult, rc, pages_number; 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 > num_physpages) { CERROR("can't set max cache more than %lu MB\n", num_physpages >> (20 - CFS_PAGE_SHIFT)); return -ERANGE; } spin_lock(&sbi->ll_lock); sbi->ll_async_page_max = pages_number ; spin_unlock(&sbi->ll_lock); if (!sbi->ll_osc_exp) /* Not set up yet, don't call llap_shrink_cache */ return count; if (sbi->ll_async_page_count >= sbi->ll_async_page_max) llap_shrink_cache(sbi, 0); return count;}static int ll_rd_checksum(char *page, char **start, off_t off, int count, int *eof, void *data){ struct super_block *sb = data; struct ll_sb_info *sbi = ll_s2sbi(sb); return snprintf(page, count, "%u\n", (sbi->ll_flags & LL_SBI_LLITE_CHECKSUM) ? 1 : 0);}static int ll_wr_checksum(struct file *file, const char *buffer, unsigned long count, void *data){ struct super_block *sb = data; struct ll_sb_info *sbi = ll_s2sbi(sb); int val, rc; if (!sbi->ll_osc_exp) /* Not set up yet */ return -EAGAIN;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -