~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/block/drbd/drbd_proc.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include "drbd_int.h"
35
35
 
36
36
static int drbd_proc_open(struct inode *inode, struct file *file);
 
37
static int drbd_proc_release(struct inode *inode, struct file *file);
37
38
 
38
39
 
39
40
struct proc_dir_entry *drbd_proc;
42
43
        .open           = drbd_proc_open,
43
44
        .read           = seq_read,
44
45
        .llseek         = seq_lseek,
45
 
        .release        = single_release,
 
46
        .release        = drbd_proc_release,
46
47
};
47
48
 
 
49
void seq_printf_with_thousands_grouping(struct seq_file *seq, long v)
 
50
{
 
51
        /* v is in kB/sec. We don't expect TiByte/sec yet. */
 
52
        if (unlikely(v >= 1000000)) {
 
53
                /* cool: > GiByte/s */
 
54
                seq_printf(seq, "%ld,", v / 1000000);
 
55
                v /= 1000000;
 
56
                seq_printf(seq, "%03ld,%03ld", v/1000, v % 1000);
 
57
        } else if (likely(v >= 1000))
 
58
                seq_printf(seq, "%ld,%03ld", v/1000, v % 1000);
 
59
        else
 
60
                seq_printf(seq, "%ld", v);
 
61
}
48
62
 
49
63
/*lge
50
64
 * progress bars shamelessly adapted from driver/md/md.c
71
85
                seq_printf(seq, ".");
72
86
        seq_printf(seq, "] ");
73
87
 
74
 
        seq_printf(seq, "sync'ed:%3u.%u%% ", res / 10, res % 10);
75
 
        /* if more than 1 GB display in MB */
76
 
        if (mdev->rs_total > 0x100000L)
77
 
                seq_printf(seq, "(%lu/%lu)M\n\t",
 
88
        if (mdev->state.conn == C_VERIFY_S || mdev->state.conn == C_VERIFY_T)
 
89
                seq_printf(seq, "verified:");
 
90
        else
 
91
                seq_printf(seq, "sync'ed:");
 
92
        seq_printf(seq, "%3u.%u%% ", res / 10, res % 10);
 
93
 
 
94
        /* if more than a few GB, display in MB */
 
95
        if (mdev->rs_total > (4UL << (30 - BM_BLOCK_SHIFT)))
 
96
                seq_printf(seq, "(%lu/%lu)M",
78
97
                            (unsigned long) Bit2KB(rs_left >> 10),
79
98
                            (unsigned long) Bit2KB(mdev->rs_total >> 10));
80
99
        else
94
113
        /* Rolling marks. last_mark+1 may just now be modified.  last_mark+2 is
95
114
         * at least (DRBD_SYNC_MARKS-2)*DRBD_SYNC_MARK_STEP old, and has at
96
115
         * least DRBD_SYNC_MARK_STEP time before it will be modified. */
 
116
        /* ------------------------ ~18s average ------------------------ */
97
117
        i = (mdev->rs_last_mark + 2) % DRBD_SYNC_MARKS;
98
118
        dt = (jiffies - mdev->rs_mark_time[i]) / HZ;
99
119
        if (dt > (DRBD_SYNC_MARK_STEP * DRBD_SYNC_MARKS))
107
127
        seq_printf(seq, "finish: %lu:%02lu:%02lu",
108
128
                rt / 3600, (rt % 3600) / 60, rt % 60);
109
129
 
110
 
        /* current speed average over (SYNC_MARKS * SYNC_MARK_STEP) jiffies */
111
130
        dbdt = Bit2KB(db/dt);
112
 
        if (dbdt > 1000)
113
 
                seq_printf(seq, " speed: %ld,%03ld",
114
 
                        dbdt/1000, dbdt % 1000);
115
 
        else
116
 
                seq_printf(seq, " speed: %ld", dbdt);
 
131
        seq_printf(seq, " speed: ");
 
132
        seq_printf_with_thousands_grouping(seq, dbdt);
 
133
        seq_printf(seq, " (");
 
134
        /* ------------------------- ~3s average ------------------------ */
 
135
        if (proc_details >= 1) {
 
136
                /* this is what drbd_rs_should_slow_down() uses */
 
137
                i = (mdev->rs_last_mark + DRBD_SYNC_MARKS-1) % DRBD_SYNC_MARKS;
 
138
                dt = (jiffies - mdev->rs_mark_time[i]) / HZ;
 
139
                if (!dt)
 
140
                        dt++;
 
141
                db = mdev->rs_mark_left[i] - rs_left;
 
142
                dbdt = Bit2KB(db/dt);
 
143
                seq_printf_with_thousands_grouping(seq, dbdt);
 
144
                seq_printf(seq, " -- ");
 
145
        }
117
146
 
 
147
        /* --------------------- long term average ---------------------- */
118
148
        /* mean speed since syncer started
119
149
         * we do account for PausedSync periods */
120
150
        dt = (jiffies - mdev->rs_start - mdev->rs_paused) / HZ;
122
152
                dt = 1;
123
153
        db = mdev->rs_total - rs_left;
124
154
        dbdt = Bit2KB(db/dt);
125
 
        if (dbdt > 1000)
126
 
                seq_printf(seq, " (%ld,%03ld)",
127
 
                        dbdt/1000, dbdt % 1000);
128
 
        else
129
 
                seq_printf(seq, " (%ld)", dbdt);
130
 
 
131
 
        if (mdev->state.conn == C_SYNC_TARGET) {
132
 
                if (mdev->c_sync_rate > 1000)
133
 
                        seq_printf(seq, " want: %d,%03d",
134
 
                                   mdev->c_sync_rate / 1000, mdev->c_sync_rate % 1000);
 
155
        seq_printf_with_thousands_grouping(seq, dbdt);
 
156
        seq_printf(seq, ")");
 
157
 
 
158
        if (mdev->state.conn == C_SYNC_TARGET ||
 
159
            mdev->state.conn == C_VERIFY_S) {
 
160
                seq_printf(seq, " want: ");
 
161
                seq_printf_with_thousands_grouping(seq, mdev->c_sync_rate);
 
162
        }
 
163
        seq_printf(seq, " K/sec%s\n", stalled ? " (stalled)" : "");
 
164
 
 
165
        if (proc_details >= 1) {
 
166
                /* 64 bit:
 
167
                 * we convert to sectors in the display below. */
 
168
                unsigned long bm_bits = drbd_bm_bits(mdev);
 
169
                unsigned long bit_pos;
 
170
                if (mdev->state.conn == C_VERIFY_S ||
 
171
                    mdev->state.conn == C_VERIFY_T)
 
172
                        bit_pos = bm_bits - mdev->ov_left;
135
173
                else
136
 
                        seq_printf(seq, " want: %d", mdev->c_sync_rate);
 
174
                        bit_pos = mdev->bm_resync_fo;
 
175
                /* Total sectors may be slightly off for oddly
 
176
                 * sized devices. So what. */
 
177
                seq_printf(seq,
 
178
                        "\t%3d%% sector pos: %llu/%llu\n",
 
179
                        (int)(bit_pos / (bm_bits/100+1)),
 
180
                        (unsigned long long)bit_pos * BM_SECT_PER_BIT,
 
181
                        (unsigned long long)bm_bits * BM_SECT_PER_BIT);
137
182
        }
138
 
        seq_printf(seq, " K/sec%s\n", stalled ? " (stalled)" : "");
139
183
}
140
184
 
141
185
static void resync_dump_detail(struct seq_file *seq, struct lc_element *e)
232
276
                           mdev->epochs,
233
277
                           write_ordering_chars[mdev->write_ordering]
234
278
                        );
235
 
                        seq_printf(seq, " oos:%lu\n",
236
 
                                   Bit2KB(drbd_bm_total_weight(mdev)));
 
279
                        seq_printf(seq, " oos:%llu\n",
 
280
                                   Bit2KB((unsigned long long)
 
281
                                           drbd_bm_total_weight(mdev)));
237
282
                }
238
283
                if (mdev->state.conn == C_SYNC_SOURCE ||
239
 
                    mdev->state.conn == C_SYNC_TARGET)
 
284
                    mdev->state.conn == C_SYNC_TARGET ||
 
285
                    mdev->state.conn == C_VERIFY_S ||
 
286
                    mdev->state.conn == C_VERIFY_T)
240
287
                        drbd_syncer_progress(mdev, seq);
241
288
 
242
 
                if (mdev->state.conn == C_VERIFY_S || mdev->state.conn == C_VERIFY_T)
243
 
                        seq_printf(seq, "\t%3d%%      %lu/%lu\n",
244
 
                                   (int)((mdev->rs_total-mdev->ov_left) /
245
 
                                         (mdev->rs_total/100+1)),
246
 
                                   mdev->rs_total - mdev->ov_left,
247
 
                                   mdev->rs_total);
248
 
 
249
289
                if (proc_details >= 1 && get_ldev_if_state(mdev, D_FAILED)) {
250
290
                        lc_seq_printf_stats(seq, mdev->resync);
251
291
                        lc_seq_printf_stats(seq, mdev->act_log);
265
305
 
266
306
static int drbd_proc_open(struct inode *inode, struct file *file)
267
307
{
268
 
        return single_open(file, drbd_seq_show, PDE(inode)->data);
 
308
        if (try_module_get(THIS_MODULE))
 
309
                return single_open(file, drbd_seq_show, PDE(inode)->data);
 
310
        return -ENODEV;
 
311
}
 
312
 
 
313
static int drbd_proc_release(struct inode *inode, struct file *file)
 
314
{
 
315
        module_put(THIS_MODULE);
 
316
        return single_release(inode, file);
269
317
}
270
318
 
271
319
/* PROC FS stuff end */