From patchwork Fri Aug 9 07:45:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 11085583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C770714D5 for ; Fri, 9 Aug 2019 07:45:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B843628BD9 for ; Fri, 9 Aug 2019 07:45:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B704A28BC9; Fri, 9 Aug 2019 07:45:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C1DA28BD9 for ; Fri, 9 Aug 2019 07:45:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 367246B0006; Fri, 9 Aug 2019 03:45:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2EF516B0007; Fri, 9 Aug 2019 03:45:41 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 208596B0008; Fri, 9 Aug 2019 03:45:41 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f200.google.com (mail-yb1-f200.google.com [209.85.219.200]) by kanga.kvack.org (Postfix) with ESMTP id F17AA6B0006 for ; Fri, 9 Aug 2019 03:45:40 -0400 (EDT) Received: by mail-yb1-f200.google.com with SMTP id s17so32988573ybg.15 for ; Fri, 09 Aug 2019 00:45:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=/VHRUY+DXfPpmqKgC4rYAop9p4HtmpgmApwNSS+7/Dg=; b=XXTzQHx3w8+bMVYKFdeik7CnvsFEvfkW9T4kmPyOCTROjwzNuSAAHjXruh3q0X39oj Yq7EWGZb5Ng9BzgJgHKDeXokEGlO/qFmcS4YHVIfd4LX6uUqOoCOg6fTntwFyi9bbeXF NsmpAQR1CEwqbP/u76xUZ92QdykbO7TgOyE2lc8rK4N0IbIHcJ8d+dLyVq5EOCjXTQlO rbJQlC2VJe7aPcoBKqv9WqaTky+R0Is7PmD6IMnYl04VXWiUkJoJsHbNeH/V9c2tPEUb x5qjAR2rDFuZ+YasOHrXpr1lGfC8AtzbLFbPCFlBs1Zl2oU6X9ymo8JPLHnI3B33DOG2 5DWw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: APjAAAXzfK6TrQABbusd2rcUFeurjdBC/6t0RxBioRytIzTnCQG0K+UF uwCyvoJcrkT3hB4DvP7SPhh/f/3UFnr1T5d+7IXwuPO1H2GWwiJsQP8B+R16MOxvcfEtnENrkRN J+W7D0WPXKROH/DLR7QLmZdkyrPJKZgyRYSejPCVoMDvM/x2EektKIffzNHjWqOVUSQ== X-Received: by 2002:a81:9889:: with SMTP id p131mr8814321ywg.127.1565336740772; Fri, 09 Aug 2019 00:45:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOq1fDXCg8Qf8DUbwZ07ENw3RxB+gl8puvijbP9DOJDW4Y1SNSKm5K6GiK+MuaqZeF5AAs X-Received: by 2002:a81:9889:: with SMTP id p131mr8814282ywg.127.1565336739636; Fri, 09 Aug 2019 00:45:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565336739; cv=none; d=google.com; s=arc-20160816; b=Q3ydF27eeBvwF8wJsvmG+3QHgR+OAvUXNQgRRuL7XyIr4zip7qk6W7f+BTXzB5Nak2 9tLShdjR9wJHCzMLGhGsIG8ovdEcH1seXjkg0w6CksipPJSn4Dew+tgFXWszlGmJvX1x kc1v5NG6qvzoAPXv/Pk1OmVDwG8c80SP2ODq3bad5HsiWKUg1AGI0STZofsgtoJ8hJkt 0dSEdmhq54tULwnr2TxbtRVu6+n14cxRqg6snQGDePHYzcwyR+BeJsdWhLbBAnzxEcCu UsMhI6Ddl+15yzF0xIisA/34CXUD48RN1d2Ioki8JzRhjISszUeZ2xLAcdLL/4X4kvUt 0fyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=/VHRUY+DXfPpmqKgC4rYAop9p4HtmpgmApwNSS+7/Dg=; b=gefO6JxzjAk1JgbzqrghFtwKF6o3NvPxqYbxlQC1fo7bD9GtARXfj4PPi8jkF8yVGo sYayepF0C2cC/84qLB4hAZkk/GFRF/Ra7E8nSNk31kG4BL7JJ/b/fQxomusMoGl5Z+yy UNIIEpxpWqwIP3vOUV6hsBdH4EXKJbvNGi5g4AVN6oesN+hazUpmPSOhbeH7QOqEvAGv 2XfYzOWbsezgASznHTK1JPAxEenOGghklI76cZ6hPfogr2BnxXngo1/wWO7YzV30sKna 6tEzLThkMxUfvY3D9fWdEdL6B0dpm7MpQtMPCkaT3zz3hozoQYv8g7YaxufrJ+9+4+ku uK4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com. [148.163.158.5]) by mx.google.com with ESMTPS id v2si33037240ybo.248.2019.08.09.00.45.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Aug 2019 00:45:39 -0700 (PDT) Received-SPF: pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) client-ip=148.163.158.5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x797i6KU131658; Fri, 9 Aug 2019 03:45:38 -0400 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0b-001b2d01.pphosted.com with ESMTP id 2u93rxt5xg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Aug 2019 03:45:38 -0400 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x797hiui004382; Fri, 9 Aug 2019 07:45:37 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma02dal.us.ibm.com with ESMTP id 2u51w66ww8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Aug 2019 07:45:37 +0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x797jaiM61341998 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 Aug 2019 07:45:36 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F3B9E6A047; Fri, 9 Aug 2019 07:45:35 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 01B246A051; Fri, 9 Aug 2019 07:45:33 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.199.36.73]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 9 Aug 2019 07:45:33 +0000 (GMT) From: "Aneesh Kumar K.V" To: dan.j.williams@intel.com Cc: linux-nvdimm@lists.01.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, "Aneesh Kumar K.V" Subject: [PATCH v5 1/4] nvdimm: Consider probe return -EOPNOTSUPP as success Date: Fri, 9 Aug 2019 13:15:17 +0530 Message-Id: <20190809074520.27115-2-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190809074520.27115-1-aneesh.kumar@linux.ibm.com> References: <20190809074520.27115-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-09_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090080 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This patch add -EOPNOTSUPP as return from probe callback to indicate we were not able to initialize a namespace due to pfn superblock feature/version mismatch. We want to consider this a probe success so that we can create new namesapce seed and there by avoid marking the failed namespace as the seed namespace. Signed-off-by: Aneesh Kumar K.V --- drivers/nvdimm/bus.c | 2 +- drivers/nvdimm/pmem.c | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c index 798c5c4aea9c..16c35e6446a7 100644 --- a/drivers/nvdimm/bus.c +++ b/drivers/nvdimm/bus.c @@ -95,7 +95,7 @@ static int nvdimm_bus_probe(struct device *dev) rc = nd_drv->probe(dev); debug_nvdimm_unlock(dev); - if (rc == 0) + if (rc == 0 || rc == -EOPNOTSUPP) nd_region_probe_success(nvdimm_bus, dev); else nd_region_disable(nvdimm_bus, dev); diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 4c121dd03dd9..3f498881dd28 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -490,6 +490,7 @@ static int pmem_attach_disk(struct device *dev, static int nd_pmem_probe(struct device *dev) { + int ret; struct nd_namespace_common *ndns; ndns = nvdimm_namespace_common_probe(dev); @@ -505,12 +506,29 @@ static int nd_pmem_probe(struct device *dev) if (is_nd_pfn(dev)) return pmem_attach_disk(dev, ndns); - /* if we find a valid info-block we'll come back as that personality */ - if (nd_btt_probe(dev, ndns) == 0 || nd_pfn_probe(dev, ndns) == 0 - || nd_dax_probe(dev, ndns) == 0) + ret = nd_btt_probe(dev, ndns); + if (ret == 0) return -ENXIO; + else if (ret == -EOPNOTSUPP) + return ret; - /* ...otherwise we're just a raw pmem device */ + ret = nd_pfn_probe(dev, ndns); + if (ret == 0) + return -ENXIO; + else if (ret == -EOPNOTSUPP) + return ret; + + ret = nd_dax_probe(dev, ndns); + if (ret == 0) + return -ENXIO; + else if (ret == -EOPNOTSUPP) + return ret; + /* + * We have two failure conditions here, there is no + * info reserver block or we found a valid info reserve block + * but failed to initialize the pfn superblock. + * Don't create a raw pmem disk for the second case. + */ return pmem_attach_disk(dev, ndns); } From patchwork Fri Aug 9 07:45:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 11085587 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7259713B1 for ; Fri, 9 Aug 2019 07:45:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5921728BDF for ; Fri, 9 Aug 2019 07:45:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D25F28C42; Fri, 9 Aug 2019 07:45:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD1A328BDF for ; Fri, 9 Aug 2019 07:45:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 95A476B0007; Fri, 9 Aug 2019 03:45:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 90BED6B0008; Fri, 9 Aug 2019 03:45:43 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 75FF76B000A; Fri, 9 Aug 2019 03:45:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 3B1E56B0007 for ; Fri, 9 Aug 2019 03:45:43 -0400 (EDT) Received: by mail-pl1-f197.google.com with SMTP id a5so57036273pla.3 for ; Fri, 09 Aug 2019 00:45:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=vBh7ndphK1zAwismU4hNm+W0DgZu0+OG2oq0WjLVa+w=; b=XDO4XB80qXhD8dkkZbf8mn5Dcplkes/m976tacNp73tptUjcBYu30DcFH+Tu3Hcsqm KButerb6nes6sK48pJM/N3Gkz4FmBMdhbbtZS6btTgdw6s1pWEsE3B/4/ml6X38IhWNM InjXeim5T0FUe2EOrl/Dynts+fwl/jvk+/klgI79sVp0nPssKHrv9mh2V4bpRe4UcqaV s7CedJoKHjsGxzXHnIDNGpnGhKSViItyb7t1vcFWTF/gipmHLno5O1qzPqlLp0MSiRcS bLOmoauxpuqqjtWg4kZHFzBHTDQWOshtsblPt27ka7vSAcSjRq8YM5RzvQS+GFb3U/dS ra7Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: APjAAAW6bYwsZfbtcU0d12XYbTu/QHtkSA3nxtytktu5kxqVdI3X2379 mX2gGX/1tLXl/qfUQ8LYFXjsU67CNlu3+LDpqCPVhc+SmveEV/XDGDnTH3vyAaxwUMxjyJj9HM3 B5fiNgrjxAYldMGs/TWTEh8ez2GRMWTD0Otsz5xH4zvyksmta6nVwaBCS+VAejXfMhw== X-Received: by 2002:a17:90a:ba94:: with SMTP id t20mr8341599pjr.116.1565336742778; Fri, 09 Aug 2019 00:45:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8jan7KkkfhDO61IzI5TlfFaDggT3u9Q816+OUVgtUBR/Tjb4FcVhmjKXajdvgNRV9t4SX X-Received: by 2002:a17:90a:ba94:: with SMTP id t20mr8341549pjr.116.1565336741996; Fri, 09 Aug 2019 00:45:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565336741; cv=none; d=google.com; s=arc-20160816; b=MdbFGQWMX/p0ATciB3s+OLCB8vccKeAo2GvBJi7IObU225xmw6JYGTmWcmBNj+smTT HmeK2qD4JOnC3dPgpvb9/ZLpoD4s0mO0YlL/rqI7NjnQRC1rYYyvOhgWCZP2th7jX+zf t2x3t/+aQ6dTjRYykJKmbx9raeiJv4q4X7Hs0grA564sJzdtspKR1p/PE2l/uaswqgtq WpoYhGY9a3JSofzIxO1wZFgrkIedC7EU/ZnCOt8TE1gAr9OQXRhjElnoN7C8gaWhmcZ2 TVUWYEF2ZLv+JEJ0/gGMhZmskw6hSVOjlTuJzcS1Z+awvLkc6wgxTVkZfhX5BNDOYCpt GUxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=vBh7ndphK1zAwismU4hNm+W0DgZu0+OG2oq0WjLVa+w=; b=RAQpTTmJmn651srtQQ+f00y5yebMyrudxKUFaBgNAT39VS9AOpTTCQgPnNvxFKX3hG LY2pfOClc+C71CLShEKfedQ/c+YANHDJxcp2Q+/8ziNvRMksjR1RQjUYZS0uhipl3gpm DR/LJ0rMDPExQHvfSjy0KoQyICv1FgTMlo5jFGMotNlxEXUa9TjvZakm7QelV75cogdp Q4dF1fZkm3szMKMrYRyXQFbvZOKh+ByXh15OLVIxBmTbBI0uV79Snsj1jQuEXnEpFWd/ 5agZgzduAu5+K4P4HMVHNGjQ29NlsH8EyDQlwYu9FnXlFm7vJn1hMUfJ0yw57GTRHd3U kRgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com. [148.163.156.1]) by mx.google.com with ESMTPS id h189si45311141pge.36.2019.08.09.00.45.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Aug 2019 00:45:41 -0700 (PDT) Received-SPF: pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) client-ip=148.163.156.1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x797hWGx129219; Fri, 9 Aug 2019 03:45:41 -0400 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com with ESMTP id 2u93rwj3ta-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Aug 2019 03:45:40 -0400 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x797hdn7012259; Fri, 9 Aug 2019 07:45:40 GMT Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by ppma04dal.us.ibm.com with ESMTP id 2u51w7cqkf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Aug 2019 07:45:39 +0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x797jcet62194166 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 Aug 2019 07:45:38 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9C4356A051; Fri, 9 Aug 2019 07:45:38 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9DEF66A047; Fri, 9 Aug 2019 07:45:36 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.199.36.73]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 9 Aug 2019 07:45:36 +0000 (GMT) From: "Aneesh Kumar K.V" To: dan.j.williams@intel.com Cc: linux-nvdimm@lists.01.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, "Aneesh Kumar K.V" Subject: [PATCH v5 2/4] mm/nvdimm: Add page size and struct page size to pfn superblock Date: Fri, 9 Aug 2019 13:15:18 +0530 Message-Id: <20190809074520.27115-3-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190809074520.27115-1-aneesh.kumar@linux.ibm.com> References: <20190809074520.27115-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-09_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090080 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This is needed so that we don't wrongly initialize a namespace which doesn't have enough space reserved for holding struct pages with the current kernel. Signed-off-by: Aneesh Kumar K.V --- drivers/nvdimm/pfn.h | 5 ++++- drivers/nvdimm/pfn_devs.c | 27 ++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/nvdimm/pfn.h b/drivers/nvdimm/pfn.h index 7381673b7b70..acb19517f678 100644 --- a/drivers/nvdimm/pfn.h +++ b/drivers/nvdimm/pfn.h @@ -29,7 +29,10 @@ struct nd_pfn_sb { /* minor-version-2 record the base alignment of the mapping */ __le32 align; /* minor-version-3 guarantee the padding and flags are zero */ - u8 padding[4000]; + /* minor-version-4 record the page size and struct page size */ + __le32 page_size; + __le16 page_struct_size; + u8 padding[3994]; __le64 checksum; }; diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index 3e7b11cf1aae..37e96811c2fc 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -460,6 +460,15 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig) if (__le16_to_cpu(pfn_sb->version_minor) < 2) pfn_sb->align = 0; + if (__le16_to_cpu(pfn_sb->version_minor) < 4) { + /* + * For a large part we use PAGE_SIZE. But we + * do have some accounting code using SZ_4K. + */ + pfn_sb->page_struct_size = cpu_to_le16(64); + pfn_sb->page_size = cpu_to_le32(PAGE_SIZE); + } + switch (le32_to_cpu(pfn_sb->mode)) { case PFN_MODE_RAM: case PFN_MODE_PMEM: @@ -475,6 +484,20 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig) align = 1UL << ilog2(offset); mode = le32_to_cpu(pfn_sb->mode); + if (le32_to_cpu(pfn_sb->page_size) != PAGE_SIZE) { + dev_err(&nd_pfn->dev, + "init failed, page size mismatch %d\n", + le32_to_cpu(pfn_sb->page_size)); + return -EOPNOTSUPP; + } + + if (le16_to_cpu(pfn_sb->page_struct_size) < sizeof(struct page)) { + dev_err(&nd_pfn->dev, + "init failed, struct page size mismatch %d\n", + le16_to_cpu(pfn_sb->page_struct_size)); + return -EOPNOTSUPP; + } + if (!nd_pfn->uuid) { /* * When probing a namepace via nd_pfn_probe() the uuid @@ -722,8 +745,10 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn) memcpy(pfn_sb->uuid, nd_pfn->uuid, 16); memcpy(pfn_sb->parent_uuid, nd_dev_to_uuid(&ndns->dev), 16); pfn_sb->version_major = cpu_to_le16(1); - pfn_sb->version_minor = cpu_to_le16(3); + pfn_sb->version_minor = cpu_to_le16(4); pfn_sb->align = cpu_to_le32(nd_pfn->align); + pfn_sb->page_struct_size = cpu_to_le16(sizeof(struct page)); + pfn_sb->page_size = cpu_to_le32(PAGE_SIZE); checksum = nd_sb_checksum((struct nd_gen_sb *) pfn_sb); pfn_sb->checksum = cpu_to_le64(checksum); From patchwork Fri Aug 9 07:45:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 11085595 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 155C513B1 for ; Fri, 9 Aug 2019 07:45:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0433E28B64 for ; Fri, 9 Aug 2019 07:45:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ECB7628BD9; Fri, 9 Aug 2019 07:45:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74F87288F6 for ; Fri, 9 Aug 2019 07:45:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 450D66B0008; Fri, 9 Aug 2019 03:45:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3D8F66B000C; Fri, 9 Aug 2019 03:45:47 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F9496B0008; Fri, 9 Aug 2019 03:45:47 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by kanga.kvack.org (Postfix) with ESMTP id E9F6B6B0008 for ; Fri, 9 Aug 2019 03:45:46 -0400 (EDT) Received: by mail-pl1-f199.google.com with SMTP id s21so56934284plr.2 for ; Fri, 09 Aug 2019 00:45:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=1cpAcPJA1eSwXtvLgTUBIv62UJQ/nuNt1oyOWsb0svY=; b=kxFmwuSjKho5It7e06d8VtJNS4cfDhSr55Ilw7Vr1M/q4yxOGE7IAdcah4BkgRmNhg 1V9IDNqSEiKxHZ7x7Q/SFBmet83WuhblY00+DZCQQOITO+pEYnBDroR7fSwSMpp4jKjm YusukXtbkgLAajoI7mA1FLD05kr/uYMCjLREB2eSXZjnLlqiDyyNbz77Ej3jZqQZ6rpi GosfcaZtrUQrPJnhtSuSBOTALlbp7CvMb0aWrb5t9lcdWQ7SYJGr1PnMGCaoZU49J/U7 ExCl7HWY7mJI/Ba5mIsQ9qCJ6QyvGD8x3hC7cioidqbjDyJmc1CTivceamZQQluZKDPK eXqg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: APjAAAXvtIZD/PvME4cES/guXKj1GkJ4/1UBkkQNk+r6Z8qdWx8HupFu XcvrSsBTMyzYZcBFEisvb+coOFInRZf7B+BA2Dluao9eb3sBEyXN0h6XKOJUCvRULfIZ6hljnLo hvF/qp33bcD4HhelDfcv00Sl4SON4SBJ9knyB0YQgPjaqgVh55bx0tVafoKX7+SExyA== X-Received: by 2002:a62:3895:: with SMTP id f143mr19761190pfa.116.1565336746602; Fri, 09 Aug 2019 00:45:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyq+VflTEgjtYYilH7OTgvDbs/leCW0d/O0lhuJ7YUSnQo/9bCY8KCLoKuSVVcGYQod3ajQ X-Received: by 2002:a62:3895:: with SMTP id f143mr19761144pfa.116.1565336745767; Fri, 09 Aug 2019 00:45:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565336745; cv=none; d=google.com; s=arc-20160816; b=ZXr6X5vxDM+U4Gz9TsdlY/TkAIisgsj5NYPBP82MMkdUEPVTqS9me8Y3AWT4ouOZlN cqpEb4ooQWNycxyHTPyk1A1+hFNBBflv0vqx1LYL4Us9RiLDkjCFrR4VTOw3GX39pNol W5hlnGZFB6qHSk7uFSXGp0RMBmjyLv1zNppq5+DNDTebVr6Z6x5xbxVE3EyTev4s9FBS jCljIv5LlksxRdNrHv7lnMn4fG9FZCOoMSH8W83mQCd5Z6IycIz/BpjJlFRiopMDxDtx y7E7ajA6TdBWXuW2tk2kHKVniEVgYOWPgIxqch1IqqEE9m6fMrfMz4hKsLIs/9MLUpx1 yrMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=1cpAcPJA1eSwXtvLgTUBIv62UJQ/nuNt1oyOWsb0svY=; b=rxvM4vvitX7a7mjdGOLV32BSXozzboCTmCHt+J3Rc3+h6gQFvfLWYt2lXSCiRv0Itp 9JyIXqtoDLwL4GU69u0ex/HOncNzB058cXicaDX2bhPpP6sYBEjILA0uViQEFk8NYHb2 bUUmCG2Xb4ysyPW0hFkcitAe4mCS4tHyFu/TZWId13XJpif4BMKO+S0ZlQJzHQ3rPpgC 5d2U/nXH3BK7wl2ydcSutwQtInQxD2ru5/Jbvfe69x1lrRnJIkELoy69qAnDd6OlVwLR P7hWLgaLKWIlrt4mNGzgpSp0n4trO50UmxeOE5WoFF/xU3URpW1e8cbalANzd8q4CLmU n1gg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com. [148.163.156.1]) by mx.google.com with ESMTPS id 11si50160675pla.248.2019.08.09.00.45.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Aug 2019 00:45:45 -0700 (PDT) Received-SPF: pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) client-ip=148.163.156.1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x797haf3104333; Fri, 9 Aug 2019 03:45:44 -0400 Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com with ESMTP id 2u91bbq0x2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Aug 2019 03:45:44 -0400 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x797hcSb015938; Fri, 9 Aug 2019 07:45:42 GMT Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by ppma01wdc.us.ibm.com with ESMTP id 2u51w73bur-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Aug 2019 07:45:42 +0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x797jfIQ33292756 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 Aug 2019 07:45:41 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2EA106A051; Fri, 9 Aug 2019 07:45:41 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 30E5C6A047; Fri, 9 Aug 2019 07:45:39 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.199.36.73]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 9 Aug 2019 07:45:38 +0000 (GMT) From: "Aneesh Kumar K.V" To: dan.j.williams@intel.com Cc: linux-nvdimm@lists.01.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, "Aneesh Kumar K.V" Subject: [PATCH v5 3/4] mm/nvdimm: Use correct #defines instead of open coding Date: Fri, 9 Aug 2019 13:15:19 +0530 Message-Id: <20190809074520.27115-4-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190809074520.27115-1-aneesh.kumar@linux.ibm.com> References: <20190809074520.27115-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-09_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090080 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Use PAGE_SIZE instead of SZ_4K and sizeof(struct page) instead of 64. If we have a kernel built with different struct page size the previous patch should handle marking the namespace disabled. Signed-off-by: Aneesh Kumar K.V Signed-off-by: Aneesh Kumar K.V --- drivers/nvdimm/label.c | 2 +- drivers/nvdimm/namespace_devs.c | 6 +++--- drivers/nvdimm/pfn_devs.c | 3 ++- drivers/nvdimm/region_devs.c | 8 ++++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c index 73e197babc2f..7ee037063be7 100644 --- a/drivers/nvdimm/label.c +++ b/drivers/nvdimm/label.c @@ -355,7 +355,7 @@ static bool slot_valid(struct nvdimm_drvdata *ndd, /* check that DPA allocations are page aligned */ if ((__le64_to_cpu(nd_label->dpa) - | __le64_to_cpu(nd_label->rawsize)) % SZ_4K) + | __le64_to_cpu(nd_label->rawsize)) % PAGE_SIZE) return false; /* check checksum */ diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c index a16e52251a30..a9c76df12cb9 100644 --- a/drivers/nvdimm/namespace_devs.c +++ b/drivers/nvdimm/namespace_devs.c @@ -1006,10 +1006,10 @@ static ssize_t __size_store(struct device *dev, unsigned long long val) return -ENXIO; } - div_u64_rem(val, SZ_4K * nd_region->ndr_mappings, &remainder); + div_u64_rem(val, PAGE_SIZE * nd_region->ndr_mappings, &remainder); if (remainder) { - dev_dbg(dev, "%llu is not %dK aligned\n", val, - (SZ_4K * nd_region->ndr_mappings) / SZ_1K); + dev_dbg(dev, "%llu is not %ldK aligned\n", val, + (PAGE_SIZE * nd_region->ndr_mappings) / SZ_1K); return -EINVAL; } diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index 37e96811c2fc..c1d9be609322 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -725,7 +725,8 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn) * when populating the vmemmap. This *should* be equal to * PMD_SIZE for most architectures. */ - offset = ALIGN(start + SZ_8K + 64 * npfns, align) - start; + offset = ALIGN(start + SZ_8K + sizeof(struct page) * npfns, + align) - start; } else if (nd_pfn->mode == PFN_MODE_RAM) offset = ALIGN(start + SZ_8K, align) - start; else diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c index af30cbe7a8ea..20e265a534f8 100644 --- a/drivers/nvdimm/region_devs.c +++ b/drivers/nvdimm/region_devs.c @@ -992,10 +992,10 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus, struct nd_mapping_desc *mapping = &ndr_desc->mapping[i]; struct nvdimm *nvdimm = mapping->nvdimm; - if ((mapping->start | mapping->size) % SZ_4K) { - dev_err(&nvdimm_bus->dev, "%s: %s mapping%d is not 4K aligned\n", - caller, dev_name(&nvdimm->dev), i); - + if ((mapping->start | mapping->size) % PAGE_SIZE) { + dev_err(&nvdimm_bus->dev, + "%s: %s mapping%d is not %ld aligned\n", + caller, dev_name(&nvdimm->dev), i, PAGE_SIZE); return NULL; } From patchwork Fri Aug 9 07:45:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 11085591 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A1A6714D5 for ; Fri, 9 Aug 2019 07:45:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91B3B28B64 for ; Fri, 9 Aug 2019 07:45:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85D6C28C56; Fri, 9 Aug 2019 07:45:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 119A528C53 for ; Fri, 9 Aug 2019 07:45:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 478A46B000A; Fri, 9 Aug 2019 03:45:49 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 404676B000C; Fri, 9 Aug 2019 03:45:49 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 27E7B6B000D; Fri, 9 Aug 2019 03:45:49 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by kanga.kvack.org (Postfix) with ESMTP id EAC016B000A for ; Fri, 9 Aug 2019 03:45:48 -0400 (EDT) Received: by mail-yb1-f198.google.com with SMTP id k5so12855884ybo.8 for ; Fri, 09 Aug 2019 00:45:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=7nMwPOELRuL1JjTfUknD5ZJvglW+NvUCwU0Q6CSgFo8=; b=OjBnWkbjVvB1NSGk2uwGDjTUdmXc5Y+RU5WFQR1pbYZ46S6tooA2caClE/b6843BKV nc/2Eb8Qgte6OyhBUrvp6uHGojMIDR9ZKsDxZeagwOb5E9IP1uz8e71h2jPBv43P8S2x XEAkt5gQtRUaI0TDNjnQyZW3B9Ki18C9k/Nglk7jcIBNqjMalD/jWhWCWArvs0Xl7HVc 9N5wBOQAJ3gmR1lRGtQyuZwY4RLoMvFqGeDiomNva0mQ/0a95t5E4dts30MZSMKkAttf n0LTvfRuhVY1XKoSaVueu1qXysNg7td6Hpyz6xbFCBX5NsTonMSU6kUofB9Fomd7vBxH 84PA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: APjAAAVRwSd1Bc8b+p5UX+bShSYVgYFNWgozgmTplXjMujFkAmUYjEoi xuKHW5Dl7U1pf+JCRIvn3seaAU9X+nOeel/DMw4Az2TUtu1qSusjxpzgwEyAh3kdTbVFmWSt7uW OTkZpsm72rqkyNGAWr6MRW7fSYdaB29iZk6SLIc2uKTMe1sGg9s90+iurBGMW3fMCZg== X-Received: by 2002:a0d:d557:: with SMTP id x84mr7528257ywd.455.1565336748683; Fri, 09 Aug 2019 00:45:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGP1zQW9nTsxENDT947o3njrh6gm9Qj2jvXYX7o43T18KO33GfR0xNPCSwvIHDjkt7N9ge X-Received: by 2002:a0d:d557:: with SMTP id x84mr7528224ywd.455.1565336747598; Fri, 09 Aug 2019 00:45:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565336747; cv=none; d=google.com; s=arc-20160816; b=FN3xsYjChHeZ0gnfp8fcu4B1iu1NrounpXumkUkWIflHI80WrnUovIl9HlRZFOH5aC uqaONHot17QAzUDTLWmR1oAtfhGawU+eOiZ6lV43KEj/2+2KtRTXAwySWRzMhCHfiB7u bQi2ho6oYzPDmmVEGu7jyb1Q0bGCzrDTQ/076MOtLd7M4e2t99gqr4WT6YNxQmzG9j4S 8X/kHPNvimmLgM/r9SaLa8PU/H74exVdiRpi/GD4kz2LBL/ODqmoykFnxGBCJbVdDS7Q dwjbA6BFL62rNNtUV+Kz5vdJokGYS8zbdcuumaud34L2Yg46ZPQCmrWIbhsFwaMWmvJ0 jrFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=7nMwPOELRuL1JjTfUknD5ZJvglW+NvUCwU0Q6CSgFo8=; b=h4Y3Wkum5K1uIMmvIaNuoslapqZaxC0JNsIA6Veq1ZvlhrRzBxOPx1F+TsobsKtsyk MuVavIedf1XJOMlX2nalUasEqiT/eTFuslPq1MktDL1aJOj4PlLuMNII70RuERZzHi70 pqs+biHU2KEkN/pNbXpDij+P0b6f+5g33+PJUknWQ764u3B5zkQxtWMqu305mNyAMp9W NTJbl4wglYFOV2pW8KeZFY+yOEsLGEIKeYTB2FEzEdwjVU27Y7m/gAmuypr8M589piKg lwOfMs9qMJwtLr+ICkZv8a3xGPuIVZVsKHUBfe/8xqCoMUrms7owfDCaQPqzTwZbuKOF iNeg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com. [148.163.158.5]) by mx.google.com with ESMTPS id f132si26783688ybf.393.2019.08.09.00.45.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Aug 2019 00:45:47 -0700 (PDT) Received-SPF: pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) client-ip=148.163.158.5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x797i6ce101665; Fri, 9 Aug 2019 03:45:46 -0400 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0b-001b2d01.pphosted.com with ESMTP id 2u91gxpka9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Aug 2019 03:45:46 -0400 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x797hcKG012256; Fri, 9 Aug 2019 07:45:45 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma04dal.us.ibm.com with ESMTP id 2u51w7cqks-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Aug 2019 07:45:45 +0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x797jh4T34996624 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 Aug 2019 07:45:43 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B421F6A04D; Fri, 9 Aug 2019 07:45:43 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B7F0A6A051; Fri, 9 Aug 2019 07:45:41 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.199.36.73]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 9 Aug 2019 07:45:41 +0000 (GMT) From: "Aneesh Kumar K.V" To: dan.j.williams@intel.com Cc: linux-nvdimm@lists.01.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, "Aneesh Kumar K.V" Subject: [PATCH v5 4/4] mm/nvdimm: Pick the right alignment default when creating dax devices Date: Fri, 9 Aug 2019 13:15:20 +0530 Message-Id: <20190809074520.27115-5-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190809074520.27115-1-aneesh.kumar@linux.ibm.com> References: <20190809074520.27115-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-09_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090080 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Allow arch to provide the supported alignments and use hugepage alignment only if we support hugepage. Right now we depend on compile time configs whereas this patch switch this to runtime discovery. Architectures like ppc64 can have THP enabled in code, but then can have hugepage size disabled by the hypervisor. This allows us to create dax devices with PAGE_SIZE alignment in this case. Existing dax namespace with alignment larger than PAGE_SIZE will fail to initialize in this specific case. We still allow fsdax namespace initialization. With respect to identifying whether to enable hugepage fault for a dax device, if THP is enabled during compile, we default to taking hugepage fault and in dax fault handler if we find the fault size > alignment we retry with PAGE_SIZE fault size. This also addresses the below failure scenario on ppc64 ndctl create-namespace --mode=devdax | grep align "align":16777216, "align":16777216 cat /sys/devices/ndbus0/region0/dax0.0/supported_alignments 65536 16777216 daxio.static-debug -z -o /dev/dax0.0 Bus error (core dumped) $ dmesg | tail lpar: Failed hash pte insert with error -4 hash-mmu: mm: Hashing failure ! EA=0x7fff17000000 access=0x8000000000000006 current=daxio hash-mmu: trap=0x300 vsid=0x22cb7a3 ssize=1 base psize=2 psize 10 pte=0xc000000501002b86 daxio[3860]: bus error (7) at 7fff17000000 nip 7fff973c007c lr 7fff973bff34 code 2 in libpmem.so.1.0.0[7fff973b0000+20000] daxio[3860]: code: 792945e4 7d494b78 e95f0098 7d494b78 f93f00a0 4800012c e93f0088 f93f0120 daxio[3860]: code: e93f00a0 f93f0128 e93f0120 e95f0128 e93f0088 39290008 f93f0110 The failure was due to guest kernel using wrong page size. The namespaces created with 16M alignment will appear as below on a config with 16M page size disabled. $ ndctl list -Ni [ { "dev":"namespace0.1", "mode":"fsdax", "map":"dev", "size":5351931904, "uuid":"fc6e9667-461a-4718-82b4-69b24570bddb", "align":16777216, "blockdev":"pmem0.1", "supported_alignments":[ 65536 ] }, { "dev":"namespace0.0", "mode":"fsdax", <==== devdax 16M alignment marked disabled. "map":"mem", "size":5368709120, "uuid":"a4bdf81a-f2ee-4bc6-91db-7b87eddd0484", "state":"disabled" } ] Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/libnvdimm.h | 9 ++++++++ arch/powerpc/mm/Makefile | 1 + arch/powerpc/mm/nvdimm.c | 34 ++++++++++++++++++++++++++++ arch/x86/include/asm/libnvdimm.h | 19 ++++++++++++++++ drivers/nvdimm/nd.h | 6 ----- drivers/nvdimm/pfn_devs.c | 32 +++++++++++++++++++++++++- include/linux/huge_mm.h | 7 +++++- 7 files changed, 100 insertions(+), 8 deletions(-) create mode 100644 arch/powerpc/include/asm/libnvdimm.h create mode 100644 arch/powerpc/mm/nvdimm.c create mode 100644 arch/x86/include/asm/libnvdimm.h diff --git a/arch/powerpc/include/asm/libnvdimm.h b/arch/powerpc/include/asm/libnvdimm.h new file mode 100644 index 000000000000..d35fd7f48603 --- /dev/null +++ b/arch/powerpc/include/asm/libnvdimm.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_POWERPC_LIBNVDIMM_H +#define _ASM_POWERPC_LIBNVDIMM_H + +#define nd_pfn_supported_alignments nd_pfn_supported_alignments +extern unsigned long *nd_pfn_supported_alignments(void); +extern unsigned long nd_pfn_default_alignment(void); + +#endif diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile index 0f499db315d6..42e4a399ba5d 100644 --- a/arch/powerpc/mm/Makefile +++ b/arch/powerpc/mm/Makefile @@ -20,3 +20,4 @@ obj-$(CONFIG_HIGHMEM) += highmem.o obj-$(CONFIG_PPC_COPRO_BASE) += copro_fault.o obj-$(CONFIG_PPC_PTDUMP) += ptdump/ obj-$(CONFIG_KASAN) += kasan/ +obj-$(CONFIG_NVDIMM_PFN) += nvdimm.o diff --git a/arch/powerpc/mm/nvdimm.c b/arch/powerpc/mm/nvdimm.c new file mode 100644 index 000000000000..a29a4510715e --- /dev/null +++ b/arch/powerpc/mm/nvdimm.c @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include + +#include +/* + * We support only pte and pmd mappings for now. + */ +const unsigned long *nd_pfn_supported_alignments(void) +{ + static unsigned long supported_alignments[3]; + + supported_alignments[0] = PAGE_SIZE; + + if (has_transparent_hugepage()) + supported_alignments[1] = HPAGE_PMD_SIZE; + else + supported_alignments[1] = 0; + + supported_alignments[2] = 0; + return supported_alignments; +} + +/* + * Use pmd mapping if supported as default alignment + */ +unsigned long nd_pfn_default_alignment(void) +{ + + if (has_transparent_hugepage()) + return HPAGE_PMD_SIZE; + return PAGE_SIZE; +} diff --git a/arch/x86/include/asm/libnvdimm.h b/arch/x86/include/asm/libnvdimm.h new file mode 100644 index 000000000000..3d5361db9164 --- /dev/null +++ b/arch/x86/include/asm/libnvdimm.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_LIBNVDIMM_H +#define _ASM_X86_LIBNVDIMM_H + +static inline unsigned long nd_pfn_default_alignment(void) +{ +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + return HPAGE_PMD_SIZE; +#else + return PAGE_SIZE; +#endif +} + +static inline unsigned long nd_altmap_align_size(unsigned long nd_align) +{ + return PMD_SIZE; +} + +#endif diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h index 1b9955651379..5d095a19ff2c 100644 --- a/drivers/nvdimm/nd.h +++ b/drivers/nvdimm/nd.h @@ -289,12 +289,6 @@ static inline struct device *nd_btt_create(struct nd_region *nd_region) struct nd_pfn *to_nd_pfn(struct device *dev); #if IS_ENABLED(CONFIG_NVDIMM_PFN) -#ifdef CONFIG_TRANSPARENT_HUGEPAGE -#define PFN_DEFAULT_ALIGNMENT HPAGE_PMD_SIZE -#else -#define PFN_DEFAULT_ALIGNMENT PAGE_SIZE -#endif - int nd_pfn_probe(struct device *dev, struct nd_namespace_common *ndns); bool is_nd_pfn(struct device *dev); struct device *nd_pfn_create(struct nd_region *nd_region); diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index c1d9be609322..f43d1baa6f33 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "nd-core.h" #include "pfn.h" #include "nd.h" @@ -103,6 +104,8 @@ static ssize_t align_show(struct device *dev, return sprintf(buf, "%ld\n", nd_pfn->align); } +#ifndef nd_pfn_supported_alignments +#define nd_pfn_supported_alignments nd_pfn_supported_alignments static const unsigned long *nd_pfn_supported_alignments(void) { /* @@ -125,6 +128,7 @@ static const unsigned long *nd_pfn_supported_alignments(void) return data; } +#endif static ssize_t align_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) @@ -302,7 +306,7 @@ struct device *nd_pfn_devinit(struct nd_pfn *nd_pfn, return NULL; nd_pfn->mode = PFN_MODE_NONE; - nd_pfn->align = PFN_DEFAULT_ALIGNMENT; + nd_pfn->align = nd_pfn_default_alignment(); dev = &nd_pfn->dev; device_initialize(&nd_pfn->dev); if (ndns && !__nd_attach_ndns(&nd_pfn->dev, ndns, &nd_pfn->ndns)) { @@ -412,6 +416,20 @@ static int nd_pfn_clear_memmap_errors(struct nd_pfn *nd_pfn) return 0; } +static bool nd_supported_alignment(unsigned long align) +{ + int i; + const unsigned long *supported = nd_pfn_supported_alignments(); + + if (align == 0) + return false; + + for (i = 0; supported[i]; i++) + if (align == supported[i]) + return true; + return false; +} + /** * nd_pfn_validate - read and validate info-block * @nd_pfn: fsdax namespace runtime state / properties @@ -498,6 +516,18 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig) return -EOPNOTSUPP; } + /* + * Check whether the we support the alignment. For Dax if the + * superblock alignment is not matching, we won't initialize + * the device. + */ + if (!nd_supported_alignment(align) && + !memcmp(pfn_sb->signature, DAX_SIG, PFN_SIG_LEN)) { + dev_err(&nd_pfn->dev, "init failed, alignment mismatch: " + "%ld:%ld\n", nd_pfn->align, align); + return -EOPNOTSUPP; + } + if (!nd_pfn->uuid) { /* * When probing a namepace via nd_pfn_probe() the uuid diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 45ede62aa85b..4fa91f9bd0da 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -108,7 +108,12 @@ static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma) if (transparent_hugepage_flags & (1 << TRANSPARENT_HUGEPAGE_FLAG)) return true; - + /* + * For dax let's try to do hugepage fault always. If we don't support + * hugepages we will not have enabled namespaces with hugepage alignment. + * This also means we try to handle hugepage fault on device with + * smaller alignment. But for then we will return with VM_FAULT_FALLBACK + */ if (vma_is_dax(vma)) return true;