linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] block, dax: move "select DAX" from BLOCK to FS_DAX
@ 2017-05-08 21:03 Dan Williams
  2017-05-08 21:03 ` [PATCH 2/2] device-dax: kill NR_DEV_DAX Dan Williams
  2017-05-08 22:36 ` [PATCH 1/2] block, dax: move "select DAX" from BLOCK to FS_DAX kbuild test robot
  0 siblings, 2 replies; 6+ messages in thread
From: Dan Williams @ 2017-05-08 21:03 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: linux-block, Geert Uytterhoeven, linux-kernel

For configurations that do not enable DAX filesystems or drivers, do not
require the DAX core to be built.

The only core block routine that calls a DAX routine is
bdev_dax_supported(), that now fails by default as expected if FS_DAX=n,
or no DAX-capable drivers are configured.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 block/Kconfig       |    1 -
 fs/Kconfig          |    1 +
 include/linux/dax.h |   37 ++++++++++++++++++++++++++++++++++---
 3 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/block/Kconfig b/block/Kconfig
index 93da7fc3f254..e9f780f815f5 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -6,7 +6,6 @@ menuconfig BLOCK
        default y
        select SBITMAP
        select SRCU
-       select DAX
        help
 	 Provide block layer support for the kernel.
 
diff --git a/fs/Kconfig b/fs/Kconfig
index 83eab52fb3f6..b0e42b6a96b9 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -39,6 +39,7 @@ config FS_DAX
 	depends on MMU
 	depends on !(ARM || MIPS || SPARC)
 	select FS_IOMAP
+	select DAX
 	help
 	  Direct Access (DAX) can be used on memory-backed block devices.
 	  If the block device supports DAX and the filesystem supports DAX,
diff --git a/include/linux/dax.h b/include/linux/dax.h
index d3158e74a59e..e3fa0ad5a12d 100644
--- a/include/linux/dax.h
+++ b/include/linux/dax.h
@@ -18,17 +18,48 @@ struct dax_operations {
 			void **, pfn_t *);
 };
 
+#if IS_ENABLED(CONFIG_DAX)
 int dax_read_lock(void);
 void dax_read_unlock(int id);
 struct dax_device *dax_get_by_host(const char *host);
+void put_dax(struct dax_device *dax_dev);
+long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages,
+		void **kaddr, pfn_t *pfn);
+#else
+static inline int dax_read_lock(void)
+{
+	/* all dax operations inside this lock will fail below */
+	return 0;
+}
+
+static inline void dax_read_unlock(int id)
+{
+}
+
+static inline struct dax_device *dax_get_by_host(const char *host)
+{
+	return NULL;
+}
+
+static inline void put_dax(struct dax_device *dax_dev)
+{
+}
+
+static inline long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff,
+		long nr_pages, void **kaddr, pfn_t *pfn)
+{
+	/* avoid 'uninitialized variable' warnings for @kaddr and @pfn */
+	*pfn = (pfn_t) { .val = ULLONG_MAX };
+	*kaddr = (void *) ULONG_MAX;
+
+	return -EOPNOTSUPP;
+}
+#endif
 struct dax_device *alloc_dax(void *private, const char *host,
 		const struct dax_operations *ops);
-void put_dax(struct dax_device *dax_dev);
 bool dax_alive(struct dax_device *dax_dev);
 void kill_dax(struct dax_device *dax_dev);
 void *dax_get_private(struct dax_device *dax_dev);
-long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages,
-		void **kaddr, pfn_t *pfn);
 
 /*
  * We use lowest available bit in exceptional entry for locking, one bit for

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] device-dax: kill NR_DEV_DAX
  2017-05-08 21:03 [PATCH 1/2] block, dax: move "select DAX" from BLOCK to FS_DAX Dan Williams
@ 2017-05-08 21:03 ` Dan Williams
  2017-05-09 14:21   ` Geert Uytterhoeven
  2017-05-08 22:36 ` [PATCH 1/2] block, dax: move "select DAX" from BLOCK to FS_DAX kbuild test robot
  1 sibling, 1 reply; 6+ messages in thread
From: Dan Williams @ 2017-05-08 21:03 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: linux-block, Geert Uytterhoeven, linux-kernel

There is no point to ask how many device-dax instances the kernel should
support. Since we are already using a dynamic major number, just allow
the max number of minors by default and be done. This also fixes the
fact that the proposed max for the NR_DEV_DAX range was larger than what
could be supported by alloc_chrdev_region().

Fixes: ba09c01d2fa8 ("dax: convert to the cdev api")
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/dax/Kconfig |    5 -----
 drivers/dax/super.c |   11 +++--------
 2 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/dax/Kconfig b/drivers/dax/Kconfig
index 6b7e20eae16c..b79aa8f7a497 100644
--- a/drivers/dax/Kconfig
+++ b/drivers/dax/Kconfig
@@ -28,9 +28,4 @@ config DEV_DAX_PMEM
 
 	  Say Y if unsure
 
-config NR_DEV_DAX
-	int "Maximum number of Device-DAX instances"
-	default 32768
-	range 256 2147483647
-
 endif
diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index 465dcd7317d5..f2d4f20eb2b8 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -20,10 +20,6 @@
 #include <linux/dax.h>
 #include <linux/fs.h>
 
-static int nr_dax = CONFIG_NR_DEV_DAX;
-module_param(nr_dax, int, S_IRUGO);
-MODULE_PARM_DESC(nr_dax, "max number of dax device instances");
-
 static dev_t dax_devt;
 DEFINE_STATIC_SRCU(dax_srcu);
 static struct vfsmount *dax_mnt;
@@ -261,7 +257,7 @@ struct dax_device *alloc_dax(void *private, const char *__host,
 	if (__host && !host)
 		return NULL;
 
-	minor = ida_simple_get(&dax_minor_ida, 0, nr_dax, GFP_KERNEL);
+	minor = ida_simple_get(&dax_minor_ida, 0, MINORMASK+1, GFP_KERNEL);
 	if (minor < 0)
 		goto err_minor;
 
@@ -405,8 +401,7 @@ static int __init dax_fs_init(void)
 	if (rc)
 		return rc;
 
-	nr_dax = max(nr_dax, 256);
-	rc = alloc_chrdev_region(&dax_devt, 0, nr_dax, "dax");
+	rc = alloc_chrdev_region(&dax_devt, 0, MINORMASK+1, "dax");
 	if (rc)
 		__dax_fs_exit();
 	return rc;
@@ -414,7 +409,7 @@ static int __init dax_fs_init(void)
 
 static void __exit dax_fs_exit(void)
 {
-	unregister_chrdev_region(dax_devt, nr_dax);
+	unregister_chrdev_region(dax_devt, MINORMASK+1);
 	ida_destroy(&dax_minor_ida);
 	__dax_fs_exit();
 }

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] block, dax: move "select DAX" from BLOCK to FS_DAX
  2017-05-08 21:03 [PATCH 1/2] block, dax: move "select DAX" from BLOCK to FS_DAX Dan Williams
  2017-05-08 21:03 ` [PATCH 2/2] device-dax: kill NR_DEV_DAX Dan Williams
@ 2017-05-08 22:36 ` kbuild test robot
  2017-05-09  7:57   ` Geert Uytterhoeven
  1 sibling, 1 reply; 6+ messages in thread
From: kbuild test robot @ 2017-05-08 22:36 UTC (permalink / raw)
  To: Dan Williams
  Cc: kbuild-all, linux-nvdimm, linux-block, Geert Uytterhoeven, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1530 bytes --]

Hi Dan,

[auto build test ERROR on linus/master]
[also build test ERROR on next-20170508]
[cannot apply to v4.11]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Dan-Williams/block-dax-move-select-DAX-from-BLOCK-to-FS_DAX/20170509-051522
config: parisc-c3000_defconfig (attached as .config)
compiler: hppa-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=parisc 

All errors (new ones prefixed by >>):

   fs/built-in.o: In function `bdev_dax_supported':
>> (.text.bdev_dax_supported+0x4c): undefined reference to `dax_get_by_host'
   fs/built-in.o: In function `bdev_dax_supported':
>> (.text.bdev_dax_supported+0x5c): undefined reference to `dax_read_lock'
   fs/built-in.o: In function `bdev_dax_supported':
>> (.text.bdev_dax_supported+0x7c): undefined reference to `dax_direct_access'
   fs/built-in.o: In function `bdev_dax_supported':
>> (.text.bdev_dax_supported+0x88): undefined reference to `dax_read_unlock'
   fs/built-in.o: In function `bdev_dax_supported':
>> (.text.bdev_dax_supported+0x90): undefined reference to `put_dax'

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 14644 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] block, dax: move "select DAX" from BLOCK to FS_DAX
  2017-05-08 22:36 ` [PATCH 1/2] block, dax: move "select DAX" from BLOCK to FS_DAX kbuild test robot
@ 2017-05-09  7:57   ` Geert Uytterhoeven
  2017-05-09 14:11     ` Dan Williams
  0 siblings, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2017-05-09  7:57 UTC (permalink / raw)
  To: Dan Williams
  Cc: kbuild-all, linux-nvdimm@lists.01.org, linux-block, linux-kernel,
	kbuild test robot

Hi Dan,

On Tue, May 9, 2017 at 12:36 AM, kbuild test robot <lkp@intel.com> wrote:
> [auto build test ERROR on linus/master]
> [also build test ERROR on next-20170508]
> [cannot apply to v4.11]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url:    https://github.com/0day-ci/linux/commits/Dan-Williams/block-dax-move-select-DAX-from-BLOCK-to-FS_DAX/20170509-051522
> config: parisc-c3000_defconfig (attached as .config)
> compiler: hppa-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
> reproduce:
>         wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # save the attached .config to linux build tree
>         make.cross ARCH=parisc
>
> All errors (new ones prefixed by >>):
>
>    fs/built-in.o: In function `bdev_dax_supported':
>>> (.text.bdev_dax_supported+0x4c): undefined reference to `dax_get_by_host'
>    fs/built-in.o: In function `bdev_dax_supported':
>>> (.text.bdev_dax_supported+0x5c): undefined reference to `dax_read_lock'
>    fs/built-in.o: In function `bdev_dax_supported':
>>> (.text.bdev_dax_supported+0x7c): undefined reference to `dax_direct_access'
>    fs/built-in.o: In function `bdev_dax_supported':
>>> (.text.bdev_dax_supported+0x88): undefined reference to `dax_read_unlock'
>    fs/built-in.o: In function `bdev_dax_supported':
>>> (.text.bdev_dax_supported+0x90): undefined reference to `put_dax'

I ran into the same issue if CONFIG_DAX=m (it's still selected by some other
modular symbol). #if IS_ENABLED(CONFIG_DAX) is true in the modular case, so
the dummies provided by include/linux/dax.h are not used.

However, while changing it to #ifdef CONFIG_DAX allows to build vmlinux, it
leads to other issues as DAX is compiled as a module:

    drivers/dax/super.c:35: error: redefinition of ‘dax_read_lock’
    include/linux/dax.h:30: error: previous definition of
‘dax_read_lock’ was here

Yes, calling into optional modular code from builtin code in fs/blockdev.c is
tricky ;-(  Perhaps you can make bdev_dax_supported() a small wrapper
that calls into the real code through a function pointer, when the DAX module
is available?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] block, dax: move "select DAX" from BLOCK to FS_DAX
  2017-05-09  7:57   ` Geert Uytterhoeven
@ 2017-05-09 14:11     ` Dan Williams
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Williams @ 2017-05-09 14:11 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: kbuild-all, linux-nvdimm@lists.01.org, linux-block, linux-kernel,
	kbuild test robot

On Tue, May 9, 2017 at 12:57 AM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> Hi Dan,
>
> On Tue, May 9, 2017 at 12:36 AM, kbuild test robot <lkp@intel.com> wrote:
>> [auto build test ERROR on linus/master]
>> [also build test ERROR on next-20170508]
>> [cannot apply to v4.11]
>> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>>
>> url:    https://github.com/0day-ci/linux/commits/Dan-Williams/block-dax-move-select-DAX-from-BLOCK-to-FS_DAX/20170509-051522
>> config: parisc-c3000_defconfig (attached as .config)
>> compiler: hppa-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
>> reproduce:
>>         wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>>         chmod +x ~/bin/make.cross
>>         # save the attached .config to linux build tree
>>         make.cross ARCH=parisc
>>
>> All errors (new ones prefixed by >>):
>>
>>    fs/built-in.o: In function `bdev_dax_supported':
>>>> (.text.bdev_dax_supported+0x4c): undefined reference to `dax_get_by_host'
>>    fs/built-in.o: In function `bdev_dax_supported':
>>>> (.text.bdev_dax_supported+0x5c): undefined reference to `dax_read_lock'
>>    fs/built-in.o: In function `bdev_dax_supported':
>>>> (.text.bdev_dax_supported+0x7c): undefined reference to `dax_direct_access'
>>    fs/built-in.o: In function `bdev_dax_supported':
>>>> (.text.bdev_dax_supported+0x88): undefined reference to `dax_read_unlock'
>>    fs/built-in.o: In function `bdev_dax_supported':
>>>> (.text.bdev_dax_supported+0x90): undefined reference to `put_dax'
>
> I ran into the same issue if CONFIG_DAX=m (it's still selected by some other
> modular symbol). #if IS_ENABLED(CONFIG_DAX) is true in the modular case, so
> the dummies provided by include/linux/dax.h are not used.
>
> However, while changing it to #ifdef CONFIG_DAX allows to build vmlinux, it
> leads to other issues as DAX is compiled as a module:
>
>     drivers/dax/super.c:35: error: redefinition of ‘dax_read_lock’
>     include/linux/dax.h:30: error: previous definition of
> ‘dax_read_lock’ was here
>
> Yes, calling into optional modular code from builtin code in fs/blockdev.c is
> tricky ;-(  Perhaps you can make bdev_dax_supported() a small wrapper
> that calls into the real code through a function pointer, when the DAX module
> is available?

In fact, that is close to what I did for v2, and it passed a full run
through the kbuild robot. I'll send it out shortly.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] device-dax: kill NR_DEV_DAX
  2017-05-08 21:03 ` [PATCH 2/2] device-dax: kill NR_DEV_DAX Dan Williams
@ 2017-05-09 14:21   ` Geert Uytterhoeven
  0 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2017-05-09 14:21 UTC (permalink / raw)
  To: Dan Williams; +Cc: linux-nvdimm@lists.01.org, linux-block, linux-kernel

On Mon, May 8, 2017 at 11:03 PM, Dan Williams <dan.j.williams@intel.com> wrote:
> There is no point to ask how many device-dax instances the kernel should
> support. Since we are already using a dynamic major number, just allow
> the max number of minors by default and be done. This also fixes the
> fact that the proposed max for the NR_DEV_DAX range was larger than what
> could be supported by alloc_chrdev_region().
>
> Fixes: ba09c01d2fa8 ("dax: convert to the cdev api")
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-05-09 14:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-08 21:03 [PATCH 1/2] block, dax: move "select DAX" from BLOCK to FS_DAX Dan Williams
2017-05-08 21:03 ` [PATCH 2/2] device-dax: kill NR_DEV_DAX Dan Williams
2017-05-09 14:21   ` Geert Uytterhoeven
2017-05-08 22:36 ` [PATCH 1/2] block, dax: move "select DAX" from BLOCK to FS_DAX kbuild test robot
2017-05-09  7:57   ` Geert Uytterhoeven
2017-05-09 14:11     ` Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).