From patchwork Sat Feb 6 00:09:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matteo Croce X-Patchwork-Id: 12071813 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=unavailable 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 0688EC433E0 for ; Sat, 6 Feb 2021 03:17:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4E5F64EEC for ; Sat, 6 Feb 2021 03:17:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231522AbhBFDRC (ORCPT ); Fri, 5 Feb 2021 22:17:02 -0500 Received: from mail-wm1-f49.google.com ([209.85.128.49]:39342 "EHLO mail-wm1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232211AbhBFCzd (ORCPT ); Fri, 5 Feb 2021 21:55:33 -0500 Received: by mail-wm1-f49.google.com with SMTP id u14so7446042wmq.4; Fri, 05 Feb 2021 18:55:16 -0800 (PST) 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=aCJ5PaXDlTI4AjcUCXBQTCjHD7JcPX94ZBJxHdZFYJs=; b=q+EabVDft+zoeSQ23UoeV4vHAXE1pK811ECDaoNlarAnD4VrXeYHR1CPrxjYKVDF+J sW+ZD37+Vcecr2nLip5DtmNkLcCb9PYaRvmw2Irj9HXlAngFfuYfj+boBRMCV0+95pEB aqrjefR0PcHEqFEiuiOMAFIx6sqY8jptoJVijO7EOJr2Ls2kKB8k2SMWS879C2+jlWZ4 1ER4QwE5IbmiWdUzBE7Etk/QBPYXTSd576bsm1LD82DpWyqdCxBabeXluhprmleh8M+x QjtrpefifQH92WslSISQqkh3Q8QZJ3Rkkz173LY0WlGwH3Wg5jDAhrCgoAxa7ySLL8Dg rVSQ== X-Gm-Message-State: AOAM532bSE+ahezXE2yhxIzC6qRb/1k42w+KnHs3+LLqesqF3bNJ8mTi jZJ+iVCzJJjJ0E2FmwUiKi1X6T5IjoA= X-Google-Smtp-Source: ABdhPJx7aqDZs1uXhcmo/ZfRQRW7gg++4yuzlD1SZ+jzLQ7pwK52YYcGgJWxOjbdbuPtsMr5bMSAow== X-Received: by 2002:a05:600c:4f8b:: with SMTP id n11mr5472818wmq.160.1612570388879; Fri, 05 Feb 2021 16:13:08 -0800 (PST) Received: from msft-t490s.teknoraver.net (net-37-182-2-234.cust.vodafonedsl.it. [37.182.2.234]) by smtp.gmail.com with ESMTPSA id d3sm14566390wrp.79.2021.02.05.16.13.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 16:13:08 -0800 (PST) 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 Subject: [PATCH 4/5] block: export diskseq in sysfs Date: Sat, 6 Feb 2021 01:09:02 +0100 Message-Id: <20210206000903.215028-5-mcroce@linux.microsoft.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210206000903.215028-1-mcroce@linux.microsoft.com> References: <20210206000903.215028-1-mcroce@linux.microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Matteo Croce Add a new sysfs handle to export the new diskseq value. Place it in /block//diskseq and document it. Signed-off-by: Matteo Croce --- Documentation/ABI/testing/sysfs-block | 12 ++++++++++++ block/genhd.c | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-block b/Documentation/ABI/testing/sysfs-block index e34cdeeeb9d4..a0ed87386639 100644 --- a/Documentation/ABI/testing/sysfs-block +++ b/Documentation/ABI/testing/sysfs-block @@ -28,6 +28,18 @@ Description: For more details refer Documentation/admin-guide/iostats.rst +What: /sys/block//diskseq +Date: February 2021 +Contact: Matteo Croce +Description: + The /sys/block//diskseq files reports the disk + sequence number, which is a monotonically increasing + number assigned to every drive. + Some devices, like the loop device, refresh such number + every time the backing file is changed. + The value type is 64 bit unsigned. + + What: /sys/block///stat Date: February 2008 Contact: Jerome Marchand diff --git a/block/genhd.c b/block/genhd.c index a59a35cf452c..1aedd4fab6f3 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1975,6 +1975,7 @@ static void disk_check_events(struct disk_events *ev, * events_async : list of events which can be detected w/o polling * (always empty, only for backwards compatibility) * events_poll_msecs : polling interval, 0: disable, -1: system default + * diskseq : disk sequence number, since boot */ static ssize_t __disk_events_show(unsigned int events, char *buf) { @@ -2045,16 +2046,26 @@ static ssize_t disk_events_poll_msecs_store(struct device *dev, return count; } +static ssize_t diskseq_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct gendisk *disk = dev_to_disk(dev); + + return sprintf(buf, "%llu\n", disk->diskseq); +} + static const DEVICE_ATTR(events, 0444, disk_events_show, NULL); static const DEVICE_ATTR(events_async, 0444, disk_events_async_show, NULL); static const DEVICE_ATTR(events_poll_msecs, 0644, disk_events_poll_msecs_show, disk_events_poll_msecs_store); +static const DEVICE_ATTR(diskseq, 0444, diskseq_show, NULL); static const struct attribute *disk_sysfs_attrs[] = { &dev_attr_events.attr, &dev_attr_events_async.attr, &dev_attr_events_poll_msecs.attr, + &dev_attr_diskseq.attr, NULL, };