Skip to content

Commit b329850

Browse files
committed
Merge tag 'for-5.10/dm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm
Pull device mapper fixes from Mike Snitzer: - Fix DM's bio splitting changes that were made during v5.9. This restores splitting in terms of varied per-target ti->max_io_len rather than use block core's single stacked 'chunk_sectors' limit. - Like DM crypt, update DM integrity to not use crypto drivers that have CRYPTO_ALG_ALLOCATES_MEMORY set. - Fix DM writecache target's argument parsing and status display. - Remove needless BUG() from dm writecache's persistent_memory_claim() - Remove old gcc workaround in DM cache target's block_div() for ARM link errors now that gcc >= 4.9 is required. - Fix RCU locking in dm_blk_report_zones and dm_dax_zero_page_range. - Remove old, and now frowned upon, BUG_ON(in_interrupt()) in dm_table_event(). - Remove invalid sparse annotations from dm_prepare_ioctl() and dm_unprepare_ioctl(). * tag 'for-5.10/dm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm: dm: remove invalid sparse __acquires and __releases annotations dm: fix double RCU unlock in dm_dax_zero_page_range() error path dm: fix IO splitting dm writecache: remove BUG() and fail gracefully instead dm table: Remove BUG_ON(in_interrupt()) dm: fix bug with RCU locking in dm_blk_report_zones Revert "dm cache: fix arm link errors with inline" dm writecache: fix the maximum number of arguments dm writecache: advance the number of arguments when reporting max_age dm integrity: don't use drivers that have CRYPTO_ALG_ALLOCATES_MEMORY
2 parents e87297f + bde3808 commit b329850

7 files changed

Lines changed: 28 additions & 39 deletions

File tree

block/blk-merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static struct bio *blk_bio_write_same_split(struct request_queue *q,
144144
static inline unsigned get_max_io_size(struct request_queue *q,
145145
struct bio *bio)
146146
{
147-
unsigned sectors = blk_max_size_offset(q, bio->bi_iter.bi_sector);
147+
unsigned sectors = blk_max_size_offset(q, bio->bi_iter.bi_sector, 0);
148148
unsigned max_sectors = sectors;
149149
unsigned pbs = queue_physical_block_size(q) >> SECTOR_SHIFT;
150150
unsigned lbs = queue_logical_block_size(q) >> SECTOR_SHIFT;

drivers/md/dm-cache-target.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -712,10 +712,6 @@ static bool block_size_is_power_of_two(struct cache *cache)
712712
return cache->sectors_per_block_shift >= 0;
713713
}
714714

715-
/* gcc on ARM generates spurious references to __udivdi3 and __umoddi3 */
716-
#if defined(CONFIG_ARM) && __GNUC__ == 4 && __GNUC_MINOR__ <= 6
717-
__always_inline
718-
#endif
719715
static dm_block_t block_div(dm_block_t b, uint32_t n)
720716
{
721717
do_div(b, n);

drivers/md/dm-integrity.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3462,7 +3462,7 @@ static int get_mac(struct crypto_shash **hash, struct alg_spec *a, char **error,
34623462
int r;
34633463

34643464
if (a->alg_string) {
3465-
*hash = crypto_alloc_shash(a->alg_string, 0, 0);
3465+
*hash = crypto_alloc_shash(a->alg_string, 0, CRYPTO_ALG_ALLOCATES_MEMORY);
34663466
if (IS_ERR(*hash)) {
34673467
*error = error_alg;
34683468
r = PTR_ERR(*hash);
@@ -3519,7 +3519,7 @@ static int create_journal(struct dm_integrity_c *ic, char **error)
35193519
struct journal_completion comp;
35203520

35213521
comp.ic = ic;
3522-
ic->journal_crypt = crypto_alloc_skcipher(ic->journal_crypt_alg.alg_string, 0, 0);
3522+
ic->journal_crypt = crypto_alloc_skcipher(ic->journal_crypt_alg.alg_string, 0, CRYPTO_ALG_ALLOCATES_MEMORY);
35233523
if (IS_ERR(ic->journal_crypt)) {
35243524
*error = "Invalid journal cipher";
35253525
r = PTR_ERR(ic->journal_crypt);

drivers/md/dm-table.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <linux/mutex.h>
1919
#include <linux/delay.h>
2020
#include <linux/atomic.h>
21-
#include <linux/lcm.h>
2221
#include <linux/blk-mq.h>
2322
#include <linux/mount.h>
2423
#include <linux/dax.h>
@@ -1247,12 +1246,6 @@ void dm_table_event_callback(struct dm_table *t,
12471246

12481247
void dm_table_event(struct dm_table *t)
12491248
{
1250-
/*
1251-
* You can no longer call dm_table_event() from interrupt
1252-
* context, use a bottom half instead.
1253-
*/
1254-
BUG_ON(in_interrupt());
1255-
12561249
mutex_lock(&_event_lock);
12571250
if (t->event_fn)
12581251
t->event_fn(t->event_context);
@@ -1455,10 +1448,6 @@ int dm_calculate_queue_limits(struct dm_table *table,
14551448
zone_sectors = ti_limits.chunk_sectors;
14561449
}
14571450

1458-
/* Stack chunk_sectors if target-specific splitting is required */
1459-
if (ti->max_io_len)
1460-
ti_limits.chunk_sectors = lcm_not_zero(ti->max_io_len,
1461-
ti_limits.chunk_sectors);
14621451
/* Set I/O hints portion of queue limits */
14631452
if (ti->type->io_hints)
14641453
ti->type->io_hints(ti, &ti_limits);

drivers/md/dm-writecache.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static int persistent_memory_claim(struct dm_writecache *wc)
319319
#else
320320
static int persistent_memory_claim(struct dm_writecache *wc)
321321
{
322-
BUG();
322+
return -EOPNOTSUPP;
323323
}
324324
#endif
325325

@@ -2041,7 +2041,7 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
20412041
struct wc_memory_superblock s;
20422042

20432043
static struct dm_arg _args[] = {
2044-
{0, 10, "Invalid number of feature args"},
2044+
{0, 16, "Invalid number of feature args"},
20452045
};
20462046

20472047
as.argc = argc;
@@ -2479,6 +2479,8 @@ static void writecache_status(struct dm_target *ti, status_type_t type,
24792479
extra_args += 2;
24802480
if (wc->autocommit_time_set)
24812481
extra_args += 2;
2482+
if (wc->max_age != MAX_AGE_UNSPECIFIED)
2483+
extra_args += 2;
24822484
if (wc->cleaner)
24832485
extra_args++;
24842486
if (wc->writeback_fua_set)

drivers/md/dm.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,10 @@ static int dm_blk_report_zones(struct gendisk *disk, sector_t sector,
476476
return -EAGAIN;
477477

478478
map = dm_get_live_table(md, &srcu_idx);
479-
if (!map)
480-
return -EIO;
479+
if (!map) {
480+
ret = -EIO;
481+
goto out;
482+
}
481483

482484
do {
483485
struct dm_target *tgt;
@@ -507,7 +509,6 @@ static int dm_blk_report_zones(struct gendisk *disk, sector_t sector,
507509

508510
static int dm_prepare_ioctl(struct mapped_device *md, int *srcu_idx,
509511
struct block_device **bdev)
510-
__acquires(md->io_barrier)
511512
{
512513
struct dm_target *tgt;
513514
struct dm_table *map;
@@ -541,7 +542,6 @@ static int dm_prepare_ioctl(struct mapped_device *md, int *srcu_idx,
541542
}
542543

543544
static void dm_unprepare_ioctl(struct mapped_device *md, int srcu_idx)
544-
__releases(md->io_barrier)
545545
{
546546
dm_put_live_table(md, srcu_idx);
547547
}
@@ -1037,15 +1037,18 @@ static sector_t max_io_len(struct dm_target *ti, sector_t sector)
10371037
sector_t max_len;
10381038

10391039
/*
1040-
* Does the target need to split even further?
1041-
* - q->limits.chunk_sectors reflects ti->max_io_len so
1042-
* blk_max_size_offset() provides required splitting.
1043-
* - blk_max_size_offset() also respects q->limits.max_sectors
1040+
* Does the target need to split IO even further?
1041+
* - varied (per target) IO splitting is a tenet of DM; this
1042+
* explains why stacked chunk_sectors based splitting via
1043+
* blk_max_size_offset() isn't possible here. So pass in
1044+
* ti->max_io_len to override stacked chunk_sectors.
10441045
*/
1045-
max_len = blk_max_size_offset(ti->table->md->queue,
1046-
target_offset);
1047-
if (len > max_len)
1048-
len = max_len;
1046+
if (ti->max_io_len) {
1047+
max_len = blk_max_size_offset(ti->table->md->queue,
1048+
target_offset, ti->max_io_len);
1049+
if (len > max_len)
1050+
len = max_len;
1051+
}
10491052

10501053
return len;
10511054
}
@@ -1196,11 +1199,9 @@ static int dm_dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff,
11961199
* ->zero_page_range() is mandatory dax operation. If we are
11971200
* here, something is wrong.
11981201
*/
1199-
dm_put_live_table(md, srcu_idx);
12001202
goto out;
12011203
}
12021204
ret = ti->type->dax_zero_page_range(ti, pgoff, nr_pages);
1203-
12041205
out:
12051206
dm_put_live_table(md, srcu_idx);
12061207

include/linux/blkdev.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,11 +1073,12 @@ static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q,
10731073
* file system requests.
10741074
*/
10751075
static inline unsigned int blk_max_size_offset(struct request_queue *q,
1076-
sector_t offset)
1076+
sector_t offset,
1077+
unsigned int chunk_sectors)
10771078
{
1078-
unsigned int chunk_sectors = q->limits.chunk_sectors;
1079-
1080-
if (!chunk_sectors)
1079+
if (!chunk_sectors && q->limits.chunk_sectors)
1080+
chunk_sectors = q->limits.chunk_sectors;
1081+
else
10811082
return q->limits.max_sectors;
10821083

10831084
if (likely(is_power_of_2(chunk_sectors)))
@@ -1101,7 +1102,7 @@ static inline unsigned int blk_rq_get_max_sectors(struct request *rq,
11011102
req_op(rq) == REQ_OP_SECURE_ERASE)
11021103
return blk_queue_get_max_sectors(q, req_op(rq));
11031104

1104-
return min(blk_max_size_offset(q, offset),
1105+
return min(blk_max_size_offset(q, offset, 0),
11051106
blk_queue_get_max_sectors(q, req_op(rq)));
11061107
}
11071108

0 commit comments

Comments
 (0)