Skip to content

Commit eba33b8

Browse files
Christoph Hellwigaxboe
authored andcommitted
dm-snap: use blkdev_issue_flush instead of open coding it
Use blkdev_issue_flush, which uses an on-stack bio instead of an opencoded version with a bio embedded into struct dm_snapshot. Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 3f868c0 commit eba33b8

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

drivers/md/dm-snap.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,6 @@ struct dm_snapshot {
141141
* for them to be committed.
142142
*/
143143
struct bio_list bios_queued_during_merge;
144-
145-
/*
146-
* Flush data after merge.
147-
*/
148-
struct bio flush_bio;
149144
};
150145

151146
/*
@@ -1127,17 +1122,6 @@ static void snapshot_merge_next_chunks(struct dm_snapshot *s)
11271122

11281123
static void error_bios(struct bio *bio);
11291124

1130-
static int flush_data(struct dm_snapshot *s)
1131-
{
1132-
struct bio *flush_bio = &s->flush_bio;
1133-
1134-
bio_reset(flush_bio);
1135-
bio_set_dev(flush_bio, s->origin->bdev);
1136-
flush_bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
1137-
1138-
return submit_bio_wait(flush_bio);
1139-
}
1140-
11411125
static void merge_callback(int read_err, unsigned long write_err, void *context)
11421126
{
11431127
struct dm_snapshot *s = context;
@@ -1151,7 +1135,7 @@ static void merge_callback(int read_err, unsigned long write_err, void *context)
11511135
goto shut;
11521136
}
11531137

1154-
if (flush_data(s) < 0) {
1138+
if (blkdev_issue_flush(s->origin->bdev) < 0) {
11551139
DMERR("Flush after merge failed: shutting down merge");
11561140
goto shut;
11571141
}
@@ -1340,7 +1324,6 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
13401324
s->first_merging_chunk = 0;
13411325
s->num_merging_chunks = 0;
13421326
bio_list_init(&s->bios_queued_during_merge);
1343-
bio_init(&s->flush_bio, NULL, 0);
13441327

13451328
/* Allocate hash table for COW data */
13461329
if (init_hash_tables(s)) {
@@ -1528,8 +1511,6 @@ static void snapshot_dtr(struct dm_target *ti)
15281511

15291512
dm_exception_store_destroy(s->store);
15301513

1531-
bio_uninit(&s->flush_bio);
1532-
15331514
dm_put_device(ti, s->cow);
15341515

15351516
dm_put_device(ti, s->origin);

0 commit comments

Comments
 (0)