From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC43CC433E1 for ; Fri, 19 Jun 2020 20:47:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7A9BB21527 for ; Fri, 19 Jun 2020 20:47:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A9BB21527 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C12348D00FB; Fri, 19 Jun 2020 16:47:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B9C2E8D00E9; Fri, 19 Jun 2020 16:47:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A65368D00FB; Fri, 19 Jun 2020 16:47:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0130.hostedemail.com [216.40.44.130]) by kanga.kvack.org (Postfix) with ESMTP id 8DF388D00E9 for ; Fri, 19 Jun 2020 16:47:37 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3F5AD33CD for ; Fri, 19 Jun 2020 20:47:37 +0000 (UTC) X-FDA: 76947147354.17.spade15_190ee5526e1b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 7EA30180D0184 for ; Fri, 19 Jun 2020 20:47:36 +0000 (UTC) X-HE-Tag: spade15_190ee5526e1b X-Filterd-Recvd-Size: 4568 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Fri, 19 Jun 2020 20:47:35 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id u128so4965127pgu.13 for ; Fri, 19 Jun 2020 13:47:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZlpRC/Mpz8aVWhkWOBV4KQndGPE3w8KEQwXgj5xVC8o=; b=QqtPyHBQ1eX5AGaIqLVxWEhnDQ+GsHq1W7QszjGl+jhUK0aojktl/ni9ddqHwWH0XE +gBQeV3JuaAocNXq0ebGq7ykiIPO5L+KVZ4tzDpOw6zKTOZboFl+dUWfN1h20mrGSSRg 5Wbe19gsS7KTs0Ots+z8jONNAYNmUWfJqedYkz5KIktPN3lBFJDX8Ilv+OjICGhbC1yI SXphcnHvjq4vvXF43KcSC10bQVVRXu1cSvEdO0lhCbAxqB04aqUDN/fz+JZ7VczTiC2Q 6CxRgMf2bCIegi/RmaoIM/0CvKSt7nAq5GgdvFQrl7cKBTncUVqdBXY5VStFLt99hOID u/tw== X-Gm-Message-State: AOAM533VGSAK+L7RKMiZoY+pIPCfIM9HNY4ovCrkYPu8rYxjzROWS2mR xISj15LClBA0At0Nyv4XBLQ= X-Google-Smtp-Source: ABdhPJyEOMPI7dRp2zsaFrfUBNU9hX4Hv01VXR4E79Tt8FRLBZbwnTJwnov/PttgARJDYchOL+CQpw== X-Received: by 2002:aa7:952a:: with SMTP id c10mr10162941pfp.252.1592599655068; Fri, 19 Jun 2020 13:47:35 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id v7sm6569138pfn.147.2020.06.19.13.47.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jun 2020 13:47:32 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 4556A41C23; Fri, 19 Jun 2020 20:47:32 +0000 (UTC) From: Luis Chamberlain To: axboe@kernel.dk, viro@zeniv.linux.org.uk, bvanassche@acm.org, gregkh@linuxfoundation.org, rostedt@goodmis.org, mingo@redhat.com, jack@suse.cz, ming.lei@redhat.com, nstange@suse.de, akpm@linux-foundation.org Cc: mhocko@suse.com, yukuai3@huawei.com, martin.petersen@oracle.com, jejb@linux.ibm.com, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Luis Chamberlain , Christoph Hellwig Subject: [PATCH v7 2/8] block: clarify context for refcount increment helpers Date: Fri, 19 Jun 2020 20:47:24 +0000 Message-Id: <20200619204730.26124-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20200619204730.26124-1-mcgrof@kernel.org> References: <20200619204730.26124-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7EA30180D0184 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Let us clarify the context under which the helpers to increment the refcount for the gendisk and request_queue can be called under. We make this explicit on the places where we may sleep with might_sleep(). We don't address the decrement context yet, as that needs some extra work and fixes, but will be addressed in the next patch. Reviewed-by: Christoph Hellwig Reviewed-by: Bart Van Assche Signed-off-by: Luis Chamberlain --- block/blk-core.c | 2 ++ block/genhd.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/block/blk-core.c b/block/blk-core.c index a0760aac110a..14c09daf55f3 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -610,6 +610,8 @@ EXPORT_SYMBOL(blk_alloc_queue); * @q: the request_queue structure to increment the refcount for * * Increment the refcount of the request_queue kobject. + * + * Context: Any context. */ bool blk_get_queue(struct request_queue *q) { diff --git a/block/genhd.c b/block/genhd.c index f741613d731f..1be86b1f43ec 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -985,11 +985,15 @@ static ssize_t disk_badblocks_store(struct device *= dev, * * This function gets the structure containing partitioning * information for the given device @devt. + * + * Context: can sleep */ struct gendisk *get_gendisk(dev_t devt, int *partno) { struct gendisk *disk =3D NULL; =20 + might_sleep(); + if (MAJOR(devt) !=3D BLOCK_EXT_MAJOR) { struct kobject *kobj; =20 @@ -1764,6 +1768,8 @@ EXPORT_SYMBOL(__alloc_disk_node); * * This increments the refcount for the struct gendisk, and the gendisk'= s * fops module owner. + * + * Context: Any context. */ struct kobject *get_disk_and_module(struct gendisk *disk) { --=20 2.26.2