1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #define DEBUG_SUBSYSTEM S_LLITE
24 #include <linux/version.h>
25 #include <linux/lustre_lite.h>
26 #include <linux/lprocfs_status.h>
27 #include <linux/seq_file.h>
28 #include <linux/obd_support.h>
30 #include "llite_internal.h"
32 /* /proc/lustre/llite mount point registration */
33 struct proc_dir_entry *proc_lustre_fs_root;
34 struct file_operations llite_dump_pgcache_fops;
35 struct file_operations ll_ra_stats_fops;
36 struct file_operations llite_wait_times_fops;
39 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
40 struct super_block *sb, char *osc, char *mdc)
44 void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi){}
47 long long mnt_instance;
49 static int ll_rd_blksize(char *page, char **start, off_t off, int count,
52 struct super_block *sb = (struct super_block *)data;
53 struct obd_statfs osfs;
57 rc = ll_statfs_internal(sb, &osfs, jiffies - HZ);
60 rc = snprintf(page, count, "%u\n", osfs.os_bsize);
66 static int ll_rd_kbytestotal(char *page, char **start, off_t off, int count,
69 struct super_block *sb = (struct super_block *)data;
70 struct obd_statfs osfs;
74 rc = ll_statfs_internal(sb, &osfs, jiffies - HZ);
76 __u32 blk_size = osfs.os_bsize >> 10;
77 __u64 result = osfs.os_blocks;
79 while (blk_size >>= 1)
83 rc = snprintf(page, count, LPU64"\n", result);
89 static int ll_rd_kbytesfree(char *page, char **start, off_t off, int count,
92 struct super_block *sb = (struct super_block *)data;
93 struct obd_statfs osfs;
97 rc = ll_statfs_internal(sb, &osfs, jiffies - HZ);
99 __u32 blk_size = osfs.os_bsize >> 10;
100 __u64 result = osfs.os_bfree;
102 while (blk_size >>= 1)
106 rc = snprintf(page, count, LPU64"\n", result);
111 static int ll_rd_kbytesavail(char *page, char **start, off_t off, int count,
112 int *eof, void *data)
114 struct super_block *sb = (struct super_block *)data;
115 struct obd_statfs osfs;
119 rc = ll_statfs_internal(sb, &osfs, jiffies - HZ);
121 __u32 blk_size = osfs.os_bsize >> 10;
122 __u64 result = osfs.os_bavail;
124 while (blk_size >>= 1)
128 rc = snprintf(page, count, LPU64"\n", result);
133 static int ll_rd_filestotal(char *page, char **start, off_t off, int count,
134 int *eof, void *data)
136 struct super_block *sb = (struct super_block *)data;
137 struct obd_statfs osfs;
141 rc = ll_statfs_internal(sb, &osfs, jiffies - HZ);
144 rc = snprintf(page, count, LPU64"\n", osfs.os_files);
149 static int ll_rd_filesfree(char *page, char **start, off_t off, int count,
150 int *eof, void *data)
152 struct super_block *sb = (struct super_block *)data;
153 struct obd_statfs osfs;
157 rc = ll_statfs_internal(sb, &osfs, jiffies - HZ);
160 rc = snprintf(page, count, LPU64"\n", osfs.os_ffree);
166 static int ll_rd_fstype(char *page, char **start, off_t off, int count,
167 int *eof, void *data)
169 struct super_block *sb = (struct super_block*)data;
173 return snprintf(page, count, "%s\n", sb->s_type->name);
176 static int ll_rd_sb_uuid(char *page, char **start, off_t off, int count,
177 int *eof, void *data)
179 struct super_block *sb = (struct super_block *)data;
183 return snprintf(page, count, "%s\n", ll_s2sbi(sb)->ll_sb_uuid.uuid);
186 static int ll_rd_read_ahead(char *page, char **start, off_t off, int count,
187 int *eof, void *data)
189 struct super_block *sb = (struct super_block*)data;
190 struct ll_sb_info *sbi = ll_s2sbi(sb);
195 val = (sbi->ll_flags & LL_SBI_READAHEAD) ? 1 : 0;
196 rc = snprintf(page, count, "%d\n", val);
200 static int ll_wr_read_ahead(struct file *file, const char *buffer,
201 unsigned long count, void *data)
203 struct super_block *sb = (struct super_block*)data;
204 struct ll_sb_info *sbi = ll_s2sbi(sb);
208 if (sscanf(buffer, "%d", &readahead) != 1)
212 sbi->ll_flags |= LL_SBI_READAHEAD;
214 sbi->ll_flags &= ~LL_SBI_READAHEAD;
219 static int ll_wr_config_update(struct file *file, const char *buffer,
220 unsigned long count, void *data)
222 struct super_block *sb = (struct super_block*)data;
223 struct ll_sb_info *sbi = ll_s2sbi(sb);
226 CWARN("Starting a LOV/OST update !\n");
227 RETURN(ll_process_config_update(sbi, 0));
230 static int ll_rd_max_read_ahead_mb(char *page, char **start, off_t off,
231 int count, int *eof, void *data)
233 struct super_block *sb = data;
234 struct ll_sb_info *sbi = ll_s2sbi(sb);
237 spin_lock(&sbi->ll_lock);
238 val = (sbi->ll_ra_info.ra_max_pages << PAGE_CACHE_SHIFT) >> 20;
239 spin_unlock(&sbi->ll_lock);
241 return snprintf(page, count, "%u\n", val);
244 static int ll_wr_max_read_ahead_mb(struct file *file, const char *buffer,
245 unsigned long count, void *data)
247 struct super_block *sb = data;
248 struct ll_sb_info *sbi = ll_s2sbi(sb);
251 rc = lprocfs_write_helper(buffer, count, &val);
255 if (val < 0 || val > (num_physpages << PAGE_SHIFT) >> 20)
258 spin_lock(&sbi->ll_lock);
259 sbi->ll_ra_info.ra_max_pages = (val << 20) >> PAGE_CACHE_SHIFT;
260 spin_unlock(&sbi->ll_lock);
265 static int ll_rd_gns_upcall(char *page, char **start, off_t off,
266 int count, int *eof, void *data)
268 struct super_block *sb = (struct super_block *)data;
269 struct ll_sb_info *sbi = ll_s2sbi(sb);
272 down(&sbi->ll_gns_sem);
273 len = snprintf(page, count, "%s\n", sbi->ll_gns_upcall);
274 up(&sbi->ll_gns_sem);
279 static int ll_wr_gns_upcall(struct file *file, const char *buffer,
280 unsigned long count, void *data)
282 struct super_block *sb = (struct super_block *)data;
283 struct ll_sb_info *sbi = ll_s2sbi(sb);
285 down(&sbi->ll_gns_sem);
286 snprintf(sbi->ll_gns_upcall, count, "%s", buffer);
287 up(&sbi->ll_gns_sem);
292 static int ll_rd_gns_object_name(char *page, char **start, off_t off,
293 int count, int *eof, void *data)
295 struct super_block *sb = (struct super_block *)data;
296 struct ll_sb_info *sbi = ll_s2sbi(sb);
299 down(&sbi->ll_gns_sem);
300 len = snprintf(page, count, "%s\n", sbi->ll_gns_oname);
301 up(&sbi->ll_gns_sem);
306 static int ll_wr_gns_object_name(struct file *file, const char *buffer,
307 unsigned long count, void *data)
309 struct super_block *sb = (struct super_block *)data;
310 struct ll_sb_info *sbi = ll_s2sbi(sb);
312 down(&sbi->ll_gns_sem);
313 snprintf(sbi->ll_gns_oname, count, "%s", buffer);
314 up(&sbi->ll_gns_sem);
319 static int ll_rd_gns_timeout(char *page, char **start, off_t off,
320 int count, int *eof, void *data)
322 struct super_block *sb = (struct super_block *)data;
323 struct ll_sb_info *sbi = ll_s2sbi(sb);
326 down(&sbi->ll_gns_sem);
327 len = snprintf(page, count, "%lu\n",
328 (unsigned long)sbi->ll_gns_timeout);
329 up(&sbi->ll_gns_sem);
334 static int ll_wr_gns_timeout(struct file *file, const char *buffer,
335 unsigned long count, void *data)
337 struct super_block *sb = (struct super_block *)data;
338 struct ll_sb_info *sbi = ll_s2sbi(sb);
341 rc = lprocfs_write_helper(buffer, count, &val);
345 down(&sbi->ll_gns_sem);
346 sbi->ll_gns_timeout = val;
347 up(&sbi->ll_gns_sem);
352 static int ll_rd_gns_tick(char *page, char **start, off_t off,
353 int count, int *eof, void *data)
355 struct super_block *sb = (struct super_block *)data;
356 struct ll_sb_info *sbi = ll_s2sbi(sb);
359 down(&sbi->ll_gns_sem);
360 len = snprintf(page, count, "%lu\n",
361 (unsigned long)sbi->ll_gns_tick);
362 up(&sbi->ll_gns_sem);
367 static int ll_wr_gns_tick(struct file *file, const char *buffer,
368 unsigned long count, void *data)
370 struct super_block *sb = (struct super_block *)data;
371 struct ll_sb_info *sbi = ll_s2sbi(sb);
374 rc = lprocfs_write_helper(buffer, count, &val);
378 down(&sbi->ll_gns_sem);
379 if (sbi->ll_gns_tick < sbi->ll_gns_timeout)
380 sbi->ll_gns_tick = val;
381 up(&sbi->ll_gns_sem);
385 static struct lprocfs_vars lprocfs_obd_vars[] = {
386 { "uuid", ll_rd_sb_uuid, 0, 0 },
387 //{ "mntpt_path", ll_rd_path, 0, 0 },
388 { "fstype", ll_rd_fstype, 0, 0 },
389 { "blocksize", ll_rd_blksize, 0, 0 },
390 { "kbytestotal", ll_rd_kbytestotal, 0, 0 },
391 { "kbytesfree", ll_rd_kbytesfree, 0, 0 },
392 { "kbytesavail", ll_rd_kbytesavail, 0, 0 },
393 { "filestotal", ll_rd_filestotal, 0, 0 },
394 { "filesfree", ll_rd_filesfree, 0, 0 },
395 //{ "filegroups", lprocfs_rd_filegroups, 0, 0 },
396 { "read_ahead", ll_rd_read_ahead, ll_wr_read_ahead, 0 },
397 { "config_update", 0, ll_wr_config_update, 0 },
398 { "max_read_ahead_mb", ll_rd_max_read_ahead_mb,
399 ll_wr_max_read_ahead_mb, 0 },
401 { "gns_upcall", ll_rd_gns_upcall,
402 ll_wr_gns_upcall, 0 },
404 { "gns_timeout", ll_rd_gns_timeout,
405 ll_wr_gns_timeout, 0 },
407 { "gns_tick", ll_rd_gns_tick,
410 { "gns_object_name", ll_rd_gns_object_name,
411 ll_wr_gns_object_name, 0 },
416 #define MAX_STRING_SIZE 128
418 struct llite_file_opcode {
422 } llite_opcode_table[LPROC_LL_FILE_OPCODES] = {
424 { LPROC_LL_DIRTY_HITS, LPROCFS_TYPE_REGS, "dirty_pages_hits" },
425 { LPROC_LL_DIRTY_MISSES, LPROCFS_TYPE_REGS, "dirty_pages_misses" },
426 { LPROC_LL_WB_WRITEPAGE, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
427 "writeback_from_writepage" },
428 { LPROC_LL_WB_PRESSURE, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
429 "writeback_from_pressure" },
430 { LPROC_LL_WB_OK, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
431 "writeback_ok_pages" },
432 { LPROC_LL_WB_FAIL, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
433 "writeback_failed_pages" },
434 { LPROC_LL_READ_BYTES, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_BYTES,
436 { LPROC_LL_WRITE_BYTES, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_BYTES,
438 { LPROC_LL_BRW_READ, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
440 { LPROC_LL_BRW_WRITE, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
443 { LPROC_LL_IOCTL, LPROCFS_TYPE_REGS, "ioctl" },
444 { LPROC_LL_OPEN, LPROCFS_TYPE_REGS, "open" },
445 { LPROC_LL_RELEASE, LPROCFS_TYPE_REGS, "close" },
446 { LPROC_LL_MAP, LPROCFS_TYPE_REGS, "mmap" },
447 { LPROC_LL_LLSEEK, LPROCFS_TYPE_REGS, "seek" },
448 { LPROC_LL_FSYNC, LPROCFS_TYPE_REGS, "fsync" },
449 /* inode operation */
450 { LPROC_LL_SETATTR, LPROCFS_TYPE_REGS, "setattr" },
451 { LPROC_LL_TRUNC, LPROCFS_TYPE_REGS, "punch" },
452 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
453 { LPROC_LL_GETATTR, LPROCFS_TYPE_REGS, "getattr" },
455 { LPROC_LL_REVALIDATE, LPROCFS_TYPE_REGS, "getattr" },
457 /* special inode operation */
458 { LPROC_LL_STAFS, LPROCFS_TYPE_REGS, "statfs" },
459 { LPROC_LL_ALLOC_INODE, LPROCFS_TYPE_REGS, "alloc_inode" },
460 { LPROC_LL_DIRECT_READ, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
462 { LPROC_LL_DIRECT_WRITE, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
464 { LPROC_LL_SETXATTR, LPROCFS_TYPE_REGS, "setxattr" },
465 { LPROC_LL_GETXATTR, LPROCFS_TYPE_REGS, "getxattr" },
468 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
469 struct super_block *sb, char *osc, char *mdc)
471 struct lprocfs_vars lvars[2];
472 struct ll_sb_info *sbi = ll_s2sbi(sb);
473 struct obd_device *obd;
474 char name[MAX_STRING_SIZE + 1];
476 struct lprocfs_stats *svc_stats = NULL;
477 struct proc_dir_entry *mdc_symlink, *osc_symlink;
478 struct proc_dir_entry *entry;
481 memset(lvars, 0, sizeof(lvars));
483 name[MAX_STRING_SIZE] = '\0';
484 lvars[0].name = name;
486 LASSERT(sbi != NULL);
487 LASSERT(mdc != NULL);
488 LASSERT(osc != NULL);
491 snprintf(name, MAX_STRING_SIZE, "fs%llu", mnt_instance);
494 sbi->ll_proc_root = lprocfs_register(name, parent, NULL, NULL);
495 if (IS_ERR(sbi->ll_proc_root)) {
496 err = PTR_ERR(sbi->ll_proc_root);
497 sbi->ll_proc_root = NULL;
501 entry = create_proc_entry("dump_page_cache", 0444, sbi->ll_proc_root);
503 GOTO(out, err = -ENOMEM);
504 entry->proc_fops = &llite_dump_pgcache_fops;
507 entry = create_proc_entry("wait_times", 0444, sbi->ll_proc_root);
509 GOTO(out, err = -ENOMEM);
510 entry->proc_fops = &llite_wait_times_fops;
513 entry = create_proc_entry("read_ahead_stats", 0444, sbi->ll_proc_root);
515 GOTO(out, err = -ENOMEM);
516 entry->proc_fops = &ll_ra_stats_fops;
519 svc_stats = lprocfs_alloc_stats(LPROC_LL_FILE_OPCODES);
520 if (svc_stats == NULL) {
524 /* do counter init */
525 for (id = 0; id < LPROC_LL_FILE_OPCODES; id++) {
526 __u32 type = llite_opcode_table[id].type;
528 if (type & LPROCFS_TYPE_REGS)
531 if (type & LPROCFS_TYPE_BYTES)
534 if (type & LPROCFS_TYPE_PAGES)
538 lprocfs_counter_init(svc_stats, llite_opcode_table[id].opcode,
539 (type & LPROCFS_CNTR_AVGMINMAX),
540 llite_opcode_table[id].opname, ptr);
542 err = lprocfs_register_stats(sbi->ll_proc_root, "stats", svc_stats);
546 sbi->ll_stats = svc_stats;
547 /* need place to keep svc_stats */
549 /* Static configuration info */
550 err = lprocfs_add_vars(sbi->ll_proc_root, lprocfs_obd_vars, sb);
555 obd = class_name2obd(mdc);
557 LASSERT(obd != NULL);
558 LASSERT(obd->obd_type != NULL);
559 LASSERT(obd->obd_type->typ_name != NULL);
561 snprintf(name, MAX_STRING_SIZE, "../../%s/%s",
562 obd->obd_type->typ_name, obd->obd_name);
563 mdc_symlink = proc_symlink(obd->obd_type->typ_name, sbi->ll_proc_root,
565 if (mdc_symlink == NULL) {
571 obd = class_name2obd(osc);
573 LASSERT(obd != NULL);
574 LASSERT(obd->obd_type != NULL);
575 LASSERT(obd->obd_type->typ_name != NULL);
577 snprintf(name, MAX_STRING_SIZE, "../../%s/%s",
578 obd->obd_type->typ_name, obd->obd_name);
579 osc_symlink = proc_symlink(obd->obd_type->typ_name, sbi->ll_proc_root,
581 if (osc_symlink == NULL)
588 lprocfs_free_stats(svc_stats);
589 if (sbi->ll_proc_root)
590 lprocfs_remove(sbi->ll_proc_root);
595 void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi)
597 if (sbi->ll_proc_root) {
598 struct proc_dir_entry *file_stats =
599 lprocfs_srch(sbi->ll_proc_root, "stats");
602 lprocfs_free_stats(sbi->ll_stats);
603 lprocfs_remove(file_stats);
607 #undef MAX_STRING_SIZE
609 static struct ll_async_page *llite_pglist_next_llap(struct ll_sb_info *sbi,
610 struct list_head *list)
612 struct ll_async_page *llap;
613 struct list_head *pos;
615 list_for_each(pos, list) {
616 if (pos == &sbi->ll_pglist)
618 llap = list_entry(pos, struct ll_async_page, llap_proc_item);
619 if (llap->llap_page == NULL)
627 #define seq_page_flag(seq, page, flag, has_flags) do { \
628 if (test_bit(PG_##flag, &(page)->flags)) { \
632 seq_putc(seq, '|'); \
633 seq_puts(seq, #flag); \
637 static int llite_dump_pgcache_seq_show(struct seq_file *seq, void *v)
639 struct ll_async_page *llap, *dummy_llap = seq->private;
640 struct ll_sb_info *sbi = dummy_llap->llap_cookie;
642 /* 2.4 doesn't seem to have SEQ_START_TOKEN, so we implement
643 * it in our own state */
644 if (dummy_llap->llap_magic == 0) {
645 seq_printf(seq, "generation | llap .cookie | page ");
646 seq_printf(seq, "inode .index [ page flags ]\n");
650 spin_lock(&sbi->ll_lock);
652 llap = llite_pglist_next_llap(sbi, &dummy_llap->llap_proc_item);
655 struct page *page = llap->llap_page;
657 seq_printf(seq, "%lu | %p %p | %p %p %lu [",
659 llap, llap->llap_cookie,
660 page, page->mapping->host, page->index);
661 seq_page_flag(seq, page, locked, has_flags);
662 seq_page_flag(seq, page, error, has_flags);
663 seq_page_flag(seq, page, referenced, has_flags);
664 seq_page_flag(seq, page, uptodate, has_flags);
665 seq_page_flag(seq, page, dirty, has_flags);
666 seq_page_flag(seq, page, highmem, has_flags);
668 seq_puts(seq, "-]\n");
670 seq_puts(seq, "]\n");
673 spin_unlock(&sbi->ll_lock);
678 static void *llite_dump_pgcache_seq_start(struct seq_file *seq, loff_t *pos)
680 struct ll_async_page *llap = seq->private;
682 if (llap->llap_magic == 2)
688 static void *llite_dump_pgcache_seq_next(struct seq_file *seq, void *v,
691 struct ll_async_page *llap, *dummy_llap = seq->private;
692 struct ll_sb_info *sbi = dummy_llap->llap_cookie;
694 /* bail if we just displayed the banner */
695 if (dummy_llap->llap_magic == 0) {
696 dummy_llap->llap_magic = 1;
700 /* we've just displayed the llap that is after us in the list.
701 * we advance to a position beyond it, returning null if there
702 * isn't another llap in the list beyond that new position. */
703 spin_lock(&sbi->ll_lock);
704 llap = llite_pglist_next_llap(sbi, &dummy_llap->llap_proc_item);
705 list_del_init(&dummy_llap->llap_proc_item);
707 list_add(&dummy_llap->llap_proc_item, &llap->llap_proc_item);
708 llap = llite_pglist_next_llap(sbi, &dummy_llap->llap_proc_item);
710 spin_unlock(&sbi->ll_lock);
714 dummy_llap->llap_magic = 2;
720 static void llite_dump_pgcache_seq_stop(struct seq_file *seq, void *v)
724 struct seq_operations llite_dump_pgcache_seq_sops = {
725 .start = llite_dump_pgcache_seq_start,
726 .stop = llite_dump_pgcache_seq_stop,
727 .next = llite_dump_pgcache_seq_next,
728 .show = llite_dump_pgcache_seq_show,
731 /* we're displaying llaps in a list_head list. we don't want to hold a lock
732 * while we walk the entire list, and we don't want to have to seek into
733 * the right position in the list as an app advances with many syscalls. we
734 * allocate a dummy llap and hang it off file->private. its position in
735 * the list records where the app is currently displaying. this way our
736 * seq .start and .stop don't actually do anything. .next returns null
737 * when the dummy hits the end of the list which eventually leads to .release
738 * where we tear down. this kind of displaying is super-racey, so we put
739 * a generation counter on the list so the output shows when the list
740 * changes between reads.
742 static int llite_dump_pgcache_seq_open(struct inode *inode, struct file *file)
744 struct proc_dir_entry *dp = PDE(inode);
745 struct ll_async_page *llap;
746 struct seq_file *seq;
747 struct ll_sb_info *sbi = dp->data;
750 OBD_ALLOC_GFP(llap, sizeof(*llap), GFP_KERNEL);
753 llap->llap_page = NULL;
754 llap->llap_cookie = sbi;
755 llap->llap_magic = 0;
757 rc = seq_open(file, &llite_dump_pgcache_seq_sops);
759 OBD_FREE(llap, sizeof(*llap));
762 seq = file->private_data;
765 spin_lock(&sbi->ll_lock);
766 list_add(&llap->llap_proc_item, &sbi->ll_pglist);
767 spin_unlock(&sbi->ll_lock);
772 static int llite_dump_pgcache_seq_release(struct inode *inode,
775 struct seq_file *seq = file->private_data;
776 struct ll_async_page *llap = seq->private;
777 struct ll_sb_info *sbi = llap->llap_cookie;
779 spin_lock(&sbi->ll_lock);
780 if (!list_empty(&llap->llap_proc_item))
781 list_del_init(&llap->llap_proc_item);
782 spin_unlock(&sbi->ll_lock);
783 OBD_FREE(llap, sizeof(*llap));
785 return seq_release(inode, file);
788 struct file_operations llite_dump_pgcache_fops = {
789 .owner = THIS_MODULE,
790 .open = llite_dump_pgcache_seq_open,
792 .release = llite_dump_pgcache_seq_release,
794 static int ll_ra_stats_seq_show(struct seq_file *seq, void *v)
797 struct ll_sb_info *sbi = seq->private;
798 struct ll_ra_info *ra = &sbi->ll_ra_info;
800 static char *ra_stat_strings[] = {
801 [RA_STAT_HIT] = "hits",
802 [RA_STAT_MISS] = "misses",
803 [RA_STAT_DISTANT_READPAGE] = "readpage not consecutive",
804 [RA_STAT_MISS_IN_WINDOW] = "miss inside window",
805 [RA_STAT_FAILED_MATCH] = "failed lock match",
806 [RA_STAT_DISCARDED] = "read but discarded",
807 [RA_STAT_ZERO_LEN] = "zero length file",
808 [RA_STAT_ZERO_WINDOW] = "zero size window",
809 [RA_STAT_EOF] = "read-ahead to EOF",
810 [RA_STAT_MAX_IN_FLIGHT] = "hit max r-a issue",
813 do_gettimeofday(&now);
815 spin_lock(&sbi->ll_lock);
817 seq_printf(seq, "snapshot_time: %lu:%lu (secs:usecs)\n",
818 now.tv_sec, now.tv_usec);
819 seq_printf(seq, "pending issued pages: %lu\n",
822 for(i = 0; i < _NR_RA_STAT; i++)
823 seq_printf(seq, "%-25s %lu\n", ra_stat_strings[i],
826 spin_unlock(&sbi->ll_lock);
831 static void *ll_ra_stats_seq_start(struct seq_file *p, loff_t *pos)
837 static void *ll_ra_stats_seq_next(struct seq_file *p, void *v, loff_t *pos)
842 static void ll_ra_stats_seq_stop(struct seq_file *p, void *v)
845 struct seq_operations ll_ra_stats_seq_sops = {
846 .start = ll_ra_stats_seq_start,
847 .stop = ll_ra_stats_seq_stop,
848 .next = ll_ra_stats_seq_next,
849 .show = ll_ra_stats_seq_show,
852 static int ll_ra_stats_seq_open(struct inode *inode, struct file *file)
854 struct proc_dir_entry *dp = PDE(inode);
855 struct seq_file *seq;
858 rc = seq_open(file, &ll_ra_stats_seq_sops);
861 seq = file->private_data;
862 seq->private = dp->data;
866 static ssize_t ll_ra_stats_seq_write(struct file *file, const char *buf,
867 size_t len, loff_t *off)
869 struct seq_file *seq = file->private_data;
870 struct ll_sb_info *sbi = seq->private;
871 struct ll_ra_info *ra = &sbi->ll_ra_info;
873 spin_lock(&sbi->ll_lock);
874 memset(ra->ra_stats, 0, sizeof(ra->ra_stats));
875 spin_unlock(&sbi->ll_lock);
880 struct file_operations ll_ra_stats_fops = {
881 .owner = THIS_MODULE,
882 .open = ll_ra_stats_seq_open,
884 .write = ll_ra_stats_seq_write,
886 .release = seq_release,
889 #define PRINTF_STIME(stime) (unsigned long)(stime)->st_num, \
890 lprocfs_stime_avg_ms(stime), lprocfs_stime_avg_us(stime)
892 static int llite_wait_times_seq_show(struct seq_file *seq, void *v)
894 struct ll_sb_info *sbi = seq->private;
897 do_gettimeofday(&now);
899 spin_lock(&sbi->ll_lock);
901 seq_printf(seq, "snapshot_time: %lu:%lu (secs:usecs)\n\n",
902 now.tv_sec, now.tv_usec);
904 seq_printf(seq, "lock wait times: (num, average ms)\n");
905 seq_printf(seq, "\tread\t%lu\t%lu.%04lu\n",
906 PRINTF_STIME(&sbi->ll_read_stime));
907 seq_printf(seq, "\twrite\t%lu\t%lu.%04lu\n",
908 PRINTF_STIME(&sbi->ll_write_stime));
909 seq_printf(seq, "\tgroup\t%lu\t%lu.%04lu\n",
910 PRINTF_STIME(&sbi->ll_grouplock_stime));
911 seq_printf(seq, "\tseek\t%lu\t%lu.%04lu\n",
912 PRINTF_STIME(&sbi->ll_seek_stime));
913 seq_printf(seq, "\tsetattr\t%lu\t%lu.%04lu\n\n",
914 PRINTF_STIME(&sbi->ll_setattr_stime));
916 seq_printf(seq, "io path wait times: (num, average ms)\n");
917 seq_printf(seq, "\tll_brw\t%lu\t%lu.%04lu\n",
918 PRINTF_STIME(&sbi->ll_brw_stime));
920 seq_printf(seq, "\tdone\t%lu\t%lu.%04lu\n",
921 PRINTF_STIME(&sbi->ll_done_stime));
924 spin_unlock(&sbi->ll_lock);
930 static void *llite_wait_times_seq_start(struct seq_file *p, loff_t *pos)
936 static void *llite_wait_times_seq_next(struct seq_file *p, void *v, loff_t *pos)
941 static void llite_wait_times_seq_stop(struct seq_file *p, void *v)
944 struct seq_operations llite_wait_times_seq_sops = {
945 .start = llite_wait_times_seq_start,
946 .stop = llite_wait_times_seq_stop,
947 .next = llite_wait_times_seq_next,
948 .show = llite_wait_times_seq_show,
951 static int llite_wait_times_seq_open(struct inode *inode, struct file *file)
953 struct proc_dir_entry *dp = PDE(inode);
954 struct seq_file *seq;
957 rc = seq_open(file, &llite_wait_times_seq_sops);
960 seq = file->private_data;
961 seq->private = dp->data;
965 static ssize_t llite_wait_times_seq_write(struct file *file, const char *buf,
966 size_t len, loff_t *off)
968 struct seq_file *seq = file->private_data;
969 struct ll_sb_info *sbi = seq->private;
971 spin_lock(&sbi->ll_lock);
972 memset(&sbi->ll_read_stime, 0, sizeof(sbi->ll_read_stime));
973 memset(&sbi->ll_write_stime, 0, sizeof(sbi->ll_write_stime));
974 memset(&sbi->ll_grouplock_stime, 0, sizeof(sbi->ll_grouplock_stime));
975 memset(&sbi->ll_seek_stime, 0, sizeof(sbi->ll_seek_stime));
976 memset(&sbi->ll_setattr_stime, 0, sizeof(sbi->ll_setattr_stime));
977 memset(&sbi->ll_brw_stime, 0, sizeof(sbi->ll_brw_stime));
978 // memset(&sbi->ll_done_stime, 0, sizeof(sbi->ll_done_stime));
979 spin_unlock(&sbi->ll_lock);
984 struct file_operations llite_wait_times_fops = {
985 .owner = THIS_MODULE,
986 .open = llite_wait_times_seq_open,
988 .write = llite_wait_times_seq_write,
990 .release = seq_release,