Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp1027762lqo; Thu, 9 May 2024 02:33:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWv3ExA4l2KGQZAnjRdUNXGWTBdyACM9M67HLj9l5Y9oesBBY3XMT0ZJ5kPTxmx/zurjm3q+xTE4uR4cWYT4xDCRGnJcj0DL+GgmULzWg== X-Google-Smtp-Source: AGHT+IEoltXWovnLXE1aDXvaUR7EYzFMeOC3yjGpLCX8nEYixg8saZuV3UZt0RYDz/ChFl7VU0p+ X-Received: by 2002:a17:907:7dac:b0:a59:adb9:6c2a with SMTP id a640c23a62f3a-a5a115ef957mr230322166b.11.1715247235450; Thu, 09 May 2024 02:33:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715247235; cv=pass; d=google.com; s=arc-20160816; b=QW/UO5NMcsFCVj/e6QyS8Edfi7eeMSGCKntDGSowdrNtrDFepBC37FV4PVbDSd9Cnz dH2vF3HyXvdhAJDkapeNtSRxbs4mIBoGUN2PQXhcQWNJ22tACH6ULjIQbsQf+2um9GF9 BVsZ1vEPrwx0XX20sN7pYLVz+rSagpHmaqmDt/GT2vNuJsL5RoAbT9lC7isbwzLwFVIG NTCl3Ey0OPktlxaknSTTBZJoazTSLx17d/aTDwo9ddqi78BZdSqnG5fNzW+sGf3cBEO4 2y2e4pf0+dQvZsgNoab7wkTRZjscD57ZgmrAPS+zipjpbcQTY1KwxcMurNey4uLQmD2W YaaA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=SE7k9bpBm/0LF2sARMu50Amc0c3imhrkc0T1iBif8O0=; fh=FofDj1TQ/OQGvI3DfKuzoCZ28OpALSHQJ61fRfr1080=; b=CxB2auqQyyJWoXgDQkty4DyMnmE1gD5RZsHcdZMPSry4KtquK8ItNHUAPCFtgJZIJk XJQtGTVAb+QUj38aHzkH01/2vW6OdyOrrHw8Mdn3D+Tiu6E1FOI1XOF65eUL2uG27RY2 R/uyMdhf87BtMzcrnGvl4690+aahT4+3FsPjFFzrXid1nS3nL0S8nqGWhqx5GQOWhAcn VV5n5/0nTdz1etMqhxz9h0YJrmAPzKrx4IZv24kppFhb271ankgb6bpPDp+JywhjvCVH IHa0RsYui03+LnOE8/hJ/fJlADD6PFrbKYlVH+r+tRCcAx8nT64mDwXd+KHc09wX9SzA K47g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-174352-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174352-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17b2204csi67840266b.478.2024.05.09.02.33.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 02:33:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174352-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-174352-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174352-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 293811F239F2 for ; Thu, 9 May 2024 09:33:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E196A14A62E; Thu, 9 May 2024 09:33:46 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2EFA1494D9; Thu, 9 May 2024 09:33:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715247226; cv=none; b=AHx1E1UiO15sIt8hbq+Fwy6audNCilfuqZPqcP9dRW0GDj3pJLmzANs6lTlHPvSVGJ2YkhHNBQtchnkyUeh6R3Ch3TiAycntlL03bAu1Bk9lx8PiTpEEup92lczrukMjX+R1Bjh2a8h3X78Mz7P1+JV8m7iGHUgid3O6e7muiH0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715247226; c=relaxed/simple; bh=aHW5/vIQ8c227jwhESnXTgt/7c8ZoU4PkjaXxYwerYI=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=JRMLEkIX31k2hgxoyrSJt7OD2C63JBnqT/x9ioFa00PFjfjG5zTLXwdRuJKPKEtUGo6AlTUt1cr/rSgiaSc3JCaBzrF0yT11DmOEs2S4u37rUUmJLEvPKYDBya1+vdXkbaVLNvOU9TZVrT1hXkPvvJJcKJnIIrFtmAZSlEiQm7M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4VZmvf4ljyz2CfJY; Thu, 9 May 2024 17:30:22 +0800 (CST) Received: from kwepemi500008.china.huawei.com (unknown [7.221.188.139]) by mail.maildlp.com (Postfix) with ESMTPS id 13F701A016C; Thu, 9 May 2024 17:33:40 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi500008.china.huawei.com (7.221.188.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 9 May 2024 17:33:39 +0800 From: Jinjie Ruan To: , , , , , , , , , , , CC: Subject: [PATCH] null_blk: Add __must_hold macro for null_flush_cache_page() Date: Thu, 9 May 2024 17:33:04 +0800 Message-ID: <20240509093304.1618775-1-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi500008.china.huawei.com (7.221.188.139) It seems that call null_flush_cache_page() must hold nullb->lock and it returns with nullb->lock held. However, this is not clearly described, and the caller may forget to hold the lock. Therefore, add __must_hold() macro to the function entry to show that the lock is held on function entry and exit, which allows sparse to do lock checking. Signed-off-by: Jinjie Ruan --- drivers/block/null_blk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index ed33cf7192d2..adca31e55deb 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -1013,7 +1013,7 @@ static int null_flush_cache_page(struct nullb *nullb, struct nullb_page *c_page) return 0; } -static int null_make_cache_space(struct nullb *nullb, unsigned long n) +static int null_make_cache_space(struct nullb *nullb, unsigned long n) __must_hold(&nullb->lock) { int i, err, nr_pages; struct nullb_page *c_pages[FREE_BATCH]; -- 2.34.1