Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5554913pxj; Wed, 23 Jun 2021 04:02:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfZImpgSmSWEt4T/R+yyRmGiXHLTHIFHHvpUGIeGVn+D8G11WiTjNX8gwPfvNnNWjVFGWJ X-Received: by 2002:aa7:d3c2:: with SMTP id o2mr11581321edr.358.1624446138079; Wed, 23 Jun 2021 04:02:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624446138; cv=none; d=google.com; s=arc-20160816; b=wN0hv6feivyKwg1XSKZ/GVqa8j5TCfWz+I48n7YuUHdni5kVs8rXR06/PUYxNSUO0t cazEOxsmd4z7ldyDNPg5m7jTbhjNIdVL+idvZEa1lM8MNTrRZtr7tsjckaINomv0zKLK lXNbrII28A3hpS1QMypqrIWcN+98TFYjoQqEVVnWyd6kRS996Vf0AayDk+9UxDpWvt9q 6KFMp1xijaIcJ8vVkdA+qqZkBRET6lp4+hZNlPaVIbUuEke7p6lGjMvK3ZrKABj/7EBW MC3hRtP/bRhHKzlFWNdsFVQgyqJU8LOY29LGjy/QwiN+jBpsi9HVgYmcTehHgqHGSnjU JQ2w== 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; bh=BlKb/nN8ZAtxyPllpUsysxr5X0Gh4ewsJLKk2TVLQgg=; b=EcSl2lcJpjtDeyRruHBGSQ2+xFnx+0umvN1kXSG377Bz2FD+HiMnhEaNIN0/7rOQHf U29QW3HGbFaR4Cmn4xNZ85M1H7rGup8XtBA/rC3K9idPbnD7MZbE9ekEGG2qVHv4CJon 72U/z0JODO/H+Jd8awxZeJyOo8XyN+6OurHB0R8QxVfyKiKuJZDX7naSXHvi7+qaAYXF +oEYuY0p1yc55wGyl44xD/P8zsL6hiH12ZGsjbqazwCH4lCLP3loevQd38Yx/caPwZf9 4/fdcEWS6bOOXPPc+xSpNah1qbHvq+uUNTqdcWURIl3yP6c4hLZILpt/wZZTrKjVhF9k wW/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w12si669725edc.87.2021.06.23.04.01.55; Wed, 23 Jun 2021 04:02:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230170AbhFWLCS (ORCPT + 99 others); Wed, 23 Jun 2021 07:02:18 -0400 Received: from mail-wr1-f46.google.com ([209.85.221.46]:35722 "EHLO mail-wr1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230288AbhFWLCO (ORCPT ); Wed, 23 Jun 2021 07:02:14 -0400 Received: by mail-wr1-f46.google.com with SMTP id m18so2159729wrv.2; Wed, 23 Jun 2021 03:59:55 -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=BlKb/nN8ZAtxyPllpUsysxr5X0Gh4ewsJLKk2TVLQgg=; b=b4ZiE42tBgTTQbFpdBrnf6c1kLeydm/34NTulrKfTQt7xxAwMoz5E46UwuYb1Brwgh 0ooto5QMHhPS1Q5d1PXePsJOwqDGjUJUCBji5QcX+NdPsD4A97WsCeTEk9COOPcCL1aB kaNw2jF+Kj/5BuZ/zeXoTCsx6D09Mv5JO4RR70thqx2iuHDKU0f0NM2aRQvnSsRbppwO EyJREblRGI7Uy5+zpua2/capfAr6LKfHB9A02dFUoTgFfR2zKsu1LbbqG9IbeCSc5o01 g92OkIumMX8ZWGMlcEm2VHxw9FRnlo9/fBrYyD3eXJ5NvyTjWZCypbikgDMk2E6RCk9k s8pg== X-Gm-Message-State: AOAM5307OtHm6Cm/VSoFBgC33Gd16nObRowUL1SeQxyOYDr48kByc6uy KUs4e1aVqSHxkDG0ctLQ9MA6sC/Qv+Rc5Q== X-Received: by 2002:a5d:69cb:: with SMTP id s11mr10905377wrw.240.1624445995119; Wed, 23 Jun 2021 03:59:55 -0700 (PDT) Received: from msft-t490s.. (mob-176-246-29-26.net.vodafone.it. [176.246.29.26]) by smtp.gmail.com with ESMTPSA id r2sm2659458wrv.39.2021.06.23.03.59.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 03:59:54 -0700 (PDT) From: Matteo Croce To: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, Jens Axboe Cc: linux-kernel@vger.kernel.org, Lennart Poettering , Luca Boccassi , Alexander Viro , Damien Le Moal , Tejun Heo , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , Niklas Cassel , Johannes Thumshirn , Hannes Reinecke , Matthew Wilcox , Christoph Hellwig , JeffleXu Subject: [PATCH v3 4/6] block: export diskseq in sysfs Date: Wed, 23 Jun 2021 12:58:56 +0200 Message-Id: <20210623105858.6978-5-mcroce@linux.microsoft.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210623105858.6978-1-mcroce@linux.microsoft.com> References: <20210623105858.6978-1-mcroce@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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. $ grep . /sys/class/block/*/diskseq /sys/class/block/loop0/diskseq:13 /sys/class/block/loop1/diskseq:14 /sys/class/block/loop2/diskseq:5 /sys/class/block/loop3/diskseq:6 /sys/class/block/ram0/diskseq:1 /sys/class/block/ram1/diskseq:2 /sys/class/block/vda/diskseq:7 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 610dd86fd4b6..768d8d5d1eca 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1680,6 +1680,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) { @@ -1750,16 +1751,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, }; -- 2.31.1