diff options
author | James Bottomley <James.Bottomley@HansenPartnership.com> | 2009-06-12 11:02:03 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2009-06-12 11:02:03 -0400 |
commit | 82681a318f9f028ea64e61f24bbd9ac535531921 (patch) | |
tree | 529b6a5b4fd040fb54b7672b1a224ebd47445876 /fs/gfs2/sys.c | |
parent | 3860c97bd60a4525bb62eb90e3e7d2f02662ac59 (diff) | |
parent | 8ebf975608aaebd7feb33d77f07ba21a6380e086 (diff) |
[SCSI] Merge branch 'linus'
Conflicts:
drivers/message/fusion/mptsas.c
fixed up conflict between req->data_len accessors and mptsas driver updates.
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'fs/gfs2/sys.c')
-rw-r--r-- | fs/gfs2/sys.c | 245 |
1 files changed, 66 insertions, 179 deletions
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index 7655f5025fec..23419dc3027b 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c | |||
@@ -26,6 +26,36 @@ | |||
26 | #include "util.h" | 26 | #include "util.h" |
27 | #include "glops.h" | 27 | #include "glops.h" |
28 | 28 | ||
29 | struct gfs2_attr { | ||
30 | struct attribute attr; | ||
31 | ssize_t (*show)(struct gfs2_sbd *, char *); | ||
32 | ssize_t (*store)(struct gfs2_sbd *, const char *, size_t); | ||
33 | }; | ||
34 | |||
35 | static ssize_t gfs2_attr_show(struct kobject *kobj, struct attribute *attr, | ||
36 | char *buf) | ||
37 | { | ||
38 | struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj); | ||
39 | struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr); | ||
40 | return a->show ? a->show(sdp, buf) : 0; | ||
41 | } | ||
42 | |||
43 | static ssize_t gfs2_attr_store(struct kobject *kobj, struct attribute *attr, | ||
44 | const char *buf, size_t len) | ||
45 | { | ||
46 | struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj); | ||
47 | struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr); | ||
48 | return a->store ? a->store(sdp, buf, len) : len; | ||
49 | } | ||
50 | |||
51 | static struct sysfs_ops gfs2_attr_ops = { | ||
52 | .show = gfs2_attr_show, | ||
53 | .store = gfs2_attr_store, | ||
54 | }; | ||
55 | |||
56 | |||
57 | static struct kset *gfs2_kset; | ||
58 | |||
29 | static ssize_t id_show(struct gfs2_sbd *sdp, char *buf) | 59 | static ssize_t id_show(struct gfs2_sbd *sdp, char *buf) |
30 | { | 60 | { |
31 | return snprintf(buf, PAGE_SIZE, "%u:%u\n", | 61 | return snprintf(buf, PAGE_SIZE, "%u:%u\n", |
@@ -212,11 +242,6 @@ static ssize_t demote_rq_store(struct gfs2_sbd *sdp, const char *buf, size_t len | |||
212 | return len; | 242 | return len; |
213 | } | 243 | } |
214 | 244 | ||
215 | struct gfs2_attr { | ||
216 | struct attribute attr; | ||
217 | ssize_t (*show)(struct gfs2_sbd *, char *); | ||
218 | ssize_t (*store)(struct gfs2_sbd *, const char *, size_t); | ||
219 | }; | ||
220 | 245 | ||
221 | #define GFS2_ATTR(name, mode, show, store) \ | 246 | #define GFS2_ATTR(name, mode, show, store) \ |
222 | static struct gfs2_attr gfs2_attr_##name = __ATTR(name, mode, show, store) | 247 | static struct gfs2_attr gfs2_attr_##name = __ATTR(name, mode, show, store) |
@@ -246,58 +271,11 @@ static struct attribute *gfs2_attrs[] = { | |||
246 | NULL, | 271 | NULL, |
247 | }; | 272 | }; |
248 | 273 | ||
249 | static ssize_t gfs2_attr_show(struct kobject *kobj, struct attribute *attr, | ||
250 | char *buf) | ||
251 | { | ||
252 | struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj); | ||
253 | struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr); | ||
254 | return a->show ? a->show(sdp, buf) : 0; | ||
255 | } | ||
256 | |||
257 | static ssize_t gfs2_attr_store(struct kobject *kobj, struct attribute *attr, | ||
258 | const char *buf, size_t len) | ||
259 | { | ||
260 | struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj); | ||
261 | struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr); | ||
262 | return a->store ? a->store(sdp, buf, len) : len; | ||
263 | } | ||
264 | |||
265 | static struct sysfs_ops gfs2_attr_ops = { | ||
266 | .show = gfs2_attr_show, | ||
267 | .store = gfs2_attr_store, | ||
268 | }; | ||
269 | |||
270 | static struct kobj_type gfs2_ktype = { | 274 | static struct kobj_type gfs2_ktype = { |
271 | .default_attrs = gfs2_attrs, | 275 | .default_attrs = gfs2_attrs, |
272 | .sysfs_ops = &gfs2_attr_ops, | 276 | .sysfs_ops = &gfs2_attr_ops, |
273 | }; | 277 | }; |
274 | 278 | ||
275 | static struct kset *gfs2_kset; | ||
276 | |||
277 | /* | ||
278 | * display struct lm_lockstruct fields | ||
279 | */ | ||
280 | |||
281 | struct lockstruct_attr { | ||
282 | struct attribute attr; | ||
283 | ssize_t (*show)(struct gfs2_sbd *, char *); | ||
284 | }; | ||
285 | |||
286 | #define LOCKSTRUCT_ATTR(name, fmt) \ | ||
287 | static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \ | ||
288 | { \ | ||
289 | return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_lockstruct.ls_##name); \ | ||
290 | } \ | ||
291 | static struct lockstruct_attr lockstruct_attr_##name = __ATTR_RO(name) | ||
292 | |||
293 | LOCKSTRUCT_ATTR(jid, "%u\n"); | ||
294 | LOCKSTRUCT_ATTR(first, "%u\n"); | ||
295 | |||
296 | static struct attribute *lockstruct_attrs[] = { | ||
297 | &lockstruct_attr_jid.attr, | ||
298 | &lockstruct_attr_first.attr, | ||
299 | NULL, | ||
300 | }; | ||
301 | 279 | ||
302 | /* | 280 | /* |
303 | * lock_module. Originally from lock_dlm | 281 | * lock_module. Originally from lock_dlm |
@@ -359,34 +337,33 @@ static ssize_t first_done_show(struct gfs2_sbd *sdp, char *buf) | |||
359 | return sprintf(buf, "%d\n", ls->ls_first_done); | 337 | return sprintf(buf, "%d\n", ls->ls_first_done); |
360 | } | 338 | } |
361 | 339 | ||
362 | static ssize_t recover_show(struct gfs2_sbd *sdp, char *buf) | 340 | static ssize_t recover_store(struct gfs2_sbd *sdp, const char *buf, size_t len) |
363 | { | ||
364 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; | ||
365 | return sprintf(buf, "%d\n", ls->ls_recover_jid); | ||
366 | } | ||
367 | |||
368 | static void gfs2_jdesc_make_dirty(struct gfs2_sbd *sdp, unsigned int jid) | ||
369 | { | 341 | { |
342 | unsigned jid; | ||
370 | struct gfs2_jdesc *jd; | 343 | struct gfs2_jdesc *jd; |
344 | int rv; | ||
345 | |||
346 | rv = sscanf(buf, "%u", &jid); | ||
347 | if (rv != 1) | ||
348 | return -EINVAL; | ||
371 | 349 | ||
350 | rv = -ESHUTDOWN; | ||
372 | spin_lock(&sdp->sd_jindex_spin); | 351 | spin_lock(&sdp->sd_jindex_spin); |
352 | if (test_bit(SDF_NORECOVERY, &sdp->sd_flags)) | ||
353 | goto out; | ||
354 | rv = -EBUSY; | ||
355 | if (sdp->sd_jdesc->jd_jid == jid) | ||
356 | goto out; | ||
357 | rv = -ENOENT; | ||
373 | list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) { | 358 | list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) { |
374 | if (jd->jd_jid != jid) | 359 | if (jd->jd_jid != jid) |
375 | continue; | 360 | continue; |
376 | jd->jd_dirty = 1; | 361 | rv = slow_work_enqueue(&jd->jd_work); |
377 | break; | 362 | break; |
378 | } | 363 | } |
364 | out: | ||
379 | spin_unlock(&sdp->sd_jindex_spin); | 365 | spin_unlock(&sdp->sd_jindex_spin); |
380 | } | 366 | return rv ? rv : len; |
381 | |||
382 | static ssize_t recover_store(struct gfs2_sbd *sdp, const char *buf, size_t len) | ||
383 | { | ||
384 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; | ||
385 | ls->ls_recover_jid = simple_strtol(buf, NULL, 0); | ||
386 | gfs2_jdesc_make_dirty(sdp, ls->ls_recover_jid); | ||
387 | if (sdp->sd_recoverd_process) | ||
388 | wake_up_process(sdp->sd_recoverd_process); | ||
389 | return len; | ||
390 | } | 367 | } |
391 | 368 | ||
392 | static ssize_t recover_done_show(struct gfs2_sbd *sdp, char *buf) | 369 | static ssize_t recover_done_show(struct gfs2_sbd *sdp, char *buf) |
@@ -401,31 +378,31 @@ static ssize_t recover_status_show(struct gfs2_sbd *sdp, char *buf) | |||
401 | return sprintf(buf, "%d\n", ls->ls_recover_jid_status); | 378 | return sprintf(buf, "%d\n", ls->ls_recover_jid_status); |
402 | } | 379 | } |
403 | 380 | ||
404 | struct gdlm_attr { | 381 | static ssize_t jid_show(struct gfs2_sbd *sdp, char *buf) |
405 | struct attribute attr; | 382 | { |
406 | ssize_t (*show)(struct gfs2_sbd *sdp, char *); | 383 | return sprintf(buf, "%u\n", sdp->sd_lockstruct.ls_jid); |
407 | ssize_t (*store)(struct gfs2_sbd *sdp, const char *, size_t); | 384 | } |
408 | }; | ||
409 | 385 | ||
410 | #define GDLM_ATTR(_name,_mode,_show,_store) \ | 386 | #define GDLM_ATTR(_name,_mode,_show,_store) \ |
411 | static struct gdlm_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store) | 387 | static struct gfs2_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store) |
412 | 388 | ||
413 | GDLM_ATTR(proto_name, 0444, proto_name_show, NULL); | 389 | GDLM_ATTR(proto_name, 0444, proto_name_show, NULL); |
414 | GDLM_ATTR(block, 0644, block_show, block_store); | 390 | GDLM_ATTR(block, 0644, block_show, block_store); |
415 | GDLM_ATTR(withdraw, 0644, withdraw_show, withdraw_store); | 391 | GDLM_ATTR(withdraw, 0644, withdraw_show, withdraw_store); |
416 | GDLM_ATTR(id, 0444, lkid_show, NULL); | 392 | GDLM_ATTR(id, 0444, lkid_show, NULL); |
417 | GDLM_ATTR(first, 0444, lkfirst_show, NULL); | 393 | GDLM_ATTR(jid, 0444, jid_show, NULL); |
418 | GDLM_ATTR(first_done, 0444, first_done_show, NULL); | 394 | GDLM_ATTR(first, 0444, lkfirst_show, NULL); |
419 | GDLM_ATTR(recover, 0644, recover_show, recover_store); | 395 | GDLM_ATTR(first_done, 0444, first_done_show, NULL); |
420 | GDLM_ATTR(recover_done, 0444, recover_done_show, NULL); | 396 | GDLM_ATTR(recover, 0200, NULL, recover_store); |
421 | GDLM_ATTR(recover_status, 0444, recover_status_show, NULL); | 397 | GDLM_ATTR(recover_done, 0444, recover_done_show, NULL); |
398 | GDLM_ATTR(recover_status, 0444, recover_status_show, NULL); | ||
422 | 399 | ||
423 | static struct attribute *lock_module_attrs[] = { | 400 | static struct attribute *lock_module_attrs[] = { |
424 | &gdlm_attr_proto_name.attr, | 401 | &gdlm_attr_proto_name.attr, |
425 | &gdlm_attr_block.attr, | 402 | &gdlm_attr_block.attr, |
426 | &gdlm_attr_withdraw.attr, | 403 | &gdlm_attr_withdraw.attr, |
427 | &gdlm_attr_id.attr, | 404 | &gdlm_attr_id.attr, |
428 | &lockstruct_attr_jid.attr, | 405 | &gdlm_attr_jid.attr, |
429 | &gdlm_attr_first.attr, | 406 | &gdlm_attr_first.attr, |
430 | &gdlm_attr_first_done.attr, | 407 | &gdlm_attr_first_done.attr, |
431 | &gdlm_attr_recover.attr, | 408 | &gdlm_attr_recover.attr, |
@@ -435,53 +412,6 @@ static struct attribute *lock_module_attrs[] = { | |||
435 | }; | 412 | }; |
436 | 413 | ||
437 | /* | 414 | /* |
438 | * display struct gfs2_args fields | ||
439 | */ | ||
440 | |||
441 | struct args_attr { | ||
442 | struct attribute attr; | ||
443 | ssize_t (*show)(struct gfs2_sbd *, char *); | ||
444 | }; | ||
445 | |||
446 | #define ARGS_ATTR(name, fmt) \ | ||
447 | static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \ | ||
448 | { \ | ||
449 | return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_args.ar_##name); \ | ||
450 | } \ | ||
451 | static struct args_attr args_attr_##name = __ATTR_RO(name) | ||
452 | |||
453 | ARGS_ATTR(lockproto, "%s\n"); | ||
454 | ARGS_ATTR(locktable, "%s\n"); | ||
455 | ARGS_ATTR(hostdata, "%s\n"); | ||
456 | ARGS_ATTR(spectator, "%d\n"); | ||
457 | ARGS_ATTR(ignore_local_fs, "%d\n"); | ||
458 | ARGS_ATTR(localcaching, "%d\n"); | ||
459 | ARGS_ATTR(localflocks, "%d\n"); | ||
460 | ARGS_ATTR(debug, "%d\n"); | ||
461 | ARGS_ATTR(upgrade, "%d\n"); | ||
462 | ARGS_ATTR(posix_acl, "%d\n"); | ||
463 | ARGS_ATTR(quota, "%u\n"); | ||
464 | ARGS_ATTR(suiddir, "%d\n"); | ||
465 | ARGS_ATTR(data, "%d\n"); | ||
466 | |||
467 | static struct attribute *args_attrs[] = { | ||
468 | &args_attr_lockproto.attr, | ||
469 | &args_attr_locktable.attr, | ||
470 | &args_attr_hostdata.attr, | ||
471 | &args_attr_spectator.attr, | ||
472 | &args_attr_ignore_local_fs.attr, | ||
473 | &args_attr_localcaching.attr, | ||
474 | &args_attr_localflocks.attr, | ||
475 | &args_attr_debug.attr, | ||
476 | &args_attr_upgrade.attr, | ||
477 | &args_attr_posix_acl.attr, | ||
478 | &args_attr_quota.attr, | ||
479 | &args_attr_suiddir.attr, | ||
480 | &args_attr_data.attr, | ||
481 | NULL, | ||
482 | }; | ||
483 | |||
484 | /* | ||
485 | * get and set struct gfs2_tune fields | 415 | * get and set struct gfs2_tune fields |
486 | */ | 416 | */ |
487 | 417 | ||
@@ -531,14 +461,8 @@ static ssize_t tune_set(struct gfs2_sbd *sdp, unsigned int *field, | |||
531 | return len; | 461 | return len; |
532 | } | 462 | } |
533 | 463 | ||
534 | struct tune_attr { | ||
535 | struct attribute attr; | ||
536 | ssize_t (*show)(struct gfs2_sbd *, char *); | ||
537 | ssize_t (*store)(struct gfs2_sbd *, const char *, size_t); | ||
538 | }; | ||
539 | |||
540 | #define TUNE_ATTR_3(name, show, store) \ | 464 | #define TUNE_ATTR_3(name, show, store) \ |
541 | static struct tune_attr tune_attr_##name = __ATTR(name, 0644, show, store) | 465 | static struct gfs2_attr tune_attr_##name = __ATTR(name, 0644, show, store) |
542 | 466 | ||
543 | #define TUNE_ATTR_2(name, store) \ | 467 | #define TUNE_ATTR_2(name, store) \ |
544 | static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \ | 468 | static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \ |
@@ -554,15 +478,6 @@ static ssize_t name##_store(struct gfs2_sbd *sdp, const char *buf, size_t len)\ | |||
554 | } \ | 478 | } \ |
555 | TUNE_ATTR_2(name, name##_store) | 479 | TUNE_ATTR_2(name, name##_store) |
556 | 480 | ||
557 | #define TUNE_ATTR_DAEMON(name, process) \ | ||
558 | static ssize_t name##_store(struct gfs2_sbd *sdp, const char *buf, size_t len)\ | ||
559 | { \ | ||
560 | ssize_t r = tune_set(sdp, &sdp->sd_tune.gt_##name, 1, buf, len); \ | ||
561 | wake_up_process(sdp->sd_##process); \ | ||
562 | return r; \ | ||
563 | } \ | ||
564 | TUNE_ATTR_2(name, name##_store) | ||
565 | |||
566 | TUNE_ATTR(incore_log_blocks, 0); | 481 | TUNE_ATTR(incore_log_blocks, 0); |
567 | TUNE_ATTR(log_flush_secs, 0); | 482 | TUNE_ATTR(log_flush_secs, 0); |
568 | TUNE_ATTR(quota_warn_period, 0); | 483 | TUNE_ATTR(quota_warn_period, 0); |
@@ -574,8 +489,6 @@ TUNE_ATTR(new_files_jdata, 0); | |||
574 | TUNE_ATTR(quota_simul_sync, 1); | 489 | TUNE_ATTR(quota_simul_sync, 1); |
575 | TUNE_ATTR(stall_secs, 1); | 490 | TUNE_ATTR(stall_secs, 1); |
576 | TUNE_ATTR(statfs_quantum, 1); | 491 | TUNE_ATTR(statfs_quantum, 1); |
577 | TUNE_ATTR_DAEMON(recoverd_secs, recoverd_process); | ||
578 | TUNE_ATTR_DAEMON(logd_secs, logd_process); | ||
579 | TUNE_ATTR_3(quota_scale, quota_scale_show, quota_scale_store); | 492 | TUNE_ATTR_3(quota_scale, quota_scale_show, quota_scale_store); |
580 | 493 | ||
581 | static struct attribute *tune_attrs[] = { | 494 | static struct attribute *tune_attrs[] = { |
@@ -589,23 +502,11 @@ static struct attribute *tune_attrs[] = { | |||
589 | &tune_attr_quota_simul_sync.attr, | 502 | &tune_attr_quota_simul_sync.attr, |
590 | &tune_attr_stall_secs.attr, | 503 | &tune_attr_stall_secs.attr, |
591 | &tune_attr_statfs_quantum.attr, | 504 | &tune_attr_statfs_quantum.attr, |
592 | &tune_attr_recoverd_secs.attr, | ||
593 | &tune_attr_logd_secs.attr, | ||
594 | &tune_attr_quota_scale.attr, | 505 | &tune_attr_quota_scale.attr, |
595 | &tune_attr_new_files_jdata.attr, | 506 | &tune_attr_new_files_jdata.attr, |
596 | NULL, | 507 | NULL, |
597 | }; | 508 | }; |
598 | 509 | ||
599 | static struct attribute_group lockstruct_group = { | ||
600 | .name = "lockstruct", | ||
601 | .attrs = lockstruct_attrs, | ||
602 | }; | ||
603 | |||
604 | static struct attribute_group args_group = { | ||
605 | .name = "args", | ||
606 | .attrs = args_attrs, | ||
607 | }; | ||
608 | |||
609 | static struct attribute_group tune_group = { | 510 | static struct attribute_group tune_group = { |
610 | .name = "tune", | 511 | .name = "tune", |
611 | .attrs = tune_attrs, | 512 | .attrs = tune_attrs, |
@@ -626,17 +527,9 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp) | |||
626 | if (error) | 527 | if (error) |
627 | goto fail; | 528 | goto fail; |
628 | 529 | ||
629 | error = sysfs_create_group(&sdp->sd_kobj, &lockstruct_group); | ||
630 | if (error) | ||
631 | goto fail_reg; | ||
632 | |||
633 | error = sysfs_create_group(&sdp->sd_kobj, &args_group); | ||
634 | if (error) | ||
635 | goto fail_lockstruct; | ||
636 | |||
637 | error = sysfs_create_group(&sdp->sd_kobj, &tune_group); | 530 | error = sysfs_create_group(&sdp->sd_kobj, &tune_group); |
638 | if (error) | 531 | if (error) |
639 | goto fail_args; | 532 | goto fail_reg; |
640 | 533 | ||
641 | error = sysfs_create_group(&sdp->sd_kobj, &lock_module_group); | 534 | error = sysfs_create_group(&sdp->sd_kobj, &lock_module_group); |
642 | if (error) | 535 | if (error) |
@@ -647,10 +540,6 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp) | |||
647 | 540 | ||
648 | fail_tune: | 541 | fail_tune: |
649 | sysfs_remove_group(&sdp->sd_kobj, &tune_group); | 542 | sysfs_remove_group(&sdp->sd_kobj, &tune_group); |
650 | fail_args: | ||
651 | sysfs_remove_group(&sdp->sd_kobj, &args_group); | ||
652 | fail_lockstruct: | ||
653 | sysfs_remove_group(&sdp->sd_kobj, &lockstruct_group); | ||
654 | fail_reg: | 543 | fail_reg: |
655 | kobject_put(&sdp->sd_kobj); | 544 | kobject_put(&sdp->sd_kobj); |
656 | fail: | 545 | fail: |
@@ -661,8 +550,6 @@ fail: | |||
661 | void gfs2_sys_fs_del(struct gfs2_sbd *sdp) | 550 | void gfs2_sys_fs_del(struct gfs2_sbd *sdp) |
662 | { | 551 | { |
663 | sysfs_remove_group(&sdp->sd_kobj, &tune_group); | 552 | sysfs_remove_group(&sdp->sd_kobj, &tune_group); |
664 | sysfs_remove_group(&sdp->sd_kobj, &args_group); | ||
665 | sysfs_remove_group(&sdp->sd_kobj, &lockstruct_group); | ||
666 | sysfs_remove_group(&sdp->sd_kobj, &lock_module_group); | 553 | sysfs_remove_group(&sdp->sd_kobj, &lock_module_group); |
667 | kobject_put(&sdp->sd_kobj); | 554 | kobject_put(&sdp->sd_kobj); |
668 | } | 555 | } |