2021-01-12 15:32:23

by Li Feng

[permalink] [raw]
Subject: [PATCH] blk: avoid divide-by-zero with zero granularity

If the physical_block_size and io_min is less than a sector, the
'granularity >> SECTOR_SHIFT' will be zero.

Signed-off-by: Li Feng <[email protected]>
---
include/linux/blkdev.h | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index f94ee3089e01..4d029e95adb4 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1485,6 +1485,10 @@ static inline int queue_alignment_offset(const struct request_queue *q)
static inline int queue_limit_alignment_offset(struct queue_limits *lim, sector_t sector)
{
unsigned int granularity = max(lim->physical_block_size, lim->io_min);
+ granularity = granularity >> SECTOR_SHIFT;
+ if (!granularity)
+ return 0;
+
unsigned int alignment = sector_div(sector, granularity >> SECTOR_SHIFT)
<< SECTOR_SHIFT;

--
2.29.2


2021-01-12 15:37:02

by Li Feng

[permalink] [raw]
Subject: Re: [PATCH] blk: avoid divide-by-zero with zero granularity

I'm sorry, ignore this one.

Li Feng <[email protected]> 于2021年1月12日周二 下午11:30写道:
>
> If the physical_block_size and io_min is less than a sector, the
> 'granularity >> SECTOR_SHIFT' will be zero.
>
> Signed-off-by: Li Feng <[email protected]>
> ---
> include/linux/blkdev.h | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index f94ee3089e01..4d029e95adb4 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -1485,6 +1485,10 @@ static inline int queue_alignment_offset(const struct request_queue *q)
> static inline int queue_limit_alignment_offset(struct queue_limits *lim, sector_t sector)
> {
> unsigned int granularity = max(lim->physical_block_size, lim->io_min);
> + granularity = granularity >> SECTOR_SHIFT;
> + if (!granularity)
> + return 0;
> +
> unsigned int alignment = sector_div(sector, granularity >> SECTOR_SHIFT)
> << SECTOR_SHIFT;
>
> --
> 2.29.2
>

2021-01-12 16:00:08

by Li Feng

[permalink] [raw]
Subject: [PATCH v2] blk: avoid divide-by-zero with zero granularity

If the physical_block_size and io_min is less than a sector, the
'granularity >> SECTOR_SHIFT' will be zero.

Signed-off-by: Li Feng <[email protected]>
---
include/linux/blkdev.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index f94ee3089e01..ffffb04ad113 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1485,7 +1485,11 @@ static inline int queue_alignment_offset(const struct request_queue *q)
static inline int queue_limit_alignment_offset(struct queue_limits *lim, sector_t sector)
{
unsigned int granularity = max(lim->physical_block_size, lim->io_min);
- unsigned int alignment = sector_div(sector, granularity >> SECTOR_SHIFT)
+ unsigned int alignment;
+ if (granularity >> SECTOR_SHIFT == 0)
+ return 0;
+
+ alignment = sector_div(sector, granularity >> SECTOR_SHIFT)
<< SECTOR_SHIFT;

return (granularity + lim->alignment_offset - alignment) % granularity;
--
2.29.2

2021-01-12 17:13:38

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH v2] blk: avoid divide-by-zero with zero granularity


Li,

> If the physical_block_size and io_min is less than a sector,

That's not supposed to happen. What device/driver is this?

--
Martin K. Petersen Oracle Linux Engineering

2021-01-12 17:31:53

by Li Feng

[permalink] [raw]
Subject: Re: [PATCH v2] blk: avoid divide-by-zero with zero granularity

Hi Martin,

I use the nvme-tcp as the host, the target is spdk nvme-tcp target,
and set a wrong block size(i.g. bs=8), then the host prints this oops:

[ 63.153018] nvme nvme0: creating 3 I/O queues.
[ 63.181644] nvme nvme0: mapped 3/0/0 default/read/poll queues.
[ 63.185568] nvme nvme0: new ctrl: NQN
"nqn.2018-11.io.spdk:nvmf-test", addr 192.168.64.217:4421
[ 63.189440] divide error: 0000 [#1] SMP NOPTI
[ 63.190963] CPU: 0 PID: 122 Comm: kworker/u8:2 Not tainted
5.9.9-200.fc33.x86_64 #1
[ 63.193426] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
BIOS 1.14.0-1.fc33 04/01/2014
[ 63.196263] Workqueue: nvme-wq nvme_scan_work [nvme_core]
[ 63.198015] RIP: 0010:blk_stack_limits+0x189/0x440
[ 63.199549] Code: 43 28 0f b6 45 62 08 43 62 8b 4d 2c 39 4d 38 0f
43 4d 38 31 d2 45 31 f6 48 8b 04 24 8b 75 34 89 cf 44 8b 43 34 c1 ef
09 09
[ 63.203169] RSP: 0018:ffffb312001ffc98 EFLAGS: 00010202
[ 63.204034] RAX: 0000000000000000 RBX: ffff9463b270ecc8 RCX: 0000000000000008
[ 63.205205] RDX: 0000000000000000 RSI: 0000000000000008 RDI: 0000000000000000
[ 63.206377] RBP: ffff9463b27083f8 R08: 0000000000000000 R09: 0000000000000008
[ 63.207553] R10: ffff9463b81d6420 R11: 0000035f00000000 R12: ffff9463b2bea000
[ 63.208725] R13: ffff9463b6d31258 R14: 0000000000000000 R15: ffff9463b6c22800
[ 63.209914] FS: 0000000000000000(0000) GS:ffff9463bec00000(0000)
knlGS:0000000000000000
[ 63.211239] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 63.212186] CR2: 000055d73270e690 CR3: 0000000036b32000 CR4: 00000000000006f0
[ 63.213383] Call Trace:
[ 63.213826] ? blk_mq_freeze_queue_wait+0x13/0x80
[ 63.214609] __nvme_revalidate_disk+0x191/0x2d0 [nvme_core]
[ 63.215528] nvme_validate_ns+0x3fa/0x960 [nvme_core]
[ 63.216374] nvme_scan_work+0x165/0x3c0 [nvme_core]
[ 63.217183] process_one_work+0x1b4/0x370
[ 63.217852] worker_thread+0x53/0x3e0
[ 63.218458] ? process_one_work+0x370/0x370
[ 63.219156] kthread+0x11b/0x140
[ 63.219700] ? __kthread_bind_mask+0x60/0x60
[ 63.220403] ret_from_fork+0x22/0x30

Martin K. Petersen <[email protected]> 于2021年1月13日周三 上午1:10写道:
>
>
> Li,
>
> > If the physical_block_size and io_min is less than a sector,
>
> That's not supposed to happen. What device/driver is this?
>
> --
> Martin K. Petersen Oracle Linux Engineering

2021-01-12 17:52:02

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH v2] blk: avoid divide-by-zero with zero granularity


Johannes,

>> I use the nvme-tcp as the host, the target is spdk nvme-tcp target,
>> and set a wrong block size(i.g. bs=8), then the host prints this oops:
>
> I think the better fix here is to reject devices which report a block size
> small than a sector.

Yep, Linux doesn't support logical block sizes < 512 bytes.

Also, the NVMe spec states:

"A value smaller than 9 (i.e., 512 bytes) is not supported."

--
Martin K. Petersen Oracle Linux Engineering

2021-01-13 02:24:43

by Johannes Thumshirn

[permalink] [raw]
Subject: Re: [PATCH v2] blk: avoid divide-by-zero with zero granularity

On 12/01/2021 18:29, Feng Li wrote:
> I use the nvme-tcp as the host, the target is spdk nvme-tcp target,
> and set a wrong block size(i.g. bs=8), then the host prints this oops:

I think the better fix here is to reject devices which report a block size
small than a sector.

2021-01-13 02:26:06

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] blk: avoid divide-by-zero with zero granularity

Hi Li,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on block/for-next]
[also build test ERROR on v5.11-rc3 next-20210112]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Li-Feng/blk-avoid-divide-by-zero-with-zero-granularity/20210112-233454
base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
config: x86_64-randconfig-c002-20210112 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/796e67f6b22f94f155669688e5e08281621b3ee6
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Li-Feng/blk-avoid-divide-by-zero-with-zero-granularity/20210112-233454
git checkout 796e67f6b22f94f155669688e5e08281621b3ee6
# save the attached .config to linux build tree
make W=1 ARCH=x86_64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

In file included from include/linux/blk-cgroup.h:23,
from include/linux/writeback.h:14,
from include/linux/memcontrol.h:22,
from include/linux/swap.h:9,
from include/linux/shmem_fs.h:6,
from drivers/gpu/drm/i915/i915_drv.h:49,
from <command-line>:
include/linux/blkdev.h: In function 'queue_limit_alignment_offset':
>> include/linux/blkdev.h:1492:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
1492 | unsigned int alignment = sector_div(sector, granularity >> SECTOR_SHIFT)
| ^~~~~~~~
cc1: all warnings being treated as errors


vim +1492 include/linux/blkdev.h

c72758f33784e5e2 Martin K. Petersen 2009-05-22 1484
e03a72e13648ac62 Martin K. Petersen 2010-01-11 1485 static inline int queue_limit_alignment_offset(struct queue_limits *lim, sector_t sector)
81744ee44ab2845c Martin K. Petersen 2009-12-29 1486 {
81744ee44ab2845c Martin K. Petersen 2009-12-29 1487 unsigned int granularity = max(lim->physical_block_size, lim->io_min);
796e67f6b22f94f1 Li Feng 2021-01-12 1488 granularity = granularity >> SECTOR_SHIFT;
796e67f6b22f94f1 Li Feng 2021-01-12 1489 if (!granularity)
796e67f6b22f94f1 Li Feng 2021-01-12 1490 return 0;
796e67f6b22f94f1 Li Feng 2021-01-12 1491
233bde21aa43516b Bart Van Assche 2018-03-14 @1492 unsigned int alignment = sector_div(sector, granularity >> SECTOR_SHIFT)
233bde21aa43516b Bart Van Assche 2018-03-14 1493 << SECTOR_SHIFT;
81744ee44ab2845c Martin K. Petersen 2009-12-29 1494
b8839b8c55f3fdd6 Mike Snitzer 2014-10-08 1495 return (granularity + lim->alignment_offset - alignment) % granularity;
c72758f33784e5e2 Martin K. Petersen 2009-05-22 1496 }
c72758f33784e5e2 Martin K. Petersen 2009-05-22 1497

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (3.27 kB)
.config.gz (35.63 kB)
Download all attachments

2021-01-13 03:23:34

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] blk: avoid divide-by-zero with zero granularity

Hi Li,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on block/for-next]
[also build test WARNING on v5.11-rc3 next-20210112]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Li-Feng/blk-avoid-divide-by-zero-with-zero-granularity/20210112-233454
base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
config: microblaze-randconfig-c004-20210112 (attached as .config)
compiler: microblaze-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/796e67f6b22f94f155669688e5e08281621b3ee6
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Li-Feng/blk-avoid-divide-by-zero-with-zero-granularity/20210112-233454
git checkout 796e67f6b22f94f155669688e5e08281621b3ee6
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=microblaze

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

In file included from include/linux/blk-cgroup.h:23,
from include/linux/writeback.h:14,
from include/linux/memcontrol.h:22,
from include/net/sock.h:53,
from include/linux/tcp.h:19,
from include/linux/ipv6.h:88,
from include/net/ipv6.h:12,
from include/net/inetpeer.h:16,
from include/net/ip_fib.h:20,
from include/net/switchdev.h:13,
from net/bridge/br.c:18:
include/linux/blkdev.h: In function 'queue_limit_alignment_offset':
>> include/linux/blkdev.h:1492:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
1492 | unsigned int alignment = sector_div(sector, granularity >> SECTOR_SHIFT)
| ^~~~~~~~


vim +1492 include/linux/blkdev.h

c72758f33784e5e2 Martin K. Petersen 2009-05-22 1484
e03a72e13648ac62 Martin K. Petersen 2010-01-11 1485 static inline int queue_limit_alignment_offset(struct queue_limits *lim, sector_t sector)
81744ee44ab2845c Martin K. Petersen 2009-12-29 1486 {
81744ee44ab2845c Martin K. Petersen 2009-12-29 1487 unsigned int granularity = max(lim->physical_block_size, lim->io_min);
796e67f6b22f94f1 Li Feng 2021-01-12 1488 granularity = granularity >> SECTOR_SHIFT;
796e67f6b22f94f1 Li Feng 2021-01-12 1489 if (!granularity)
796e67f6b22f94f1 Li Feng 2021-01-12 1490 return 0;
796e67f6b22f94f1 Li Feng 2021-01-12 1491
233bde21aa43516b Bart Van Assche 2018-03-14 @1492 unsigned int alignment = sector_div(sector, granularity >> SECTOR_SHIFT)
233bde21aa43516b Bart Van Assche 2018-03-14 1493 << SECTOR_SHIFT;
81744ee44ab2845c Martin K. Petersen 2009-12-29 1494
b8839b8c55f3fdd6 Mike Snitzer 2014-10-08 1495 return (granularity + lim->alignment_offset - alignment) % granularity;
c72758f33784e5e2 Martin K. Petersen 2009-05-22 1496 }
c72758f33784e5e2 Martin K. Petersen 2009-05-22 1497

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (3.62 kB)
.config.gz (29.87 kB)
Download all attachments

2021-01-13 03:44:16

by Li Feng

[permalink] [raw]
Subject: Re: [PATCH v2] blk: avoid divide-by-zero with zero granularity

Yes, Reject the device is the right fix. I will try to send another fix.
By the way, I think this fix is good protection, maybe some other devices
violate this block size constraint.

Divide zero is unacceptable.

Thanks,
Feng Li

Martin K. Petersen <[email protected]> 于2021年1月13日周三 上午1:48写道:
>
>
> Johannes,
>
> >> I use the nvme-tcp as the host, the target is spdk nvme-tcp target,
> >> and set a wrong block size(i.g. bs=8), then the host prints this oops:
> >
> > I think the better fix here is to reject devices which report a block size
> > small than a sector.
>
> Yep, Linux doesn't support logical block sizes < 512 bytes.
>
> Also, the NVMe spec states:
>
> "A value smaller than 9 (i.e., 512 bytes) is not supported."
>
> --
> Martin K. Petersen Oracle Linux Engineering

2021-01-13 04:07:52

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] blk: avoid divide-by-zero with zero granularity

Hi Li,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on block/for-next]
[also build test WARNING on v5.11-rc3 next-20210112]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Li-Feng/blk-avoid-divide-by-zero-with-zero-granularity/20210112-233454
base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
config: arm-randconfig-r012-20210112 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 32bcfcda4e28375e5a85268d2acfabcfcc011abf)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/0day-ci/linux/commit/796e67f6b22f94f155669688e5e08281621b3ee6
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Li-Feng/blk-avoid-divide-by-zero-with-zero-granularity/20210112-233454
git checkout 796e67f6b22f94f155669688e5e08281621b3ee6
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

In file included from drivers/ata/ahci_ceva.c:11:
In file included from include/linux/libata.h:21:
In file included from include/scsi/scsi_host.h:11:
In file included from include/linux/blk-mq.h:5:
>> include/linux/blkdev.h:1492:15: warning: ISO C90 forbids mixing declarations and code [-Wdeclaration-after-statement]
unsigned int alignment = sector_div(sector, granularity >> SECTOR_SHIFT)
^
drivers/ata/ahci_ceva.c:187:2: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:387:16: note: expanded from macro 'AHCI_SHT'
.can_queue = AHCI_MAX_CMDS, \
^~~~~~~~~~~~~
drivers/ata/ahci_ceva.c:187:2: note: previous initialization is here
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:386:2: note: expanded from macro 'AHCI_SHT'
ATA_NCQ_SHT(drv_name), \
^~~~~~~~~~~~~~~~~~~~~
include/linux/libata.h:1418:2: note: expanded from macro 'ATA_NCQ_SHT'
__ATA_BASE_SHT(drv_name), \
^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/libata.h:1400:16: note: expanded from macro '__ATA_BASE_SHT'
.can_queue = ATA_DEF_QUEUE, \
^~~~~~~~~~~~~
drivers/ata/ahci_ceva.c:187:2: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:391:17: note: expanded from macro 'AHCI_SHT'
.sdev_attrs = ahci_sdev_attrs
^~~~~~~~~~~~~~~
drivers/ata/ahci_ceva.c:187:2: note: previous initialization is here
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:386:2: note: expanded from macro 'AHCI_SHT'
ATA_NCQ_SHT(drv_name), \
^~~~~~~~~~~~~~~~~~~~~
include/linux/libata.h:1419:17: note: expanded from macro 'ATA_NCQ_SHT'
.sdev_attrs = ata_ncq_sdev_attrs, \
^~~~~~~~~~~~~~~~~~
3 warnings generated.
--
In file included from drivers/ata/ahci_sunxi.c:19:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:22:
In file included from include/linux/writeback.h:14:
In file included from include/linux/blk-cgroup.h:23:
>> include/linux/blkdev.h:1492:15: warning: ISO C90 forbids mixing declarations and code [-Wdeclaration-after-statement]
unsigned int alignment = sector_div(sector, granularity >> SECTOR_SHIFT)
^
drivers/ata/ahci_sunxi.c:210:2: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:387:16: note: expanded from macro 'AHCI_SHT'
.can_queue = AHCI_MAX_CMDS, \
^~~~~~~~~~~~~
drivers/ata/ahci_sunxi.c:210:2: note: previous initialization is here
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:386:2: note: expanded from macro 'AHCI_SHT'
ATA_NCQ_SHT(drv_name), \
^~~~~~~~~~~~~~~~~~~~~
include/linux/libata.h:1418:2: note: expanded from macro 'ATA_NCQ_SHT'
__ATA_BASE_SHT(drv_name), \
^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/libata.h:1400:16: note: expanded from macro '__ATA_BASE_SHT'
.can_queue = ATA_DEF_QUEUE, \
^~~~~~~~~~~~~
drivers/ata/ahci_sunxi.c:210:2: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:391:17: note: expanded from macro 'AHCI_SHT'
.sdev_attrs = ahci_sdev_attrs
^~~~~~~~~~~~~~~
drivers/ata/ahci_sunxi.c:210:2: note: previous initialization is here
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:386:2: note: expanded from macro 'AHCI_SHT'
ATA_NCQ_SHT(drv_name), \
^~~~~~~~~~~~~~~~~~~~~
include/linux/libata.h:1419:17: note: expanded from macro 'ATA_NCQ_SHT'
.sdev_attrs = ata_ncq_sdev_attrs, \
^~~~~~~~~~~~~~~~~~
3 warnings generated.
--
In file included from drivers/ata/ahci_st.c:16:
In file included from include/linux/libata.h:21:
In file included from include/scsi/scsi_host.h:11:
In file included from include/linux/blk-mq.h:5:
>> include/linux/blkdev.h:1492:15: warning: ISO C90 forbids mixing declarations and code [-Wdeclaration-after-statement]
unsigned int alignment = sector_div(sector, granularity >> SECTOR_SHIFT)
^
drivers/ata/ahci_st.c:142:2: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:387:16: note: expanded from macro 'AHCI_SHT'
.can_queue = AHCI_MAX_CMDS, \
^~~~~~~~~~~~~
drivers/ata/ahci_st.c:142:2: note: previous initialization is here
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:386:2: note: expanded from macro 'AHCI_SHT'
ATA_NCQ_SHT(drv_name), \
^~~~~~~~~~~~~~~~~~~~~
include/linux/libata.h:1418:2: note: expanded from macro 'ATA_NCQ_SHT'
__ATA_BASE_SHT(drv_name), \
^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/libata.h:1400:16: note: expanded from macro '__ATA_BASE_SHT'
.can_queue = ATA_DEF_QUEUE, \
^~~~~~~~~~~~~
drivers/ata/ahci_st.c:142:2: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:391:17: note: expanded from macro 'AHCI_SHT'
.sdev_attrs = ahci_sdev_attrs
^~~~~~~~~~~~~~~
drivers/ata/ahci_st.c:142:2: note: previous initialization is here
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:386:2: note: expanded from macro 'AHCI_SHT'
ATA_NCQ_SHT(drv_name), \
^~~~~~~~~~~~~~~~~~~~~
include/linux/libata.h:1419:17: note: expanded from macro 'ATA_NCQ_SHT'
.sdev_attrs = ata_ncq_sdev_attrs, \
^~~~~~~~~~~~~~~~~~
3 warnings generated.
--
In file included from drivers/ata/pata_platform.c:16:
>> include/linux/blkdev.h:1492:15: warning: ISO C90 forbids mixing declarations and code [-Wdeclaration-after-statement]
unsigned int alignment = sector_div(sector, granularity >> SECTOR_SHIFT)
^
1 warning generated.
--
In file included from drivers/ata/ahci_imx.c:18:
In file included from include/linux/libata.h:21:
In file included from include/scsi/scsi_host.h:11:
In file included from include/linux/blk-mq.h:5:
>> include/linux/blkdev.h:1492:15: warning: ISO C90 forbids mixing declarations and code [-Wdeclaration-after-statement]
unsigned int alignment = sector_div(sector, granularity >> SECTOR_SHIFT)
^
drivers/ata/ahci_imx.c:978:2: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:387:16: note: expanded from macro 'AHCI_SHT'
.can_queue = AHCI_MAX_CMDS, \
^~~~~~~~~~~~~
drivers/ata/ahci_imx.c:978:2: note: previous initialization is here
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:386:2: note: expanded from macro 'AHCI_SHT'
ATA_NCQ_SHT(drv_name), \
^~~~~~~~~~~~~~~~~~~~~
include/linux/libata.h:1418:2: note: expanded from macro 'ATA_NCQ_SHT'
__ATA_BASE_SHT(drv_name), \
^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/libata.h:1400:16: note: expanded from macro '__ATA_BASE_SHT'
.can_queue = ATA_DEF_QUEUE, \
^~~~~~~~~~~~~
drivers/ata/ahci_imx.c:978:2: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:391:17: note: expanded from macro 'AHCI_SHT'
.sdev_attrs = ahci_sdev_attrs
^~~~~~~~~~~~~~~
drivers/ata/ahci_imx.c:978:2: note: previous initialization is here
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:386:2: note: expanded from macro 'AHCI_SHT'
ATA_NCQ_SHT(drv_name), \
^~~~~~~~~~~~~~~~~~~~~
include/linux/libata.h:1419:17: note: expanded from macro 'ATA_NCQ_SHT'
.sdev_attrs = ata_ncq_sdev_attrs, \
^~~~~~~~~~~~~~~~~~
3 warnings generated.
--
In file included from drivers/ata/ahci_tegra.c:17:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:22:
In file included from include/linux/writeback.h:14:
In file included from include/linux/blk-cgroup.h:23:
>> include/linux/blkdev.h:1492:15: warning: ISO C90 forbids mixing declarations and code [-Wdeclaration-after-statement]
unsigned int alignment = sector_div(sector, granularity >> SECTOR_SHIFT)
^
drivers/ata/ahci_tegra.c:477:2: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:387:16: note: expanded from macro 'AHCI_SHT'
.can_queue = AHCI_MAX_CMDS, \
^~~~~~~~~~~~~
drivers/ata/ahci_tegra.c:477:2: note: previous initialization is here
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:386:2: note: expanded from macro 'AHCI_SHT'
ATA_NCQ_SHT(drv_name), \
^~~~~~~~~~~~~~~~~~~~~
include/linux/libata.h:1418:2: note: expanded from macro 'ATA_NCQ_SHT'
__ATA_BASE_SHT(drv_name), \
^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/libata.h:1400:16: note: expanded from macro '__ATA_BASE_SHT'
.can_queue = ATA_DEF_QUEUE, \
^~~~~~~~~~~~~
drivers/ata/ahci_tegra.c:477:2: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:391:17: note: expanded from macro 'AHCI_SHT'
.sdev_attrs = ahci_sdev_attrs
^~~~~~~~~~~~~~~
drivers/ata/ahci_tegra.c:477:2: note: previous initialization is here
AHCI_SHT(DRV_NAME),
^~~~~~~~~~~~~~~~~~
drivers/ata/ahci.h:386:2: note: expanded from macro 'AHCI_SHT'
ATA_NCQ_SHT(drv_name), \
^~~~~~~~~~~~~~~~~~~~~
include/linux/libata.h:1419:17: note: expanded from macro 'ATA_NCQ_SHT'
.sdev_attrs = ata_ncq_sdev_attrs, \
^~~~~~~~~~~~~~~~~~
3 warnings generated.


vim +1492 include/linux/blkdev.h

c72758f33784e5e2 Martin K. Petersen 2009-05-22 1484
e03a72e13648ac62 Martin K. Petersen 2010-01-11 1485 static inline int queue_limit_alignment_offset(struct queue_limits *lim, sector_t sector)
81744ee44ab2845c Martin K. Petersen 2009-12-29 1486 {
81744ee44ab2845c Martin K. Petersen 2009-12-29 1487 unsigned int granularity = max(lim->physical_block_size, lim->io_min);
796e67f6b22f94f1 Li Feng 2021-01-12 1488 granularity = granularity >> SECTOR_SHIFT;
796e67f6b22f94f1 Li Feng 2021-01-12 1489 if (!granularity)
796e67f6b22f94f1 Li Feng 2021-01-12 1490 return 0;
796e67f6b22f94f1 Li Feng 2021-01-12 1491
233bde21aa43516b Bart Van Assche 2018-03-14 @1492 unsigned int alignment = sector_div(sector, granularity >> SECTOR_SHIFT)
233bde21aa43516b Bart Van Assche 2018-03-14 1493 << SECTOR_SHIFT;
81744ee44ab2845c Martin K. Petersen 2009-12-29 1494
b8839b8c55f3fdd6 Mike Snitzer 2014-10-08 1495 return (granularity + lim->alignment_offset - alignment) % granularity;
c72758f33784e5e2 Martin K. Petersen 2009-05-22 1496 }
c72758f33784e5e2 Martin K. Petersen 2009-05-22 1497

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (15.57 kB)
.config.gz (36.94 kB)
Download all attachments