1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 #define DEBUG_SUBSYSTEM S_LLITE
38 #include <linux/version.h>
39 #include <lustre_lite.h>
40 #include <lprocfs_status.h>
41 #include <linux/seq_file.h>
42 #include <obd_support.h>
44 #include "llite_internal.h"
46 struct proc_dir_entry *proc_lustre_fs_root;
49 /* /proc/lustre/llite mount point registration */
50 struct file_operations llite_dump_pgcache_fops;
51 struct file_operations ll_rw_extents_stats_fops;
52 struct file_operations ll_rw_extents_stats_pp_fops;
53 struct file_operations ll_rw_offset_stats_fops;
55 static int ll_rd_blksize(char *page, char **start, off_t off, int count,
58 struct super_block *sb = (struct super_block *)data;
59 struct obd_statfs osfs;
63 rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - HZ,
67 rc = snprintf(page, count, "%u\n", osfs.os_bsize);
73 static int ll_rd_kbytestotal(char *page, char **start, off_t off, int count,
76 struct super_block *sb = (struct super_block *)data;
77 struct obd_statfs osfs;
81 rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - HZ,
84 __u32 blk_size = osfs.os_bsize >> 10;
85 __u64 result = osfs.os_blocks;
87 while (blk_size >>= 1)
91 rc = snprintf(page, count, LPU64"\n", result);
97 static int ll_rd_kbytesfree(char *page, char **start, off_t off, int count,
100 struct super_block *sb = (struct super_block *)data;
101 struct obd_statfs osfs;
105 rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - HZ,
108 __u32 blk_size = osfs.os_bsize >> 10;
109 __u64 result = osfs.os_bfree;
111 while (blk_size >>= 1)
115 rc = snprintf(page, count, LPU64"\n", result);
120 static int ll_rd_kbytesavail(char *page, char **start, off_t off, int count,
121 int *eof, void *data)
123 struct super_block *sb = (struct super_block *)data;
124 struct obd_statfs osfs;
128 rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - HZ,
131 __u32 blk_size = osfs.os_bsize >> 10;
132 __u64 result = osfs.os_bavail;
134 while (blk_size >>= 1)
138 rc = snprintf(page, count, LPU64"\n", result);
143 static int ll_rd_filestotal(char *page, char **start, off_t off, int count,
144 int *eof, void *data)
146 struct super_block *sb = (struct super_block *)data;
147 struct obd_statfs osfs;
151 rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - HZ,
155 rc = snprintf(page, count, LPU64"\n", osfs.os_files);
160 static int ll_rd_filesfree(char *page, char **start, off_t off, int count,
161 int *eof, void *data)
163 struct super_block *sb = (struct super_block *)data;
164 struct obd_statfs osfs;
168 rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - HZ,
172 rc = snprintf(page, count, LPU64"\n", osfs.os_ffree);
178 static int ll_rd_client_type(char *page, char **start, off_t off, int count,
179 int *eof, void *data)
181 struct ll_sb_info *sbi = ll_s2sbi((struct super_block *)data);
184 LASSERT(sbi != NULL);
187 if (sbi->ll_flags & LL_SBI_RMT_CLIENT)
188 rc = snprintf(page, count, "remote client\n");
190 rc = snprintf(page, count, "local client\n");
195 static int ll_rd_fstype(char *page, char **start, off_t off, int count,
196 int *eof, void *data)
198 struct super_block *sb = (struct super_block*)data;
202 return snprintf(page, count, "%s\n", sb->s_type->name);
205 static int ll_rd_sb_uuid(char *page, char **start, off_t off, int count,
206 int *eof, void *data)
208 struct super_block *sb = (struct super_block *)data;
212 return snprintf(page, count, "%s\n", ll_s2sbi(sb)->ll_sb_uuid.uuid);
215 static int ll_rd_max_readahead_mb(char *page, char **start, off_t off,
216 int count, int *eof, void *data)
218 struct super_block *sb = data;
219 struct ll_sb_info *sbi = ll_s2sbi(sb);
223 spin_lock(&sbi->ll_lock);
224 pages_number = sbi->ll_ra_info.ra_max_pages;
225 spin_unlock(&sbi->ll_lock);
227 mult = 1 << (20 - PAGE_CACHE_SHIFT);
228 return lprocfs_read_frac_helper(page, count, pages_number, mult);
231 static int ll_wr_max_readahead_mb(struct file *file, const char *buffer,
232 unsigned long count, void *data)
234 struct super_block *sb = data;
235 struct ll_sb_info *sbi = ll_s2sbi(sb);
236 int mult, rc, pages_number;
238 mult = 1 << (20 - CFS_PAGE_SHIFT);
239 rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
243 if (pages_number < 0 || pages_number > num_physpages / 2) {
244 CERROR("can't set file readahead more than %lu MB\n",
245 num_physpages >> (20 - CFS_PAGE_SHIFT + 1)); /*1/2 of RAM*/
249 spin_lock(&sbi->ll_lock);
250 sbi->ll_ra_info.ra_max_pages = pages_number;
251 spin_unlock(&sbi->ll_lock);
256 static int ll_rd_max_read_ahead_whole_mb(char *page, char **start, off_t off,
257 int count, int *eof, void *data)
259 struct super_block *sb = data;
260 struct ll_sb_info *sbi = ll_s2sbi(sb);
264 spin_lock(&sbi->ll_lock);
265 pages_number = sbi->ll_ra_info.ra_max_read_ahead_whole_pages;
266 spin_unlock(&sbi->ll_lock);
268 mult = 1 << (20 - CFS_PAGE_SHIFT);
269 return lprocfs_read_frac_helper(page, count, pages_number, mult);
272 static int ll_wr_max_read_ahead_whole_mb(struct file *file, const char *buffer,
273 unsigned long count, void *data)
275 struct super_block *sb = data;
276 struct ll_sb_info *sbi = ll_s2sbi(sb);
277 int mult, rc, pages_number;
279 mult = 1 << (20 - CFS_PAGE_SHIFT);
280 rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
284 /* Cap this at the current max readahead window size, the readahead
285 * algorithm does this anyway so it's pointless to set it larger. */
286 if (pages_number < 0 || pages_number > sbi->ll_ra_info.ra_max_pages) {
287 CERROR("can't set max_read_ahead_whole_mb more than "
288 "max_read_ahead_mb: %lu\n",
289 sbi->ll_ra_info.ra_max_pages >> (20 - CFS_PAGE_SHIFT));
293 spin_lock(&sbi->ll_lock);
294 sbi->ll_ra_info.ra_max_read_ahead_whole_pages = pages_number;
295 spin_unlock(&sbi->ll_lock);
300 static int ll_rd_max_cached_mb(char *page, char **start, off_t off,
301 int count, int *eof, void *data)
303 struct super_block *sb = data;
304 struct ll_sb_info *sbi = ll_s2sbi(sb);
308 spin_lock(&sbi->ll_lock);
309 pages_number = sbi->ll_async_page_max;
310 spin_unlock(&sbi->ll_lock);
312 mult = 1 << (20 - CFS_PAGE_SHIFT);
313 return lprocfs_read_frac_helper(page, count, pages_number, mult);;
316 static int ll_wr_max_cached_mb(struct file *file, const char *buffer,
317 unsigned long count, void *data)
319 struct super_block *sb = data;
320 struct ll_sb_info *sbi = ll_s2sbi(sb);
321 unsigned long budget;
322 int mult, rc, pages_number, cpu;
324 mult = 1 << (20 - CFS_PAGE_SHIFT);
325 rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
329 if (pages_number < 0 || pages_number > num_physpages) {
330 CERROR("can't set max cache more than %lu MB\n",
331 num_physpages >> (20 - CFS_PAGE_SHIFT));
335 spin_lock(&sbi->ll_lock);
336 sbi->ll_async_page_max = pages_number ;
337 spin_unlock(&sbi->ll_lock);
340 /* Not set up yet, don't call llap_shrink_cache */
343 spin_lock(&sbi->ll_async_page_reblnc_lock);
344 budget = sbi->ll_async_page_max / num_online_cpus();
345 for_each_online_cpu(cpu)
346 LL_PGLIST_DATA_CPU(sbi, cpu)->llpd_budget = budget;
347 spin_unlock(&sbi->ll_async_page_reblnc_lock);
349 if (lcounter_read(&sbi->ll_async_page_count) >= sbi->ll_async_page_max)
350 llap_shrink_cache(sbi, -1);
355 static int ll_rd_pgcache_bnlc(char *page, char **start, off_t off,
356 int count, int *eof, void *data)
358 struct super_block *sb = data;
359 struct ll_sb_info *sbi = ll_s2sbi(sb);
360 struct ll_pglist_data *pd;
361 unsigned long total_budget = 0;
364 n += snprintf(page +n, count - n,
365 "cpu\tpage count\tbudget\t\treblnc count\tgen\thit\tmiss\tcross\n");
366 for_each_online_cpu(cpu) {
367 pd = LL_PGLIST_DATA_CPU(sbi, cpu);
368 n += snprintf(page + n, count - n,
369 "%d\t%-8lu\t%-8lu\t%-8lu\t%lu\t%lu\t%lu\t%lu\n",
370 cpu, pd->llpd_count, pd->llpd_budget,
371 pd->llpd_reblnc_count, pd->llpd_gen,
372 pd->llpd_hit, pd->llpd_miss, pd->llpd_cross);
373 total_budget += pd->llpd_budget;
375 n += snprintf(page + n, count - n,
376 "Total budget: %lu, page max: %lu, rebalance cnt: %lu\n",
377 total_budget, sbi->ll_async_page_max,
378 sbi->ll_async_page_reblnc_count);
383 static int ll_rd_checksum(char *page, char **start, off_t off,
384 int count, int *eof, void *data)
386 struct super_block *sb = data;
387 struct ll_sb_info *sbi = ll_s2sbi(sb);
389 return snprintf(page, count, "%u\n",
390 (sbi->ll_flags & LL_SBI_CHECKSUM) ? 1 : 0);
393 static int ll_wr_checksum(struct file *file, const char *buffer,
394 unsigned long count, void *data)
396 struct super_block *sb = data;
397 struct ll_sb_info *sbi = ll_s2sbi(sb);
404 rc = lprocfs_write_helper(buffer, count, &val);
408 sbi->ll_flags |= LL_SBI_CHECKSUM;
410 sbi->ll_flags &= ~LL_SBI_CHECKSUM;
412 rc = obd_set_info_async(sbi->ll_dt_exp, sizeof(KEY_CHECKSUM),
413 KEY_CHECKSUM, sizeof(val), &val, NULL);
415 CWARN("Failed to set OSC checksum flags: %d\n", rc);
420 static int ll_rd_max_rw_chunk(char *page, char **start, off_t off,
421 int count, int *eof, void *data)
423 struct super_block *sb = data;
425 return snprintf(page, count, "%lu\n", ll_s2sbi(sb)->ll_max_rw_chunk);
428 static int ll_wr_max_rw_chunk(struct file *file, const char *buffer,
429 unsigned long count, void *data)
431 struct super_block *sb = data;
434 rc = lprocfs_write_helper(buffer, count, &val);
437 ll_s2sbi(sb)->ll_max_rw_chunk = val;
441 static int ll_rd_track_id(char *page, int count, void *data,
442 enum stats_track_type type)
444 struct super_block *sb = data;
446 if (ll_s2sbi(sb)->ll_stats_track_type == type) {
447 return snprintf(page, count, "%d\n",
448 ll_s2sbi(sb)->ll_stats_track_id);
450 } else if (ll_s2sbi(sb)->ll_stats_track_type == STATS_TRACK_ALL) {
451 return snprintf(page, count, "0 (all)\n");
453 return snprintf(page, count, "untracked\n");
457 static int ll_wr_track_id(const char *buffer, unsigned long count, void *data,
458 enum stats_track_type type)
460 struct super_block *sb = data;
463 rc = lprocfs_write_helper(buffer, count, &pid);
466 ll_s2sbi(sb)->ll_stats_track_id = pid;
468 ll_s2sbi(sb)->ll_stats_track_type = STATS_TRACK_ALL;
470 ll_s2sbi(sb)->ll_stats_track_type = type;
471 lprocfs_clear_stats(ll_s2sbi(sb)->ll_stats);
475 static int ll_rd_track_pid(char *page, char **start, off_t off,
476 int count, int *eof, void *data)
478 return (ll_rd_track_id(page, count, data, STATS_TRACK_PID));
481 static int ll_wr_track_pid(struct file *file, const char *buffer,
482 unsigned long count, void *data)
484 return (ll_wr_track_id(buffer, count, data, STATS_TRACK_PID));
487 static int ll_rd_track_ppid(char *page, char **start, off_t off,
488 int count, int *eof, void *data)
490 return (ll_rd_track_id(page, count, data, STATS_TRACK_PPID));
493 static int ll_wr_track_ppid(struct file *file, const char *buffer,
494 unsigned long count, void *data)
496 return (ll_wr_track_id(buffer, count, data, STATS_TRACK_PPID));
499 static int ll_rd_track_gid(char *page, char **start, off_t off,
500 int count, int *eof, void *data)
502 return (ll_rd_track_id(page, count, data, STATS_TRACK_GID));
505 static int ll_wr_track_gid(struct file *file, const char *buffer,
506 unsigned long count, void *data)
508 return (ll_wr_track_id(buffer, count, data, STATS_TRACK_GID));
511 static int ll_rd_statahead_max(char *page, char **start, off_t off,
512 int count, int *eof, void *data)
514 struct super_block *sb = data;
515 struct ll_sb_info *sbi = ll_s2sbi(sb);
517 return snprintf(page, count, "%u\n", sbi->ll_sa_max);
520 static int ll_wr_statahead_max(struct file *file, const char *buffer,
521 unsigned long count, void *data)
523 struct super_block *sb = data;
524 struct ll_sb_info *sbi = ll_s2sbi(sb);
527 rc = lprocfs_write_helper(buffer, count, &val);
531 if (val >= 0 && val <= LL_SA_RPC_MAX)
532 sbi->ll_sa_max = val;
534 CERROR("Bad statahead_max value %d. Valid values are in the "
535 "range [0, %d]\n", val, LL_SA_RPC_MAX);
540 static int ll_rd_statahead_stats(char *page, char **start, off_t off,
541 int count, int *eof, void *data)
543 struct super_block *sb = data;
544 struct ll_sb_info *sbi = ll_s2sbi(sb);
546 return snprintf(page, count,
547 "statahead wrong: %u\n"
548 "statahead total: %u\n"
552 "miss count: %llu\n",
561 static int ll_rd_contention_time(char *page, char **start, off_t off,
562 int count, int *eof, void *data)
564 struct super_block *sb = data;
567 return snprintf(page, count, "%u\n", ll_s2sbi(sb)->ll_contention_time);
571 static int ll_wr_contention_time(struct file *file, const char *buffer,
572 unsigned long count, void *data)
574 struct super_block *sb = data;
575 struct ll_sb_info *sbi = ll_s2sbi(sb);
577 return lprocfs_write_helper(buffer, count,&sbi->ll_contention_time) ?:
581 static int ll_rd_lockless_truncate(char *page, char **start, off_t off,
582 int count, int *eof, void *data)
584 struct super_block *sb = data;
587 return snprintf(page, count, "%u\n",
588 ll_s2sbi(sb)->ll_lockless_truncate_enable);
591 static int ll_wr_lockless_truncate(struct file *file, const char *buffer,
592 unsigned long count, void *data)
594 struct super_block *sb = data;
595 struct ll_sb_info *sbi = ll_s2sbi(sb);
597 return lprocfs_write_helper(buffer, count,
598 &sbi->ll_lockless_truncate_enable)
602 static struct lprocfs_vars lprocfs_llite_obd_vars[] = {
603 { "uuid", ll_rd_sb_uuid, 0, 0 },
604 //{ "mntpt_path", ll_rd_path, 0, 0 },
605 { "fstype", ll_rd_fstype, 0, 0 },
606 { "blocksize", ll_rd_blksize, 0, 0 },
607 { "kbytestotal", ll_rd_kbytestotal, 0, 0 },
608 { "kbytesfree", ll_rd_kbytesfree, 0, 0 },
609 { "kbytesavail", ll_rd_kbytesavail, 0, 0 },
610 { "filestotal", ll_rd_filestotal, 0, 0 },
611 { "filesfree", ll_rd_filesfree, 0, 0 },
612 { "client_type", ll_rd_client_type, 0, 0 },
613 //{ "filegroups", lprocfs_rd_filegroups, 0, 0 },
614 { "max_read_ahead_mb", ll_rd_max_readahead_mb,
615 ll_wr_max_readahead_mb, 0 },
616 { "max_read_ahead_whole_mb", ll_rd_max_read_ahead_whole_mb,
617 ll_wr_max_read_ahead_whole_mb, 0 },
618 { "max_cached_mb", ll_rd_max_cached_mb, ll_wr_max_cached_mb, 0 },
619 { "pgcache_balance",ll_rd_pgcache_bnlc, 0, 0 },
620 { "checksum_pages", ll_rd_checksum, ll_wr_checksum, 0 },
621 { "max_rw_chunk", ll_rd_max_rw_chunk, ll_wr_max_rw_chunk, 0 },
622 { "stats_track_pid", ll_rd_track_pid, ll_wr_track_pid, 0 },
623 { "stats_track_ppid", ll_rd_track_ppid, ll_wr_track_ppid, 0 },
624 { "stats_track_gid", ll_rd_track_gid, ll_wr_track_gid, 0 },
625 { "statahead_max", ll_rd_statahead_max, ll_wr_statahead_max, 0 },
626 { "statahead_stats", ll_rd_statahead_stats, 0, 0 },
627 { "contention_seconds", ll_rd_contention_time, ll_wr_contention_time, 0},
628 { "lockless_truncate", ll_rd_lockless_truncate,
629 ll_wr_lockless_truncate, 0},
633 #define MAX_STRING_SIZE 128
635 struct llite_file_opcode {
639 } llite_opcode_table[LPROC_LL_FILE_OPCODES] = {
641 { LPROC_LL_DIRTY_HITS, LPROCFS_TYPE_REGS, "dirty_pages_hits" },
642 { LPROC_LL_DIRTY_MISSES, LPROCFS_TYPE_REGS, "dirty_pages_misses" },
643 { LPROC_LL_WB_WRITEPAGE, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
644 "writeback_from_writepage" },
645 { LPROC_LL_WB_PRESSURE, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
646 "writeback_from_pressure" },
647 { LPROC_LL_WB_OK, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
648 "writeback_ok_pages" },
649 { LPROC_LL_WB_FAIL, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
650 "writeback_failed_pages" },
651 { LPROC_LL_READ_BYTES, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_BYTES,
653 { LPROC_LL_WRITE_BYTES, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_BYTES,
655 { LPROC_LL_BRW_READ, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
657 { LPROC_LL_BRW_WRITE, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
660 { LPROC_LL_IOCTL, LPROCFS_TYPE_REGS, "ioctl" },
661 { LPROC_LL_OPEN, LPROCFS_TYPE_REGS, "open" },
662 { LPROC_LL_RELEASE, LPROCFS_TYPE_REGS, "close" },
663 { LPROC_LL_MAP, LPROCFS_TYPE_REGS, "mmap" },
664 { LPROC_LL_LLSEEK, LPROCFS_TYPE_REGS, "seek" },
665 { LPROC_LL_FSYNC, LPROCFS_TYPE_REGS, "fsync" },
666 /* inode operation */
667 { LPROC_LL_SETATTR, LPROCFS_TYPE_REGS, "setattr" },
668 { LPROC_LL_TRUNC, LPROCFS_TYPE_REGS, "truncate" },
669 { LPROC_LL_LOCKLESS_TRUNC, LPROCFS_TYPE_REGS, "lockless_truncate"},
670 { LPROC_LL_FLOCK, LPROCFS_TYPE_REGS, "flock" },
671 { LPROC_LL_GETATTR, LPROCFS_TYPE_REGS, "getattr" },
672 /* special inode operation */
673 { LPROC_LL_STAFS, LPROCFS_TYPE_REGS, "statfs" },
674 { LPROC_LL_ALLOC_INODE, LPROCFS_TYPE_REGS, "alloc_inode" },
675 { LPROC_LL_SETXATTR, LPROCFS_TYPE_REGS, "setxattr" },
676 { LPROC_LL_GETXATTR, LPROCFS_TYPE_REGS, "getxattr" },
677 { LPROC_LL_LISTXATTR, LPROCFS_TYPE_REGS, "listxattr" },
678 { LPROC_LL_REMOVEXATTR, LPROCFS_TYPE_REGS, "removexattr" },
679 { LPROC_LL_INODE_PERM, LPROCFS_TYPE_REGS, "inode_permission" },
680 { LPROC_LL_DIRECT_READ, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
682 { LPROC_LL_DIRECT_WRITE, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
684 { LPROC_LL_LOCKLESS_READ, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_BYTES,
685 "lockless_read_bytes" },
686 { LPROC_LL_LOCKLESS_WRITE, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_BYTES,
687 "lockless_write_bytes" },
691 void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count)
695 if (sbi->ll_stats_track_type == STATS_TRACK_ALL)
696 lprocfs_counter_add(sbi->ll_stats, op, count);
697 else if (sbi->ll_stats_track_type == STATS_TRACK_PID &&
698 sbi->ll_stats_track_id == current->pid)
699 lprocfs_counter_add(sbi->ll_stats, op, count);
700 else if (sbi->ll_stats_track_type == STATS_TRACK_PPID &&
701 sbi->ll_stats_track_id == current->p_pptr->pid)
702 lprocfs_counter_add(sbi->ll_stats, op, count);
703 else if (sbi->ll_stats_track_type == STATS_TRACK_GID &&
704 sbi->ll_stats_track_id == current->gid)
705 lprocfs_counter_add(sbi->ll_stats, op, count);
707 EXPORT_SYMBOL(ll_stats_ops_tally);
709 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
710 struct super_block *sb, char *osc, char *mdc)
712 struct lprocfs_vars lvars[2];
713 struct lustre_sb_info *lsi = s2lsi(sb);
714 struct ll_sb_info *sbi = ll_s2sbi(sb);
715 struct obd_device *obd;
716 char name[MAX_STRING_SIZE + 1], *ptr;
717 int err, id, len, rc;
718 static const char *ra_stats_string[] = LL_RA_STAT_STRINGS;
721 memset(lvars, 0, sizeof(lvars));
723 name[MAX_STRING_SIZE] = '\0';
724 lvars[0].name = name;
726 LASSERT(sbi != NULL);
727 LASSERT(mdc != NULL);
728 LASSERT(osc != NULL);
731 len = strlen(lsi->lsi_lmd->lmd_profile);
732 ptr = strrchr(lsi->lsi_lmd->lmd_profile, '-');
733 if (ptr && (strcmp(ptr, "-client") == 0))
737 snprintf(name, MAX_STRING_SIZE, "%.*s-%p", len,
738 lsi->lsi_lmd->lmd_profile, sb);
740 sbi->ll_proc_root = lprocfs_register(name, parent, NULL, NULL);
741 if (IS_ERR(sbi->ll_proc_root)) {
742 err = PTR_ERR(sbi->ll_proc_root);
743 sbi->ll_proc_root = NULL;
748 rc = lprocfs_seq_create(sbi->ll_proc_root, "dump_page_cache", 0444,
749 &llite_dump_pgcache_fops, sbi);
751 CWARN("Error adding the dump_page_cache file\n");
753 rc = lprocfs_seq_create(sbi->ll_proc_root, "extents_stats", 0644,
754 &ll_rw_extents_stats_fops, sbi);
756 CWARN("Error adding the extent_stats file\n");
758 rc = lprocfs_seq_create(sbi->ll_proc_root, "extents_stats_per_process",
759 0644, &ll_rw_extents_stats_pp_fops, sbi);
761 CWARN("Error adding the extents_stats_per_process file\n");
763 rc = lprocfs_seq_create(sbi->ll_proc_root, "offset_stats", 0644,
764 &ll_rw_offset_stats_fops, sbi);
766 CWARN("Error adding the offset_stats file\n");
768 /* File operations stats */
769 sbi->ll_stats = lprocfs_alloc_stats(LPROC_LL_FILE_OPCODES,
770 LPROCFS_STATS_FLAG_PERCPU);
771 if (sbi->ll_stats == NULL)
772 GOTO(out, err = -ENOMEM);
773 /* do counter init */
774 for (id = 0; id < LPROC_LL_FILE_OPCODES; id++) {
775 __u32 type = llite_opcode_table[id].type;
777 if (type & LPROCFS_TYPE_REGS)
779 else if (type & LPROCFS_TYPE_BYTES)
781 else if (type & LPROCFS_TYPE_PAGES)
783 lprocfs_counter_init(sbi->ll_stats,
784 llite_opcode_table[id].opcode,
785 (type & LPROCFS_CNTR_AVGMINMAX),
786 llite_opcode_table[id].opname, ptr);
788 err = lprocfs_register_stats(sbi->ll_proc_root, "stats", sbi->ll_stats);
792 sbi->ll_ra_stats = lprocfs_alloc_stats(LL_RA_STAT,
793 LPROCFS_STATS_FLAG_PERCPU);
794 if (sbi->ll_ra_stats == NULL)
795 GOTO(out, err = -ENOMEM);
797 for (id = 0; id < LL_RA_STAT; id++)
798 lprocfs_counter_init(sbi->ll_ra_stats, id, 0,
799 ra_stats_string[id], "pages");
800 err = lprocfs_register_stats(sbi->ll_proc_root, "read_ahead_stats",
806 err = lprocfs_add_vars(sbi->ll_proc_root, lprocfs_llite_obd_vars, sb);
811 obd = class_name2obd(mdc);
813 LASSERT(obd != NULL);
814 LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
815 LASSERT(obd->obd_type->typ_name != NULL);
817 snprintf(name, MAX_STRING_SIZE, "%s/common_name",
818 obd->obd_type->typ_name);
819 lvars[0].read_fptr = lprocfs_rd_name;
820 err = lprocfs_add_vars(sbi->ll_proc_root, lvars, obd);
824 snprintf(name, MAX_STRING_SIZE, "%s/uuid", obd->obd_type->typ_name);
825 lvars[0].read_fptr = lprocfs_rd_uuid;
826 err = lprocfs_add_vars(sbi->ll_proc_root, lvars, obd);
831 obd = class_name2obd(osc);
833 LASSERT(obd != NULL);
834 LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
835 LASSERT(obd->obd_type->typ_name != NULL);
837 snprintf(name, MAX_STRING_SIZE, "%s/common_name",
838 obd->obd_type->typ_name);
839 lvars[0].read_fptr = lprocfs_rd_name;
840 err = lprocfs_add_vars(sbi->ll_proc_root, lvars, obd);
844 snprintf(name, MAX_STRING_SIZE, "%s/uuid", obd->obd_type->typ_name);
845 lvars[0].read_fptr = lprocfs_rd_uuid;
846 err = lprocfs_add_vars(sbi->ll_proc_root, lvars, obd);
849 lprocfs_remove(&sbi->ll_proc_root);
850 lprocfs_free_stats(&sbi->ll_ra_stats);
851 lprocfs_free_stats(&sbi->ll_stats);
856 void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi)
858 if (sbi->ll_proc_root) {
859 lprocfs_remove(&sbi->ll_proc_root);
860 lprocfs_free_stats(&sbi->ll_ra_stats);
861 lprocfs_free_stats(&sbi->ll_stats);
864 #undef MAX_STRING_SIZE
866 #define seq_page_flag(seq, page, flag, has_flags) do { \
867 if (test_bit(PG_##flag, &(page)->flags)) { \
871 seq_putc(seq, '|'); \
872 seq_puts(seq, #flag); \
876 static void *llite_dump_pgcache_seq_start(struct seq_file *seq, loff_t *pos)
878 struct ll_async_page *dummy_llap = seq->private;
880 if (dummy_llap->llap_magic == 2)
886 static int llite_dump_pgcache_seq_show(struct seq_file *seq, void *v)
888 struct ll_async_page *llap, *dummy_llap = seq->private;
889 struct ll_sb_info *sbi = dummy_llap->llap_cookie;
890 struct ll_pglist_data *pd;
891 int cpu = dummy_llap->llap_pglist_cpu;
893 /* 2.4 doesn't seem to have SEQ_START_TOKEN, so we implement
894 * it in our own state */
895 if (dummy_llap->llap_magic == 0) {
896 seq_printf(seq, "gener | llap cookie origin wq du wb | page "
897 "inode index count [ page flags ]\n");
901 pd = ll_pglist_cpu_lock(sbi, cpu);
902 llap = llite_pglist_next_llap(&pd->llpd_list,
903 &dummy_llap->llap_pglist_item);
905 int has_flags = 0, i;
906 struct page *page = llap->llap_page;
907 unsigned long gen = 0UL;
909 LASSERTF(llap->llap_origin < LLAP__ORIGIN_MAX, "%u\n",
912 for_each_online_cpu(i)
913 gen += LL_PGLIST_DATA_CPU(sbi, i)->llpd_gen;
915 seq_printf(seq," %5lu | %p %p %s %s %s %s | %p %lu/%u(%p) "
918 llap, llap->llap_cookie,
919 llap_origins[llap->llap_origin],
920 llap->llap_write_queued ? "wq" : "- ",
921 llap->llap_defer_uptodate ? "du" : "- ",
922 PageWriteback(page) ? "wb" : "-",
923 page, page->mapping->host->i_ino,
924 page->mapping->host->i_generation,
925 page->mapping->host, page->index,
927 seq_page_flag(seq, page, locked, has_flags);
928 seq_page_flag(seq, page, error, has_flags);
929 seq_page_flag(seq, page, referenced, has_flags);
930 seq_page_flag(seq, page, uptodate, has_flags);
931 seq_page_flag(seq, page, dirty, has_flags);
932 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,12))
933 seq_page_flag(seq, page, highmem, has_flags);
935 seq_page_flag(seq, page, writeback, has_flags);
937 seq_puts(seq, "-]\n");
939 seq_puts(seq, "]\n");
941 ll_pglist_cpu_unlock(sbi, cpu);
946 static void *llite_dump_pgcache_seq_next(struct seq_file *seq, void *v,
949 struct ll_async_page *llap, *dummy_llap = seq->private;
950 struct ll_sb_info *sbi = dummy_llap->llap_cookie;
951 struct ll_pglist_data *pd, *next;
952 int cpu = dummy_llap->llap_pglist_cpu;
954 /* bail if we just displayed the banner */
955 if (dummy_llap->llap_magic == 0) {
956 dummy_llap->llap_magic = 1;
960 /* we've just displayed the llap that is after us in the list.
961 * we advance to a position beyond it, returning null if there
962 * isn't another llap in the list beyond that new position. */
963 pd = ll_pglist_cpu_lock(sbi, cpu);
964 llap = llite_pglist_next_llap(&pd->llpd_list,
965 &dummy_llap->llap_pglist_item);
966 list_del_init(&dummy_llap->llap_pglist_item);
968 list_add(&dummy_llap->llap_pglist_item,&llap->llap_pglist_item);
969 llap = llite_pglist_next_llap(&pd->llpd_list,
970 &dummy_llap->llap_pglist_item);
974 for (next = NULL; i < num_possible_cpus(); i++, next = NULL) {
975 next = ll_pglist_cpu_lock(sbi, i);
976 if (!list_empty(&next->llpd_list))
978 ll_pglist_cpu_unlock(sbi, i);
981 list_move(&dummy_llap->llap_pglist_item,
983 dummy_llap->llap_pglist_cpu = i;
984 ll_pglist_cpu_unlock(sbi, cpu);
985 llap = llite_pglist_next_llap(&next->llpd_list,
986 &dummy_llap->llap_pglist_item);
991 ll_pglist_cpu_unlock(sbi, cpu);
995 dummy_llap->llap_magic = 2;
1001 static void null_stop(struct seq_file *seq, void *v)
1005 struct seq_operations llite_dump_pgcache_seq_sops = {
1006 .start = llite_dump_pgcache_seq_start,
1008 .next = llite_dump_pgcache_seq_next,
1009 .show = llite_dump_pgcache_seq_show,
1012 /* we're displaying llaps in a list_head list. we don't want to hold a lock
1013 * while we walk the entire list, and we don't want to have to seek into
1014 * the right position in the list as an app advances with many syscalls. we
1015 * allocate a dummy llap and hang it off file->private. its position in
1016 * the list records where the app is currently displaying. this way our
1017 * seq .start and .stop don't actually do anything. .next returns null
1018 * when the dummy hits the end of the list which eventually leads to .release
1019 * where we tear down. this kind of displaying is super-racey, so we put
1020 * a generation counter on the list so the output shows when the list
1021 * changes between reads.
1023 static int llite_dump_pgcache_seq_open(struct inode *inode, struct file *file)
1025 struct proc_dir_entry *dp = PDE(inode);
1026 struct ll_async_page *dummy_llap;
1027 struct seq_file *seq;
1028 struct ll_sb_info *sbi = dp->data;
1029 struct ll_pglist_data *pd;
1032 LPROCFS_ENTRY_AND_CHECK(dp);
1034 OBD_ALLOC_PTR_WAIT(dummy_llap);
1035 if (dummy_llap == NULL)
1037 dummy_llap->llap_page = NULL;
1038 dummy_llap->llap_cookie = sbi;
1039 dummy_llap->llap_magic = 0;
1040 dummy_llap->llap_pglist_cpu = 0;
1042 rc = seq_open(file, &llite_dump_pgcache_seq_sops);
1044 OBD_FREE(dummy_llap, sizeof(*dummy_llap));
1047 seq = file->private_data;
1048 seq->private = dummy_llap;
1050 pd = ll_pglist_cpu_lock(sbi, 0);
1051 list_add(&dummy_llap->llap_pglist_item, &pd->llpd_list);
1052 ll_pglist_cpu_unlock(sbi, 0);
1060 static int llite_dump_pgcache_seq_release(struct inode *inode,
1063 struct seq_file *seq = file->private_data;
1064 struct ll_async_page *dummy_llap = seq->private;
1065 struct ll_sb_info *sbi = dummy_llap->llap_cookie;
1066 int cpu = dummy_llap->llap_pglist_cpu;
1068 ll_pglist_cpu_lock(sbi, cpu);
1069 if (!list_empty(&dummy_llap->llap_pglist_item))
1070 list_del_init(&dummy_llap->llap_pglist_item);
1071 ll_pglist_cpu_unlock(sbi, cpu);
1072 OBD_FREE(dummy_llap, sizeof(*dummy_llap));
1074 return lprocfs_seq_release(inode, file);
1077 struct file_operations llite_dump_pgcache_fops = {
1078 .owner = THIS_MODULE,
1079 .open = llite_dump_pgcache_seq_open,
1081 .release = llite_dump_pgcache_seq_release,
1084 #define pct(a,b) (b ? a * 100 / b : 0)
1086 static void ll_display_extents_info(struct ll_rw_extents_info *io_extents,
1087 struct seq_file *seq, int which)
1089 unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum;
1090 unsigned long start, end, r, w;
1091 char *unitp = "KMGTPEZY";
1093 struct per_process_info *pp_info = &io_extents->pp_extents[which];
1099 for(i = 0; i < LL_HIST_MAX; i++) {
1100 read_tot += pp_info->pp_r_hist.oh_buckets[i];
1101 write_tot += pp_info->pp_w_hist.oh_buckets[i];
1104 for(i = 0; i < LL_HIST_MAX; i++) {
1105 r = pp_info->pp_r_hist.oh_buckets[i];
1106 w = pp_info->pp_w_hist.oh_buckets[i];
1109 end = 1 << (i + LL_HIST_START - units);
1110 seq_printf(seq, "%4lu%c - %4lu%c%c: %14lu %4lu %4lu | "
1111 "%14lu %4lu %4lu\n", start, *unitp, end, *unitp,
1112 (i == LL_HIST_MAX - 1) ? '+' : ' ',
1113 r, pct(r, read_tot), pct(read_cum, read_tot),
1114 w, pct(w, write_tot), pct(write_cum, write_tot));
1116 if (start == 1<<10) {
1121 if (read_cum == read_tot && write_cum == write_tot)
1126 static int ll_rw_extents_stats_pp_seq_show(struct seq_file *seq, void *v)
1129 struct ll_sb_info *sbi = seq->private;
1130 struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info;
1133 do_gettimeofday(&now);
1135 if (!sbi->ll_rw_stats_on) {
1136 seq_printf(seq, "Disabled\n"
1137 "Write anything in this file to activate\n");
1140 seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n",
1141 now.tv_sec, now.tv_usec);
1142 seq_printf(seq, "%15s %19s | %20s\n", " ", "read", "write");
1143 seq_printf(seq, "%13s %14s %4s %4s | %14s %4s %4s\n",
1144 "extents", "calls", "%", "cum%",
1145 "calls", "%", "cum%");
1146 spin_lock(&sbi->ll_pp_extent_lock);
1147 for(k = 0; k < LL_PROCESS_HIST_MAX; k++) {
1148 if(io_extents->pp_extents[k].pid != 0) {
1149 seq_printf(seq, "\nPID: %d\n",
1150 io_extents->pp_extents[k].pid);
1151 ll_display_extents_info(io_extents, seq, k);
1154 spin_unlock(&sbi->ll_pp_extent_lock);
1158 static ssize_t ll_rw_extents_stats_pp_seq_write(struct file *file,
1159 const char *buf, size_t len,
1162 struct seq_file *seq = file->private_data;
1163 struct ll_sb_info *sbi = seq->private;
1164 struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info;
1167 sbi->ll_rw_stats_on = 1;
1168 spin_lock(&sbi->ll_pp_extent_lock);
1169 for(i = 0; i < LL_PROCESS_HIST_MAX; i++) {
1170 io_extents->pp_extents[i].pid = 0;
1171 lprocfs_oh_clear(&io_extents->pp_extents[i].pp_r_hist);
1172 lprocfs_oh_clear(&io_extents->pp_extents[i].pp_w_hist);
1174 spin_unlock(&sbi->ll_pp_extent_lock);
1178 LPROC_SEQ_FOPS(ll_rw_extents_stats_pp);
1180 static int ll_rw_extents_stats_seq_show(struct seq_file *seq, void *v)
1183 struct ll_sb_info *sbi = seq->private;
1184 struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info;
1186 do_gettimeofday(&now);
1188 if (!sbi->ll_rw_stats_on) {
1189 seq_printf(seq, "Disabled\n"
1190 "Write anything in this file to activate\n");
1193 seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n",
1194 now.tv_sec, now.tv_usec);
1196 seq_printf(seq, "%15s %19s | %20s\n", " ", "read", "write");
1197 seq_printf(seq, "%13s %14s %4s %4s | %14s %4s %4s\n",
1198 "extents", "calls", "%", "cum%",
1199 "calls", "%", "cum%");
1200 spin_lock(&sbi->ll_lock);
1201 ll_display_extents_info(io_extents, seq, LL_PROCESS_HIST_MAX);
1202 spin_unlock(&sbi->ll_lock);
1207 static ssize_t ll_rw_extents_stats_seq_write(struct file *file, const char *buf,
1208 size_t len, loff_t *off)
1210 struct seq_file *seq = file->private_data;
1211 struct ll_sb_info *sbi = seq->private;
1212 struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info;
1215 sbi->ll_rw_stats_on = 1;
1216 spin_lock(&sbi->ll_pp_extent_lock);
1217 for(i = 0; i <= LL_PROCESS_HIST_MAX; i++)
1219 io_extents->pp_extents[i].pid = 0;
1220 lprocfs_oh_clear(&io_extents->pp_extents[i].pp_r_hist);
1221 lprocfs_oh_clear(&io_extents->pp_extents[i].pp_w_hist);
1223 spin_unlock(&sbi->ll_pp_extent_lock);
1228 LPROC_SEQ_FOPS(ll_rw_extents_stats);
1230 void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct file
1231 *file, size_t count, int rw)
1234 struct ll_rw_process_info *process;
1235 struct ll_rw_process_info *offset;
1236 int *off_count = &sbi->ll_rw_offset_entry_count;
1237 int *process_count = &sbi->ll_offset_process_count;
1238 struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info;
1240 if(!sbi->ll_rw_stats_on)
1242 process = sbi->ll_rw_process_info;
1243 offset = sbi->ll_rw_offset_info;
1245 spin_lock(&sbi->ll_pp_extent_lock);
1246 /* Extent statistics */
1247 for(i = 0; i < LL_PROCESS_HIST_MAX; i++) {
1248 if(io_extents->pp_extents[i].pid == pid) {
1256 sbi->ll_extent_process_count =
1257 (sbi->ll_extent_process_count + 1) % LL_PROCESS_HIST_MAX;
1258 cur = sbi->ll_extent_process_count;
1259 io_extents->pp_extents[cur].pid = pid;
1260 lprocfs_oh_clear(&io_extents->pp_extents[cur].pp_r_hist);
1261 lprocfs_oh_clear(&io_extents->pp_extents[cur].pp_w_hist);
1264 for(i = 0; (count >= (1 << LL_HIST_START << i)) &&
1265 (i < (LL_HIST_MAX - 1)); i++);
1267 io_extents->pp_extents[cur].pp_r_hist.oh_buckets[i]++;
1268 io_extents->pp_extents[LL_PROCESS_HIST_MAX].pp_r_hist.oh_buckets[i]++;
1270 io_extents->pp_extents[cur].pp_w_hist.oh_buckets[i]++;
1271 io_extents->pp_extents[LL_PROCESS_HIST_MAX].pp_w_hist.oh_buckets[i]++;
1273 spin_unlock(&sbi->ll_pp_extent_lock);
1275 spin_lock(&sbi->ll_process_lock);
1276 /* Offset statistics */
1277 for (i = 0; i < LL_PROCESS_HIST_MAX; i++) {
1278 if (process[i].rw_pid == pid) {
1279 if (process[i].rw_last_file != file) {
1280 process[i].rw_range_start = file->f_pos;
1281 process[i].rw_last_file_pos =
1282 file->f_pos + count;
1283 process[i].rw_smallest_extent = count;
1284 process[i].rw_largest_extent = count;
1285 process[i].rw_offset = 0;
1286 process[i].rw_last_file = file;
1287 spin_unlock(&sbi->ll_process_lock);
1290 if (process[i].rw_last_file_pos != file->f_pos) {
1292 (*off_count + 1) % LL_OFFSET_HIST_MAX;
1293 offset[*off_count].rw_op = process[i].rw_op;
1294 offset[*off_count].rw_pid = pid;
1295 offset[*off_count].rw_range_start =
1296 process[i].rw_range_start;
1297 offset[*off_count].rw_range_end =
1298 process[i].rw_last_file_pos;
1299 offset[*off_count].rw_smallest_extent =
1300 process[i].rw_smallest_extent;
1301 offset[*off_count].rw_largest_extent =
1302 process[i].rw_largest_extent;
1303 offset[*off_count].rw_offset =
1304 process[i].rw_offset;
1305 process[i].rw_op = rw;
1306 process[i].rw_range_start = file->f_pos;
1307 process[i].rw_smallest_extent = count;
1308 process[i].rw_largest_extent = count;
1309 process[i].rw_offset = file->f_pos -
1310 process[i].rw_last_file_pos;
1312 if(process[i].rw_smallest_extent > count)
1313 process[i].rw_smallest_extent = count;
1314 if(process[i].rw_largest_extent < count)
1315 process[i].rw_largest_extent = count;
1316 process[i].rw_last_file_pos = file->f_pos + count;
1317 spin_unlock(&sbi->ll_process_lock);
1321 *process_count = (*process_count + 1) % LL_PROCESS_HIST_MAX;
1322 process[*process_count].rw_pid = pid;
1323 process[*process_count].rw_op = rw;
1324 process[*process_count].rw_range_start = file->f_pos;
1325 process[*process_count].rw_last_file_pos = file->f_pos + count;
1326 process[*process_count].rw_smallest_extent = count;
1327 process[*process_count].rw_largest_extent = count;
1328 process[*process_count].rw_offset = 0;
1329 process[*process_count].rw_last_file = file;
1330 spin_unlock(&sbi->ll_process_lock);
1333 char lpszt[] = LPSZ;
1335 static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v)
1338 struct ll_sb_info *sbi = seq->private;
1339 struct ll_rw_process_info *offset = sbi->ll_rw_offset_info;
1340 struct ll_rw_process_info *process = sbi->ll_rw_process_info;
1344 do_gettimeofday(&now);
1346 if (!sbi->ll_rw_stats_on) {
1347 seq_printf(seq, "Disabled\n"
1348 "Write anything in this file to activate\n");
1351 spin_lock(&sbi->ll_process_lock);
1353 seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n",
1354 now.tv_sec, now.tv_usec);
1355 seq_printf(seq, "%3s %10s %14s %14s %17s %17s %14s\n",
1356 "R/W", "PID", "RANGE START", "RANGE END",
1357 "SMALLEST EXTENT", "LARGEST EXTENT", "OFFSET");
1358 sprintf(format, "%s%s%s%s%s\n",
1359 "%3c %10d %14Lu %14Lu %17", lpszt+1, " %17", lpszt+1, " %14Ld");
1360 /* We stored the discontiguous offsets here; print them first */
1361 for(i = 0; i < LL_OFFSET_HIST_MAX; i++) {
1362 if (offset[i].rw_pid != 0)
1363 /* Is there a way to snip the '%' off of LPSZ? */
1364 seq_printf(seq, format,
1365 offset[i].rw_op ? 'W' : 'R',
1367 offset[i].rw_range_start,
1368 offset[i].rw_range_end,
1369 offset[i].rw_smallest_extent,
1370 offset[i].rw_largest_extent,
1371 offset[i].rw_offset);
1373 /* Then print the current offsets for each process */
1374 for(i = 0; i < LL_PROCESS_HIST_MAX; i++) {
1375 if (process[i].rw_pid != 0)
1376 seq_printf(seq, format,
1377 process[i].rw_op ? 'W' : 'R',
1379 process[i].rw_range_start,
1380 process[i].rw_last_file_pos,
1381 process[i].rw_smallest_extent,
1382 process[i].rw_largest_extent,
1383 process[i].rw_offset);
1385 spin_unlock(&sbi->ll_process_lock);
1390 static ssize_t ll_rw_offset_stats_seq_write(struct file *file, const char *buf,
1391 size_t len, loff_t *off)
1393 struct seq_file *seq = file->private_data;
1394 struct ll_sb_info *sbi = seq->private;
1395 struct ll_rw_process_info *process_info = sbi->ll_rw_process_info;
1396 struct ll_rw_process_info *offset_info = sbi->ll_rw_offset_info;
1398 sbi->ll_rw_stats_on = 1;
1400 spin_lock(&sbi->ll_process_lock);
1401 sbi->ll_offset_process_count = 0;
1402 sbi->ll_rw_offset_entry_count = 0;
1403 memset(process_info, 0, sizeof(struct ll_rw_process_info) *
1404 LL_PROCESS_HIST_MAX);
1405 memset(offset_info, 0, sizeof(struct ll_rw_process_info) *
1406 LL_OFFSET_HIST_MAX);
1407 spin_unlock(&sbi->ll_process_lock);
1412 LPROC_SEQ_FOPS(ll_rw_offset_stats);
1414 void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars)
1416 lvars->module_vars = NULL;
1417 lvars->obd_vars = lprocfs_llite_obd_vars;
1419 #endif /* LPROCFS */