From patchwork Thu May 20 13:56:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matteo Croce X-Patchwork-Id: 12270369 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 906E8C43470 for ; Thu, 20 May 2021 13:59:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 555AB613CA for ; Thu, 20 May 2021 13:59:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240011AbhETOBQ (ORCPT ); Thu, 20 May 2021 10:01:16 -0400 Received: from mail-ed1-f51.google.com ([209.85.208.51]:40917 "EHLO mail-ed1-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243546AbhETOAF (ORCPT ); Thu, 20 May 2021 10:00:05 -0400 Received: by mail-ed1-f51.google.com with SMTP id t3so19501101edc.7; Thu, 20 May 2021 06:58:44 -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=KtlDwB3yEpx8TeFOnWtic2oPG9XbfzOFhlQoKOiiSos=; b=L9+OgeYXZXOUAnxXmDaQ7TiacMKMfHybau048JM+ce6ZDq56WlmVRcAEH4C4UV2Scq ZMclq2iyogJs/0PIn105fN0XEeIj8tRDbPAmEN/7mvSoEgRdKboUtaE4BWix4Dtspb0O EJ45R+GBapfzT/J98XiCh1RVP698YHnjxamvqyesP8qFN8+yajWfxPiXIn8rJ434lVL1 Khr4/OClW7FCt+KU2La1J4PkpDNYXT/i0wEQmobv3yr3ccVokd6bvnkwIXBXTPJ9WSkq q0X/wyWtJFTtQF/dMo9vOggs4wPLTqQaSeafhbSoqPN9bJEh1lA3QKdddrfsVq8bX/ii EATQ== X-Gm-Message-State: AOAM5302Rh82lHi0KIjQGfLXMMBS2QYEvJZWpuc16kmLr53CyD4U6iKm X2UvDBSP6x156QDE9SRSXwyV4va0JVBna+sE X-Google-Smtp-Source: ABdhPJzyZajk10SLdiMnhCpzUy1ZNox8Rmvv7xIIn3LrC0A4+H10JVykOD0mYkXIzmX/MxKAg6XTJw== X-Received: by 2002:a05:6402:3511:: with SMTP id b17mr5084804edd.71.1621519122543; Thu, 20 May 2021 06:58:42 -0700 (PDT) Received: from msft-t490s.teknoraver.net (net-5-94-253-60.cust.vodafonedsl.it. [5.94.253.60]) by smtp.gmail.com with ESMTPSA id 9sm1434492ejv.73.2021.05.20.06.58.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 06:58:42 -0700 (PDT) From: Matteo Croce To: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Lennart Poettering , Luca Boccassi , Jens Axboe , Alexander Viro , Damien Le Moal , Tejun Heo , =?utf-8?q?Javier_Gonz=C3=A1lez?= , Niklas Cassel , Johannes Thumshirn , Hannes Reinecke , Matthew Wilcox , Christoph Hellwig , JeffleXu Subject: [PATCH v2 5/6] block: increment sequence number Date: Thu, 20 May 2021 15:56:21 +0200 Message-Id: <20210520135622.44625-6-mcroce@linux.microsoft.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520135622.44625-1-mcroce@linux.microsoft.com> References: <20210520135622.44625-1-mcroce@linux.microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Matteo Croce Increment the disk sequence number when the media has changed, i.e. on DISK_EVENT_MEDIA_CHANGE event. $ cat /sys/class/block/sr0/diskseq 12 $ eject $ cat /sys/class/block/sr0/diskseq 22 Signed-off-by: Matteo Croce --- block/genhd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/genhd.c b/block/genhd.c index 67519c034f9f..5bc6b6c248c4 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1666,6 +1666,9 @@ static void disk_check_events(struct disk_events *ev, spin_unlock_irq(&ev->lock); + if (events & DISK_EVENT_MEDIA_CHANGE) + inc_diskseq(disk); + /* * Tell userland about new events. Only the events listed in * @disk->events are reported, and only if DISK_EVENT_FLAG_UEVENT