locking/atomic, kref: Add KREF_INIT()
authorPeter Zijlstra <peterz@infradead.org>
Mon, 14 Nov 2016 16:12:23 +0000 (17:12 +0100)
committerIngo Molnar <mingo@kernel.org>
Sat, 14 Jan 2017 10:37:18 +0000 (11:37 +0100)
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>
drivers/block/drbd/drbd_bitmap.c
fs/fuse/fuse_i.h
include/linux/kref.h
init/version.c
kernel/pid.c

index ab62b81..dece26f 100644 (file)
@@ -1070,7 +1070,7 @@ static int bm_rw(struct drbd_device *device, const unsigned int flags, unsigned
                .done = 0,
                .flags = flags,
                .error = 0,
-               .kref = { ATOMIC_INIT(2) },
+               .kref = KREF_INIT(2),
        };
 
        if (!get_ldev_if_state(device, D_ATTACHING)) {  /* put is in drbd_bm_aio_ctx_destroy() */
index 9130794..052f8d3 100644 (file)
@@ -256,7 +256,7 @@ struct fuse_io_priv {
 
 #define FUSE_IO_PRIV_SYNC(f) \
 {                                      \
-       .refcnt = { ATOMIC_INIT(1) },   \
+       .refcnt = KREF_INIT(1),         \
        .async = 0,                     \
        .file = f,                      \
 }
index e15828f..9af255a 100644 (file)
@@ -24,6 +24,8 @@ struct kref {
        atomic_t refcount;
 };
 
+#define KREF_INIT(n)   { .refcount = ATOMIC_INIT(n), }
+
 /**
  * kref_init - initialize object.
  * @kref: object in question.
index fe41a63..5606341 100644 (file)
@@ -23,9 +23,7 @@ int version_string(LINUX_VERSION_CODE);
 #endif
 
 struct uts_namespace init_uts_ns = {
-       .kref = {
-               .refcount       = ATOMIC_INIT(2),
-       },
+       .kref = KREF_INIT(2),
        .name = {
                .sysname        = UTS_SYSNAME,
                .nodename       = UTS_NODENAME,
index f66162f..0291804 100644 (file)
@@ -68,9 +68,7 @@ static inline int mk_pid(struct pid_namespace *pid_ns,
  * the scheme scales to up to 4 million PIDs, runtime.
  */
 struct pid_namespace init_pid_ns = {
-       .kref = {
-               .refcount       = ATOMIC_INIT(2),
-       },
+       .kref = KREF_INIT(2),
        .pidmap = {
                [ 0 ... PIDMAP_ENTRIES-1] = { ATOMIC_INIT(BITS_PER_PAGE), NULL }
        },