Skip to content

Commit 5c47daf

Browse files
committed
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 <[email protected]>
1 parent 23da422 commit 5c47daf

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

drivers/md/md.c

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -590,32 +590,9 @@ static struct mddev *mddev_find(dev_t unit)
590590
goto retry;
591591
}
592592

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-
616593
static struct attribute_group md_redundancy_group;
617594

618-
static void mddev_unlock(struct mddev *mddev)
595+
void mddev_unlock(struct mddev *mddev)
619596
{
620597
if (mddev->to_remove) {
621598
/* These cannot be removed under reconfig_mutex as
@@ -657,6 +634,7 @@ static void mddev_unlock(struct mddev *mddev)
657634
md_wakeup_thread(mddev->thread);
658635
spin_unlock(&pers_lock);
659636
}
637+
EXPORT_SYMBOL_GPL(mddev_unlock);
660638

661639
static struct md_rdev *find_rdev_nr_rcu(struct mddev *mddev, int nr)
662640
{

drivers/md/md.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,30 @@ struct mddev {
450450
void (*sync_super)(struct mddev *mddev, struct md_rdev *rdev);
451451
};
452452

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+
453477
static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
454478
{
455479
int faulty = test_bit(Faulty, &rdev->flags);

0 commit comments

Comments
 (0)