Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dlm: Remove seq_printf() return checks and use seq_has_overflowed()

The seq_printf() return is going away soon and users of it should
check seq_has_overflowed() to see if the buffer is full and will
not accept any more data.

Convert functions returning int to void where seq_printf() is used.

Link: http://lkml.kernel.org/p/43590057bcb83846acbbcc1fe641f792b2fb7773.1412031505.git.joe@perches.com
Link: http://lkml.kernel.org/r/20141029220107.939492048@goodmis.org

Acked-by: David Teigland <teigland@redhat.com>
Cc: Christine Caulfield <ccaulfie@redhat.com>
Cc: cluster-devel@redhat.com
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

authored by

Joe Perches and committed by
Steven Rostedt
d6d906b2 e71456ae

+117 -134
+117 -134
fs/dlm/debug_fs.c
··· 48 48 } 49 49 } 50 50 51 - static int print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb, 52 - struct dlm_rsb *res) 51 + static void print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb, 52 + struct dlm_rsb *res) 53 53 { 54 54 seq_printf(s, "%08x %s", lkb->lkb_id, print_lockmode(lkb->lkb_grmode)); 55 55 ··· 68 68 if (lkb->lkb_wait_type) 69 69 seq_printf(s, " wait_type: %d", lkb->lkb_wait_type); 70 70 71 - return seq_puts(s, "\n"); 71 + seq_puts(s, "\n"); 72 72 } 73 73 74 - static int print_format1(struct dlm_rsb *res, struct seq_file *s) 74 + static void print_format1(struct dlm_rsb *res, struct seq_file *s) 75 75 { 76 76 struct dlm_lkb *lkb; 77 77 int i, lvblen = res->res_ls->ls_lvblen, recover_list, root_list; 78 - int rv; 79 78 80 79 lock_rsb(res); 81 80 82 - rv = seq_printf(s, "\nResource %p Name (len=%d) \"", 83 - res, res->res_length); 84 - if (rv) 85 - goto out; 81 + seq_printf(s, "\nResource %p Name (len=%d) \"", res, res->res_length); 86 82 87 83 for (i = 0; i < res->res_length; i++) { 88 84 if (isprint(res->res_name[i])) ··· 88 92 } 89 93 90 94 if (res->res_nodeid > 0) 91 - rv = seq_printf(s, "\"\nLocal Copy, Master is node %d\n", 92 - res->res_nodeid); 95 + seq_printf(s, "\"\nLocal Copy, Master is node %d\n", 96 + res->res_nodeid); 93 97 else if (res->res_nodeid == 0) 94 - rv = seq_puts(s, "\"\nMaster Copy\n"); 98 + seq_puts(s, "\"\nMaster Copy\n"); 95 99 else if (res->res_nodeid == -1) 96 - rv = seq_printf(s, "\"\nLooking up master (lkid %x)\n", 97 - res->res_first_lkid); 100 + seq_printf(s, "\"\nLooking up master (lkid %x)\n", 101 + res->res_first_lkid); 98 102 else 99 - rv = seq_printf(s, "\"\nInvalid master %d\n", 100 - res->res_nodeid); 101 - if (rv) 103 + seq_printf(s, "\"\nInvalid master %d\n", res->res_nodeid); 104 + if (seq_has_overflowed(s)) 102 105 goto out; 103 106 104 107 /* Print the LVB: */ ··· 111 116 } 112 117 if (rsb_flag(res, RSB_VALNOTVALID)) 113 118 seq_puts(s, " (INVALID)"); 114 - rv = seq_puts(s, "\n"); 115 - if (rv) 119 + seq_puts(s, "\n"); 120 + if (seq_has_overflowed(s)) 116 121 goto out; 117 122 } 118 123 ··· 120 125 recover_list = !list_empty(&res->res_recover_list); 121 126 122 127 if (root_list || recover_list) { 123 - rv = seq_printf(s, "Recovery: root %d recover %d flags %lx " 124 - "count %d\n", root_list, recover_list, 125 - res->res_flags, res->res_recover_locks_count); 126 - if (rv) 127 - goto out; 128 + seq_printf(s, "Recovery: root %d recover %d flags %lx count %d\n", 129 + root_list, recover_list, 130 + res->res_flags, res->res_recover_locks_count); 128 131 } 129 132 130 133 /* Print the locks attached to this resource */ 131 134 seq_puts(s, "Granted Queue\n"); 132 135 list_for_each_entry(lkb, &res->res_grantqueue, lkb_statequeue) { 133 - rv = print_format1_lock(s, lkb, res); 134 - if (rv) 136 + print_format1_lock(s, lkb, res); 137 + if (seq_has_overflowed(s)) 135 138 goto out; 136 139 } 137 140 138 141 seq_puts(s, "Conversion Queue\n"); 139 142 list_for_each_entry(lkb, &res->res_convertqueue, lkb_statequeue) { 140 - rv = print_format1_lock(s, lkb, res); 141 - if (rv) 143 + print_format1_lock(s, lkb, res); 144 + if (seq_has_overflowed(s)) 142 145 goto out; 143 146 } 144 147 145 148 seq_puts(s, "Waiting Queue\n"); 146 149 list_for_each_entry(lkb, &res->res_waitqueue, lkb_statequeue) { 147 - rv = print_format1_lock(s, lkb, res); 148 - if (rv) 150 + print_format1_lock(s, lkb, res); 151 + if (seq_has_overflowed(s)) 149 152 goto out; 150 153 } 151 154 ··· 152 159 153 160 seq_puts(s, "Lookup Queue\n"); 154 161 list_for_each_entry(lkb, &res->res_lookup, lkb_rsb_lookup) { 155 - rv = seq_printf(s, "%08x %s", lkb->lkb_id, 156 - print_lockmode(lkb->lkb_rqmode)); 162 + seq_printf(s, "%08x %s", 163 + lkb->lkb_id, print_lockmode(lkb->lkb_rqmode)); 157 164 if (lkb->lkb_wait_type) 158 165 seq_printf(s, " wait_type: %d", lkb->lkb_wait_type); 159 - rv = seq_puts(s, "\n"); 166 + seq_puts(s, "\n"); 167 + if (seq_has_overflowed(s)) 168 + goto out; 160 169 } 161 170 out: 162 171 unlock_rsb(res); 163 - return rv; 164 172 } 165 173 166 - static int print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb, 167 - struct dlm_rsb *r) 174 + static void print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb, 175 + struct dlm_rsb *r) 168 176 { 169 177 u64 xid = 0; 170 178 u64 us; 171 - int rv; 172 179 173 180 if (lkb->lkb_flags & DLM_IFL_USER) { 174 181 if (lkb->lkb_ua) ··· 181 188 /* id nodeid remid pid xid exflags flags sts grmode rqmode time_us 182 189 r_nodeid r_len r_name */ 183 190 184 - rv = seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %llu %u %d \"%s\"\n", 185 - lkb->lkb_id, 186 - lkb->lkb_nodeid, 187 - lkb->lkb_remid, 188 - lkb->lkb_ownpid, 189 - (unsigned long long)xid, 190 - lkb->lkb_exflags, 191 - lkb->lkb_flags, 192 - lkb->lkb_status, 193 - lkb->lkb_grmode, 194 - lkb->lkb_rqmode, 195 - (unsigned long long)us, 196 - r->res_nodeid, 197 - r->res_length, 198 - r->res_name); 199 - return rv; 191 + seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %llu %u %d \"%s\"\n", 192 + lkb->lkb_id, 193 + lkb->lkb_nodeid, 194 + lkb->lkb_remid, 195 + lkb->lkb_ownpid, 196 + (unsigned long long)xid, 197 + lkb->lkb_exflags, 198 + lkb->lkb_flags, 199 + lkb->lkb_status, 200 + lkb->lkb_grmode, 201 + lkb->lkb_rqmode, 202 + (unsigned long long)us, 203 + r->res_nodeid, 204 + r->res_length, 205 + r->res_name); 200 206 } 201 207 202 - static int print_format2(struct dlm_rsb *r, struct seq_file *s) 208 + static void print_format2(struct dlm_rsb *r, struct seq_file *s) 203 209 { 204 210 struct dlm_lkb *lkb; 205 - int rv = 0; 206 211 207 212 lock_rsb(r); 208 213 209 214 list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) { 210 - rv = print_format2_lock(s, lkb, r); 211 - if (rv) 215 + print_format2_lock(s, lkb, r); 216 + if (seq_has_overflowed(s)) 212 217 goto out; 213 218 } 214 219 215 220 list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) { 216 - rv = print_format2_lock(s, lkb, r); 217 - if (rv) 221 + print_format2_lock(s, lkb, r); 222 + if (seq_has_overflowed(s)) 218 223 goto out; 219 224 } 220 225 221 226 list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) { 222 - rv = print_format2_lock(s, lkb, r); 223 - if (rv) 227 + print_format2_lock(s, lkb, r); 228 + if (seq_has_overflowed(s)) 224 229 goto out; 225 230 } 226 231 out: 227 232 unlock_rsb(r); 228 - return rv; 229 233 } 230 234 231 - static int print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb, 235 + static void print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb, 232 236 int rsb_lookup) 233 237 { 234 238 u64 xid = 0; 235 - int rv; 236 239 237 240 if (lkb->lkb_flags & DLM_IFL_USER) { 238 241 if (lkb->lkb_ua) 239 242 xid = lkb->lkb_ua->xid; 240 243 } 241 244 242 - rv = seq_printf(s, "lkb %x %d %x %u %llu %x %x %d %d %d %d %d %d %u %llu %llu\n", 243 - lkb->lkb_id, 244 - lkb->lkb_nodeid, 245 - lkb->lkb_remid, 246 - lkb->lkb_ownpid, 247 - (unsigned long long)xid, 248 - lkb->lkb_exflags, 249 - lkb->lkb_flags, 250 - lkb->lkb_status, 251 - lkb->lkb_grmode, 252 - lkb->lkb_rqmode, 253 - lkb->lkb_last_bast.mode, 254 - rsb_lookup, 255 - lkb->lkb_wait_type, 256 - lkb->lkb_lvbseq, 257 - (unsigned long long)ktime_to_ns(lkb->lkb_timestamp), 258 - (unsigned long long)ktime_to_ns(lkb->lkb_last_bast_time)); 259 - return rv; 245 + seq_printf(s, "lkb %x %d %x %u %llu %x %x %d %d %d %d %d %d %u %llu %llu\n", 246 + lkb->lkb_id, 247 + lkb->lkb_nodeid, 248 + lkb->lkb_remid, 249 + lkb->lkb_ownpid, 250 + (unsigned long long)xid, 251 + lkb->lkb_exflags, 252 + lkb->lkb_flags, 253 + lkb->lkb_status, 254 + lkb->lkb_grmode, 255 + lkb->lkb_rqmode, 256 + lkb->lkb_last_bast.mode, 257 + rsb_lookup, 258 + lkb->lkb_wait_type, 259 + lkb->lkb_lvbseq, 260 + (unsigned long long)ktime_to_ns(lkb->lkb_timestamp), 261 + (unsigned long long)ktime_to_ns(lkb->lkb_last_bast_time)); 260 262 } 261 263 262 - static int print_format3(struct dlm_rsb *r, struct seq_file *s) 264 + static void print_format3(struct dlm_rsb *r, struct seq_file *s) 263 265 { 264 266 struct dlm_lkb *lkb; 265 267 int i, lvblen = r->res_ls->ls_lvblen; 266 268 int print_name = 1; 267 - int rv; 268 269 269 270 lock_rsb(r); 270 271 271 - rv = seq_printf(s, "rsb %p %d %x %lx %d %d %u %d ", 272 - r, 273 - r->res_nodeid, 274 - r->res_first_lkid, 275 - r->res_flags, 276 - !list_empty(&r->res_root_list), 277 - !list_empty(&r->res_recover_list), 278 - r->res_recover_locks_count, 279 - r->res_length); 280 - if (rv) 272 + seq_printf(s, "rsb %p %d %x %lx %d %d %u %d ", 273 + r, 274 + r->res_nodeid, 275 + r->res_first_lkid, 276 + r->res_flags, 277 + !list_empty(&r->res_root_list), 278 + !list_empty(&r->res_recover_list), 279 + r->res_recover_locks_count, 280 + r->res_length); 281 + if (seq_has_overflowed(s)) 281 282 goto out; 282 283 283 284 for (i = 0; i < r->res_length; i++) { ··· 287 300 else 288 301 seq_printf(s, " %02x", (unsigned char)r->res_name[i]); 289 302 } 290 - rv = seq_puts(s, "\n"); 291 - if (rv) 303 + seq_puts(s, "\n"); 304 + if (seq_has_overflowed(s)) 292 305 goto out; 293 306 294 307 if (!r->res_lvbptr) ··· 298 311 299 312 for (i = 0; i < lvblen; i++) 300 313 seq_printf(s, " %02x", (unsigned char)r->res_lvbptr[i]); 301 - rv = seq_puts(s, "\n"); 302 - if (rv) 314 + seq_puts(s, "\n"); 315 + if (seq_has_overflowed(s)) 303 316 goto out; 304 317 305 318 do_locks: 306 319 list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) { 307 - rv = print_format3_lock(s, lkb, 0); 308 - if (rv) 320 + print_format3_lock(s, lkb, 0); 321 + if (seq_has_overflowed(s)) 309 322 goto out; 310 323 } 311 324 312 325 list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) { 313 - rv = print_format3_lock(s, lkb, 0); 314 - if (rv) 326 + print_format3_lock(s, lkb, 0); 327 + if (seq_has_overflowed(s)) 315 328 goto out; 316 329 } 317 330 318 331 list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) { 319 - rv = print_format3_lock(s, lkb, 0); 320 - if (rv) 332 + print_format3_lock(s, lkb, 0); 333 + if (seq_has_overflowed(s)) 321 334 goto out; 322 335 } 323 336 324 337 list_for_each_entry(lkb, &r->res_lookup, lkb_rsb_lookup) { 325 - rv = print_format3_lock(s, lkb, 1); 326 - if (rv) 338 + print_format3_lock(s, lkb, 1); 339 + if (seq_has_overflowed(s)) 327 340 goto out; 328 341 } 329 342 out: 330 343 unlock_rsb(r); 331 - return rv; 332 344 } 333 345 334 - static int print_format4(struct dlm_rsb *r, struct seq_file *s) 346 + static void print_format4(struct dlm_rsb *r, struct seq_file *s) 335 347 { 336 348 int our_nodeid = dlm_our_nodeid(); 337 349 int print_name = 1; 338 - int i, rv; 350 + int i; 339 351 340 352 lock_rsb(r); 341 353 342 - rv = seq_printf(s, "rsb %p %d %d %d %d %lu %lx %d ", 343 - r, 344 - r->res_nodeid, 345 - r->res_master_nodeid, 346 - r->res_dir_nodeid, 347 - our_nodeid, 348 - r->res_toss_time, 349 - r->res_flags, 350 - r->res_length); 351 - if (rv) 352 - goto out; 354 + seq_printf(s, "rsb %p %d %d %d %d %lu %lx %d ", 355 + r, 356 + r->res_nodeid, 357 + r->res_master_nodeid, 358 + r->res_dir_nodeid, 359 + our_nodeid, 360 + r->res_toss_time, 361 + r->res_flags, 362 + r->res_length); 353 363 354 364 for (i = 0; i < r->res_length; i++) { 355 365 if (!isascii(r->res_name[i]) || !isprint(r->res_name[i])) ··· 361 377 else 362 378 seq_printf(s, " %02x", (unsigned char)r->res_name[i]); 363 379 } 364 - rv = seq_puts(s, "\n"); 365 - out: 380 + seq_puts(s, "\n"); 381 + 366 382 unlock_rsb(r); 367 - return rv; 368 383 } 369 384 370 385 struct rsbtbl_iter { ··· 373 390 int header; 374 391 }; 375 392 376 - /* seq_printf returns -1 if the buffer is full, and 0 otherwise. 377 - If the buffer is full, seq_printf can be called again, but it 378 - does nothing and just returns -1. So, the these printing routines 379 - periodically check the return value to avoid wasting too much time 380 - trying to print to a full buffer. */ 393 + /* 394 + * If the buffer is full, seq_printf can be called again, but it 395 + * does nothing. So, the these printing routines periodically check 396 + * seq_has_overflowed to avoid wasting too much time trying to print to 397 + * a full buffer. 398 + */ 381 399 382 400 static int table_seq_show(struct seq_file *seq, void *iter_ptr) 383 401 { 384 402 struct rsbtbl_iter *ri = iter_ptr; 385 - int rv = 0; 386 403 387 404 switch (ri->format) { 388 405 case 1: 389 - rv = print_format1(ri->rsb, seq); 406 + print_format1(ri->rsb, seq); 390 407 break; 391 408 case 2: 392 409 if (ri->header) { ··· 395 412 "r_nodeid r_len r_name\n"); 396 413 ri->header = 0; 397 414 } 398 - rv = print_format2(ri->rsb, seq); 415 + print_format2(ri->rsb, seq); 399 416 break; 400 417 case 3: 401 418 if (ri->header) { 402 419 seq_printf(seq, "version rsb 1.1 lvb 1.1 lkb 1.1\n"); 403 420 ri->header = 0; 404 421 } 405 - rv = print_format3(ri->rsb, seq); 422 + print_format3(ri->rsb, seq); 406 423 break; 407 424 case 4: 408 425 if (ri->header) { 409 426 seq_printf(seq, "version 4 rsb 2\n"); 410 427 ri->header = 0; 411 428 } 412 - rv = print_format4(ri->rsb, seq); 429 + print_format4(ri->rsb, seq); 413 430 break; 414 431 } 415 432 416 - return rv; 433 + return 0; 417 434 } 418 435 419 436 static const struct seq_operations format1_seq_ops;