Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752094AbdGAAlk (ORCPT ); Fri, 30 Jun 2017 20:41:40 -0400 Received: from g4t3427.houston.hpe.com ([15.241.140.73]:16397 "EHLO g4t3427.houston.hpe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751680AbdGAAli (ORCPT ); Fri, 30 Jun 2017 20:41:38 -0400 From: "Kani, Toshimitsu" To: Dan Williams CC: Vishal L Verma , "Knippers, Linda" , "linux-nvdimm@lists.01.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH v2] libnvdimm, pmem: Add sysfs notifications to badblocks Thread-Topic: [PATCH v2] libnvdimm, pmem: Add sysfs notifications to badblocks Thread-Index: AQHS48rXHia2DqmigUe4/diXsaUyG6I9uY6AgACDKwA= Date: Sat, 1 Jul 2017 00:41:32 +0000 Message-ID: References: <20170612222511.22030-1-toshi.kani@hpe.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=hpe.com; x-originating-ip: [202.216.21.108] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DF4PR84MB0075;7:zo49v7K3iiD77S9LWjMuIW0L8AtT6bevHHgZo9rRyKydydZhKgUMLyRsSlIbeOEQ67113GKAUnYgTJ9i9c0iCmp69ldU2sTl9E7EOArhTjG9cLEamdnh/wYhZqakxgc0ul82556Ih5WrTqa2a/Z6qqbJGOPmu7uPEmPUwAxCQfjXKZTJCqd+CWfkCUgvPeUMjGjUVkxVRBBAOhwZ4u2uq+JNQ4i0IoKW81jY+hYkibbZ/lsauSiX/6Y/1CraXdKBGyfz4dGfUFA+9Taa7b28o9WSMlkxIEIeAyKtxGKruLjuj5O15gc5MUy3/AayvApkW/9CJWAmlEpyYPLnjJ2n4LgHkIM7L++Y/d6IjgqN5yZiZUVHaiqxlKtFpSGhGlceGOIb1RDtp6vDyXKG6Bqmc66mkZlsLAlfxgo4PlAfpPhXtjlP5cE5sK/oFMHDD/tatwF75uhYWKCHrhRzRvDF7ahUILXmnqVn+H8wVRrBLvrrXHfYkuCmnTs5xrPzW9/kJwQUh8V4dYeenkqNW+b8Ml0KMh3GKX19veteS3gFbktRgxLlzpEbtbanS2L4V7u+wsYyU+F+GiaagZGebG4uVih35IQGnLzHlj3vrmyo24k19QIjApm4a1+bYkuF1tBgPPB4VVAvS31Ed3pmKtUzGc2MBPK0E5GY9IQ0XzqIfRGLWq5HYHdgwVwIxnJZ2bm9h0ElGpICttQ1qwJeYXdJ6FKOJKw8r3ES/vp8Fs64f5Htcf/OdhNvUYbwRenRQ7CNgbuMTo7O2BRb63u9ThSziH5yo2yycDrSo+hB3ndRe50= x-forefront-antispam-report: SFV:SKI;SCL:-1SFV:NSPM;SFS:(10019020)(6009001)(39840400002)(39850400002)(39400400002)(39860400002)(39450400003)(39410400002)(81166006)(8676002)(2950100002)(478600001)(6116002)(102836003)(6246003)(6916009)(5890100001)(110136004)(38730400002)(305945005)(3660700001)(189998001)(54356999)(76176999)(74316002)(25786009)(7736002)(8936002)(50986999)(3280700002)(5660300001)(54906002)(33656002)(4326008)(7696004)(77096006)(15650500001)(2906002)(6506006)(6436002)(55016002)(53936002)(9686003)(86362001)(66066001)(14454004)(2900100001);DIR:OUT;SFP:1102;SCL:1;SRVR:DF4PR84MB0075;H:DF4PR84MB0105.NAMPRD84.PROD.OUTLOOK.COM;FPR:;SPF:None;MLV:sfv;LANG:en; x-ms-office365-filtering-correlation-id: bbce252a-6e90-4bbf-c547-08d4c019ebec x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254075)(48565401081)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:DF4PR84MB0075; x-ms-traffictypediagnostic: DF4PR84MB0075: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(227479698468861)(133145235818549)(236129657087228)(148574349560750)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(100000703101)(100105400095)(93006095)(93001095)(6055026)(6041248)(20161123558100)(20161123560025)(20161123555025)(20161123564025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DF4PR84MB0075;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DF4PR84MB0075; x-forefront-prvs: 0355F3A3AE spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Jul 2017 00:41:32.9289 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR84MB0075 X-OriginatorOrg: hpe.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v610fnYo025548 Content-Length: 2415 Lines: 65 > > Sysfs "badblocks" information may be updated during run-time that: > > - MCE, SCI, and sysfs "scrub" may add new bad blocks > > - Writes and ioctl() may clear bad blocks > > > > Add support to send sysfs notifications to sysfs "badblocks" file > > under region and pmem directories when their badblocks information > > is re-evaluated (but is not necessarily changed) during run-time. > > > > Signed-off-by: Toshi Kani > > Cc: Dan Williams > > Cc: Vishal Verma > > Cc: Linda Knippers > > --- > > v2: Send notifications for the clearing case > > --- > > drivers/nvdimm/bus.c | 3 +++ > > drivers/nvdimm/nd.h | 1 + > > drivers/nvdimm/pmem.c | 14 ++++++++++++++ > > drivers/nvdimm/pmem.h | 1 + > > drivers/nvdimm/region.c | 12 ++++++++++-- > > 5 files changed, 29 insertions(+), 2 deletions(-) > > > [..] > > diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c > > index c544d46..6c14c72 100644 > > --- a/drivers/nvdimm/pmem.c > > +++ b/drivers/nvdimm/pmem.c > [..] > > @@ -377,6 +379,13 @@ static int pmem_attach_disk(struct device *dev, > > > > revalidate_disk(disk); > > > > + pmem->bb_state = sysfs_get_dirent(disk_to_dev(disk)->kobj.sd, > > + "badblocks"); > > + if (pmem->bb_state) > > + sysfs_put(pmem->bb_state); > > Sorry I missed this on the first review, but this looks broken. We > need to hold the reference for as long as we might trigger > notifications, so the sysfs_put() should wait until > pmem_release_disk(). I see. > [..] > > diff --git a/drivers/nvdimm/region.c b/drivers/nvdimm/region.c > > index 869a886..ca94029 100644 > > --- a/drivers/nvdimm/region.c > > +++ b/drivers/nvdimm/region.c > > @@ -58,10 +58,16 @@ static int nd_region_probe(struct device *dev) > > > > if (devm_init_badblocks(dev, &nd_region->bb)) > > return -ENODEV; > > + nd_region->bb_state = sysfs_get_dirent(nd_region->dev.kobj.sd, > > + "badblocks"); > > + if (nd_region->bb_state) > > + sysfs_put(nd_region->bb_state); > > ...same here. This should wait until we tear down the region. > > I'll take a look at an incremental fix patch. Thanks Dan! -Toshi