Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755404AbbHQME5 (ORCPT ); Mon, 17 Aug 2015 08:04:57 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:34013 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754608AbbHQMEz (ORCPT ); Mon, 17 Aug 2015 08:04:55 -0400 From: Maxime Lorrillere To: Oleg Drokin , Andreas Dilger , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Maxime Lorrillere Subject: [PATCH] staging: lustre: simplify ptlrpc_deactivate_and_unlock_import Date: Mon, 17 Aug 2015 14:04:49 +0200 Message-Id: <1439813089-23263-1-git-send-email-maxime.lorrillere@gmail.com> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2470 Lines: 65 The locking scheme used in ptlrpc_deactivate_and_unlock_import and ptlrpc_deactivate_import generates the followings sparse errors: drivers/staging/lustre/lustre/ptlrpc/import.c:209:9: warning: context imbalance in 'ptlrpc_deactivate_and_unlock_import' - unexpected unlock drivers/staging/lustre/lustre/ptlrpc/import.c:221:6: warning: context imbalance in 'ptlrpc_deactivate_import' - wrong count at exit As ptlrpc_deactivate_and_unlock_import is only used by ptlrpc_deactivate_import as a helper function, this patch moves its code into ptlrpc_deactivatre_import to fix the sparse warnings. Signed-off-by: Maxime Lorrillere --- drivers/staging/lustre/lustre/ptlrpc/import.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index 1eae389..1fd8510 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -200,12 +200,15 @@ int ptlrpc_set_import_discon(struct obd_import *imp, __u32 conn_cnt) return rc; } -/* Must be called with imp_lock held! */ -static void ptlrpc_deactivate_and_unlock_import(struct obd_import *imp) +/* + * This acts as a barrier; all existing requests are rejected, and + * no new requests will be accepted until the import is valid again. + */ +void ptlrpc_deactivate_import(struct obd_import *imp) { - assert_spin_locked(&imp->imp_lock); - CDEBUG(D_HA, "setting import %s INVALID\n", obd2cli_tgt(imp->imp_obd)); + + spin_lock(&imp->imp_lock); imp->imp_invalid = 1; imp->imp_generation++; spin_unlock(&imp->imp_lock); @@ -213,16 +216,6 @@ static void ptlrpc_deactivate_and_unlock_import(struct obd_import *imp) ptlrpc_abort_inflight(imp); obd_import_event(imp->imp_obd, imp, IMP_EVENT_INACTIVE); } - -/* - * This acts as a barrier; all existing requests are rejected, and - * no new requests will be accepted until the import is valid again. - */ -void ptlrpc_deactivate_import(struct obd_import *imp) -{ - spin_lock(&imp->imp_lock); - ptlrpc_deactivate_and_unlock_import(imp); -} EXPORT_SYMBOL(ptlrpc_deactivate_import); static unsigned int -- 2.5.0 -- 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/