Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1281355pxf; Fri, 9 Apr 2021 04:50:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJRLebO+UwiT/5pxqD22GBEzUfh4nJBtEOKbNBlBBhuOcDteabZlghCoXN9oqrf79uVs1Z X-Received: by 2002:aa7:d88b:: with SMTP id u11mr17239197edq.254.1617969040811; Fri, 09 Apr 2021 04:50:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617969040; cv=none; d=google.com; s=arc-20160816; b=tA645ZezihwiZ6T+WOZtkSTL7jKDTE1uhlQxuvQTUYidhsqAwuEK61BAiqE/CMh/C1 TRKCMnnZFf7CQyLHAXg8DwleZi+191kmPtR3M9gVC8RieI8NB72SwAuZ4Ca3mYSdtt2L TzXamsXbUO48tMl6kIlIgeLfBd4CgUBwx3TIiFl07mEKoVuTpGoj5zSnCKWQgIUSwtMj b23ArNd8p4/Jq4rFiHtH3p8Lq72gT2HYtkt5bpN7nX+O0T6B3FRvfhEze+DkyfQU93fX gTiC1xIxIUmml1R2d+euKwCaVdYw00G4XOsSdS/53YHs4VBY3uAiv7CPkTLc6RtbiKiH emrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=rAzHWObjMq2YRLIIgst7bN3x/hlCxuVwlQCV3inUf34=; b=LnOEl7giw3Bo5M0qVgKAKee+tapDgYlvW5JADnKGnQz3gQ2YSe+5W0mQnoR4bj5Pxr J/X3M7singMw+4DkXgczEDi601LjaFHj1b96yV/3kkdW+qagZLxwGw+GwnZf4TH0VnS4 qbYslhsWyvwlbI6Kx+6r+S/vlp/tGJjtj6tM0VvbgQ/i1WE1omSKP9T8hoS1w/r8iMix AfTo+zpoRmHTkBTzgbtmt0U8k1sdE8xKam+0OqIrbqOVZv/w3nqKZ9HiFJdSkrUNTW5X V/5Y1yCZKhZPmNcItWv9IFxfYVwJkzt8B1B6qwWZ1LPk1uilnoNk7vROTuzeQVS72RE3 yRZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@veeam.com header.s=mx2 header.b=ThS5DifG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=veeam.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v24si2252309edy.243.2021.04.09.04.50.17; Fri, 09 Apr 2021 04:50:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@veeam.com header.s=mx2 header.b=ThS5DifG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=veeam.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233811AbhDILsr (ORCPT + 99 others); Fri, 9 Apr 2021 07:48:47 -0400 Received: from mx2.veeam.com ([64.129.123.6]:50556 "EHLO mx2.veeam.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233718AbhDILso (ORCPT ); Fri, 9 Apr 2021 07:48:44 -0400 Received: from mail.veeam.com (prgmbx01.amust.local [172.24.0.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.veeam.com (Postfix) with ESMTPS id 461554146C; Fri, 9 Apr 2021 07:48:28 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=veeam.com; s=mx2; t=1617968908; bh=rAzHWObjMq2YRLIIgst7bN3x/hlCxuVwlQCV3inUf34=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=ThS5DifGAnwZkFT9IE7gR+5ixyCidbcsgXGfpVYTre2ldtcDjo2BuiOMicE0QQtU3 7jh+RLMBHWqI2Katk8CAIMcrdoL1235uK3klX52Lid9ZR8/K15cHsF7ihl9NEIXzwE RNHfdQQEujYp4/WL3bwh93lXJ7OY3p7/CN50ZK7o= Received: from prgdevlinuxpatch01.amust.local (172.24.14.5) by prgmbx01.amust.local (172.24.0.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.721.2; Fri, 9 Apr 2021 13:48:21 +0200 From: Sergei Shtepa To: Christoph Hellwig , Hannes Reinecke , Mike Snitzer , Alasdair Kergon , Alexander Viro , Jens Axboe , , , , CC: , Subject: [PATCH v8 4/4] fix origin_map - don't split a bio for the origin device if it does not have registered snapshots. Date: Fri, 9 Apr 2021 14:48:04 +0300 Message-ID: <1617968884-15149-5-git-send-email-sergei.shtepa@veeam.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1617968884-15149-1-git-send-email-sergei.shtepa@veeam.com> References: <1617968884-15149-1-git-send-email-sergei.shtepa@veeam.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.24.14.5] X-ClientProxiedBy: prgmbx01.amust.local (172.24.0.171) To prgmbx01.amust.local (172.24.0.171) X-EsetResult: clean, is OK X-EsetId: 37303A29D2A50B59657262 X-Veeam-MMEX: True Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Sergei Shtepa --- 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