Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2194776/?format=api
{ "id": 2194776, "url": "http://patchwork.ozlabs.org/api/patches/2194776/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-ide/patch/20260209212151.342151-1-ipylypiv@google.com/", "project": { "id": 13, "url": "http://patchwork.ozlabs.org/api/projects/13/?format=api", "name": "Linux IDE development", "link_name": "linux-ide", "list_id": "linux-ide.vger.kernel.org", "list_email": "linux-ide@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260209212151.342151-1-ipylypiv@google.com>", "list_archive_url": null, "date": "2026-02-09T21:21:51", "name": "[v3] scsi: core: Add 'serial' sysfs attribute for SCSI/SATA", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "ae7871f7c6b67b5c3506842cec0f11e79edc0449", "submitter": { "id": 86149, "url": "http://patchwork.ozlabs.org/api/people/86149/?format=api", "name": "Igor Pylypiv", "email": "ipylypiv@google.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-ide/patch/20260209212151.342151-1-ipylypiv@google.com/mbox/", "series": [ { "id": 491571, "url": "http://patchwork.ozlabs.org/api/series/491571/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-ide/list/?series=491571", "date": "2026-02-09T21:21:51", "name": "[v3] scsi: core: Add 'serial' sysfs attribute for SCSI/SATA", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/491571/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2194776/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2194776/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <linux-ide+bounces-4996-incoming=patchwork.ozlabs.org@vger.kernel.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "linux-ide@vger.kernel.org" ], "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256\n header.s=20230601 header.b=TfmwBafU;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=linux-ide+bounces-4996-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)", "smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=google.com header.i=@google.com\n header.b=\"TfmwBafU\"", "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.216.74", "smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=google.com", "smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com" ], "Received": [ "from tor.lore.kernel.org (tor.lore.kernel.org\n [IPv6:2600:3c04:e001:36c::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4f8yMB2F7Cz1xvb\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 10 Feb 2026 08:22:14 +1100 (AEDT)", "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 67E803022575\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 9 Feb 2026 21:22:05 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 4D0AF3115B5;\n\tMon, 9 Feb 2026 21:21:59 +0000 (UTC)", "from mail-pj1-f74.google.com (mail-pj1-f74.google.com\n [209.85.216.74])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id AB6B230F7FE\n\tfor <linux-ide@vger.kernel.org>; Mon, 9 Feb 2026 21:21:55 +0000 (UTC)", "by mail-pj1-f74.google.com with SMTP id\n 98e67ed59e1d1-3562370038dso113511a91.3\n for <linux-ide@vger.kernel.org>; Mon, 09 Feb 2026 13:21:55 -0800 (PST)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1770672118; cv=none;\n b=tChfXWmLF5Rd+ykLUopFKcKpq9rsebGhd2kTUA4PAllF3zalGF+8SSKpmqMkmXDGvcHOuvUCxnoopC+ZMnZ7X3JxzSQDjyDleEU8AefvQAlK5V8OFNv+HR50gNJby2pd7vM3OcnPYxq08BU/MdI7lN1UqBMa9oCWx+3fK4eR9Z4=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1770672118; c=relaxed/simple;\n\tbh=jgWvaQR0EIAORcGXYrAtndNCUokb7X0l1Mv6K8fcCfw=;\n\th=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type;\n b=nsFvzvHSsOoIZun+sMUq3EYW3G0w3Ot18poAIPk9uQJavntJewWf1VxzwsB7yhJrn93lOHogrj0r34kVy+neIBIppiydU4Ha/HH5YYQeanUohUy+jOBbSPpQfXAaVRWvmbG8T3mb3yvTz9+6uQmVZc3AM65e8yVlf7qqZUR+ka0=", "ARC-Authentication-Results": "i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=google.com;\n spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com;\n dkim=pass (2048-bit key) header.d=google.com header.i=@google.com\n header.b=TfmwBafU; arc=none smtp.client-ip=209.85.216.74", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=google.com; s=20230601; t=1770672115; x=1771276915;\n darn=vger.kernel.org;\n h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject\n :date:message-id:reply-to;\n bh=GP/nw0GntmUv4Aco/T3zEuIFJQ9TGTiXcOsKoDvcON0=;\n b=TfmwBafUCrkX+YM3Ll28XgY7kMvPcbOkEbxESiS21BR7elgq/DWy9kkVcnssOhuLGE\n hoQuefTj5IDpdYhULy+RS8de5MCOQRsQ5JReVAo3y/771TVJjmMmrgPNuFTH2QG8P6oh\n a6x3nmuNeqFDQmdWcnwVyKiXyvOSSNjLjvNJ4vZf7NOy8Bf090u8kOArf5b7jzSdF4KS\n 3/Lv3OilEvJDe2OFPdCJP6CQyhitaMeLZ3OfqBNYCoDPLPZTeLSobcvj4RS5woyIZEsL\n nbSGh6/U+orO8Le+USD3hTlSv4o7UHBWY4QcS9ngkIjBNKY5/vieP+5TAIhIKfFqdX5n\n vKaA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1770672115; x=1771276915;\n h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state\n :from:to:cc:subject:date:message-id:reply-to;\n bh=GP/nw0GntmUv4Aco/T3zEuIFJQ9TGTiXcOsKoDvcON0=;\n b=wUMl89Xki5WF233YkLmMnrw2kmhgi5d3a0nrS7tOLnxCIt/nk5M+7expn54D72wOsZ\n qUrNyBls72d9lCzP7Kquc3amUEPdEMuZDhYxTHpf0YgkPEeKKblz6y9PLghjE4U4kQBl\n h2CWUXIOFjc62hkiCTPxMYkFdUZv8yyjO0kLCZ8NEjIxpBVOWYcYazERXzSiC35/wStc\n IiCBSYPvn90Q6z5IGes97nSfODHMuYQQgXhA+wgHUs5pXs4knLsWivovOuiBVOdfFy7/\n SqXR4VF2dSYNyqeEl/i8h9nLV8eSuFxkyj34FoZMF01DMjstLM+MH+2LYbgxgE7YVvDP\n Hq1Q==", "X-Forwarded-Encrypted": "i=1;\n AJvYcCXTjThKH3i8i3ZFemIWLm5A+wDKvqAjJwLoSMR5uU22x5hM8SRBQQa6IySR40X1c6Y2I3vRTwlwycc=@vger.kernel.org", "X-Gm-Message-State": "AOJu0YzURZzpkf0iHbJi/xqmlD5xcFZQ+XLcE4W/+MUV7jEVb9SGhie/\n\t2J4sTtmKLvWUkD6IP5Vt6xkuknaWJact9bsUwK+lU0IeMhmA+x0NLPGIC6+/HZcEdAx8QYgCxlP\n\tich1C/YRuohjvKA==", "X-Received": "from pjbst4.prod.google.com ([2002:a17:90b:1fc4:b0:356:2fe0:f5b4])\n (user=ipylypiv job=prod-delivery.src-stubby-dispatcher) by\n 2002:a17:90a:e7c3:b0:356:35a5:4a64 with SMTP id\n 98e67ed59e1d1-35635a5534fmr4964057a91.4.1770672114993;\n Mon, 09 Feb 2026 13:21:54 -0800 (PST)", "Date": "Mon, 9 Feb 2026 13:21:51 -0800", "Precedence": "bulk", "X-Mailing-List": "linux-ide@vger.kernel.org", "List-Id": "<linux-ide.vger.kernel.org>", "List-Subscribe": "<mailto:linux-ide+subscribe@vger.kernel.org>", "List-Unsubscribe": "<mailto:linux-ide+unsubscribe@vger.kernel.org>", "Mime-Version": "1.0", "X-Mailer": "git-send-email 2.53.0.rc2.204.g2597b5adb4-goog", "Message-ID": "<20260209212151.342151-1-ipylypiv@google.com>", "Subject": "[PATCH v3] scsi: core: Add 'serial' sysfs attribute for SCSI/SATA", "From": "Igor Pylypiv <ipylypiv@google.com>", "To": "\"James E.J. Bottomley\" <James.Bottomley@HansenPartnership.com>,\n\t\"Martin K. Petersen\" <martin.petersen@oracle.com>", "Cc": "Bart Van Assche <bvanassche@acm.org>, linux-scsi@vger.kernel.org,\n\tlinux-ide@vger.kernel.org, linux-kernel@vger.kernel.org,\n\tIgor Pylypiv <ipylypiv@google.com>", "Content-Type": "text/plain; charset=\"UTF-8\"" }, "content": "Add a 'serial' sysfs attribute for SCSI and SATA devices. This attribute\nexposes the Unit Serial Number, which is derived from the Device\nIdentification Vital Product Data (VPD) page 0x80.\n\nWhitespace is stripped from the retrieved serial number to handle\nthe different alignment (right-aligned for SCSI, potentially\nleft-aligned for SATA). As noted in SAT-5 10.5.3, \"Although SPC-5 defines\nthe PRODUCT SERIAL NUMBER field as right-aligned, ACS-5 does not require\nits SERIAL NUMBER field to be right-aligned. Therefore, right-alignment\nof the PRODUCT SERIAL NUMBER field for the translation is not assured.\"\n\nThis attribute is used by tools such as lsblk to display the serial\nnumber of block devices.\n\nSigned-off-by: Igor Pylypiv <ipylypiv@google.com>\n---\n\nv2->v3 changes:\n- Replaced sysfs_emit(buf, \"%s\\n\", buf) with a manual newline placement\n to avoid undefined behavior of passing the output buffer as an input.\n\nv1->v2 changes:\n- Reordered declarations in scsi_vpd_lun_serial() from longest to shortest.\n- Replaced rcu_read_lock()/rcu_read_unlock() with guard(rcu)().\n\n\n drivers/scsi/scsi_lib.c | 47 ++++++++++++++++++++++++++++++++++++++\n drivers/scsi/scsi_sysfs.c | 16 +++++++++++++\n include/scsi/scsi_device.h | 1 +\n 3 files changed, 64 insertions(+)", "diff": "diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c\nindex 4a902c9dfd8b..c17fbe4dd845 100644\n--- a/drivers/scsi/scsi_lib.c\n+++ b/drivers/scsi/scsi_lib.c\n@@ -13,6 +13,7 @@\n #include <linux/bitops.h>\n #include <linux/blkdev.h>\n #include <linux/completion.h>\n+#include <linux/ctype.h>\n #include <linux/kernel.h>\n #include <linux/export.h>\n #include <linux/init.h>\n@@ -3459,6 +3460,52 @@ int scsi_vpd_lun_id(struct scsi_device *sdev, char *id, size_t id_len)\n }\n EXPORT_SYMBOL(scsi_vpd_lun_id);\n \n+/**\n+ * scsi_vpd_lun_serial - return a unique device serial number\n+ * @sdev: SCSI device\n+ * @sn: buffer for the serial number\n+ * @sn_size: size of the buffer\n+ *\n+ * Copies the device serial number into @sn based on the information in\n+ * the VPD page 0x80 of the device. The string will be null terminated\n+ * and have leading and trailing whitespace stripped.\n+ *\n+ * Returns the length of the serial number or error on failure.\n+ */\n+int scsi_vpd_lun_serial(struct scsi_device *sdev, char *sn, size_t sn_size)\n+{\n+\tconst struct scsi_vpd *vpd_pg80;\n+\tconst unsigned char *d;\n+\tint len;\n+\n+\tguard(rcu)();\n+\tvpd_pg80 = rcu_dereference(sdev->vpd_pg80);\n+\tif (!vpd_pg80)\n+\t\treturn -ENXIO;\n+\n+\tlen = vpd_pg80->len - 4;\n+\td = vpd_pg80->data + 4;\n+\n+\t/* Skip leading spaces */\n+\twhile (len > 0 && isspace(*d)) {\n+\t\tlen--;\n+\t\td++;\n+\t}\n+\n+\t/* Skip trailing spaces */\n+\twhile (len > 0 && isspace(d[len - 1]))\n+\t\tlen--;\n+\n+\tif (sn_size < len + 1)\n+\t\treturn -EINVAL;\n+\n+\tmemcpy(sn, d, len);\n+\tsn[len] = '\\0';\n+\n+\treturn len;\n+}\n+EXPORT_SYMBOL(scsi_vpd_lun_serial);\n+\n /**\n * scsi_vpd_tpg_id - return a target port group identifier\n * @sdev: SCSI device\ndiff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c\nindex 99eb0a30df61..9c4f47e7a298 100644\n--- a/drivers/scsi/scsi_sysfs.c\n+++ b/drivers/scsi/scsi_sysfs.c\n@@ -1013,6 +1013,21 @@ sdev_show_wwid(struct device *dev, struct device_attribute *attr,\n }\n static DEVICE_ATTR(wwid, S_IRUGO, sdev_show_wwid, NULL);\n \n+static ssize_t\n+sdev_show_serial(struct device *dev, struct device_attribute *attr, char *buf)\n+{\n+\tstruct scsi_device *sdev = to_scsi_device(dev);\n+\tssize_t ret;\n+\n+\tret = scsi_vpd_lun_serial(sdev, buf, PAGE_SIZE);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tbuf[ret] = '\\n';\n+\treturn ret + 1;\n+}\n+static DEVICE_ATTR(serial, S_IRUGO, sdev_show_serial, NULL);\n+\n #define BLIST_FLAG_NAME(name)\t\t\t\t\t\\\n \t[const_ilog2((__force __u64)BLIST_##name)] = #name\n static const char *const sdev_bflags_name[] = {\n@@ -1257,6 +1272,7 @@ static struct attribute *scsi_sdev_attrs[] = {\n \t&dev_attr_device_busy.attr,\n \t&dev_attr_vendor.attr,\n \t&dev_attr_model.attr,\n+\t&dev_attr_serial.attr,\n \t&dev_attr_rev.attr,\n \t&dev_attr_rescan.attr,\n \t&dev_attr_delete.attr,\ndiff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h\nindex d32f5841f4f8..9c2a7bbe5891 100644\n--- a/include/scsi/scsi_device.h\n+++ b/include/scsi/scsi_device.h\n@@ -571,6 +571,7 @@ void scsi_put_internal_cmd(struct scsi_cmnd *scmd);\n extern void sdev_disable_disk_events(struct scsi_device *sdev);\n extern void sdev_enable_disk_events(struct scsi_device *sdev);\n extern int scsi_vpd_lun_id(struct scsi_device *, char *, size_t);\n+extern int scsi_vpd_lun_serial(struct scsi_device *, char *, size_t);\n extern int scsi_vpd_tpg_id(struct scsi_device *, int *);\n \n #ifdef CONFIG_PM\n", "prefixes": [ "v3" ] }