diff options
author | NeilBrown <neilb@suse.de> | 2014-12-14 20:57:01 -0500 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2015-02-05 17:32:56 -0500 |
commit | 5c47daf6e76f657d961a96d89f6419fde8eda557 (patch) | |
tree | ce0388871ccbb03e48da2b839f3e4fa4c492df56 /drivers/md | |
parent | 23da422b1951cb8dbcb7c3090057cb6d5ceedf49 (diff) |
md: move mddev_lock and related to md.h
The one which is not inline (mddev_unlock) gets EXPORTed.
This makes the locking available to personality modules so that it
doesn't have to be imposed upon them.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/md.c | 26 | ||||
-rw-r--r-- | drivers/md/md.h | 24 |
2 files changed, 26 insertions, 24 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 0f00c1e2d829..ea839d811f64 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -590,32 +590,9 @@ static struct mddev *mddev_find(dev_t unit) | |||
590 | goto retry; | 590 | goto retry; |
591 | } | 591 | } |
592 | 592 | ||
593 | static inline int __must_check mddev_lock(struct mddev *mddev) | ||
594 | { | ||
595 | return mutex_lock_interruptible(&mddev->reconfig_mutex); | ||
596 | } | ||
597 | |||
598 | /* Sometimes we need to take the lock in a situation where | ||
599 | * failure due to interrupts is not acceptable. | ||
600 | */ | ||
601 | static inline void mddev_lock_nointr(struct mddev *mddev) | ||
602 | { | ||
603 | mutex_lock(&mddev->reconfig_mutex); | ||
604 | } | ||
605 | |||
606 | static inline int mddev_is_locked(struct mddev *mddev) | ||
607 | { | ||
608 | return mutex_is_locked(&mddev->reconfig_mutex); | ||
609 | } | ||
610 | |||
611 | static inline int mddev_trylock(struct mddev *mddev) | ||
612 | { | ||
613 | return mutex_trylock(&mddev->reconfig_mutex); | ||
614 | } | ||
615 | |||
616 | static struct attribute_group md_redundancy_group; | 593 | static struct attribute_group md_redundancy_group; |
617 | 594 | ||
618 | static void mddev_unlock(struct mddev *mddev) | 595 | void mddev_unlock(struct mddev *mddev) |
619 | { | 596 | { |
620 | if (mddev->to_remove) { | 597 | if (mddev->to_remove) { |
621 | /* These cannot be removed under reconfig_mutex as | 598 | /* These cannot be removed under reconfig_mutex as |
@@ -657,6 +634,7 @@ static void mddev_unlock(struct mddev *mddev) | |||
657 | md_wakeup_thread(mddev->thread); | 634 | md_wakeup_thread(mddev->thread); |
658 | spin_unlock(&pers_lock); | 635 | spin_unlock(&pers_lock); |
659 | } | 636 | } |
637 | EXPORT_SYMBOL_GPL(mddev_unlock); | ||
660 | 638 | ||
661 | static struct md_rdev *find_rdev_nr_rcu(struct mddev *mddev, int nr) | 639 | static struct md_rdev *find_rdev_nr_rcu(struct mddev *mddev, int nr) |
662 | { | 640 | { |
diff --git a/drivers/md/md.h b/drivers/md/md.h index 6bf3faa951ec..14367d919351 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h | |||
@@ -450,6 +450,30 @@ struct mddev { | |||
450 | void (*sync_super)(struct mddev *mddev, struct md_rdev *rdev); | 450 | void (*sync_super)(struct mddev *mddev, struct md_rdev *rdev); |
451 | }; | 451 | }; |
452 | 452 | ||
453 | static inline int __must_check mddev_lock(struct mddev *mddev) | ||
454 | { | ||
455 | return mutex_lock_interruptible(&mddev->reconfig_mutex); | ||
456 | } | ||
457 | |||
458 | /* Sometimes we need to take the lock in a situation where | ||
459 | * failure due to interrupts is not acceptable. | ||
460 | */ | ||
461 | static inline void mddev_lock_nointr(struct mddev *mddev) | ||
462 | { | ||
463 | mutex_lock(&mddev->reconfig_mutex); | ||
464 | } | ||
465 | |||
466 | static inline int mddev_is_locked(struct mddev *mddev) | ||
467 | { | ||
468 | return mutex_is_locked(&mddev->reconfig_mutex); | ||
469 | } | ||
470 | |||
471 | static inline int mddev_trylock(struct mddev *mddev) | ||
472 | { | ||
473 | return mutex_trylock(&mddev->reconfig_mutex); | ||
474 | } | ||
475 | extern void mddev_unlock(struct mddev *mddev); | ||
476 | |||
453 | static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev) | 477 | static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev) |
454 | { | 478 | { |
455 | int faulty = test_bit(Faulty, &rdev->flags); | 479 | int faulty = test_bit(Faulty, &rdev->flags); |