NVDIMM plugin

This commit is contained in:
Vojtech Trefny 2018-04-11 10:11:48 +02:00
parent 5884541e62
commit d93bec5ee1
4 changed files with 2828 additions and 2 deletions

1685
0001-nvdim-plugin.patch Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,68 @@
From 625dc74ed3d5a2c7d1ee8dc82cecd572b8e31a35 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Tue, 20 Mar 2018 09:42:57 +0100
Subject: [PATCH] Get sector size for non-block NVDIMM namespaces too
ndctl utility now prints sector size for all namespaces that are
not in DAX mode, not only for namespaces in sector/block mode, so
we should do that too.
---
src/plugins/nvdimm.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/src/plugins/nvdimm.c b/src/plugins/nvdimm.c
index 40ade055..abec7adf 100644
--- a/src/plugins/nvdimm.c
+++ b/src/plugins/nvdimm.c
@@ -429,22 +429,19 @@ static BDNVDIMMNamespaceInfo* get_nvdimm_namespace_info (struct ndctl_namespace
uuid_unparse (uuid, uuid_buf);
info->uuid = g_strdup (uuid_buf);
- info->sector_size = ndctl_btt_get_sector_size (btt);
info->blockdev = g_strdup (ndctl_btt_get_block_device (btt));
} else if (pfn) {
ndctl_pfn_get_uuid (pfn, uuid);
uuid_unparse (uuid, uuid_buf);
info->uuid = g_strdup (uuid_buf);
- info->sector_size = 0; // no sector size for memory mode
info->blockdev = g_strdup (ndctl_pfn_get_block_device (pfn));
} else if (dax) {
ndctl_dax_get_uuid (dax, uuid);
uuid_unparse (uuid, uuid_buf);
info->uuid = g_strdup (uuid_buf);
- /* no sector size or blockdev for dax mode */
- info->sector_size = 0;
+ /* no blockdev for dax mode */
info->blockdev = NULL;
} else {
ndctl_namespace_get_uuid (ndns, uuid);
@@ -456,10 +453,26 @@ static BDNVDIMMNamespaceInfo* get_nvdimm_namespace_info (struct ndctl_namespace
info->uuid = g_strdup (uuid_buf);
}
- info->sector_size = 0; // no sector size for raw mode
info->blockdev = g_strdup (ndctl_namespace_get_block_device (ndns));
}
+ if (btt)
+ info->sector_size = ndctl_btt_get_sector_size (btt);
+ else if (dax)
+ /* no sector size for dax mode */
+ info->sector_size = 0;
+ else {
+ info->sector_size = ndctl_namespace_get_sector_size (ndns);
+
+ /* apparently the default value for sector size is 512
+ on non DAX namespaces even if libndctl says it's 0
+ https://github.com/pmem/ndctl/commit/a7320456f1bca5edf15352ce977e757fdf78ed58
+ */
+
+ if (info->sector_size == 0)
+ info->sector_size = 512;
+ }
+
info->enabled = ndctl_namespace_is_active (ndns);
return info;

1016
0003-aclocal.patch Normal file

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,7 @@
%define with_kbd 1
%define with_part 1
%define with_fs 1
%define with_nvdimm 1
%define with_gi 1
# python3 is not available on older RHEL
@ -59,19 +60,25 @@
%if %{with_fs} != 1
%define fs_copts --without-fs
%endif
%if %{with_nvdimm} != 1
%define nvdimm_copts --without-nvdimm
%endif
%if %{with_gi} != 1
%define gi_copts --disable-introspection
%endif
%define configure_opts %{?distro_copts} %{?btrfs_copts} %{?crypto_copts} %{?dm_copts} %{?loop_copts} %{?lvm_copts} %{?lvm_dbus_copts} %{?mdraid_copts} %{?mpath_copts} %{?swap_copts} %{?kbd_copts} %{?part_copts} %{?fs_copts} %{?gi_copts}
%define configure_opts %{?distro_copts} %{?btrfs_copts} %{?crypto_copts} %{?dm_copts} %{?loop_copts} %{?lvm_copts} %{?lvm_dbus_copts} %{?mdraid_copts} %{?mpath_copts} %{?swap_copts} %{?kbd_copts} %{?part_copts} %{?fs_copts} %{?nvdimm_copts} %{?gi_copts}
Name: libblockdev
Version: 2.16
Release: 2%{?dist}
Release: 3%{?dist}
Summary: A library for low-level manipulation with block devices
License: LGPLv2+
URL: https://github.com/storaged-project/libblockdev
Source0: https://github.com/storaged-project/libblockdev/releases/download/%{version}-%{release}/%{name}-%{version}.tar.gz
Patch0: 0001-nvdim-plugin.patch
Patch1: 0002-nvdimm-nonblock-sector-size.patch
Patch2: 0003-aclocal.patch
BuildRequires: glib2-devel
%if %{with_gi}
@ -394,6 +401,29 @@ This package contains header files and pkg-config files needed for development
with the libblockdev-mpath plugin/library.
%endif
%if %{with_nvdimm}
%package nvdimm
BuildRequires: ndctl-devel
BuildRequires: libuuid-devel
Summary: The NVDIMM plugin for the libblockdev library
Requires: %{name}-utils%{?_isa} >= 0.11
Requires: ndctl
%description nvdimm
The libblockdev library plugin (and in the same time a standalone library)
providing the functionality related to operations with NVDIMM devices.
%package nvdimm-devel
Summary: Development files for the libblockdev-nvdimm plugin/library
Requires: %{name}-nvdimm%{?_isa} = %{version}-%{release}
Requires: %{name}-utils-devel%{?_isa}
Requires: glib2-devel
%description nvdimm-devel
This package contains header files and pkg-config files needed for development
with the libblockdev-nvdimm plugin/library.
%endif
%if %{with_part}
%package part
@ -502,6 +532,10 @@ Requires: %{name}-mdraid%{?_isa} = %{version}-%{release}
Requires: %{name}-mpath%{?_isa} = %{version}-%{release}
%endif
%if %{with_nvdimm}
Requires: %{name}-nvdimm%{?_isa} = %{version}-%{release}
%endif
%if %{with_part}
Requires: %{name}-part%{?_isa} = %{version}-%{release}
%endif
@ -520,6 +554,9 @@ A meta-package that pulls all the libblockdev plugins as dependencies.
%prep
%setup -q -n %{name}-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%build
%configure %{?configure_opts}
@ -569,6 +606,10 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
%ldconfig_scriptlets mpath
%endif
%if %{with_nvdimm}
%ldconfig_scriptlets nvdimm
%endif
%if %{with_part}
%ldconfig_scriptlets part
%endif
@ -749,6 +790,15 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
%{_includedir}/blockdev/mpath.h
%endif
%if %{with_nvdimm}
%files nvdimm
%{_libdir}/libbd_nvdimm.so.*
%files nvdimm-devel
%{_libdir}/libbd_nvdimm.so
%dir %{_includedir}/blockdev
%{_includedir}/blockdev/nvdimm.h
%endif
%if %{with_part}
%files part
@ -785,6 +835,13 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
%files plugins-all
%changelog
* Wed Apr 11 2018 Vojtech Trefny <vtrefny@redhat.com> - 2.16-3
- Add the NVDIMM plugin (vtrefny)
- Add tests for the NVDIMM plugin (vtrefny)
- Add --without-xyz to DISTCHECK_CONFIGURE_FLAGS for disabled plugins (vtrefny)
- Add function for getting NVDIMM namespace name from devname or path (vtrefny)
- Get sector size for non-block NVDIMM namespaces too (vtrefny)
* Fri Feb 09 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 2.16-2
- Escape macros in %%changelog