Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | drbd_proc.c |
| 3 | |
| 4 | This file is part of DRBD by Philipp Reisner and Lars Ellenberg. |
| 5 | |
| 6 | Copyright (C) 2001-2008, LINBIT Information Technologies GmbH. |
| 7 | Copyright (C) 1999-2008, Philipp Reisner <philipp.reisner@linbit.com>. |
| 8 | Copyright (C) 2002-2008, Lars Ellenberg <lars.ellenberg@linbit.com>. |
| 9 | |
| 10 | drbd is free software; you can redistribute it and/or modify |
| 11 | it under the terms of the GNU General Public License as published by |
| 12 | the Free Software Foundation; either version 2, or (at your option) |
| 13 | any later version. |
| 14 | |
| 15 | drbd is distributed in the hope that it will be useful, |
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | GNU General Public License for more details. |
| 19 | |
| 20 | You should have received a copy of the GNU General Public License |
| 21 | along with drbd; see the file COPYING. If not, write to |
| 22 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
| 23 | |
| 24 | */ |
| 25 | |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 26 | #include <linux/module.h> |
| 27 | |
| 28 | #include <asm/uaccess.h> |
| 29 | #include <linux/fs.h> |
| 30 | #include <linux/file.h> |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 31 | #include <linux/proc_fs.h> |
| 32 | #include <linux/seq_file.h> |
| 33 | #include <linux/drbd.h> |
| 34 | #include "drbd_int.h" |
| 35 | |
| 36 | static int drbd_proc_open(struct inode *inode, struct file *file); |
Lars Ellenberg | 3da127f | 2010-11-24 10:33:02 +0100 | [diff] [blame] | 37 | static int drbd_proc_release(struct inode *inode, struct file *file); |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 38 | |
| 39 | |
| 40 | struct proc_dir_entry *drbd_proc; |
Emese Revfy | 7d4e9d0 | 2009-12-14 00:59:30 +0100 | [diff] [blame] | 41 | const struct file_operations drbd_proc_fops = { |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 42 | .owner = THIS_MODULE, |
| 43 | .open = drbd_proc_open, |
| 44 | .read = seq_read, |
| 45 | .llseek = seq_lseek, |
Lars Ellenberg | 3da127f | 2010-11-24 10:33:02 +0100 | [diff] [blame] | 46 | .release = drbd_proc_release, |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 47 | }; |
| 48 | |
Rashika Kheria | fbe0d91 | 2013-12-19 15:04:47 +0530 | [diff] [blame] | 49 | static void seq_printf_with_thousands_grouping(struct seq_file *seq, long v) |
Lars Ellenberg | 439d595 | 2010-11-05 09:52:46 +0100 | [diff] [blame] | 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); |
Lars Ellenberg | fc251d5 | 2011-06-03 21:13:17 +0200 | [diff] [blame] | 55 | v %= 1000000; |
Lars Ellenberg | 439d595 | 2010-11-05 09:52:46 +0100 | [diff] [blame] | 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 | } |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 62 | |
| 63 | /*lge |
| 64 | * progress bars shamelessly adapted from driver/md/md.c |
| 65 | * output looks like |
| 66 | * [=====>..............] 33.5% (23456/123456) |
| 67 | * finish: 2:20:20 speed: 6,345 (6,456) K/sec |
| 68 | */ |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 69 | static void drbd_syncer_progress(struct drbd_device *device, struct seq_file *seq) |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 70 | { |
| 71 | unsigned long db, dt, dbdt, rt, rs_left; |
| 72 | unsigned int res; |
| 73 | int i, x, y; |
Lars Ellenberg | 1d7734a | 2010-08-11 21:21:50 +0200 | [diff] [blame] | 74 | int stalled = 0; |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 75 | |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 76 | drbd_get_syncer_progress(device, &rs_left, &res); |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 77 | |
| 78 | x = res/50; |
| 79 | y = 20-x; |
| 80 | seq_printf(seq, "\t["); |
| 81 | for (i = 1; i < x; i++) |
| 82 | seq_printf(seq, "="); |
| 83 | seq_printf(seq, ">"); |
| 84 | for (i = 0; i < y; i++) |
| 85 | seq_printf(seq, "."); |
| 86 | seq_printf(seq, "] "); |
| 87 | |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 88 | if (device->state.conn == C_VERIFY_S || device->state.conn == C_VERIFY_T) |
Lars Ellenberg | 5f9915b | 2010-11-09 14:15:24 +0100 | [diff] [blame] | 89 | seq_printf(seq, "verified:"); |
| 90 | else |
| 91 | seq_printf(seq, "sync'ed:"); |
| 92 | seq_printf(seq, "%3u.%u%% ", res / 10, res % 10); |
| 93 | |
Lars Ellenberg | 4b0715f | 2010-12-14 15:13:04 +0100 | [diff] [blame] | 94 | /* if more than a few GB, display in MB */ |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 95 | if (device->rs_total > (4UL << (30 - BM_BLOCK_SHIFT))) |
Lars Ellenberg | 4b0715f | 2010-12-14 15:13:04 +0100 | [diff] [blame] | 96 | seq_printf(seq, "(%lu/%lu)M", |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 97 | (unsigned long) Bit2KB(rs_left >> 10), |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 98 | (unsigned long) Bit2KB(device->rs_total >> 10)); |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 99 | else |
Lars Ellenberg | e7f52df | 2010-08-03 20:20:20 +0200 | [diff] [blame] | 100 | seq_printf(seq, "(%lu/%lu)K\n\t", |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 101 | (unsigned long) Bit2KB(rs_left), |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 102 | (unsigned long) Bit2KB(device->rs_total)); |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 103 | |
| 104 | /* see drivers/md/md.c |
| 105 | * We do not want to overflow, so the order of operands and |
| 106 | * the * 100 / 100 trick are important. We do a +1 to be |
| 107 | * safe against division by zero. We only estimate anyway. |
| 108 | * |
| 109 | * dt: time from mark until now |
| 110 | * db: blocks written from mark until now |
| 111 | * rt: remaining time |
| 112 | */ |
Lars Ellenberg | 1d7734a | 2010-08-11 21:21:50 +0200 | [diff] [blame] | 113 | /* Rolling marks. last_mark+1 may just now be modified. last_mark+2 is |
| 114 | * at least (DRBD_SYNC_MARKS-2)*DRBD_SYNC_MARK_STEP old, and has at |
| 115 | * least DRBD_SYNC_MARK_STEP time before it will be modified. */ |
Lars Ellenberg | 439d595 | 2010-11-05 09:52:46 +0100 | [diff] [blame] | 116 | /* ------------------------ ~18s average ------------------------ */ |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 117 | i = (device->rs_last_mark + 2) % DRBD_SYNC_MARKS; |
| 118 | dt = (jiffies - device->rs_mark_time[i]) / HZ; |
Lars Ellenberg | 9ae4726 | 2014-04-28 18:43:16 +0200 | [diff] [blame] | 119 | if (dt > 180) |
Lars Ellenberg | 1d7734a | 2010-08-11 21:21:50 +0200 | [diff] [blame] | 120 | stalled = 1; |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 121 | |
| 122 | if (!dt) |
| 123 | dt++; |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 124 | db = device->rs_mark_left[i] - rs_left; |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 125 | rt = (dt * (rs_left / (db/100+1)))/100; /* seconds */ |
| 126 | |
| 127 | seq_printf(seq, "finish: %lu:%02lu:%02lu", |
| 128 | rt / 3600, (rt % 3600) / 60, rt % 60); |
| 129 | |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 130 | dbdt = Bit2KB(db/dt); |
Lars Ellenberg | 439d595 | 2010-11-05 09:52:46 +0100 | [diff] [blame] | 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 */ |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 137 | i = (device->rs_last_mark + DRBD_SYNC_MARKS-1) % DRBD_SYNC_MARKS; |
| 138 | dt = (jiffies - device->rs_mark_time[i]) / HZ; |
Lars Ellenberg | 439d595 | 2010-11-05 09:52:46 +0100 | [diff] [blame] | 139 | if (!dt) |
| 140 | dt++; |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 141 | db = device->rs_mark_left[i] - rs_left; |
Lars Ellenberg | 439d595 | 2010-11-05 09:52:46 +0100 | [diff] [blame] | 142 | dbdt = Bit2KB(db/dt); |
| 143 | seq_printf_with_thousands_grouping(seq, dbdt); |
| 144 | seq_printf(seq, " -- "); |
| 145 | } |
| 146 | |
| 147 | /* --------------------- long term average ---------------------- */ |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 148 | /* mean speed since syncer started |
| 149 | * we do account for PausedSync periods */ |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 150 | dt = (jiffies - device->rs_start - device->rs_paused) / HZ; |
Dan Carpenter | 2265769 | 2010-08-12 00:38:45 +0200 | [diff] [blame] | 151 | if (dt == 0) |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 152 | dt = 1; |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 153 | db = device->rs_total - rs_left; |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 154 | dbdt = Bit2KB(db/dt); |
Lars Ellenberg | 439d595 | 2010-11-05 09:52:46 +0100 | [diff] [blame] | 155 | seq_printf_with_thousands_grouping(seq, dbdt); |
| 156 | seq_printf(seq, ")"); |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 157 | |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 158 | if (device->state.conn == C_SYNC_TARGET || |
| 159 | device->state.conn == C_VERIFY_S) { |
Lars Ellenberg | 5f9915b | 2010-11-09 14:15:24 +0100 | [diff] [blame] | 160 | seq_printf(seq, " want: "); |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 161 | seq_printf_with_thousands_grouping(seq, device->c_sync_rate); |
Lars Ellenberg | 1d7734a | 2010-08-11 21:21:50 +0200 | [diff] [blame] | 162 | } |
| 163 | seq_printf(seq, " K/sec%s\n", stalled ? " (stalled)" : ""); |
Lars Ellenberg | 5f9915b | 2010-11-09 14:15:24 +0100 | [diff] [blame] | 164 | |
| 165 | if (proc_details >= 1) { |
| 166 | /* 64 bit: |
| 167 | * we convert to sectors in the display below. */ |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 168 | unsigned long bm_bits = drbd_bm_bits(device); |
Lars Ellenberg | 4896e8c | 2010-11-11 22:41:04 +0100 | [diff] [blame] | 169 | unsigned long bit_pos; |
Lars Ellenberg | 58ffa58 | 2012-07-26 14:09:49 +0200 | [diff] [blame] | 170 | unsigned long long stop_sector = 0; |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 171 | if (device->state.conn == C_VERIFY_S || |
| 172 | device->state.conn == C_VERIFY_T) { |
| 173 | bit_pos = bm_bits - device->ov_left; |
| 174 | if (verify_can_do_stop_sector(device)) |
| 175 | stop_sector = device->ov_stop_sector; |
Lars Ellenberg | 58ffa58 | 2012-07-26 14:09:49 +0200 | [diff] [blame] | 176 | } else |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 177 | bit_pos = device->bm_resync_fo; |
Lars Ellenberg | 5f9915b | 2010-11-09 14:15:24 +0100 | [diff] [blame] | 178 | /* Total sectors may be slightly off for oddly |
| 179 | * sized devices. So what. */ |
| 180 | seq_printf(seq, |
Lars Ellenberg | 58ffa58 | 2012-07-26 14:09:49 +0200 | [diff] [blame] | 181 | "\t%3d%% sector pos: %llu/%llu", |
Lars Ellenberg | 5f9915b | 2010-11-09 14:15:24 +0100 | [diff] [blame] | 182 | (int)(bit_pos / (bm_bits/100+1)), |
Lars Ellenberg | 4896e8c | 2010-11-11 22:41:04 +0100 | [diff] [blame] | 183 | (unsigned long long)bit_pos * BM_SECT_PER_BIT, |
| 184 | (unsigned long long)bm_bits * BM_SECT_PER_BIT); |
Lars Ellenberg | 58ffa58 | 2012-07-26 14:09:49 +0200 | [diff] [blame] | 185 | if (stop_sector != 0 && stop_sector != ULLONG_MAX) |
| 186 | seq_printf(seq, " stop sector: %llu", stop_sector); |
| 187 | seq_printf(seq, "\n"); |
Lars Ellenberg | 5f9915b | 2010-11-09 14:15:24 +0100 | [diff] [blame] | 188 | } |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 189 | } |
| 190 | |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 191 | static int drbd_seq_show(struct seq_file *seq, void *v) |
| 192 | { |
Philipp Reisner | 81a5d60 | 2011-02-22 19:53:16 -0500 | [diff] [blame] | 193 | int i, prev_i = -1; |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 194 | const char *sn; |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 195 | struct drbd_device *device; |
Philipp Reisner | 44ed167 | 2011-04-19 17:10:19 +0200 | [diff] [blame] | 196 | struct net_conf *nc; |
| 197 | char wp; |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 198 | |
| 199 | static char write_ordering_chars[] = { |
| 200 | [WO_none] = 'n', |
| 201 | [WO_drain_io] = 'd', |
| 202 | [WO_bdev_flush] = 'f', |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 203 | }; |
| 204 | |
| 205 | seq_printf(seq, "version: " REL_VERSION " (api:%d/proto:%d-%d)\n%s\n", |
| 206 | API_VERSION, PRO_VERSION_MIN, PRO_VERSION_MAX, drbd_buildtag()); |
| 207 | |
| 208 | /* |
| 209 | cs .. connection state |
| 210 | ro .. node role (local/remote) |
| 211 | ds .. disk state (local/remote) |
| 212 | protocol |
| 213 | various flags |
| 214 | ns .. network send |
| 215 | nr .. network receive |
| 216 | dw .. disk write |
| 217 | dr .. disk read |
| 218 | al .. activity log write count |
| 219 | bm .. bitmap update write count |
| 220 | pe .. pending (waiting for ack or data reply) |
| 221 | ua .. unack'd (still need to send ack or data reply) |
| 222 | ap .. application requests accepted, but not yet completed |
| 223 | ep .. number of epochs currently "on the fly", P_BARRIER_ACK pending |
| 224 | wo .. write ordering mode currently in use |
| 225 | oos .. known out-of-sync kB |
| 226 | */ |
| 227 | |
Philipp Reisner | c141ebd | 2011-05-05 16:13:10 +0200 | [diff] [blame] | 228 | rcu_read_lock(); |
Andreas Gruenbacher | 05a10ec | 2011-06-07 22:54:17 +0200 | [diff] [blame] | 229 | idr_for_each_entry(&drbd_devices, device, i) { |
Philipp Reisner | 81a5d60 | 2011-02-22 19:53:16 -0500 | [diff] [blame] | 230 | if (prev_i != i - 1) |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 231 | seq_printf(seq, "\n"); |
Philipp Reisner | 81a5d60 | 2011-02-22 19:53:16 -0500 | [diff] [blame] | 232 | prev_i = i; |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 233 | |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 234 | sn = drbd_conn_str(device->state.conn); |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 235 | |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 236 | if (device->state.conn == C_STANDALONE && |
| 237 | device->state.disk == D_DISKLESS && |
| 238 | device->state.role == R_SECONDARY) { |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 239 | seq_printf(seq, "%2d: cs:Unconfigured\n", i); |
| 240 | } else { |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 241 | /* reset device->congestion_reason */ |
| 242 | bdi_rw_congested(&device->rq_queue->backing_dev_info); |
Lars Ellenberg | 8a94317 | 2012-07-30 09:09:36 +0200 | [diff] [blame] | 243 | |
Andreas Gruenbacher | a6b32bc | 2011-05-31 14:33:49 +0200 | [diff] [blame] | 244 | nc = rcu_dereference(first_peer_device(device)->connection->net_conf); |
Philipp Reisner | 44ed167 | 2011-04-19 17:10:19 +0200 | [diff] [blame] | 245 | wp = nc ? nc->wire_protocol - DRBD_PROT_A + 'A' : ' '; |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 246 | seq_printf(seq, |
Philipp Reisner | 0778286 | 2010-08-31 12:00:50 +0200 | [diff] [blame] | 247 | "%2d: cs:%s ro:%s/%s ds:%s/%s %c %c%c%c%c%c%c\n" |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 248 | " ns:%u nr:%u dw:%u dr:%u al:%u bm:%u " |
| 249 | "lo:%d pe:%d ua:%d ap:%d ep:%d wo:%c", |
| 250 | i, sn, |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 251 | drbd_role_str(device->state.role), |
| 252 | drbd_role_str(device->state.peer), |
| 253 | drbd_disk_str(device->state.disk), |
| 254 | drbd_disk_str(device->state.pdsk), |
Philipp Reisner | 44ed167 | 2011-04-19 17:10:19 +0200 | [diff] [blame] | 255 | wp, |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 256 | drbd_suspended(device) ? 's' : 'r', |
| 257 | device->state.aftr_isp ? 'a' : '-', |
| 258 | device->state.peer_isp ? 'p' : '-', |
| 259 | device->state.user_isp ? 'u' : '-', |
| 260 | device->congestion_reason ?: '-', |
| 261 | test_bit(AL_SUSPENDED, &device->flags) ? 's' : '-', |
| 262 | device->send_cnt/2, |
| 263 | device->recv_cnt/2, |
| 264 | device->writ_cnt/2, |
| 265 | device->read_cnt/2, |
| 266 | device->al_writ_cnt, |
| 267 | device->bm_writ_cnt, |
| 268 | atomic_read(&device->local_cnt), |
| 269 | atomic_read(&device->ap_pending_cnt) + |
| 270 | atomic_read(&device->rs_pending_cnt), |
| 271 | atomic_read(&device->unacked_cnt), |
| 272 | atomic_read(&device->ap_bio_cnt), |
Andreas Gruenbacher | a6b32bc | 2011-05-31 14:33:49 +0200 | [diff] [blame] | 273 | first_peer_device(device)->connection->epochs, |
Philipp Reisner | e952658 | 2013-11-22 15:53:41 +0100 | [diff] [blame] | 274 | write_ordering_chars[device->resource->write_ordering] |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 275 | ); |
Lars Ellenberg | 18edc0b | 2010-11-09 14:12:10 +0100 | [diff] [blame] | 276 | seq_printf(seq, " oos:%llu\n", |
| 277 | Bit2KB((unsigned long long) |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 278 | drbd_bm_total_weight(device))); |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 279 | } |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 280 | if (device->state.conn == C_SYNC_SOURCE || |
| 281 | device->state.conn == C_SYNC_TARGET || |
| 282 | device->state.conn == C_VERIFY_S || |
| 283 | device->state.conn == C_VERIFY_T) |
| 284 | drbd_syncer_progress(device, seq); |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 285 | |
Andreas Gruenbacher | b30ab79 | 2011-07-03 13:26:43 +0200 | [diff] [blame] | 286 | if (proc_details >= 1 && get_ldev_if_state(device, D_FAILED)) { |
| 287 | lc_seq_printf_stats(seq, device->resync); |
| 288 | lc_seq_printf_stats(seq, device->act_log); |
| 289 | put_ldev(device); |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 290 | } |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 291 | } |
Philipp Reisner | c141ebd | 2011-05-05 16:13:10 +0200 | [diff] [blame] | 292 | rcu_read_unlock(); |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 293 | |
| 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | static int drbd_proc_open(struct inode *inode, struct file *file) |
| 298 | { |
Alexey Khoroshilov | 193d015 | 2013-03-27 14:08:46 +0100 | [diff] [blame] | 299 | int err; |
| 300 | |
| 301 | if (try_module_get(THIS_MODULE)) { |
Andreas Gruenbacher | caa3db0 | 2014-02-27 20:49:54 +0100 | [diff] [blame^] | 302 | err = single_open(file, drbd_seq_show, NULL); |
Alexey Khoroshilov | 193d015 | 2013-03-27 14:08:46 +0100 | [diff] [blame] | 303 | if (err) |
| 304 | module_put(THIS_MODULE); |
| 305 | return err; |
| 306 | } |
Lars Ellenberg | 3da127f | 2010-11-24 10:33:02 +0100 | [diff] [blame] | 307 | return -ENODEV; |
| 308 | } |
| 309 | |
| 310 | static int drbd_proc_release(struct inode *inode, struct file *file) |
| 311 | { |
| 312 | module_put(THIS_MODULE); |
| 313 | return single_release(inode, file); |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | /* PROC FS stuff end */ |