From patchwork Thu Jan 26 03:33:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Demi Marie Obenour X-Patchwork-Id: 48488 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp77291wrn; Wed, 25 Jan 2023 19:43:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXst6bx5Yl8uAxLHzNqkJFPwCoNY/Tubg/sSYNblLKj9lKr0k3ZZz9+e/y9MwfXozSHsXxdm X-Received: by 2002:a17:906:25db:b0:877:6a03:9ad1 with SMTP id n27-20020a17090625db00b008776a039ad1mr24477236ejb.7.1674704629541; Wed, 25 Jan 2023 19:43:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674704629; cv=none; d=google.com; s=arc-20160816; b=B0rh2PohZYrOjTg4c2K6RXtTe7nniTg/TxuxyPB9A9bGZvvsmLMW4ze6iRb4lzPn1O h9ZVq5+wwX6ZEwAAb56adD6LcQRSM9oA0+gFnUA03J2PqxIZ+Lhes0ZjQoxmczdAY9se rGY7FS+DkhnFL3UWclY0Gd1otBEEKVGYWAJ/o7wvwNyNRcGkRfh5yrUDx3YqzGRpD2R9 HUvgjgdKbIIixbKW4ZTdVlClOBXp4Xfh/zLAp6kRt1OGr5s+c7rKkb2wMYtYUVEMxpfC mzyx96diy0kb4kso/M+fSuBrGSba4UFzl9RKQXDX8/XFgBJriO6kw0iQ3q0FUruh/YMr Wqew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=z0ynB5y0JUWTzScYTn7Q3OC3bp6u5sO9TqW4X6XkP2I=; b=DsBv/KI2CtTLJGCLAsu2otCZ7Ywyct1tu9cwaHSgUPy9DlZWMLLgK3EJeaNEUWdv3x +tTo7HrzI77mwXNJT+EPMFgGEZeOJDoxhJ4uvKOPG6CiomjyKsTkKzVSBH0d7USgOpha E73PLjOSUYYmkxMdAPX6SFuozB2/DY5vqlNITMOcrSZfWPLBAY/zdnmI3FxTmEFE7DL4 FHf2vl/CofLTnPM7Vrmo4kEB8vUwwyXqj9LOCRkhuFFB6l/lHI4DIDAawHaOa0lkvHH2 gSElCZiUA+9EMk9aNdqx5ELXhDLRWOWNCDExBwH1Zzyypps1/6bbZyMELcpUQ2klLHbG HgTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@invisiblethingslab.com header.s=fm3 header.b=hDNnUBhG; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=UwYtMTzI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fb22-20020a1709073a1600b008778979370csi8285750ejc.405.2023.01.25.19.43.26; Wed, 25 Jan 2023 19:43:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@invisiblethingslab.com header.s=fm3 header.b=hDNnUBhG; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=UwYtMTzI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236496AbjAZDee (ORCPT + 99 others); Wed, 25 Jan 2023 22:34:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236334AbjAZDeV (ORCPT ); Wed, 25 Jan 2023 22:34:21 -0500 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0753266010; Wed, 25 Jan 2023 19:34:16 -0800 (PST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 695895C0153; Wed, 25 Jan 2023 22:34:15 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 25 Jan 2023 22:34:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= invisiblethingslab.com; h=cc:cc:content-transfer-encoding:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1674704055; x=1674790455; bh=z0ynB5y0JUWTzScYTn7Q3OC3bp6u5sO9TqW 4X6XkP2I=; b=hDNnUBhGT+NH0/s8SzP4A/3FBNKtiCW9hYWlUgoQd/BgGqFxmBw T+0KEanvu5FC+5O92YvKLmMsPEXXNFyNawzj0hha/x36KwNWzZWXlW/uegUZR0Rz UPdQL6Lr0w21Hua7wVFE4b3GlOvehj17ZeT8WkntOH1Ky5rlufJZHBXw+nm3bekX F4MdItj5G2q3DUnlj23e6vNfzs8LU7G0Roy/hJxJ1Yf2ty3OAv7FW3167lWjCaB1 0cfltfv/ikJqKZoZ4v+u8LkUO8Z8qgxpvpQmzV95N+Dy3VF2UCL3B84Ubrj1tIBu Alo7F8zKTdhI7u7YcaQlOStO+1Lwk8jEAcA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1674704055; x=1674790455; bh=z0ynB5y0JUWTz ScYTn7Q3OC3bp6u5sO9TqW4X6XkP2I=; b=UwYtMTzIn2dV76r8isxyffojuG/6+ xpE20r3t5Tb0AA+fr1wsYXnZVK9V1cj0DE+DY0wgKbssMvWz1a0VK9v64km05Pt4 dgkcU2wcGDbA3YMTHkA7ofwKICbXPw1Ll4eryaKXva6VqGJNX1gPUABv1RogXQLN cFpiq6bY9ehiJL0e0WnTt4oTgdMY6Psd5Q+K42+k8T1nlLOsibi3ySD5qEgo0nl5 VcHAhqRbmwBSw2KwPhfj6caZ5jKDvg5sVbEnH8uu39ZqRzraxrZOehrpqOTeOKQc Aw4Qlr+3RUfs1mzUjB2f/5vStJaDB2HwFgMgRWG7qiXfzjtCSLoyw2obw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedruddvfedgheelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepffgvmhhi ucforghrihgvucfqsggvnhhouhhruceouggvmhhisehinhhvihhsihgslhgvthhhihhngh hslhgrsgdrtghomheqnecuggftrfgrthhtvghrnhepjeffjefggfeugeduvedvjeekgfeh gffhhfffjeetkeelueefffetfffhtdduheetnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepuggvmhhisehinhhvihhsihgslhgvthhhihhnghhs lhgrsgdrtghomh X-ME-Proxy: Feedback-ID: iac594737:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 25 Jan 2023 22:34:14 -0500 (EST) From: Demi Marie Obenour To: Jens Axboe Cc: Demi Marie Obenour , =?utf-8?q?Marek_Marczy?= =?utf-8?q?kowski-G=C3=B3recki?= , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 4/7] Increment diskseq when releasing a loop device Date: Wed, 25 Jan 2023 22:33:56 -0500 Message-Id: <20230126033358.1880-5-demi@invisiblethingslab.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126033358.1880-1-demi@invisiblethingslab.com> References: <20230126033358.1880-1-demi@invisiblethingslab.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756055081331595619?= X-GMAIL-MSGID: =?utf-8?q?1756055081331595619?= This ensures that userspace is aware that the device may now point to something else. Signed-off-by: Demi Marie Obenour --- block/genhd.c | 1 + drivers/block/loop.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/block/genhd.c b/block/genhd.c index 23cf83b3331cdea5c916fbf01cb5b92aeb2f7cf8..5bf7664273c66d04b40730434f17f7b65fbfe101 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1490,3 +1490,4 @@ void inc_diskseq(struct gendisk *disk) { disk->diskseq = atomic64_inc_return(&diskseq); } +EXPORT_SYMBOL(inc_diskseq); diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 1518a6423279bc890221e8184a8f2e420cb16715..f862b0ab1dce43b3617b1381be8e2de3aab828b1 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1205,6 +1205,12 @@ static void __loop_clr_fd(struct loop_device *lo, bool release) if (!part_shift) set_bit(GD_SUPPRESS_PART_SCAN, &lo->lo_disk->state); mutex_lock(&lo->lo_mutex); + + /* + * Increment the disk sequence number, so that userspace knows this + * device now points to something else. + */ + inc_diskseq(lo->lo_disk); lo->lo_state = Lo_unbound; mutex_unlock(&lo->lo_mutex);