drivers/md/dm-mpath.c:1682 multipath_end_io_bio() error: double unlocked 'm->lock' (orig line 1675)

From: kernel test robot
Date: Sat Aug 08 2020 - 07:06:50 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 449dc8c97089a6e09fb2dac4d92b1b7ac0eb7c1e
commit: a271a89c6e4773478b1c4f8213dfe8351ea66723 dm mpath: take m->lock spinlock when testing QUEUE_IF_NO_PATH
date: 4 weeks ago
config: arm-randconfig-m031-20200808 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

New smatch warnings:
drivers/md/dm-mpath.c:1682 multipath_end_io_bio() error: double unlocked 'm->lock' (orig line 1675)
drivers/md/dm-mpath.c:1988 multipath_prepare_ioctl() error: double unlocked 'm->lock' (orig line 1977)

Old smatch warnings:
drivers/md/dm-mpath.c:432 choose_pgpath() error: double unlocked 'm->lock' (orig line 402)
drivers/md/dm-mpath.c:443 choose_pgpath() error: double unlocked 'm->lock' (orig line 389)
drivers/md/dm-mpath.c:593 __map_bio() error: double unlocked 'm->lock' (orig line 589)
drivers/md/dm-mpath.c:1574 pg_init_done() error: double unlocked 'm->lock' (orig line 1527)

vim +1682 drivers/md/dm-mpath.c

^1da177e4c3f41 Linus Torvalds 2005-04-16 1647
4e4cbee93d5613 Christoph Hellwig 2017-06-03 1648 static int multipath_end_io_bio(struct dm_target *ti, struct bio *clone,
4e4cbee93d5613 Christoph Hellwig 2017-06-03 1649 blk_status_t *error)
76e33fe4e2c436 Mike Snitzer 2016-05-19 1650 {
14ef1e48269dde Christoph Hellwig 2017-06-03 1651 struct multipath *m = ti->private;
14ef1e48269dde Christoph Hellwig 2017-06-03 1652 struct dm_mpath_io *mpio = get_mpio_from_bio(clone);
14ef1e48269dde Christoph Hellwig 2017-06-03 1653 struct pgpath *pgpath = mpio->pgpath;
76e33fe4e2c436 Mike Snitzer 2016-05-19 1654 unsigned long flags;
1be56909845889 Christoph Hellwig 2017-06-03 1655 int r = DM_ENDIO_DONE;
76e33fe4e2c436 Mike Snitzer 2016-05-19 1656
a1275677f8cd06 Keith Busch 2018-01-09 1657 if (!*error || !blk_path_error(*error))
14ef1e48269dde Christoph Hellwig 2017-06-03 1658 goto done;
76e33fe4e2c436 Mike Snitzer 2016-05-19 1659
14ef1e48269dde Christoph Hellwig 2017-06-03 1660 if (pgpath)
14ef1e48269dde Christoph Hellwig 2017-06-03 1661 fail_path(pgpath);
76e33fe4e2c436 Mike Snitzer 2016-05-19 1662
a271a89c6e4773 Mike Snitzer 2020-06-10 1663 if (!atomic_read(&m->nr_valid_paths)) {
a271a89c6e4773 Mike Snitzer 2020-06-10 1664 spin_lock_irqsave(&m->lock, flags);
a271a89c6e4773 Mike Snitzer 2020-06-10 1665 if (!test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) {
a862e4e2154289 Mike Snitzer 2020-05-26 1666 if (__must_push_back(m)) {
c1fd0abee0d52e Mike Snitzer 2017-12-07 1667 r = DM_ENDIO_REQUEUE;
c1fd0abee0d52e Mike Snitzer 2017-12-07 1668 } else {
18a482f5245cc8 Christoph Hellwig 2017-05-15 1669 dm_report_EIO(m);
4e4cbee93d5613 Christoph Hellwig 2017-06-03 1670 *error = BLK_STS_IOERR;
c1fd0abee0d52e Mike Snitzer 2017-12-07 1671 }
a271a89c6e4773 Mike Snitzer 2020-06-10 1672 spin_unlock_irqrestore(&m->lock, flags);
14ef1e48269dde Christoph Hellwig 2017-06-03 1673 goto done;
18a482f5245cc8 Christoph Hellwig 2017-05-15 1674 }
a271a89c6e4773 Mike Snitzer 2020-06-10 @1675 spin_unlock_irqrestore(&m->lock, flags);
a271a89c6e4773 Mike Snitzer 2020-06-10 1676 }
76e33fe4e2c436 Mike Snitzer 2016-05-19 1677
76e33fe4e2c436 Mike Snitzer 2016-05-19 1678 spin_lock_irqsave(&m->lock, flags);
76e33fe4e2c436 Mike Snitzer 2016-05-19 1679 bio_list_add(&m->queued_bios, clone);
76e33fe4e2c436 Mike Snitzer 2016-05-19 1680 if (!test_bit(MPATHF_QUEUE_IO, &m->flags))
76e33fe4e2c436 Mike Snitzer 2016-05-19 1681 queue_work(kmultipathd, &m->process_queued_bios);
69cea0d45a618a Mike Snitzer 2020-06-10 @1682 spin_unlock_irqrestore(&m->lock, flags);
76e33fe4e2c436 Mike Snitzer 2016-05-19 1683
1be56909845889 Christoph Hellwig 2017-06-03 1684 r = DM_ENDIO_INCOMPLETE;
14ef1e48269dde Christoph Hellwig 2017-06-03 1685 done:
76e33fe4e2c436 Mike Snitzer 2016-05-19 1686 if (pgpath) {
14ef1e48269dde Christoph Hellwig 2017-06-03 1687 struct path_selector *ps = &pgpath->pg->ps;
14ef1e48269dde Christoph Hellwig 2017-06-03 1688
76e33fe4e2c436 Mike Snitzer 2016-05-19 1689 if (ps->type->end_io)
087615bf3acdaf Gabriel Krisman Bertazi 2020-04-30 1690 ps->type->end_io(ps, &pgpath->path, mpio->nr_bytes,
087615bf3acdaf Gabriel Krisman Bertazi 2020-04-30 1691 dm_start_time_ns_from_clone(clone));
76e33fe4e2c436 Mike Snitzer 2016-05-19 1692 }
76e33fe4e2c436 Mike Snitzer 2016-05-19 1693
1be56909845889 Christoph Hellwig 2017-06-03 1694 return r;
76e33fe4e2c436 Mike Snitzer 2016-05-19 1695 }
76e33fe4e2c436 Mike Snitzer 2016-05-19 1696

:::::: The code at line 1682 was first introduced by commit
:::::: 69cea0d45a618ad4ae74f36386ef1af5128b2b19 dm mpath: changes from initial m->flags locking audit

:::::: TO: Mike Snitzer <snitzer@xxxxxxxxxx>
:::::: CC: Mike Snitzer <snitzer@xxxxxxxxxx>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip