* [PATCH] [v2] blkdev: always export SECTOR_SHIFT
@ 2019-07-19 11:31 Arnd Bergmann
2019-07-19 12:13 ` Christoph Hellwig
2019-07-19 12:47 ` Masahiro Yamada
0 siblings, 2 replies; 6+ messages in thread
From: Arnd Bergmann @ 2019-07-19 11:31 UTC (permalink / raw)
To: linux-kernel
Cc: Masahiro Yamada, Jani Nikula, Randy Dunlap, Arnd Bergmann,
Darrick J. Wong, Christoph Hellwig, Jens Axboe, Hannes Reinecke,
Omar Sandoval, Martin K. Petersen
When CONFIG_BLOCK is disabled, SECTOR_SHIFT is unknown, and this leads
to a failure in the testing infrastructure added from commit c93a0368aaa2
("kbuild: do not create wrappers for header-test-y"):
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;
If we want to keep build testing all headers, the macro needs to
either be defined, or not used. Move it out of the #ifdef
section to ensure it is visible.
Fixes: db074436f421 ("iomap: move the direct IO code into a separate file")
Link: https://lore.kernel.org/lkml/20190718125509.775525-1-arnd@arndb.de/T/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
The discussion about the build testing is still going on, but I promised
to send this version anyway for reference. I see no other header-test
failures in randconfig builds with this patch.
---
include/linux/blkdev.h | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 0ec4f975437e..9c22d8bc6bf9 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -5,6 +5,19 @@
#include <linux/sched.h>
#include <linux/sched/clock.h>
+/*
+ * The basic unit of block I/O is a sector. It is used in a number of contexts
+ * in Linux (blk, bio, genhd). The size of one sector is 512 = 2**9
+ * bytes. Variables of type sector_t represent an offset or size that is a
+ * multiple of 512 bytes. Hence these two constants.
+ */
+#ifndef SECTOR_SHIFT
+#define SECTOR_SHIFT 9
+#endif
+#ifndef SECTOR_SIZE
+#define SECTOR_SIZE (1 << SECTOR_SHIFT)
+#endif
+
#ifdef CONFIG_BLOCK
#include <linux/major.h>
@@ -889,19 +902,6 @@ static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
return bdev->bd_disk->queue; /* this is never NULL */
}
-/*
- * The basic unit of block I/O is a sector. It is used in a number of contexts
- * in Linux (blk, bio, genhd). The size of one sector is 512 = 2**9
- * bytes. Variables of type sector_t represent an offset or size that is a
- * multiple of 512 bytes. Hence these two constants.
- */
-#ifndef SECTOR_SHIFT
-#define SECTOR_SHIFT 9
-#endif
-#ifndef SECTOR_SIZE
-#define SECTOR_SIZE (1 << SECTOR_SHIFT)
-#endif
-
/*
* blk_rq_pos() : the current sector
* blk_rq_bytes() : bytes left in the entire request
--
2.20.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] [v2] blkdev: always export SECTOR_SHIFT
2019-07-19 11:31 [PATCH] [v2] blkdev: always export SECTOR_SHIFT Arnd Bergmann
@ 2019-07-19 12:13 ` Christoph Hellwig
2019-07-19 13:14 ` Arnd Bergmann
2019-07-19 12:47 ` Masahiro Yamada
1 sibling, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2019-07-19 12:13 UTC (permalink / raw)
To: Arnd Bergmann
Cc: linux-kernel, Masahiro Yamada, Jani Nikula, Randy Dunlap,
Darrick J. Wong, Christoph Hellwig, Jens Axboe, Hannes Reinecke,
Omar Sandoval, Martin K. Petersen
> +/*
> + * The basic unit of block I/O is a sector. It is used in a number of contexts
> + * in Linux (blk, bio, genhd). The size of one sector is 512 = 2**9
> + * bytes. Variables of type sector_t represent an offset or size that is a
> + * multiple of 512 bytes. Hence these two constants.
> + */
> +#ifndef SECTOR_SHIFT
> +#define SECTOR_SHIFT 9
> +#endif
> +#ifndef SECTOR_SIZE
> +#define SECTOR_SIZE (1 << SECTOR_SHIFT)
> +#endif
While we're at it we really should drop the ifndefs.
Otherwise looks good.
In fact given that sector_t is in linux/types.h I wonder if these
should just move there.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [v2] blkdev: always export SECTOR_SHIFT
2019-07-19 11:31 [PATCH] [v2] blkdev: always export SECTOR_SHIFT Arnd Bergmann
2019-07-19 12:13 ` Christoph Hellwig
@ 2019-07-19 12:47 ` Masahiro Yamada
2019-07-19 13:15 ` Arnd Bergmann
1 sibling, 1 reply; 6+ messages in thread
From: Masahiro Yamada @ 2019-07-19 12:47 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Linux Kernel Mailing List, Jani Nikula, Randy Dunlap,
Darrick J. Wong, Christoph Hellwig, Jens Axboe, Hannes Reinecke,
Omar Sandoval, Martin K. Petersen
Hi Arnd,
On Fri, Jul 19, 2019 at 8:32 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> When CONFIG_BLOCK is disabled, SECTOR_SHIFT is unknown, and this leads
> to a failure in the testing infrastructure added from commit c93a0368aaa2
> ("kbuild: do not create wrappers for header-test-y"):
I think this should be
commit 43c78d88036e ("kbuild: compile-test kernel headers to ensure
they are self-contained")
Thanks.
>
> 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;
>
> If we want to keep build testing all headers, the macro needs to
> either be defined, or not used. Move it out of the #ifdef
> section to ensure it is visible.
>
> Fixes: db074436f421 ("iomap: move the direct IO code into a separate file")
> Link: https://lore.kernel.org/lkml/20190718125509.775525-1-arnd@arndb.de/T/
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> The discussion about the build testing is still going on, but I promised
> to send this version anyway for reference. I see no other header-test
> failures in randconfig builds with this patch.
> ---
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [v2] blkdev: always export SECTOR_SHIFT
2019-07-19 12:13 ` Christoph Hellwig
@ 2019-07-19 13:14 ` Arnd Bergmann
2019-07-19 13:28 ` Arnd Bergmann
0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2019-07-19 13:14 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Linux Kernel Mailing List, Masahiro Yamada, Jani Nikula,
Randy Dunlap, Darrick J. Wong, Jens Axboe, Hannes Reinecke,
Omar Sandoval, Martin K. Petersen
On Fri, Jul 19, 2019 at 2:13 PM Christoph Hellwig <hch@lst.de> wrote:
>
> > +/*
> > + * The basic unit of block I/O is a sector. It is used in a number of contexts
> > + * in Linux (blk, bio, genhd). The size of one sector is 512 = 2**9
> > + * bytes. Variables of type sector_t represent an offset or size that is a
> > + * multiple of 512 bytes. Hence these two constants.
> > + */
> > +#ifndef SECTOR_SHIFT
> > +#define SECTOR_SHIFT 9
> > +#endif
> > +#ifndef SECTOR_SIZE
> > +#define SECTOR_SIZE (1 << SECTOR_SHIFT)
> > +#endif
>
> While we're at it we really should drop the ifndefs.
Good idea. Needs some more build testing then.
> Otherwise looks good.
>
> In fact given that sector_t is in linux/types.h I wonder if these
> should just move there.
Less sure about that, we don't really have other constants in that
file, just typedefs and a few common structures.
ARnd
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [v2] blkdev: always export SECTOR_SHIFT
2019-07-19 12:47 ` Masahiro Yamada
@ 2019-07-19 13:15 ` Arnd Bergmann
0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2019-07-19 13:15 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Linux Kernel Mailing List, Jani Nikula, Randy Dunlap,
Darrick J. Wong, Christoph Hellwig, Jens Axboe, Hannes Reinecke,
Omar Sandoval, Martin K. Petersen
On Fri, Jul 19, 2019 at 2:48 PM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> Hi Arnd,
>
> On Fri, Jul 19, 2019 at 8:32 PM Arnd Bergmann <arnd@arndb.de> wrote:
> >
> > When CONFIG_BLOCK is disabled, SECTOR_SHIFT is unknown, and this leads
> > to a failure in the testing infrastructure added from commit c93a0368aaa2
> > ("kbuild: do not create wrappers for header-test-y"):
>
> I think this should be
>
> commit 43c78d88036e ("kbuild: compile-test kernel headers to ensure
> they are self-contained")
Ok, fixing that in the resend without the #ifndef.
Arnd
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [v2] blkdev: always export SECTOR_SHIFT
2019-07-19 13:14 ` Arnd Bergmann
@ 2019-07-19 13:28 ` Arnd Bergmann
0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2019-07-19 13:28 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Linux Kernel Mailing List, Masahiro Yamada, Jani Nikula,
Randy Dunlap, Darrick J. Wong, Jens Axboe, Hannes Reinecke,
Omar Sandoval, Martin K. Petersen
On Fri, Jul 19, 2019 at 3:14 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Fri, Jul 19, 2019 at 2:13 PM Christoph Hellwig <hch@lst.de> wrote:
> >
> > > +/*
> > > + * The basic unit of block I/O is a sector. It is used in a number of contexts
> > > + * in Linux (blk, bio, genhd). The size of one sector is 512 = 2**9
> > > + * bytes. Variables of type sector_t represent an offset or size that is a
> > > + * multiple of 512 bytes. Hence these two constants.
> > > + */
> > > +#ifndef SECTOR_SHIFT
> > > +#define SECTOR_SHIFT 9
> > > +#endif
> > > +#ifndef SECTOR_SIZE
> > > +#define SECTOR_SIZE (1 << SECTOR_SHIFT)
> > > +#endif
> >
> > While we're at it we really should drop the ifndefs.
>
> Good idea. Needs some more build testing then.
Did not take long:
In file included from block/partitions/msdos.c:24:
In file included from block/partitions/check.h:3:
include/linux/blkdev.h:15:9: error: 'SECTOR_SIZE' macro redefined
[-Werror,-Wmacro-redefined]
#define SECTOR_SIZE (1 << SECTOR_SHIFT)
^
include/uapi/linux/msdos_fs.h:14:9: note: previous definition is here
#define SECTOR_SIZE 512 /* sector size (bytes) */
^
This could clearly be fixed as well, but I suspect we're better off not touching
it any further than necessary.
Arnd
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-07-19 13:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-19 11:31 [PATCH] [v2] blkdev: always export SECTOR_SHIFT Arnd Bergmann
2019-07-19 12:13 ` Christoph Hellwig
2019-07-19 13:14 ` Arnd Bergmann
2019-07-19 13:28 ` Arnd Bergmann
2019-07-19 12:47 ` Masahiro Yamada
2019-07-19 13:15 ` Arnd Bergmann
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).