Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3378405pxv; Mon, 12 Jul 2021 16:11:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyN2+0idbm3KgwOIgjJULFRBBsApK5yGv07Oq0VNKVi7RkJY1MdxR6SY1JJEIrnD1eS9KUj X-Received: by 2002:a17:906:6b1b:: with SMTP id q27mr1674688ejr.169.1626131485115; Mon, 12 Jul 2021 16:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626131485; cv=none; d=google.com; s=arc-20160816; b=E2rXm8cHvcryZMUXMutrgM5v3JzKccr7ZdgCMGyoAvGAv41yRUmWEFtrZ4N7firaXf wXZyj4x1ap09vXycfAMdGQJBFHjgSM2ZIDYh6KsPwSS14kDx9GkUIZGjPujwHSSACKrg dVlsKqbvlT9wk0VT3rPDkTFZeYKtNVK5OfPv1RpvF0LBEtqCGghMwvGhhzTT92wdlOhG OGzg534rHzgRnBee/DGDrQY8AwDaEqoYGfq0P8zdfo2MwS4oEK3sqftMiUQQWSnkQ/QR xm5L6Wtuy+vFqcSKaoBxS3/n8aykEh/gxfQsAqMX+/FLAjcMgWn0ICeFCI1khk3uu88e 7cqA== 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=EvP6Fne4aXdnLMlil8UuaLMPcQSUTlS5a68+UjZbj8g=; b=PX6I/hQl/pVxfU+HYJWUiUXAiUt85a0KJWIFK1L0Zyh/RonkEGgyVWwztZ58SA75l5 5HpZiGmlxBg4l12p2GL9LJdNFuJ/Ptmk10IVFsevH2UpV/cQZ0a6em2ScBBeFt7lRbM7 PhnrP61/R7GogjYWg5tT37RixRGpBzQmo8rHZOPOmXk5UPtgYsz0uwTjAlfdE6t7C2Fe xLuZ/xAMlWw4gee8ZwCBc/GUdXqiWC+Bt+WNvvBUP/eMt/QMrOxB47JHVxJem+wLo7gQ WN/4l3ZcmrDsxv8oTfmpK4ryxKR3VFbhhuHMSgc20lEIYPCyUi/tiKNyHLZfI7vNCvgh sC4A== 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 p20si18029320ejr.572.2021.07.12.16.11.00; Mon, 12 Jul 2021 16:11:25 -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 S233305AbhGLXKg (ORCPT + 99 others); Mon, 12 Jul 2021 19:10:36 -0400 Received: from mail-ej1-f49.google.com ([209.85.218.49]:47068 "EHLO mail-ej1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232724AbhGLXKf (ORCPT ); Mon, 12 Jul 2021 19:10:35 -0400 Received: by mail-ej1-f49.google.com with SMTP id c17so37697566ejk.13; Mon, 12 Jul 2021 16:07:45 -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=EvP6Fne4aXdnLMlil8UuaLMPcQSUTlS5a68+UjZbj8g=; b=R1+Np6xeQIQCyf++wiome/TkCh59O6XyRW9kg+WTgqflJ2grjXSsJfnQ361CDWdFK2 CMD7XyvKMfq+7no5Czlyhvb3OG9xsTCTKa9eX28LK8YWC9GrbEUioTjiokoS6UeaMGrw ye9LMPMTQh+SA/RzH03GEFLoAjeGEZ5jJx4xex8SwcIFcdn+KzsY7Q0CbdXg++oIU1nY GNliyvKV/G3hzt2XqaKLmuFsVwdta1eszBs4p9H9fe1hwjAosKgg3OP/DeZ+DiwP5V3b QqKCyarYLwDIo3CzpUYC8sBOzwqmrK8ZGc3bn9frEh40m8w8IaRX93akne5kBIMhBpOw nGwA== X-Gm-Message-State: AOAM532xlfp3bmU+waQD1okxYUiVCsN3TZ6Y5Zvz46ehJfifZV3UP7tD GC0ST4CsdED/t28qnI2akjK3lVZ2zZvlGA== X-Received: by 2002:a17:906:a18b:: with SMTP id s11mr1783529ejy.8.1626131264326; Mon, 12 Jul 2021 16:07:44 -0700 (PDT) Received: from msft-t490s.fritz.box (host-95-250-115-52.retail.telecomitalia.it. [95.250.115.52]) by smtp.gmail.com with ESMTPSA id h3sm5494111ejf.53.2021.07.12.16.07.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 16:07:43 -0700 (PDT) From: Matteo Croce To: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, Jens Axboe , Christoph Hellwig 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 , JeffleXu Subject: [PATCH v5 4/6] block: export diskseq in sysfs Date: Tue, 13 Jul 2021 01:05:28 +0200 Message-Id: <20210712230530.29323-5-mcroce@linux.microsoft.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210712230530.29323-1-mcroce@linux.microsoft.com> References: <20210712230530.29323-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 Reviewed-by: Christoph Hellwig Signed-off-by: Matteo Croce --- Documentation/ABI/testing/sysfs-block | 12 ++++++++++++ block/genhd.c | 10 ++++++++++ 2 files changed, 22 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 3126f8afe3b8..9ac41500caf9 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -985,6 +985,14 @@ static ssize_t disk_discard_alignment_show(struct device *dev, return sprintf(buf, "%d\n", queue_discard_alignment(disk->queue)); } +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 DEVICE_ATTR(range, 0444, disk_range_show, NULL); static DEVICE_ATTR(ext_range, 0444, disk_ext_range_show, NULL); static DEVICE_ATTR(removable, 0444, disk_removable_show, NULL); @@ -997,6 +1005,7 @@ static DEVICE_ATTR(capability, 0444, disk_capability_show, NULL); static DEVICE_ATTR(stat, 0444, part_stat_show, NULL); static DEVICE_ATTR(inflight, 0444, part_inflight_show, NULL); static DEVICE_ATTR(badblocks, 0644, disk_badblocks_show, disk_badblocks_store); +static DEVICE_ATTR(diskseq, 0444, diskseq_show, NULL); #ifdef CONFIG_FAIL_MAKE_REQUEST ssize_t part_fail_show(struct device *dev, @@ -1042,6 +1051,7 @@ static struct attribute *disk_attrs[] = { &dev_attr_events.attr, &dev_attr_events_async.attr, &dev_attr_events_poll_msecs.attr, + &dev_attr_diskseq.attr, #ifdef CONFIG_FAIL_MAKE_REQUEST &dev_attr_fail.attr, #endif -- 2.31.1