Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp801961pxj; Thu, 20 May 2021 22:53:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyU3qLrcDBU0IPjgGOCrwU6Hy1oLd9roe1/Zrxa9xw4ThGRiO8Hae9jVvw4rChxS4cUpM1f X-Received: by 2002:a05:6402:5a:: with SMTP id f26mr9190584edu.306.1621576428651; Thu, 20 May 2021 22:53:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621576428; cv=none; d=google.com; s=arc-20160816; b=DO1nr+1UQKCiWPW4uk3+IWHW/2j7MXTPxUYAXlE6x1oU8yOT5HSzB2huFF4UWNgiUt 3uU6p1o+8vbofVNrZJtXyHrz3bKgVpC7x1Dbn56H9A8TXgKKNGRZyTzxrottqCi1cxOP qZT7ADvLCFT+5doPLWvI5kA6qKs/WN6m8G/wmYPR/I+YYx0+Z5j3P/UBPt+gJl1xWLOl CqDjuDvIwLzzL0ZnkfVcg7Cp1PbEen6ZocFFYwDT9Epn3EqWFB6kB0tgKl+qMGh/Gwqo vbMWNsnuE/kor2RVV/0BeoPnUpo1ibbt4iS35N9VR+pdN3y1UALx+sJyPCBAw02UuDlk ZPdg== 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=M/6Asmzm9q2pjoZlswx9y5LN/G6/90yiJ/pdetWstA8=; b=rbbMupEqOWTbAoDbDA4E2MWQ+yopER085wP5r6rmrwmavC0SO0luM71P4PnS/67X5M 6RoQyydodcYFjJdoNegtYnEMLjuEniGgpcHfcKgwflP5wtZ3YqynWLRUg1G14gV6NDVt /NfJUaQFuzEa7xQ9IhEGmKnevyDPUcUrwLuEoE7oJ9m7PdSA6tNp4zXcYBNmuvFUoZQ8 r4Iv6jWME5nOkV3kT8yAUWD15BKX4MD0Sv5+DfDgF+HWtxo/rNS6T5t4PTpinpUrMVOU PMCNcs48Sq16VlVumH42s5onjEG9Lo93uE05sy14IovyIZvSOClRwmFlxcBZsxXzsR4d 9H3w== 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 hp18si3159532ejc.718.2021.05.20.22.53.25; Thu, 20 May 2021 22:53:48 -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 S239734AbhETOCB (ORCPT + 99 others); Thu, 20 May 2021 10:02:01 -0400 Received: from mail-ej1-f48.google.com ([209.85.218.48]:35681 "EHLO mail-ej1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243534AbhETOAC (ORCPT ); Thu, 20 May 2021 10:00:02 -0400 Received: by mail-ej1-f48.google.com with SMTP id k14so21992470eji.2; Thu, 20 May 2021 06:58:39 -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=M/6Asmzm9q2pjoZlswx9y5LN/G6/90yiJ/pdetWstA8=; b=V2LagRhlLpm95kxga/7nF3xvHwTZg769xIYp5tClrh4EtXQmCwl4e0/A23RFZrA21b 1eQO1bcgqEkCfFfnImYNE7h4R9DnUANxJ4UF2ExBfGpDfQfFw3DJm3dohdhDb1oVJ9Mf qr45QObuEuYQighxPy9/R1UhtTUqdj4DRBKToeEccPjm3YvXkZLjz3s+MTFpa/qsfUE3 4vhaebF7WPU5SUQobB7cdU/qtSTuVD3cwpkfhXYzA30hQFBYFWpVGj7Eo6/NrHfCiNMe rtE6te6twxAAyjMstL1dJLhd+9NmnKnQusLr4ufI1wxG0WaiQZlePYTOVeCr4+jmp0Uo WBFA== X-Gm-Message-State: AOAM532wBHucOjZgePL6ItykRRi1YF6RuCDaO8cJmoR4y84FymT2Z0qS 66tKncYnN711EAyjP++5HmYuw+vtGaT6ys9R X-Received: by 2002:a17:906:e096:: with SMTP id gh22mr4860444ejb.101.1621519118504; Thu, 20 May 2021 06:58:38 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 06:58:37 -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=20Gonz=C3=A1lez?= , Niklas Cassel , Johannes Thumshirn , Hannes Reinecke , Matthew Wilcox , Christoph Hellwig , JeffleXu Subject: [PATCH v2 4/6] block: export diskseq in sysfs Date: Thu, 20 May 2021 15:56:20 +0200 Message-Id: <20210520135622.44625-5-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 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 417dd5666be5..67519c034f9f 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1689,6 +1689,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) { @@ -1759,16 +1760,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