Received: by 10.223.185.111 with SMTP id b44csp918404wrg; Fri, 9 Mar 2018 16:50:53 -0800 (PST) X-Google-Smtp-Source: AG47ELvSDWusOl17Ndd2WZJfMgR4bygrh8Zs7o2/FmmvgQvfPbiHzxAqQul+JxkeIzPcyjqBACcJ X-Received: by 10.98.13.211 with SMTP id 80mr366929pfn.69.1520643053693; Fri, 09 Mar 2018 16:50:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520643053; cv=none; d=google.com; s=arc-20160816; b=OVlu/jyGRHPQZDJvjENqXfgNYgPcij3LzHwYStFrp5c2WS69gZ5TAWCYENGyuMbWGF IzdF1dcq7dQY7X+3HvK1CvQxyr9BOA89vNtiZliAOOyyx5LdyKS+ckKPMNEVNWPQQS+i 7yvrvFsOaLWi14reth4NHgv4A8TMle48RlizIv7LRkQYQLJqh7lAXgzrtUKuvCOi58O1 fgGL6PwE4eTJeqxcnwjB9LZMYTjvFRVo6Kdn0S00yro4rXH/75PVS/WO6lCX385j5eIu YZchZyWRVGBBqtaMlnsGBQug5u2NX1qTMvSSrGM7AmK1P+k1d99FbWBw5zep1gBXTwZQ svQQ== 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=2ZDCwdYaKku6iYwcMuOpfn9oMgCq1IsRRjN0i6VssEo=; b=tPGq/u8JfCDCqERu0xzYlSQxylVw3wzzEL+cEmCXh+qwoOqPk05tug7WbpHPwYrVNH iB7BjPyIGXKn6GZueAuJGJWrx6iSLvvoFvoU2BTNdqIbX9oL3oQVNe9QtwxSshfe8d31 GWKgECblAJ+BNQg+UYNa7ObUhjrM0FKBTDzGuEw5ivyxYLUkMSgdmyTalnGWsod2Dl7J fdRDPQKOOlQg0eeu7ovjqvOgKTaorfeJ41dwVFveNeE6FpZ9vM5G37u6D4lbd0flIDbc kvDM7bt9UPiHHGgZPGZYTN88NGE2+OKqYtZB2+vG9SokJ/P3iroEG9ILZiZMobsBFPpz wkiQ== 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 n3-v6si1730312pld.347.2018.03.09.16.50.39; Fri, 09 Mar 2018 16:50:53 -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 S933178AbeCJAtg (ORCPT + 99 others); Fri, 9 Mar 2018 19:49:36 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:38696 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932967AbeCJATa (ORCPT ); Fri, 9 Mar 2018 19:19:30 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 10DA8F1D; Sat, 10 Mar 2018 00:19: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 3.18 21/21] dm io: fix duplicate bio completion due to missing ref count Date: Fri, 9 Mar 2018 16:18:43 -0800 Message-Id: <20180310001802.413510669@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180310001801.045114869@linuxfoundation.org> References: <20180310001801.045114869@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 3.18-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 @@ -299,6 +299,7 @@ static void do_region(int rw, unsigned r else if (rw & REQ_WRITE_SAME) special_cmd_max_sectors = q->limits.max_write_same_sectors; if ((rw & (REQ_DISCARD | REQ_WRITE_SAME)) && special_cmd_max_sectors == 0) { + atomic_inc(&io->count); dec_count(io, region, -EOPNOTSUPP); return; }