[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1617968884-15149-5-git-send-email-sergei.shtepa@veeam.com>
Date: Fri, 9 Apr 2021 14:48:04 +0300
From: Sergei Shtepa <sergei.shtepa@...am.com>
To: Christoph Hellwig <hch@...radead.org>,
Hannes Reinecke <hare@...e.de>,
Mike Snitzer <snitzer@...hat.com>,
Alasdair Kergon <agk@...hat.com>,
Alexander Viro <viro@...iv.linux.org.uk>,
Jens Axboe <axboe@...nel.dk>, <dm-devel@...hat.com>,
<linux-fsdevel@...r.kernel.org>, <linux-block@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
CC: <sergei.shtepa@...am.com>, <pavel.tide@...am.com>
Subject: [PATCH v8 4/4] fix origin_map - don't split a bio for the origin device if it does not have registered snapshots.
Signed-off-by: Sergei Shtepa <sergei.shtepa@...am.com>
---
drivers/md/dm-snap.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 11890db71f3f..81e8e3bb6d25 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -2685,11 +2685,18 @@ static int origin_map(struct dm_target *ti, struct bio *bio)
if (bio_data_dir(bio) != WRITE)
return DM_MAPIO_REMAPPED;
- available_sectors = o->split_boundary -
- ((unsigned)bio->bi_iter.bi_sector & (o->split_boundary - 1));
+ /*
+ * If no snapshot is connected to origin, then split_boundary
+ * will be set to zero. In this case, we don't need to split a bio.
+ */
+ if (o->split_boundary) {
+ available_sectors = o->split_boundary -
+ ((unsigned int)bio->bi_iter.bi_sector &
+ (o->split_boundary - 1));
- if (bio_sectors(bio) > available_sectors)
- dm_accept_partial_bio(bio, available_sectors);
+ if (bio_sectors(bio) > available_sectors)
+ dm_accept_partial_bio(bio, available_sectors);
+ }
/* Only tell snapshots if this is a write */
return do_origin(o->dev, bio, true);
--
2.20.1
Powered by blists - more mailing lists