Skip to contentSkip to conversation

iomap: hide iomap_sector with CONFIG_BLOCK=n

PATCH In review Arnd Bergmann 6 participants 12 messages Jul 18, 2019 – Jul 19, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iomap: hide iomap_sector with CONFIG_BLOCK=n

When CONFIG_BLOCK is disabled, SECTOR_SHIFT is unknown:

In file included from <built-in>:3:
include/linux/iomap.h:76:48: error: use of undeclared identifier 'SECTOR_SHIFT'

        return (iomap->addr + pos - iomap->offset) >> SECTOR_SHIFT;

Since there are no callers in this case, just hide the function in the same ifdef.

Fixes db074436f421 ("iomap: move the direct IO code into a separate file")
---
 include/linux/iomap.h | 2 ++
 1 file changed, 2 insertions(+)
include/linux/iomap.h +2 -0
index bc499ceae392..bb07f31e3b6f 100644
@@ -70,11 +70,13 @@ struct iomap {
 	const struct iomap_page_ops *page_ops;
 };
 
+#ifdef CONFIG_BLOCK
 static inline sector_t
 iomap_sector(struct iomap *iomap, loff_t pos)
 {
 	return (iomap->addr + pos - iomap->offset) >> SECTOR_SHIFT;
 }
+#endif
 
 /*
  * When a filesystem sets page_ops in an iomap mapping it returns, page_prepare
Signature · 1 line
2.20.0
#1 lore raw
Quoted 11 lines · Arnd Bergmann

When CONFIG_BLOCK is disabled, SECTOR_SHIFT is unknown:

In file included from <built-in>:3:
include/linux/iomap.h:76:48: error: use of undeclared identifier 'SECTOR_SHIFT'

        return (iomap->addr + pos - iomap->offset) >> SECTOR_SHIFT;

Since there are no callers in this case, just hide the function in the same ifdef.

Fixes db074436f421 ("iomap: move the direct IO code into a separate file")

Can we just not include iomap.c when CONFIG_BLOCK is not set? Which file do you see this with?

#2 lore raw
Quoted 8 lines · Christoph Hellwig
Quoted 6 lines · Arnd Bergmann

When CONFIG_BLOCK is disabled, SECTOR_SHIFT is unknown:

In file included from <built-in>:3:
include/linux/iomap.h:76:48: error: use of undeclared identifier 'SECTOR_SHIFT'

        return (iomap->addr + pos - iomap->offset) >> SECTOR_SHIFT;
Quoted 8 lines
Quoted 5 lines

Since there are no callers in this case, just hide the function in the same ifdef.

Fixes db074436f421 ("iomap: move the direct IO code into a separate file")

Can we just not include iomap.c when CONFIG_BLOCK is not set? Which file do you see this with?

The inclusion comes from the recently added header check in commit c93a0368aaa2 ("kbuild: do not create wrappers for header-test-y").

This just tries to include every header by itself to see if there are build failures from missing indirect includes. We probably don't want to add an exception for iomap.h there.

Arnd

#3 lore raw
Quoted 6 lines · Arnd Bergmann

The inclusion comes from the recently added header check in commit c93a0368aaa2 ("kbuild: do not create wrappers for header-test-y").

This just tries to include every header by itself to see if there are build failures from missing indirect includes. We probably don't want to add an exception for iomap.h there.

I very much disagree with that check. We don't need to make every header compilable with a setup where it should not be included.

That being said if you feel this is worth fixing I'd rather define SECTOR_SIZE/SECTOR_SHIFT unconditionally.

#4 lore raw
Quoted 10 lines · Christoph Hellwig
Quoted 6 lines · Arnd Bergmann

The inclusion comes from the recently added header check in commit c93a0368aaa2 ("kbuild: do not create wrappers for header-test-y").

This just tries to include every header by itself to see if there are build failures from missing indirect includes. We probably don't want to add an exception for iomap.h there.

I very much disagree with that check. We don't need to make every header compilable with a setup where it should not be included.

Seconded, unless there's some scenario where someone needs iomap when CONFIG_BLOCK=n (???)

--D

Quoted 2 lines

That being said if you feel this is worth fixing I'd rather define SECTOR_SIZE/SECTOR_SHIFT unconditionally.

#5 lore raw

Hi.

Quoted 10 lines · Darrick J. Wong
Quoted 8 lines · Christoph Hellwig
Quoted 6 lines · Arnd Bergmann

The inclusion comes from the recently added header check in commit c93a0368aaa2 ("kbuild: do not create wrappers for header-test-y").

This just tries to include every header by itself to see if there are build failures from missing indirect includes. We probably don't want to add an exception for iomap.h there.

Quoted 5 lines
Quoted 2 lines

I very much disagree with that check. We don't need to make every header compilable with a setup where it should not be included.

Seconded, unless there's some scenario where someone needs iomap when CONFIG_BLOCK=n (???)

I agree.

There is no situation that iomap.h is included when CONFIG_BLOCK=n. So, it is pointless to surround offending code with #ifdef just for the purpose of satisfying the header-test.

I started to think
compiling all headers is more painful than useful.

MW is closing, so I am thinking of disabling it for now to take time to re-think.

init/Kconfig +1 -0
index bd7d650d4a99..cbb31d134f7e 100644
@@ -111,6 +111,7 @@ config HEADER_TEST
 config KERNEL_HEADER_TEST
        bool "Compile test kernel headers"
        depends on HEADER_TEST
+       depends on BROKEN
        help
          Headers in include/ are used to build external moduls.
          Compile test them to ensure they are self-contained, i.e.

Maybe, we should compile-test headers
only when it is reasonable to do so.

Signature · 2 lines
Best Regards
Masahiro Yamada
#6 lore raw
Quoted 50 lines · Masahiro Yamada

Hi.

Quoted 10 lines · Darrick J. Wong
Quoted 8 lines · Christoph Hellwig
Quoted 6 lines · Arnd Bergmann

The inclusion comes from the recently added header check in commit c93a0368aaa2 ("kbuild: do not create wrappers for header-test-y").

This just tries to include every header by itself to see if there are build failures from missing indirect includes. We probably don't want to add an exception for iomap.h there.

Quoted 5 lines
Quoted 2 lines

I very much disagree with that check. We don't need to make every header compilable with a setup where it should not be included.

Seconded, unless there's some scenario where someone needs iomap when CONFIG_BLOCK=n (???)

I agree.

There is no situation that iomap.h is included when CONFIG_BLOCK=n. So, it is pointless to surround offending code with #ifdef just for the purpose of satisfying the header-test.

I started to think
compiling all headers is more painful than useful.

MW is closing, so I am thinking of disabling it for now to take time to re-think.

init/Kconfig +1 -0
index bd7d650d4a99..cbb31d134f7e 100644
@@ -111,6 +111,7 @@ config HEADER_TEST
 config KERNEL_HEADER_TEST
        bool "Compile test kernel headers"
        depends on HEADER_TEST
+       depends on BROKEN
        help
          Headers in include/ are used to build external moduls.
          Compile test them to ensure they are self-contained, i.e.
Quoted 2 lines

Maybe, we should compile-test headers
only when it is reasonable to do so.

Maybe. But I would find it easier to use if it were a make target instead of a Kconfig symbol, so someone could do

$ make compile_test_headers

for example. Then it would be done only on demand (or command).

Signature · 1 line
~Randy
#7 lore raw
Quoted 52 lines · Randy Dunlap
Quoted 50 lines · Masahiro Yamada

Hi.

Quoted 10 lines · Darrick J. Wong
Quoted 8 lines · Christoph Hellwig
Quoted 6 lines · Arnd Bergmann

The inclusion comes from the recently added header check in commit c93a0368aaa2 ("kbuild: do not create wrappers for header-test-y").

This just tries to include every header by itself to see if there are build failures from missing indirect includes. We probably don't want to add an exception for iomap.h there.

Quoted 5 lines
Quoted 2 lines

I very much disagree with that check. We don't need to make every header compilable with a setup where it should not be included.

Seconded, unless there's some scenario where someone needs iomap when CONFIG_BLOCK=n (???)

I agree.

There is no situation that iomap.h is included when CONFIG_BLOCK=n. So, it is pointless to surround offending code with #ifdef just for the purpose of satisfying the header-test.

I started to think
compiling all headers is more painful than useful.

MW is closing, so I am thinking of disabling it for now to take time to re-think.

init/Kconfig +1 -0
index bd7d650d4a99..cbb31d134f7e 100644
@@ -111,6 +111,7 @@ config HEADER_TEST
 config KERNEL_HEADER_TEST
        bool "Compile test kernel headers"
        depends on HEADER_TEST
+       depends on BROKEN
        help
          Headers in include/ are used to build external moduls.
          Compile test them to ensure they are self-contained, i.e.
Quoted 6 lines
Quoted 2 lines

Maybe, we should compile-test headers
only when it is reasonable to do so.

Maybe. But I would find it easier to use if it were a make target instead of a Kconfig symbol, so someone could do

$ make compile_test_headers

You can do equivalent with this:

$ ./scripts/config -e HEADER_TEST
$ make include/
Signature · 2 lines
Best Regards
Masahiro Yamada
#8 lore raw
In reply to Masahiro Yamada
Quoted 6 lines · Masahiro Yamada

I started to think
compiling all headers is more painful than useful.

MW is closing, so I am thinking of disabling it for now to take time to re-think.

For now this seems like the best idea. In the long run maybe we can limit the tests to certain configs, e.g.

headers-$(CONFIG_IOMAP) += iomap.h

in include/linux/Kbuild

and base it off that?

#9 lore raw
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Masahiro Yamada

I started to think
compiling all headers is more painful than useful.

Quoted 8 lines
Quoted 2 lines

MW is closing, so I am thinking of disabling it for now to take time to re-think.

For now this seems like the best idea. In the long run maybe we can limit the tests to certain configs, e.g.

headers-$(CONFIG_IOMAP) += iomap.h

I cannot find CONFIG_IOMAP.

Do you mean

header-test-$(CONFIG_BLOCK) += iomap.h

?

Quoted 3 lines

in include/linux/Kbuild

and base it off that?

Yes, I was thinking of that.

Signature · 2 lines
Best Regards
Masahiro Yamada
#10 lore raw
Quoted 7 lines · Masahiro Yamada
Quoted 1 line

headers-$(CONFIG_IOMAP) += iomap.h

I cannot find CONFIG_IOMAP.

Do you mean

header-test-$(CONFIG_BLOCK) += iomap.h

Yeah, we could use CONFIG_BLOCK.

#11 lore raw
In reply to Christoph Hellwig
Quoted 11 lines · Christoph Hellwig
Quoted 6 lines · Arnd Bergmann

The inclusion comes from the recently added header check in commit c93a0368aaa2 ("kbuild: do not create wrappers for header-test-y").

This just tries to include every header by itself to see if there are build failures from missing indirect includes. We probably don't want to add an exception for iomap.h there.

I very much disagree with that check. We don't need to make every header compilable with a setup where it should not be included.

I do like the extra check there, and it did not seem to need too many fixes to get it working in the first place.

Quoted 2 lines

That being said if you feel this is worth fixing I'd rather define SECTOR_SIZE/SECTOR_SHIFT unconditionally.

I'll give that a try and send a replacement patch after build testing succeeds for a number of randconfig builds.

Arnd