From patchwork Tue Jan 8 19:51:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10752795 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 D013A1399 for ; Tue, 8 Jan 2019 20:04:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFA1328D11 for ; Tue, 8 Jan 2019 20:04:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3F7328D3B; Tue, 8 Jan 2019 20:04:38 +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 ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A33A028D11 for ; Tue, 8 Jan 2019 20:04:37 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7377C211AE8DE; Tue, 8 Jan 2019 12:04:37 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=dan.j.williams@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5AFA22119EF4E for ; Tue, 8 Jan 2019 12:04:36 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2019 12:04:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,455,1539673200"; d="scan'208";a="124364068" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by FMSMGA003.fm.intel.com with ESMTP; 08 Jan 2019 12:04:35 -0800 Subject: [pmdk PATCH] common/file: Make detection of device-dax instances more robust From: Dan Williams To: marcin.slusarz@intel.com Date: Tue, 08 Jan 2019 11:51:58 -0800 Message-ID: <154697711872.985876.15063592205044647642.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pmem@googlegroups.com, linux-nvdimm@lists.01.org Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP In preparation for the kernel switching device-dax instances from the "/sys/class/dax" subsystem to "/sys/bus/dax" [1], teach the device-dax instance detection to be subsystem-type agnostic. Note that the subsystem switch will require an administrator, or distro, opt-in. The opt-in will either be at kernel compile time by disabling the default compatibility driver in the kernel, or at runtime with a modprobe policy to override which kernel module services device-dax devices. The daxctl utility [2] will ship a command to install the modprobe policy and include a man page that lists the potential regression risk to older PMDK and other userspace tools that are hard coded to "/sys/class/dax". [1]: https://lwn.net/Articles/770128/ [2]: https://github.com/pmem/ndctl/tree/master/daxctl Reported-by: Jeff Moyer Signed-off-by: Dan Williams --- src/common/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/file.c b/src/common/file.c index ff36e70e1fff..e660c136506a 100644 --- a/src/common/file.c +++ b/src/common/file.c @@ -53,7 +53,6 @@ #include "out.h" #include "mmap.h" -#define DEVICE_DAX_PREFIX "/sys/class/dax" #define MAX_SIZE_LENGTH 64 #define DEVICE_DAX_ZERO_LEN (2 * MEGABYTE) @@ -180,7 +179,8 @@ get_file_type_internal(os_stat_t *st) return OTHER_ERROR; } - if (strcmp(DEVICE_DAX_PREFIX, rpath) != 0) { + char *basename = strrchr(rpath, '/'); + if (!basename || strcmp("dax", basename+1) != 0) { LOG(3, "%s path does not match device dax prefix path", rpath); errno = EINVAL; return OTHER_ERROR;