diff options
Diffstat (limited to 'fs/jbd2/journal.c')
-rw-r--r-- | fs/jbd2/journal.c | 198 |
1 files changed, 14 insertions, 184 deletions
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 53b86e16e5fe..b0ab5219becb 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c | |||
@@ -136,10 +136,6 @@ static int kjournald2(void *arg) | |||
136 | journal->j_task = current; | 136 | journal->j_task = current; |
137 | wake_up(&journal->j_wait_done_commit); | 137 | wake_up(&journal->j_wait_done_commit); |
138 | 138 | ||
139 | printk(KERN_INFO "kjournald2 starting: pid %d, dev %s, " | ||
140 | "commit interval %ld seconds\n", current->pid, | ||
141 | journal->j_devname, journal->j_commit_interval / HZ); | ||
142 | |||
143 | /* | 139 | /* |
144 | * And now, wait forever for commit wakeup events. | 140 | * And now, wait forever for commit wakeup events. |
145 | */ | 141 | */ |
@@ -223,7 +219,8 @@ static int jbd2_journal_start_thread(journal_t *journal) | |||
223 | { | 219 | { |
224 | struct task_struct *t; | 220 | struct task_struct *t; |
225 | 221 | ||
226 | t = kthread_run(kjournald2, journal, "kjournald2"); | 222 | t = kthread_run(kjournald2, journal, "jbd2/%s", |
223 | journal->j_devname); | ||
227 | if (IS_ERR(t)) | 224 | if (IS_ERR(t)) |
228 | return PTR_ERR(t); | 225 | return PTR_ERR(t); |
229 | 226 | ||
@@ -679,153 +676,6 @@ struct jbd2_stats_proc_session { | |||
679 | int max; | 676 | int max; |
680 | }; | 677 | }; |
681 | 678 | ||
682 | static void *jbd2_history_skip_empty(struct jbd2_stats_proc_session *s, | ||
683 | struct transaction_stats_s *ts, | ||
684 | int first) | ||
685 | { | ||
686 | if (ts == s->stats + s->max) | ||
687 | ts = s->stats; | ||
688 | if (!first && ts == s->stats + s->start) | ||
689 | return NULL; | ||
690 | while (ts->ts_type == 0) { | ||
691 | ts++; | ||
692 | if (ts == s->stats + s->max) | ||
693 | ts = s->stats; | ||
694 | if (ts == s->stats + s->start) | ||
695 | return NULL; | ||
696 | } | ||
697 | return ts; | ||
698 | |||
699 | } | ||
700 | |||
701 | static void *jbd2_seq_history_start(struct seq_file *seq, loff_t *pos) | ||
702 | { | ||
703 | struct jbd2_stats_proc_session *s = seq->private; | ||
704 | struct transaction_stats_s *ts; | ||
705 | int l = *pos; | ||
706 | |||
707 | if (l == 0) | ||
708 | return SEQ_START_TOKEN; | ||
709 | ts = jbd2_history_skip_empty(s, s->stats + s->start, 1); | ||
710 | if (!ts) | ||
711 | return NULL; | ||
712 | l--; | ||
713 | while (l) { | ||
714 | ts = jbd2_history_skip_empty(s, ++ts, 0); | ||
715 | if (!ts) | ||
716 | break; | ||
717 | l--; | ||
718 | } | ||
719 | return ts; | ||
720 | } | ||
721 | |||
722 | static void *jbd2_seq_history_next(struct seq_file *seq, void *v, loff_t *pos) | ||
723 | { | ||
724 | struct jbd2_stats_proc_session *s = seq->private; | ||
725 | struct transaction_stats_s *ts = v; | ||
726 | |||
727 | ++*pos; | ||
728 | if (v == SEQ_START_TOKEN) | ||
729 | return jbd2_history_skip_empty(s, s->stats + s->start, 1); | ||
730 | else | ||
731 | return jbd2_history_skip_empty(s, ++ts, 0); | ||
732 | } | ||
733 | |||
734 | static int jbd2_seq_history_show(struct seq_file *seq, void *v) | ||
735 | { | ||
736 | struct transaction_stats_s *ts = v; | ||
737 | if (v == SEQ_START_TOKEN) { | ||
738 | seq_printf(seq, "%-4s %-5s %-5s %-5s %-5s %-5s %-5s %-6s %-5s " | ||
739 | "%-5s %-5s %-5s %-5s %-5s\n", "R/C", "tid", | ||
740 | "wait", "run", "lock", "flush", "log", "hndls", | ||
741 | "block", "inlog", "ctime", "write", "drop", | ||
742 | "close"); | ||
743 | return 0; | ||
744 | } | ||
745 | if (ts->ts_type == JBD2_STATS_RUN) | ||
746 | seq_printf(seq, "%-4s %-5lu %-5u %-5u %-5u %-5u %-5u " | ||
747 | "%-6lu %-5lu %-5lu\n", "R", ts->ts_tid, | ||
748 | jiffies_to_msecs(ts->u.run.rs_wait), | ||
749 | jiffies_to_msecs(ts->u.run.rs_running), | ||
750 | jiffies_to_msecs(ts->u.run.rs_locked), | ||
751 | jiffies_to_msecs(ts->u.run.rs_flushing), | ||
752 | jiffies_to_msecs(ts->u.run.rs_logging), | ||
753 | ts->u.run.rs_handle_count, | ||
754 | ts->u.run.rs_blocks, | ||
755 | ts->u.run.rs_blocks_logged); | ||
756 | else if (ts->ts_type == JBD2_STATS_CHECKPOINT) | ||
757 | seq_printf(seq, "%-4s %-5lu %48s %-5u %-5lu %-5lu %-5lu\n", | ||
758 | "C", ts->ts_tid, " ", | ||
759 | jiffies_to_msecs(ts->u.chp.cs_chp_time), | ||
760 | ts->u.chp.cs_written, ts->u.chp.cs_dropped, | ||
761 | ts->u.chp.cs_forced_to_close); | ||
762 | else | ||
763 | J_ASSERT(0); | ||
764 | return 0; | ||
765 | } | ||
766 | |||
767 | static void jbd2_seq_history_stop(struct seq_file *seq, void *v) | ||
768 | { | ||
769 | } | ||
770 | |||
771 | static const struct seq_operations jbd2_seq_history_ops = { | ||
772 | .start = jbd2_seq_history_start, | ||
773 | .next = jbd2_seq_history_next, | ||
774 | .stop = jbd2_seq_history_stop, | ||
775 | .show = jbd2_seq_history_show, | ||
776 | }; | ||
777 | |||
778 | static int jbd2_seq_history_open(struct inode *inode, struct file *file) | ||
779 | { | ||
780 | journal_t *journal = PDE(inode)->data; | ||
781 | struct jbd2_stats_proc_session *s; | ||
782 | int rc, size; | ||
783 | |||
784 | s = kmalloc(sizeof(*s), GFP_KERNEL); | ||
785 | if (s == NULL) | ||
786 | return -ENOMEM; | ||
787 | size = sizeof(struct transaction_stats_s) * journal->j_history_max; | ||
788 | s->stats = kmalloc(size, GFP_KERNEL); | ||
789 | if (s->stats == NULL) { | ||
790 | kfree(s); | ||
791 | return -ENOMEM; | ||
792 | } | ||
793 | spin_lock(&journal->j_history_lock); | ||
794 | memcpy(s->stats, journal->j_history, size); | ||
795 | s->max = journal->j_history_max; | ||
796 | s->start = journal->j_history_cur % s->max; | ||
797 | spin_unlock(&journal->j_history_lock); | ||
798 | |||
799 | rc = seq_open(file, &jbd2_seq_history_ops); | ||
800 | if (rc == 0) { | ||
801 | struct seq_file *m = file->private_data; | ||
802 | m->private = s; | ||
803 | } else { | ||
804 | kfree(s->stats); | ||
805 | kfree(s); | ||
806 | } | ||
807 | return rc; | ||
808 | |||
809 | } | ||
810 | |||
811 | static int jbd2_seq_history_release(struct inode *inode, struct file *file) | ||
812 | { | ||
813 | struct seq_file *seq = file->private_data; | ||
814 | struct jbd2_stats_proc_session *s = seq->private; | ||
815 | |||
816 | kfree(s->stats); | ||
817 | kfree(s); | ||
818 | return seq_release(inode, file); | ||
819 | } | ||
820 | |||
821 | static struct file_operations jbd2_seq_history_fops = { | ||
822 | .owner = THIS_MODULE, | ||
823 | .open = jbd2_seq_history_open, | ||
824 | .read = seq_read, | ||
825 | .llseek = seq_lseek, | ||
826 | .release = jbd2_seq_history_release, | ||
827 | }; | ||
828 | |||
829 | static void *jbd2_seq_info_start(struct seq_file *seq, loff_t *pos) | 679 | static void *jbd2_seq_info_start(struct seq_file *seq, loff_t *pos) |
830 | { | 680 | { |
831 | return *pos ? NULL : SEQ_START_TOKEN; | 681 | return *pos ? NULL : SEQ_START_TOKEN; |
@@ -842,29 +692,29 @@ static int jbd2_seq_info_show(struct seq_file *seq, void *v) | |||
842 | 692 | ||
843 | if (v != SEQ_START_TOKEN) | 693 | if (v != SEQ_START_TOKEN) |
844 | return 0; | 694 | return 0; |
845 | seq_printf(seq, "%lu transaction, each upto %u blocks\n", | 695 | seq_printf(seq, "%lu transaction, each up to %u blocks\n", |
846 | s->stats->ts_tid, | 696 | s->stats->ts_tid, |
847 | s->journal->j_max_transaction_buffers); | 697 | s->journal->j_max_transaction_buffers); |
848 | if (s->stats->ts_tid == 0) | 698 | if (s->stats->ts_tid == 0) |
849 | return 0; | 699 | return 0; |
850 | seq_printf(seq, "average: \n %ums waiting for transaction\n", | 700 | seq_printf(seq, "average: \n %ums waiting for transaction\n", |
851 | jiffies_to_msecs(s->stats->u.run.rs_wait / s->stats->ts_tid)); | 701 | jiffies_to_msecs(s->stats->run.rs_wait / s->stats->ts_tid)); |
852 | seq_printf(seq, " %ums running transaction\n", | 702 | seq_printf(seq, " %ums running transaction\n", |
853 | jiffies_to_msecs(s->stats->u.run.rs_running / s->stats->ts_tid)); | 703 | jiffies_to_msecs(s->stats->run.rs_running / s->stats->ts_tid)); |
854 | seq_printf(seq, " %ums transaction was being locked\n", | 704 | seq_printf(seq, " %ums transaction was being locked\n", |
855 | jiffies_to_msecs(s->stats->u.run.rs_locked / s->stats->ts_tid)); | 705 | jiffies_to_msecs(s->stats->run.rs_locked / s->stats->ts_tid)); |
856 | seq_printf(seq, " %ums flushing data (in ordered mode)\n", | 706 | seq_printf(seq, " %ums flushing data (in ordered mode)\n", |
857 | jiffies_to_msecs(s->stats->u.run.rs_flushing / s->stats->ts_tid)); | 707 | jiffies_to_msecs(s->stats->run.rs_flushing / s->stats->ts_tid)); |
858 | seq_printf(seq, " %ums logging transaction\n", | 708 | seq_printf(seq, " %ums logging transaction\n", |
859 | jiffies_to_msecs(s->stats->u.run.rs_logging / s->stats->ts_tid)); | 709 | jiffies_to_msecs(s->stats->run.rs_logging / s->stats->ts_tid)); |
860 | seq_printf(seq, " %lluus average transaction commit time\n", | 710 | seq_printf(seq, " %lluus average transaction commit time\n", |
861 | div_u64(s->journal->j_average_commit_time, 1000)); | 711 | div_u64(s->journal->j_average_commit_time, 1000)); |
862 | seq_printf(seq, " %lu handles per transaction\n", | 712 | seq_printf(seq, " %lu handles per transaction\n", |
863 | s->stats->u.run.rs_handle_count / s->stats->ts_tid); | 713 | s->stats->run.rs_handle_count / s->stats->ts_tid); |
864 | seq_printf(seq, " %lu blocks per transaction\n", | 714 | seq_printf(seq, " %lu blocks per transaction\n", |
865 | s->stats->u.run.rs_blocks / s->stats->ts_tid); | 715 | s->stats->run.rs_blocks / s->stats->ts_tid); |
866 | seq_printf(seq, " %lu logged blocks per transaction\n", | 716 | seq_printf(seq, " %lu logged blocks per transaction\n", |
867 | s->stats->u.run.rs_blocks_logged / s->stats->ts_tid); | 717 | s->stats->run.rs_blocks_logged / s->stats->ts_tid); |
868 | return 0; | 718 | return 0; |
869 | } | 719 | } |
870 | 720 | ||
@@ -920,7 +770,7 @@ static int jbd2_seq_info_release(struct inode *inode, struct file *file) | |||
920 | return seq_release(inode, file); | 770 | return seq_release(inode, file); |
921 | } | 771 | } |
922 | 772 | ||
923 | static struct file_operations jbd2_seq_info_fops = { | 773 | static const struct file_operations jbd2_seq_info_fops = { |
924 | .owner = THIS_MODULE, | 774 | .owner = THIS_MODULE, |
925 | .open = jbd2_seq_info_open, | 775 | .open = jbd2_seq_info_open, |
926 | .read = seq_read, | 776 | .read = seq_read, |
@@ -934,8 +784,6 @@ static void jbd2_stats_proc_init(journal_t *journal) | |||
934 | { | 784 | { |
935 | journal->j_proc_entry = proc_mkdir(journal->j_devname, proc_jbd2_stats); | 785 | journal->j_proc_entry = proc_mkdir(journal->j_devname, proc_jbd2_stats); |
936 | if (journal->j_proc_entry) { | 786 | if (journal->j_proc_entry) { |
937 | proc_create_data("history", S_IRUGO, journal->j_proc_entry, | ||
938 | &jbd2_seq_history_fops, journal); | ||
939 | proc_create_data("info", S_IRUGO, journal->j_proc_entry, | 787 | proc_create_data("info", S_IRUGO, journal->j_proc_entry, |
940 | &jbd2_seq_info_fops, journal); | 788 | &jbd2_seq_info_fops, journal); |
941 | } | 789 | } |
@@ -944,27 +792,9 @@ static void jbd2_stats_proc_init(journal_t *journal) | |||
944 | static void jbd2_stats_proc_exit(journal_t *journal) | 792 | static void jbd2_stats_proc_exit(journal_t *journal) |
945 | { | 793 | { |
946 | remove_proc_entry("info", journal->j_proc_entry); | 794 | remove_proc_entry("info", journal->j_proc_entry); |
947 | remove_proc_entry("history", journal->j_proc_entry); | ||
948 | remove_proc_entry(journal->j_devname, proc_jbd2_stats); | 795 | remove_proc_entry(journal->j_devname, proc_jbd2_stats); |
949 | } | 796 | } |
950 | 797 | ||
951 | static void journal_init_stats(journal_t *journal) | ||
952 | { | ||
953 | int size; | ||
954 | |||
955 | if (!proc_jbd2_stats) | ||
956 | return; | ||
957 | |||
958 | journal->j_history_max = 100; | ||
959 | size = sizeof(struct transaction_stats_s) * journal->j_history_max; | ||
960 | journal->j_history = kzalloc(size, GFP_KERNEL); | ||
961 | if (!journal->j_history) { | ||
962 | journal->j_history_max = 0; | ||
963 | return; | ||
964 | } | ||
965 | spin_lock_init(&journal->j_history_lock); | ||
966 | } | ||
967 | |||
968 | /* | 798 | /* |
969 | * Management for journal control blocks: functions to create and | 799 | * Management for journal control blocks: functions to create and |
970 | * destroy journal_t structures, and to initialise and read existing | 800 | * destroy journal_t structures, and to initialise and read existing |
@@ -1009,7 +839,7 @@ static journal_t * journal_init_common (void) | |||
1009 | goto fail; | 839 | goto fail; |
1010 | } | 840 | } |
1011 | 841 | ||
1012 | journal_init_stats(journal); | 842 | spin_lock_init(&journal->j_history_lock); |
1013 | 843 | ||
1014 | return journal; | 844 | return journal; |
1015 | fail: | 845 | fail: |
@@ -1115,7 +945,7 @@ journal_t * jbd2_journal_init_inode (struct inode *inode) | |||
1115 | while ((p = strchr(p, '/'))) | 945 | while ((p = strchr(p, '/'))) |
1116 | *p = '!'; | 946 | *p = '!'; |
1117 | p = journal->j_devname + strlen(journal->j_devname); | 947 | p = journal->j_devname + strlen(journal->j_devname); |
1118 | sprintf(p, ":%lu", journal->j_inode->i_ino); | 948 | sprintf(p, "-%lu", journal->j_inode->i_ino); |
1119 | jbd_debug(1, | 949 | jbd_debug(1, |
1120 | "journal %p: inode %s/%ld, size %Ld, bits %d, blksize %ld\n", | 950 | "journal %p: inode %s/%ld, size %Ld, bits %d, blksize %ld\n", |
1121 | journal, inode->i_sb->s_id, inode->i_ino, | 951 | journal, inode->i_sb->s_id, inode->i_ino, |