Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751933AbaKWQke (ORCPT ); Sun, 23 Nov 2014 11:40:34 -0500 Received: from mail-ig0-f169.google.com ([209.85.213.169]:64594 "EHLO mail-ig0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751762AbaKWQkd (ORCPT ); Sun, 23 Nov 2014 11:40:33 -0500 Message-ID: <1416760829.17888.19.camel@edumazet-glaptop2.roam.corp.google.com> Subject: [PATCH ] drivers/md: use proper rcu accessor From: Eric Dumazet To: Pranith Kumar Cc: "Kirill A. Shutemov" , "Paul E. McKenney" , LKML , Ingo Molnar , Lai Jiangshan , Dipankar Sarma , Andrew Morton , Mathieu Desnoyers , Josh Triplett , Thomas Gleixner , Peter Zijlstra , Steven Rostedt , David Howells , Eric Dumazet , dvhart@linux.intel.com, =?ISO-8859-1?Q?Fr=E9d=E9ric?= Weisbecker , Oleg Nesterov Date: Sun, 23 Nov 2014 08:40:29 -0800 In-Reply-To: References: <20141028220944.GA26114@linux.vnet.ibm.com> <1414534202-27312-1-git-send-email-paulmck@linux.vnet.ibm.com> <1414534202-27312-3-git-send-email-paulmck@linux.vnet.ibm.com> <20141121133145.GA17245@node.dhcp.inet.fi> <546F4C8C.4040904@gmail.com> <20141121145817.GA17710@node.dhcp.inet.fi> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet rcu_dereference() should be used in sections protected by rcu_read_lock. For writers, holding some kind of mutex or lock, rcu_dereference_protected() is the way to go, adding explicit lockdep bits. In __unbind(), although there is no mutex or lock held, we are about to free the mapped device, so can use the constant '1' instead of a lockdep_is_held() Reported-by: Kirill A. Shutemov Signed-off-by: Eric Dumazet Fixes: 33423974bfc1 ("dm: Use rcu_dereference() for accessing rcu pointer") Cc: Pranith Kumar --- drivers/md/dm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index a0ece87ad426..2e0aa2273382 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -2335,7 +2335,8 @@ static struct dm_table *__bind(struct mapped_device *md, struct dm_table *t, merge_is_optional = dm_table_merge_is_optional(t); - old_map = rcu_dereference(md->map); + old_map = rcu_dereference_protected(md->map, + lockdep_is_held(&md->suspend_lock)); rcu_assign_pointer(md->map, t); md->immutable_target_type = dm_table_get_immutable_target_type(t); @@ -2355,7 +2356,7 @@ static struct dm_table *__bind(struct mapped_device *md, struct dm_table *t, */ static struct dm_table *__unbind(struct mapped_device *md) { - struct dm_table *map = rcu_dereference(md->map); + struct dm_table *map = rcu_dereference_protected(md->map, 1); if (!map) return NULL; @@ -2850,7 +2851,8 @@ retry: goto retry; } - map = rcu_dereference(md->map); + map = rcu_dereference_protected(md->map, + lockdep_is_held(&md->suspend_lock)); r = __dm_suspend(md, map, suspend_flags, TASK_INTERRUPTIBLE); if (r) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/