summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorShaohua Li <shli@fb.com>2017-05-01 14:09:21 -0700
committerShaohua Li <shli@fb.com>2017-05-01 14:09:21 -0700
commite265eb3a30543a237b2ebc4e0422ac82e55b07e4 (patch)
tree5485bce4a0645e5e9b6ef4686bd390b7b2599ffb /lib
parent85724edecbdc19f53ed4b902fc3a32e4d1b61c9b (diff)
parentb506335e5d2b4ec687dde392a3bdbf7601778f1d (diff)
downloadlinux-e265eb3a30543a237b2ebc4e0422ac82e55b07e4.tar.bz2
Merge branch 'md-next' into md-linus
Diffstat (limited to 'lib')
-rw-r--r--lib/percpu-refcount.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
index 9ac959ef4cae..fe03c6d52761 100644
--- a/lib/percpu-refcount.c
+++ b/lib/percpu-refcount.c
@@ -260,6 +260,22 @@ void percpu_ref_switch_to_atomic(struct percpu_ref *ref,
spin_unlock_irqrestore(&percpu_ref_switch_lock, flags);
}
+EXPORT_SYMBOL_GPL(percpu_ref_switch_to_atomic);
+
+/**
+ * percpu_ref_switch_to_atomic_sync - switch a percpu_ref to atomic mode
+ * @ref: percpu_ref to switch to atomic mode
+ *
+ * Schedule switching the ref to atomic mode, and wait for the
+ * switch to complete. Caller must ensure that no other thread
+ * will switch back to percpu mode.
+ */
+void percpu_ref_switch_to_atomic_sync(struct percpu_ref *ref)
+{
+ percpu_ref_switch_to_atomic(ref, NULL);
+ wait_event(percpu_ref_switch_waitq, !ref->confirm_switch);
+}
+EXPORT_SYMBOL_GPL(percpu_ref_switch_to_atomic_sync);
/**
* percpu_ref_switch_to_percpu - switch a percpu_ref to percpu mode
@@ -290,6 +306,7 @@ void percpu_ref_switch_to_percpu(struct percpu_ref *ref)
spin_unlock_irqrestore(&percpu_ref_switch_lock, flags);
}
+EXPORT_SYMBOL_GPL(percpu_ref_switch_to_percpu);
/**
* percpu_ref_kill_and_confirm - drop the initial ref and schedule confirmation