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;
40 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
41 struct super_block *sb, char *osc, char *mdc)
45 void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi){}
48 long long mnt_instance;
50 static int ll_rd_blksize(char *page, char **start, off_t off, int count,
53 struct super_block *sb = (struct super_block *)data;
54 struct obd_statfs osfs;
58 rc = ll_statfs_internal(sb, &osfs, jiffies - HZ);
61 rc = snprintf(page, count, "%u\n", osfs.os_bsize);
67 static int ll_rd_kbytestotal(char *page, char **start, off_t off, int count,
70 struct super_block *sb = (struct super_block *)data;
71 struct obd_statfs osfs;
75 rc = ll_statfs_internal(sb, &osfs, jiffies - HZ);
77 __u32 blk_size = osfs.os_bsize >> 10;
78 __u64 result = osfs.os_blocks;
80 while (blk_size >>= 1)
84 rc = snprintf(page, count, LPU64"\n", result);
90 static int ll_rd_kbytesfree(char *page, char **start, off_t off, int count,
93 struct super_block *sb = (struct super_block *)data;
94 struct obd_statfs osfs;
98 rc = ll_statfs_internal(sb, &osfs, jiffies - HZ);
100 __u32 blk_size = osfs.os_bsize >> 10;
101 __u64 result = osfs.os_bfree;
103 while (blk_size >>= 1)
107 rc = snprintf(page, count, LPU64"\n", result);
112 static int ll_rd_kbytesavail(char *page, char **start, off_t off, int count,
113 int *eof, void *data)
115 struct super_block *sb = (struct super_block *)data;
116 struct obd_statfs osfs;
120 rc = ll_statfs_internal(sb, &osfs, jiffies - HZ);
122 __u32 blk_size = osfs.os_bsize >> 10;
123 __u64 result = osfs.os_bavail;
125 while (blk_size >>= 1)
129 rc = snprintf(page, count, LPU64"\n", result);
134 static int ll_rd_filestotal(char *page, char **start, off_t off, int count,
135 int *eof, void *data)
137 struct super_block *sb = (struct super_block *)data;
138 struct obd_statfs osfs;
142 rc = ll_statfs_internal(sb, &osfs, jiffies - HZ);
145 rc = snprintf(page, count, LPU64"\n", osfs.os_files);
150 static int ll_rd_filesfree(char *page, char **start, off_t off, int count,
151 int *eof, void *data)
153 struct super_block *sb = (struct super_block *)data;
154 struct obd_statfs osfs;
158 rc = ll_statfs_internal(sb, &osfs, jiffies - HZ);
161 rc = snprintf(page, count, LPU64"\n", osfs.os_ffree);
167 static int ll_rd_fstype(char *page, char **start, off_t off, int count,
168 int *eof, void *data)
170 struct super_block *sb = (struct super_block*)data;
174 return snprintf(page, count, "%s\n", sb->s_type->name);
177 static int ll_rd_sb_uuid(char *page, char **start, off_t off, int count,
178 int *eof, void *data)
180 struct super_block *sb = (struct super_block *)data;
184 return snprintf(page, count, "%s\n", ll_s2sbi(sb)->ll_sb_uuid.uuid);
187 static int ll_rd_read_ahead(char *page, char **start, off_t off, int count,
188 int *eof, void *data)
190 struct super_block *sb = (struct super_block*)data;
191 struct ll_sb_info *sbi = ll_s2sbi(sb);
196 val = (sbi->ll_flags & LL_SBI_READAHEAD) ? 1 : 0;
197 rc = snprintf(page, count, "%d\n", val);
201 static int ll_wr_read_ahead(struct file *file, const char *buffer,
202 unsigned long count, void *data)
204 struct super_block *sb = (struct super_block*)data;
205 struct ll_sb_info *sbi = ll_s2sbi(sb);
209 if (sscanf(buffer, "%d", &readahead) != 1)
213 sbi->ll_flags |= LL_SBI_READAHEAD;
215 sbi->ll_flags &= ~LL_SBI_READAHEAD;
220 static int ll_wr_config_update(struct file *file, const char *buffer,
221 unsigned long count, void *data)
223 struct super_block *sb = (struct super_block*)data;
224 struct ll_sb_info *sbi = ll_s2sbi(sb);
227 CWARN("Starting a LOV/OST update !\n");
228 RETURN(ll_process_config_update(sbi, 0));
231 static int ll_rd_max_read_ahead_mb(char *page, char **start, off_t off,
232 int count, int *eof, void *data)
234 struct super_block *sb = data;
235 struct ll_sb_info *sbi = ll_s2sbi(sb);
238 spin_lock(&sbi->ll_lock);
239 val = (sbi->ll_ra_info.ra_max_pages << PAGE_CACHE_SHIFT) >> 20;
240 spin_unlock(&sbi->ll_lock);
242 return snprintf(page, count, "%u\n", val);
245 static int ll_wr_max_read_ahead_mb(struct file *file, const char *buffer,
246 unsigned long count, void *data)
248 struct super_block *sb = data;
249 struct ll_sb_info *sbi = ll_s2sbi(sb);
252 rc = lprocfs_write_helper(buffer, count, &val);
256 if (val < 0 || val > (num_physpages << PAGE_SHIFT) >> 20)
259 spin_lock(&sbi->ll_lock);
260 sbi->ll_ra_info.ra_max_pages = (val << 20) >> PAGE_CACHE_SHIFT;
261 spin_unlock(&sbi->ll_lock);
266 static struct lprocfs_vars lprocfs_obd_vars[] = {
267 { "uuid", ll_rd_sb_uuid, 0, 0 },
268 //{ "mntpt_path", ll_rd_path, 0, 0 },
269 { "fstype", ll_rd_fstype, 0, 0 },
270 { "blocksize", ll_rd_blksize, 0, 0 },
271 { "kbytestotal", ll_rd_kbytestotal, 0, 0 },
272 { "kbytesfree", ll_rd_kbytesfree, 0, 0 },
273 { "kbytesavail", ll_rd_kbytesavail, 0, 0 },
274 { "filestotal", ll_rd_filestotal, 0, 0 },
275 { "filesfree", ll_rd_filesfree, 0, 0 },
276 //{ "filegroups", lprocfs_rd_filegroups, 0, 0 },
277 { "read_ahead", ll_rd_read_ahead, ll_wr_read_ahead, 0 },
278 { "config_update", 0, ll_wr_config_update, 0 },
279 { "max_read_ahead_mb", ll_rd_max_read_ahead_mb,
280 ll_wr_max_read_ahead_mb, 0 },
284 #define MAX_STRING_SIZE 128
286 struct llite_file_opcode {
290 } llite_opcode_table[LPROC_LL_FILE_OPCODES] = {
292 { LPROC_LL_DIRTY_HITS, LPROCFS_TYPE_REGS, "dirty_pages_hits" },
293 { LPROC_LL_DIRTY_MISSES, LPROCFS_TYPE_REGS, "dirty_pages_misses" },
294 { LPROC_LL_WB_WRITEPAGE, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
295 "writeback_from_writepage" },
296 { LPROC_LL_WB_PRESSURE, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
297 "writeback_from_pressure" },
298 { LPROC_LL_WB_OK, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
299 "writeback_ok_pages" },
300 { LPROC_LL_WB_FAIL, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
301 "writeback_failed_pages" },
302 { LPROC_LL_READ_BYTES, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_BYTES,
304 { LPROC_LL_WRITE_BYTES, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_BYTES,
306 { LPROC_LL_BRW_READ, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
308 { LPROC_LL_BRW_WRITE, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
311 { LPROC_LL_IOCTL, LPROCFS_TYPE_REGS, "ioctl" },
312 { LPROC_LL_OPEN, LPROCFS_TYPE_REGS, "open" },
313 { LPROC_LL_RELEASE, LPROCFS_TYPE_REGS, "close" },
314 { LPROC_LL_MAP, LPROCFS_TYPE_REGS, "mmap" },
315 { LPROC_LL_LLSEEK, LPROCFS_TYPE_REGS, "seek" },
316 { LPROC_LL_FSYNC, LPROCFS_TYPE_REGS, "fsync" },
317 /* inode operation */
318 { LPROC_LL_SETATTR, LPROCFS_TYPE_REGS, "setattr" },
319 { LPROC_LL_TRUNC, LPROCFS_TYPE_REGS, "punch" },
320 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
321 { LPROC_LL_GETATTR, LPROCFS_TYPE_REGS, "getattr" },
323 { LPROC_LL_REVALIDATE, LPROCFS_TYPE_REGS, "getattr" },
325 /* special inode operation */
326 { LPROC_LL_STAFS, LPROCFS_TYPE_REGS, "statfs" },
327 { LPROC_LL_ALLOC_INODE, LPROCFS_TYPE_REGS, "alloc_inode" },
328 { LPROC_LL_DIRECT_READ, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
330 { LPROC_LL_DIRECT_WRITE, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES,
335 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
336 struct super_block *sb, char *osc, char *mdc)
338 struct lprocfs_vars lvars[2];
339 struct ll_sb_info *sbi = ll_s2sbi(sb);
340 struct obd_device *obd;
341 char name[MAX_STRING_SIZE + 1];
343 struct lprocfs_stats *svc_stats = NULL;
344 struct proc_dir_entry *mdc_symlink, *osc_symlink;
345 struct proc_dir_entry *entry;
348 memset(lvars, 0, sizeof(lvars));
350 name[MAX_STRING_SIZE] = '\0';
351 lvars[0].name = name;
353 LASSERT(sbi != NULL);
354 LASSERT(mdc != NULL);
355 LASSERT(osc != NULL);
358 snprintf(name, MAX_STRING_SIZE, "fs%llu", mnt_instance);
361 sbi->ll_proc_root = lprocfs_register(name, parent, NULL, NULL);
362 if (IS_ERR(sbi->ll_proc_root)) {
363 err = PTR_ERR(sbi->ll_proc_root);
364 sbi->ll_proc_root = NULL;
368 entry = create_proc_entry("dump_page_cache", 0444, sbi->ll_proc_root);
370 GOTO(out, err = -ENOMEM);
371 entry->proc_fops = &llite_dump_pgcache_fops;
374 entry = create_proc_entry("wait_times", 0444, sbi->ll_proc_root);
376 GOTO(out, err = -ENOMEM);
377 entry->proc_fops = &llite_wait_times_fops;
380 entry = create_proc_entry("read_ahead_stats", 0444, sbi->ll_proc_root);
382 GOTO(out, err = -ENOMEM);
383 entry->proc_fops = &ll_ra_stats_fops;
386 svc_stats = lprocfs_alloc_stats(LPROC_LL_FILE_OPCODES);
387 if (svc_stats == NULL) {
391 /* do counter init */
392 for (id = 0; id < LPROC_LL_FILE_OPCODES; id++) {
393 __u32 type = llite_opcode_table[id].type;
395 if (type & LPROCFS_TYPE_REGS)
398 if (type & LPROCFS_TYPE_BYTES)
401 if (type & LPROCFS_TYPE_PAGES)
405 lprocfs_counter_init(svc_stats, llite_opcode_table[id].opcode,
406 (type & LPROCFS_CNTR_AVGMINMAX),
407 llite_opcode_table[id].opname, ptr);
409 err = lprocfs_register_stats(sbi->ll_proc_root, "stats", svc_stats);
413 sbi->ll_stats = svc_stats;
414 /* need place to keep svc_stats */
416 /* Static configuration info */
417 err = lprocfs_add_vars(sbi->ll_proc_root, lprocfs_obd_vars, sb);
422 obd = class_name2obd(mdc);
424 LASSERT(obd != NULL);
425 LASSERT(obd->obd_type != NULL);
426 LASSERT(obd->obd_type->typ_name != NULL);
428 snprintf(name, MAX_STRING_SIZE, "../../%s/%s",
429 obd->obd_type->typ_name, obd->obd_name);
430 mdc_symlink = proc_symlink(obd->obd_type->typ_name, sbi->ll_proc_root,
432 if (mdc_symlink == NULL) {
438 obd = class_name2obd(osc);
440 LASSERT(obd != NULL);
441 LASSERT(obd->obd_type != NULL);
442 LASSERT(obd->obd_type->typ_name != NULL);
444 snprintf(name, MAX_STRING_SIZE, "../../%s/%s",
445 obd->obd_type->typ_name, obd->obd_name);
446 osc_symlink = proc_symlink(obd->obd_type->typ_name, sbi->ll_proc_root,
448 if (osc_symlink == NULL)
455 lprocfs_free_stats(svc_stats);
456 if (sbi->ll_proc_root)
457 lprocfs_remove(sbi->ll_proc_root);
462 void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi)
464 if (sbi->ll_proc_root) {
465 struct proc_dir_entry *file_stats =
466 lprocfs_srch(sbi->ll_proc_root, "stats");
469 lprocfs_free_stats(sbi->ll_stats);
470 lprocfs_remove(file_stats);
474 #undef MAX_STRING_SIZE
476 static struct ll_async_page *llite_pglist_next_llap(struct ll_sb_info *sbi,
477 struct list_head *list)
479 struct ll_async_page *llap;
480 struct list_head *pos;
482 list_for_each(pos, list) {
483 if (pos == &sbi->ll_pglist)
485 llap = list_entry(pos, struct ll_async_page, llap_proc_item);
486 if (llap->llap_page == NULL)
494 #define seq_page_flag(seq, page, flag, has_flags) do { \
495 if (test_bit(PG_##flag, &(page)->flags)) { \
499 seq_putc(seq, '|'); \
500 seq_puts(seq, #flag); \
504 static int llite_dump_pgcache_seq_show(struct seq_file *seq, void *v)
506 struct ll_async_page *llap, *dummy_llap = seq->private;
507 struct ll_sb_info *sbi = dummy_llap->llap_cookie;
509 /* 2.4 doesn't seem to have SEQ_START_TOKEN, so we implement
510 * it in our own state */
511 if (dummy_llap->llap_magic == 0) {
512 seq_printf(seq, "generation | llap .cookie | page ");
513 seq_printf(seq, "inode .index [ page flags ]\n");
517 spin_lock(&sbi->ll_lock);
519 llap = llite_pglist_next_llap(sbi, &dummy_llap->llap_proc_item);
522 struct page *page = llap->llap_page;
524 seq_printf(seq, "%lu | %p %p | %p %p %lu [",
526 llap, llap->llap_cookie,
527 page, page->mapping->host, page->index);
528 seq_page_flag(seq, page, locked, has_flags);
529 seq_page_flag(seq, page, error, has_flags);
530 seq_page_flag(seq, page, referenced, has_flags);
531 seq_page_flag(seq, page, uptodate, has_flags);
532 seq_page_flag(seq, page, dirty, has_flags);
533 seq_page_flag(seq, page, highmem, has_flags);
535 seq_puts(seq, "-]\n");
537 seq_puts(seq, "]\n");
540 spin_unlock(&sbi->ll_lock);
545 static void *llite_dump_pgcache_seq_start(struct seq_file *seq, loff_t *pos)
547 struct ll_async_page *llap = seq->private;
549 if (llap->llap_magic == 2)
555 static void *llite_dump_pgcache_seq_next(struct seq_file *seq, void *v,
558 struct ll_async_page *llap, *dummy_llap = seq->private;
559 struct ll_sb_info *sbi = dummy_llap->llap_cookie;
561 /* bail if we just displayed the banner */
562 if (dummy_llap->llap_magic == 0) {
563 dummy_llap->llap_magic = 1;
567 /* we've just displayed the llap that is after us in the list.
568 * we advance to a position beyond it, returning null if there
569 * isn't another llap in the list beyond that new position. */
570 spin_lock(&sbi->ll_lock);
571 llap = llite_pglist_next_llap(sbi, &dummy_llap->llap_proc_item);
572 list_del_init(&dummy_llap->llap_proc_item);
574 list_add(&dummy_llap->llap_proc_item, &llap->llap_proc_item);
575 llap = llite_pglist_next_llap(sbi, &dummy_llap->llap_proc_item);
577 spin_unlock(&sbi->ll_lock);
581 dummy_llap->llap_magic = 2;
587 static void llite_dump_pgcache_seq_stop(struct seq_file *seq, void *v)
591 struct seq_operations llite_dump_pgcache_seq_sops = {
592 .start = llite_dump_pgcache_seq_start,
593 .stop = llite_dump_pgcache_seq_stop,
594 .next = llite_dump_pgcache_seq_next,
595 .show = llite_dump_pgcache_seq_show,
598 /* we're displaying llaps in a list_head list. we don't want to hold a lock
599 * while we walk the entire list, and we don't want to have to seek into
600 * the right position in the list as an app advances with many syscalls. we
601 * allocate a dummy llap and hang it off file->private. its position in
602 * the list records where the app is currently displaying. this way our
603 * seq .start and .stop don't actually do anything. .next returns null
604 * when the dummy hits the end of the list which eventually leads to .release
605 * where we tear down. this kind of displaying is super-racey, so we put
606 * a generation counter on the list so the output shows when the list
607 * changes between reads.
609 static int llite_dump_pgcache_seq_open(struct inode *inode, struct file *file)
611 struct proc_dir_entry *dp = PDE(inode);
612 struct ll_async_page *llap;
613 struct seq_file *seq;
614 struct ll_sb_info *sbi = dp->data;
617 OBD_ALLOC_GFP(llap, sizeof(*llap), GFP_KERNEL);
620 llap->llap_page = NULL;
621 llap->llap_cookie = sbi;
622 llap->llap_magic = 0;
624 rc = seq_open(file, &llite_dump_pgcache_seq_sops);
626 OBD_FREE(llap, sizeof(*llap));
629 seq = file->private_data;
632 spin_lock(&sbi->ll_lock);
633 list_add(&llap->llap_proc_item, &sbi->ll_pglist);
634 spin_unlock(&sbi->ll_lock);
639 static int llite_dump_pgcache_seq_release(struct inode *inode,
642 struct seq_file *seq = file->private_data;
643 struct ll_async_page *llap = seq->private;
644 struct ll_sb_info *sbi = llap->llap_cookie;
646 spin_lock(&sbi->ll_lock);
647 if (!list_empty(&llap->llap_proc_item))
648 list_del_init(&llap->llap_proc_item);
649 spin_unlock(&sbi->ll_lock);
650 OBD_FREE(llap, sizeof(*llap));
652 return seq_release(inode, file);
655 struct file_operations llite_dump_pgcache_fops = {
656 .owner = THIS_MODULE,
657 .open = llite_dump_pgcache_seq_open,
659 .release = llite_dump_pgcache_seq_release,
661 static int ll_ra_stats_seq_show(struct seq_file *seq, void *v)
664 struct ll_sb_info *sbi = seq->private;
665 struct ll_ra_info *ra = &sbi->ll_ra_info;
667 static char *ra_stat_strings[] = {
668 [RA_STAT_HIT] = "hits",
669 [RA_STAT_MISS] = "misses",
670 [RA_STAT_DISTANT_READPAGE] = "readpage not consecutive",
671 [RA_STAT_MISS_IN_WINDOW] = "miss inside window",
672 [RA_STAT_FAILED_MATCH] = "failed lock match",
673 [RA_STAT_DISCARDED] = "read but discarded",
674 [RA_STAT_ZERO_LEN] = "zero length file",
675 [RA_STAT_ZERO_WINDOW] = "zero size window",
676 [RA_STAT_EOF] = "read-ahead to EOF",
677 [RA_STAT_MAX_IN_FLIGHT] = "hit max r-a issue",
680 do_gettimeofday(&now);
682 spin_lock(&sbi->ll_lock);
684 seq_printf(seq, "snapshot_time: %lu:%lu (secs:usecs)\n",
685 now.tv_sec, now.tv_usec);
686 seq_printf(seq, "pending issued pages: %lu\n",
689 for(i = 0; i < _NR_RA_STAT; i++)
690 seq_printf(seq, "%-25s %lu\n", ra_stat_strings[i],
693 spin_unlock(&sbi->ll_lock);
698 static void *ll_ra_stats_seq_start(struct seq_file *p, loff_t *pos)
704 static void *ll_ra_stats_seq_next(struct seq_file *p, void *v, loff_t *pos)
709 static void ll_ra_stats_seq_stop(struct seq_file *p, void *v)
712 struct seq_operations ll_ra_stats_seq_sops = {
713 .start = ll_ra_stats_seq_start,
714 .stop = ll_ra_stats_seq_stop,
715 .next = ll_ra_stats_seq_next,
716 .show = ll_ra_stats_seq_show,
719 static int ll_ra_stats_seq_open(struct inode *inode, struct file *file)
721 struct proc_dir_entry *dp = PDE(inode);
722 struct seq_file *seq;
725 rc = seq_open(file, &ll_ra_stats_seq_sops);
728 seq = file->private_data;
729 seq->private = dp->data;
733 static ssize_t ll_ra_stats_seq_write(struct file *file, const char *buf,
734 size_t len, loff_t *off)
736 struct seq_file *seq = file->private_data;
737 struct ll_sb_info *sbi = seq->private;
738 struct ll_ra_info *ra = &sbi->ll_ra_info;
740 spin_lock(&sbi->ll_lock);
741 memset(ra->ra_stats, 0, sizeof(ra->ra_stats));
742 spin_unlock(&sbi->ll_lock);
747 struct file_operations ll_ra_stats_fops = {
748 .owner = THIS_MODULE,
749 .open = ll_ra_stats_seq_open,
751 .write = ll_ra_stats_seq_write,
753 .release = seq_release,
756 #define PRINTF_STIME(stime) (unsigned long)(stime)->st_num, \
757 lprocfs_stime_avg_ms(stime), lprocfs_stime_avg_us(stime)
759 static int llite_wait_times_seq_show(struct seq_file *seq, void *v)
761 struct ll_sb_info *sbi = seq->private;
764 do_gettimeofday(&now);
766 spin_lock(&sbi->ll_lock);
768 seq_printf(seq, "snapshot_time: %lu:%lu (secs:usecs)\n\n",
769 now.tv_sec, now.tv_usec);
771 seq_printf(seq, "lock wait times: (num, average ms)\n");
772 seq_printf(seq, "\tread\t%lu\t%lu.%04lu\n",
773 PRINTF_STIME(&sbi->ll_read_stime));
774 seq_printf(seq, "\twrite\t%lu\t%lu.%04lu\n",
775 PRINTF_STIME(&sbi->ll_write_stime));
776 seq_printf(seq, "\tgroup\t%lu\t%lu.%04lu\n",
777 PRINTF_STIME(&sbi->ll_grouplock_stime));
778 seq_printf(seq, "\tseek\t%lu\t%lu.%04lu\n",
779 PRINTF_STIME(&sbi->ll_seek_stime));
780 seq_printf(seq, "\tsetattr\t%lu\t%lu.%04lu\n\n",
781 PRINTF_STIME(&sbi->ll_setattr_stime));
783 seq_printf(seq, "io path wait times: (num, average ms)\n");
784 seq_printf(seq, "\tll_brw\t%lu\t%lu.%04lu\n",
785 PRINTF_STIME(&sbi->ll_brw_stime));
787 seq_printf(seq, "\tdone\t%lu\t%lu.%04lu\n",
788 PRINTF_STIME(&sbi->ll_done_stime));
791 spin_unlock(&sbi->ll_lock);
797 static void *llite_wait_times_seq_start(struct seq_file *p, loff_t *pos)
803 static void *llite_wait_times_seq_next(struct seq_file *p, void *v, loff_t *pos)
808 static void llite_wait_times_seq_stop(struct seq_file *p, void *v)
811 struct seq_operations llite_wait_times_seq_sops = {
812 .start = llite_wait_times_seq_start,
813 .stop = llite_wait_times_seq_stop,
814 .next = llite_wait_times_seq_next,
815 .show = llite_wait_times_seq_show,
818 static int llite_wait_times_seq_open(struct inode *inode, struct file *file)
820 struct proc_dir_entry *dp = PDE(inode);
821 struct seq_file *seq;
824 rc = seq_open(file, &llite_wait_times_seq_sops);
827 seq = file->private_data;
828 seq->private = dp->data;
832 static ssize_t llite_wait_times_seq_write(struct file *file, const char *buf,
833 size_t len, loff_t *off)
835 struct seq_file *seq = file->private_data;
836 struct ll_sb_info *sbi = seq->private;
838 spin_lock(&sbi->ll_lock);
839 memset(&sbi->ll_read_stime, 0, sizeof(sbi->ll_read_stime));
840 memset(&sbi->ll_write_stime, 0, sizeof(sbi->ll_write_stime));
841 memset(&sbi->ll_grouplock_stime, 0, sizeof(sbi->ll_grouplock_stime));
842 memset(&sbi->ll_seek_stime, 0, sizeof(sbi->ll_seek_stime));
843 memset(&sbi->ll_setattr_stime, 0, sizeof(sbi->ll_setattr_stime));
844 memset(&sbi->ll_brw_stime, 0, sizeof(sbi->ll_brw_stime));
845 // memset(&sbi->ll_done_stime, 0, sizeof(sbi->ll_done_stime));
846 spin_unlock(&sbi->ll_lock);
851 struct file_operations llite_wait_times_fops = {
852 .owner = THIS_MODULE,
853 .open = llite_wait_times_seq_open,
855 .write = llite_wait_times_seq_write,
857 .release = seq_release,