Skip to content

Commit cbe232a

Browse files
committed
Merge tag 'for-5.19/dm-fixes-4' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm
Pull device mapper fixes from Mike Snitzer: - Fix DM era to commit metadata during suspend using drain_workqueue instead of flush_workqueue. - Fix DM core's dm_io_complete to not return early if io error is BLK_STS_AGAIN but bio polling is not in use. - Fix DM core's dm_io_complete BLK_STS_DM_REQUEUE handling when dm_io represents a split bio. - Fix recent DM mirror log regression by clearing bits up to BITS_PER_LONG boundary. * tag 'for-5.19/dm-fixes-4' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm: dm mirror log: clear log bits up to BITS_PER_LONG boundary dm: fix BLK_STS_DM_REQUEUE handling when dm_io represents split bio dm: do not return early from dm_io_complete if BLK_STS_AGAIN without polling dm era: commit metadata in postsuspend after worker stops
2 parents 4362761 + 90736eb commit cbe232a

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

drivers/md/dm-core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ struct dm_io {
272272
atomic_t io_count;
273273
struct mapped_device *md;
274274

275+
struct bio *split_bio;
275276
/* The three fields represent mapped part of original bio */
276277
struct bio *orig_bio;
277278
unsigned int sector_offset; /* offset to end of orig_bio */

drivers/md/dm-era-target.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ static void start_worker(struct era *era)
14001400
static void stop_worker(struct era *era)
14011401
{
14021402
atomic_set(&era->suspended, 1);
1403-
flush_workqueue(era->wq);
1403+
drain_workqueue(era->wq);
14041404
}
14051405

14061406
/*----------------------------------------------------------------
@@ -1570,6 +1570,12 @@ static void era_postsuspend(struct dm_target *ti)
15701570
}
15711571

15721572
stop_worker(era);
1573+
1574+
r = metadata_commit(era->md);
1575+
if (r) {
1576+
DMERR("%s: metadata_commit failed", __func__);
1577+
/* FIXME: fail mode */
1578+
}
15731579
}
15741580

15751581
static int era_preresume(struct dm_target *ti)

drivers/md/dm-log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ static int disk_resume(struct dm_dirty_log *log)
615615
log_clear_bit(lc, lc->clean_bits, i);
616616

617617
/* clear any old bits -- device has shrunk */
618-
for (i = lc->region_count; i % (sizeof(*lc->clean_bits) << BYTE_SHIFT); i++)
618+
for (i = lc->region_count; i % BITS_PER_LONG; i++)
619619
log_clear_bit(lc, lc->clean_bits, i);
620620

621621
/* copy clean across to sync */

drivers/md/dm.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio)
594594
atomic_set(&io->io_count, 2);
595595
this_cpu_inc(*md->pending_io);
596596
io->orig_bio = bio;
597+
io->split_bio = NULL;
597598
io->md = md;
598599
spin_lock_init(&io->lock);
599600
io->start_time = jiffies;
@@ -887,7 +888,7 @@ static void dm_io_complete(struct dm_io *io)
887888
{
888889
blk_status_t io_error;
889890
struct mapped_device *md = io->md;
890-
struct bio *bio = io->orig_bio;
891+
struct bio *bio = io->split_bio ? io->split_bio : io->orig_bio;
891892

892893
if (io->status == BLK_STS_DM_REQUEUE) {
893894
unsigned long flags;
@@ -939,9 +940,11 @@ static void dm_io_complete(struct dm_io *io)
939940
if (io_error == BLK_STS_AGAIN) {
940941
/* io_uring doesn't handle BLK_STS_AGAIN (yet) */
941942
queue_io(md, bio);
943+
return;
942944
}
943945
}
944-
return;
946+
if (io_error == BLK_STS_DM_REQUEUE)
947+
return;
945948
}
946949

947950
if (bio_is_flush_with_data(bio)) {
@@ -1691,9 +1694,11 @@ static void dm_split_and_process_bio(struct mapped_device *md,
16911694
* Remainder must be passed to submit_bio_noacct() so it gets handled
16921695
* *after* bios already submitted have been completely processed.
16931696
*/
1694-
bio_trim(bio, io->sectors, ci.sector_count);
1695-
trace_block_split(bio, bio->bi_iter.bi_sector);
1696-
bio_inc_remaining(bio);
1697+
WARN_ON_ONCE(!dm_io_flagged(io, DM_IO_WAS_SPLIT));
1698+
io->split_bio = bio_split(bio, io->sectors, GFP_NOIO,
1699+
&md->queue->bio_split);
1700+
bio_chain(io->split_bio, bio);
1701+
trace_block_split(io->split_bio, bio->bi_iter.bi_sector);
16971702
submit_bio_noacct(bio);
16981703
out:
16991704
/*

0 commit comments

Comments
 (0)