Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2456455pxb; Fri, 5 Feb 2021 19:57:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxKALemKT7nJFVd1IeUGczIpV6V5gu1UEZGGRzq2rCTnpvbuOzlbJj6ai/OJp6fRnWn/gDX X-Received: by 2002:a17:906:1d0f:: with SMTP id n15mr6800602ejh.26.1612583842078; Fri, 05 Feb 2021 19:57:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612583842; cv=none; d=google.com; s=arc-20160816; b=ucPyyp2UpGl+b76A7qlz6VCvggosrqty+AYRx4oZ/RSS/yrlo8uSTATG8NziyenKyR gQDgb93kdmEki4Z22TUIU32Pt8kCWF7Msm0ieLCadQ3psV6yl77C3zQyalkFtG6Nlc/t bwwEaSETMtjaKFNLzD20Je9NuPGNUdUdZE6aG1zW3Wi8xsCCloyx23U/5CwXZvDI45wZ UKneNUJBXgIEUX0iIO+BzcqJgaaW0mvvaHKygOU8ry5d8Gx2OefJHU11WpVmlXiaBrAr idahdSg/lc9EhDt+nM9jVuQ7JgxJkAxoppTKcULPErroSTNBAE7Yby/zFzPHDtBZkgZB 3wng== 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 :message-id:date:subject:cc:to:from; bh=AYoAF7gPgCmz0hFYeiRmD4lOmSaTwA1DbF9cbEqAcQ0=; b=fmLL9+p5i6ZfKlwryEA07Izgaw7npveJ0BuBL00/b551KwY1qUzPf1/xzHcdZnXiIL zHxG+zaf4hAcZP0ur0AJ7r5KaTqH8LJiRdqSbf6wh5XmELhBKSC/zfH+wsj2qMBHH0Dj n1uoHA275aF8y7e+tF1nFaL2/0AO1Oc9JjHp19FKQA25J2H8/vFiqbFTrnutGxzgw3Gm e0fsOU+2x6HndCJxeqUnNUj7ZxVHg3aLR72ksH5ZExSZfgWGLW2uCn/arg2PBasAPD3P 4XcoLVOTpHKXqTIrcHecKiVQDl+lXYjz0QGi5WDDkr/Mn8synDmNCNk3CGX8DGikAkT9 Fcfg== 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 ci1si6332667ejc.348.2021.02.05.19.56.57; Fri, 05 Feb 2021 19:57:22 -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 S231142AbhBFDyN (ORCPT + 99 others); Fri, 5 Feb 2021 22:54:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231648AbhBFCwv (ORCPT ); Fri, 5 Feb 2021 21:52:51 -0500 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C7BBC033275; Fri, 5 Feb 2021 17:26:54 -0800 (PST) Received: by mail-lf1-x12b.google.com with SMTP id a8so12786755lfi.8; Fri, 05 Feb 2021 17:26:54 -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:mime-version :content-transfer-encoding; bh=AYoAF7gPgCmz0hFYeiRmD4lOmSaTwA1DbF9cbEqAcQ0=; b=ie63wiewQTPFO5AyrseRnYIWAna3cvOcmTRM5ltEPbD/emfDeZilCvFSRht467yRcU ZEB6fBxFTpZEoCOnKTGrp9PBRcBCX3ds2VEpVtxD65Iazdpv8z+lAVJmFOfJgoYTkUg2 AVJyZJLnX4OYRbYlHYVeuO7tRizj+wEnCT69pI745LhjTB0wyk69MifKgYNnKyMTa10r udJG6kPRhuAJbQoryGMdbrSF1fFeiZXSd/+do9GOTUK6XdDnIh1Behu/KA/ndg1Zd2r7 jVtx9qjqZi8M5yYCCSkxAmC8ul2LD8nDoNeQUkYReihA75x6X6dfGPSdpmTWbWuJVDNP owLw== X-Gm-Message-State: AOAM531BqxcM1IzhRPKa5mHXDJEWIaJvx8RUP8VZJOtFUr63kUX1MBAc H2Q8iiwZ9A1OrPRYmaZWTNezPSIHBBc= X-Received: by 2002:a5d:49c1:: with SMTP id t1mr7634170wrs.56.1612570147262; Fri, 05 Feb 2021 16:09:07 -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.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 16:09:06 -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 0/5] block: add a sequence number to disks Date: Sat, 6 Feb 2021 01:08:58 +0100 Message-Id: <20210206000903.215028-1-mcroce@linux.microsoft.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matteo Croce With this series a monotonically increasing number is added to disks, precisely in the genhd struct, and it's exported in sysfs and uevent. This helps the userspace correlate events for devices that reuse the same device, like loop. The first patch is the core one, the 2..4 expose the information in different ways, while the last one increase the sequence number for loop devices at every attach. # udevadm monitor -kp |grep -e ^DEVNAME -e ^DISKSEQ & [1] 523 # losetup -fP 3part [ 3698.615848] loop0: detected capacity change from 16384 to 0 DEVNAME=/dev/loop0 DISKSEQ=13 [ 3698.647189] loop0: p1 p2 p3 DEVNAME=/dev/loop0 DISKSEQ=13 DEVNAME=/dev/loop0p1 DISKSEQ=13 DEVNAME=/dev/loop0p2 DISKSEQ=13 DEVNAME=/dev/loop0p3 DISKSEQ=13 # losetup -fP 2part [ 3705.170766] loop1: detected capacity change from 40960 to 0 DEVNAME=/dev/loop1 DISKSEQ=14 [ 3705.247280] loop1: p1 p2 DEVNAME=/dev/loop1 DISKSEQ=14 DEVNAME=/dev/loop1p1 DISKSEQ=14 DEVNAME=/dev/loop1p2 DISKSEQ=14 # ./getdiskseq /dev/loop* /dev/loop0: 13 /dev/loop0p1: 13 /dev/loop0p2: 13 /dev/loop0p3: 13 /dev/loop1: 14 /dev/loop1p1: 14 /dev/loop1p2: 14 /dev/loop2: 5 /dev/loop3: 6 /dev/loop-control: Function not implemented # 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 If merged, this feature will immediately used by the userspace: https://github.com/systemd/systemd/issues/17469#issuecomment-762919781 Matteo Croce (5): block: add disk sequence number block: add ioctl to read the disk sequence number block: refactor sysfs code block: export diskseq in sysfs loop: increment sequence number Documentation/ABI/testing/sysfs-block | 12 ++++++++ block/genhd.c | 43 ++++++++++++++++++++++++--- block/ioctl.c | 2 ++ drivers/block/loop.c | 3 ++ include/linux/genhd.h | 2 ++ include/uapi/linux/fs.h | 1 + 6 files changed, 59 insertions(+), 4 deletions(-) -- 2.29.2