Received: by 10.223.185.111 with SMTP id b44csp906737wrg; Fri, 9 Mar 2018 16:32:22 -0800 (PST) X-Google-Smtp-Source: AG47ELvXAo7Tv0dpYm6EJk3r53rb4OHs0ZV2bRDNKDizMmKmCorG/0HNY3AdjU/R16Ta1oM7HOII X-Received: by 10.101.83.199 with SMTP id z7mr290631pgr.105.1520641942440; Fri, 09 Mar 2018 16:32:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520641942; cv=none; d=google.com; s=arc-20160816; b=UM11mVYh9wDlZcoS0QKhwXlVPETGVi9KMLwAEGelPt75AHacbAFbIG8wx+Pkr++YxH j5XI1L+cPXjOKmkF4z1EnNKhKCg05KAfMsMOzjMKBbZX1m9aO607i0/rylHM80Mk9Ag/ I8m354YERkwIR88JXEAYTRAm3aJn7A0xHHzAFyIGOqmpSS5CC+VdY6CYAujbSLorMlsS u6p+K50fp6E4gNFtDdWhnPYZqRwCfJfNUQxfjwKRGRZp+79zfj0noWSTNuvPBznMjv4m qvh/uQY85TSrzq/lzIBTVkAk3vg6P9BTa6Vkx4nEz6HozooHKpaPCDYcRqPOYIWJ/BTR ZfGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=O0yTtLy4kzpTcj4CQDL05LnHWTLyc+qHNwQUE7C+pEA=; b=1BDv9yglYu+9a66FeLc1gADzqJQZM0MQZTIvfZUwfi9aTIyHJ/tWB8uKHlb20Iyosw HpgZdr53ok0ns+Ub128W7Jh6iadyirkm1jmLeNjPDTLpZLO4u+SFpfN6QXMHJKij/kUU xr6psru8NGrDlGXmvjgm3eK0C3MZyL9kfsiqzRp8UjgB/a9tYnDZiJ0i1fnB+eRSy6Wt JXUQ/GMWLylBsb3D2mTgqC4OtTPh8CqOx80Kg4MR4cwnS0bFFcmQNF6LNfu5HqcKbPiw xt1Xh4H8VKz74PWF6+SeKoRzkL7uwyuNTGUxZAJSuZjvxa3VpoF/dhi9jAUFkmPOCbez tJbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3-v6si1735903plv.81.2018.03.09.16.32.08; Fri, 09 Mar 2018 16:32:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933931AbeCJAWj (ORCPT + 99 others); Fri, 9 Mar 2018 19:22:39 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:40036 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933881AbeCJAWa (ORCPT ); Fri, 9 Mar 2018 19:22:30 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9B8251183; Sat, 10 Mar 2018 00:22:29 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Yi , Mike Snitzer Subject: [PATCH 4.9 25/65] dm io: fix duplicate bio completion due to missing ref count Date: Fri, 9 Mar 2018 16:18:25 -0800 Message-Id: <20180310001826.924856436@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180310001824.927996722@linuxfoundation.org> References: <20180310001824.927996722@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mike Snitzer commit feb7695fe9fb83084aa29de0094774f4c9d4c9fc upstream. If only a subset of the devices associated with multiple regions support a given special operation (eg. DISCARD) then the dec_count() that is used to set error for the region must increment the io->count. Otherwise, when the dec_count() is called it can cause the dm-io caller's bio to be completed multiple times. As was reported against the dm-mirror target that had mirror legs with a mix of discard capabilities. Bug: https://bugzilla.kernel.org/show_bug.cgi?id=196077 Reported-by: Zhang Yi Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-io.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/md/dm-io.c +++ b/drivers/md/dm-io.c @@ -302,6 +302,7 @@ static void do_region(int op, int op_fla special_cmd_max_sectors = q->limits.max_write_same_sectors; if ((op == REQ_OP_DISCARD || op == REQ_OP_WRITE_SAME) && special_cmd_max_sectors == 0) { + atomic_inc(&io->count); dec_count(io, region, -EOPNOTSUPP); return; }