diff options
author | Peter Zijlstra <peterz@infradead.org> | 2016-11-14 11:12:23 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-01-14 05:37:18 -0500 |
commit | 1e24edca0557dba6486d39d3c24c288475432bcf (patch) | |
tree | 9ee0931fdfa80b2b2b809bd26ad2aced7c8bce33 | |
parent | 2b0b211134a65401ed874ce0d5d48844f4f6f341 (diff) |
locking/atomic, kref: Add KREF_INIT()
Since we need to change the implementation, stop exposing internals.
Provide KREF_INIT() to allow static initialization of struct kref.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | drivers/block/drbd/drbd_bitmap.c | 2 | ||||
-rw-r--r-- | fs/fuse/fuse_i.h | 2 | ||||
-rw-r--r-- | include/linux/kref.h | 2 | ||||
-rw-r--r-- | init/version.c | 4 | ||||
-rw-r--r-- | kernel/pid.c | 4 |
5 files changed, 6 insertions, 8 deletions
diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c index ab62b81c2ca7..dece26f119d4 100644 --- a/drivers/block/drbd/drbd_bitmap.c +++ b/drivers/block/drbd/drbd_bitmap.c | |||
@@ -1070,7 +1070,7 @@ static int bm_rw(struct drbd_device *device, const unsigned int flags, unsigned | |||
1070 | .done = 0, | 1070 | .done = 0, |
1071 | .flags = flags, | 1071 | .flags = flags, |
1072 | .error = 0, | 1072 | .error = 0, |
1073 | .kref = { ATOMIC_INIT(2) }, | 1073 | .kref = KREF_INIT(2), |
1074 | }; | 1074 | }; |
1075 | 1075 | ||
1076 | if (!get_ldev_if_state(device, D_ATTACHING)) { /* put is in drbd_bm_aio_ctx_destroy() */ | 1076 | if (!get_ldev_if_state(device, D_ATTACHING)) { /* put is in drbd_bm_aio_ctx_destroy() */ |
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 91307940c8ac..052f8d3c41cb 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h | |||
@@ -256,7 +256,7 @@ struct fuse_io_priv { | |||
256 | 256 | ||
257 | #define FUSE_IO_PRIV_SYNC(f) \ | 257 | #define FUSE_IO_PRIV_SYNC(f) \ |
258 | { \ | 258 | { \ |
259 | .refcnt = { ATOMIC_INIT(1) }, \ | 259 | .refcnt = KREF_INIT(1), \ |
260 | .async = 0, \ | 260 | .async = 0, \ |
261 | .file = f, \ | 261 | .file = f, \ |
262 | } | 262 | } |
diff --git a/include/linux/kref.h b/include/linux/kref.h index e15828fd71f1..9af255ad1e2f 100644 --- a/include/linux/kref.h +++ b/include/linux/kref.h | |||
@@ -24,6 +24,8 @@ struct kref { | |||
24 | atomic_t refcount; | 24 | atomic_t refcount; |
25 | }; | 25 | }; |
26 | 26 | ||
27 | #define KREF_INIT(n) { .refcount = ATOMIC_INIT(n), } | ||
28 | |||
27 | /** | 29 | /** |
28 | * kref_init - initialize object. | 30 | * kref_init - initialize object. |
29 | * @kref: object in question. | 31 | * @kref: object in question. |
diff --git a/init/version.c b/init/version.c index fe41a63efed6..5606341e9efd 100644 --- a/init/version.c +++ b/init/version.c | |||
@@ -23,9 +23,7 @@ int version_string(LINUX_VERSION_CODE); | |||
23 | #endif | 23 | #endif |
24 | 24 | ||
25 | struct uts_namespace init_uts_ns = { | 25 | struct uts_namespace init_uts_ns = { |
26 | .kref = { | 26 | .kref = KREF_INIT(2), |
27 | .refcount = ATOMIC_INIT(2), | ||
28 | }, | ||
29 | .name = { | 27 | .name = { |
30 | .sysname = UTS_SYSNAME, | 28 | .sysname = UTS_SYSNAME, |
31 | .nodename = UTS_NODENAME, | 29 | .nodename = UTS_NODENAME, |
diff --git a/kernel/pid.c b/kernel/pid.c index f66162f2359b..0291804151b5 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
@@ -68,9 +68,7 @@ static inline int mk_pid(struct pid_namespace *pid_ns, | |||
68 | * the scheme scales to up to 4 million PIDs, runtime. | 68 | * the scheme scales to up to 4 million PIDs, runtime. |
69 | */ | 69 | */ |
70 | struct pid_namespace init_pid_ns = { | 70 | struct pid_namespace init_pid_ns = { |
71 | .kref = { | 71 | .kref = KREF_INIT(2), |
72 | .refcount = ATOMIC_INIT(2), | ||
73 | }, | ||
74 | .pidmap = { | 72 | .pidmap = { |
75 | [ 0 ... PIDMAP_ENTRIES-1] = { ATOMIC_INIT(BITS_PER_PAGE), NULL } | 73 | [ 0 ... PIDMAP_ENTRIES-1] = { ATOMIC_INIT(BITS_PER_PAGE), NULL } |
76 | }, | 74 | }, |