Skip to content

Commit

Permalink
common: Make detection of device-dax instances more robust
Browse files Browse the repository at this point in the history
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 <jmoyer@redhat.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
  • Loading branch information
djbw authored and kilobyte committed Jan 9, 2019
1 parent 78519f3 commit 91bc862
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/common/file.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2018, Intel Corporation
* Copyright 2014-2019, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 91bc862

Please sign in to comment.