Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2463612pxb; Fri, 5 Feb 2021 20:12:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEFIYv7qikQHlipgbOYvlWLb8O65EOfl7AhwA0uYnzG6M/b+ezeDJnFCEMNyE23Zbacz2R X-Received: by 2002:a50:ee10:: with SMTP id g16mr6778248eds.62.1612584760743; Fri, 05 Feb 2021 20:12:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612584760; cv=none; d=google.com; s=arc-20160816; b=ldt+TzeWJq7BD08M8Bx/I7lAdP9ssR3F4RhuA+zhO8K2ajAAYGzZwDG3A6SdGXPNbA LTYIicvQ4s2AmMyJau7InsWEecfGKgHGBXMVaewpPwzyo4+bGNn5UvSTgl2fbyrEsvzV yoWGJs/nT8Y90uY8TOCZ3ChKPRwRWxuKrwaKAFTDujWJoTmi2lo9SpllN+HjynGCp7X9 YXtGJR7sMDjQa6famuaRb1kVrqlGj8wEjE7E4dhajQq9plvTr4Tc52zVbSOUWK4aObwn lns8CvwDl+F85pTJdNHkhDEfTjhTc3tuNmzYrLn37Ng/ugvRmZk6R/k4HgHyZMhGgPDU +ejg== 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=aCJ5PaXDlTI4AjcUCXBQTCjHD7JcPX94ZBJxHdZFYJs=; b=l1E323UZK9kwkdoZ459z2wUAYmZEC/ZOq7YMhGhBR3PmMmHERTUxw0eShnDjp24/hn 0GJTEpempF6qxeCyiKoSKVxYOEh0GWR88y3slYa3sK+iST2d/hiNQQmRSFv4QoAM8XME uayUtwwr4MPKLoi4i41Ff6Vbrw3LtItL97ZC7wfCNAliEGY2MimyO2nXui+63HV0u0l6 xacufACf+ufELOxeBu78Eu5KyskCeQT5x+pcI/jAZwboX6vg+xH48t5A63dJAmxiTy4R TDFj8ObpLlRQS13FYfP0awrSwTlKr9h8GkxT1ulripm+MUQrf2ugxezUKGhd+B8/mL8N Mf8g== 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 o28si6600340edz.348.2021.02.05.20.12.16; Fri, 05 Feb 2021 20:12:40 -0800 (PST) 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 S229754AbhBFELl (ORCPT + 99 others); Fri, 5 Feb 2021 23:11:41 -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-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 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. 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, }; -- 2.29.2