Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Peter Zijlstra and committed by
Ingo Molnar
1e24edca 2b0b2111

+6 -8
+1 -1
drivers/block/drbd/drbd_bitmap.c
··· 1070 1070 .done = 0, 1071 1071 .flags = flags, 1072 1072 .error = 0, 1073 - .kref = { ATOMIC_INIT(2) }, 1073 + .kref = KREF_INIT(2), 1074 1074 }; 1075 1075 1076 1076 if (!get_ldev_if_state(device, D_ATTACHING)) { /* put is in drbd_bm_aio_ctx_destroy() */
+1 -1
fs/fuse/fuse_i.h
··· 256 256 257 257 #define FUSE_IO_PRIV_SYNC(f) \ 258 258 { \ 259 - .refcnt = { ATOMIC_INIT(1) }, \ 259 + .refcnt = KREF_INIT(1), \ 260 260 .async = 0, \ 261 261 .file = f, \ 262 262 }
+2
include/linux/kref.h
··· 24 24 atomic_t refcount; 25 25 }; 26 26 27 + #define KREF_INIT(n) { .refcount = ATOMIC_INIT(n), } 28 + 27 29 /** 28 30 * kref_init - initialize object. 29 31 * @kref: object in question.
+1 -3
init/version.c
··· 23 23 #endif 24 24 25 25 struct uts_namespace init_uts_ns = { 26 - .kref = { 27 - .refcount = ATOMIC_INIT(2), 28 - }, 26 + .kref = KREF_INIT(2), 29 27 .name = { 30 28 .sysname = UTS_SYSNAME, 31 29 .nodename = UTS_NODENAME,
+1 -3
kernel/pid.c
··· 68 68 * the scheme scales to up to 4 million PIDs, runtime. 69 69 */ 70 70 struct pid_namespace init_pid_ns = { 71 - .kref = { 72 - .refcount = ATOMIC_INIT(2), 73 - }, 71 + .kref = KREF_INIT(2), 74 72 .pidmap = { 75 73 [ 0 ... PIDMAP_ENTRIES-1] = { ATOMIC_INIT(BITS_PER_PAGE), NULL } 76 74 },