Received: by 10.223.185.111 with SMTP id b44csp915701wrg; Fri, 9 Mar 2018 16:46:39 -0800 (PST) X-Google-Smtp-Source: AG47ELvWrA3CHf35I7AfepYQ4DAkcZjDWhxgtg4ou5vt9gwiYZDM6SdtrZelVVFONJZ8+aOxL5/b X-Received: by 10.101.101.138 with SMTP id u10mr290134pgv.299.1520642799319; Fri, 09 Mar 2018 16:46:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520642799; cv=none; d=google.com; s=arc-20160816; b=Zrye5IeNWbZ2+PUeygz+4+vD/Wt0EYw8XInSTyaOdbvaIKGHDSBp1SFt/DUoOVQTkG 25nvhYIWvME9PR7my4uTD/7eC4BRzvWOOYKOQQOKr7cfSGdvY0Tzq2wAzON/ZmXinXL1 N62GAZ/k2Eg1yZfeP/CEyRxJf02guewLp73xythEcofDmpx0NucgiQwx+o7yHjJBL0nS 9wwyyC+YB6PkcOyw/IkAU/KWl5x5em14qFQ1VAS4GkSJsWVAPOO3900PowTbj8nMDOWC uyzfTWKquQhvE144EIYjxl5jtbTDRlZ/wsLTA6TtNrMTdL5RIT3JZZegFIwPhE1E0WOh wvGA== 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=XvCU50PC7u3+kkdd3B1fa7iYG0KWLmagx96s3ABLpJw=; b=cY5ljiZPWnellfcWFzcQTp2PP5qQnsLrosmNvnA3HW0hjBoIDB+3FP52ZRX57B7kzp XXPUIKgAalhZzb704oS3eLQ05GqPaJKYNiNUK7FjW97jC+cKQB5QZts3IjpN41w/hUnZ NKnZ/Hp6q4/GWFHQFNM72/jqaMYErJGChuY+XyMMH+hyhwz1aEFtb7d1QV4d7gY9xTnw zY8hp/OYrTjRXagWOefH+L3HI0xZ9tDM/N4E8aITwL4r8fESW+BJInytfM0nrh33zsT6 hlOJCFEb405U1cjVeqP+VirtlT+R7HDobDqVfsyF/iyH9AQT03/JMP+T4F7WDuR4GhLf DrMg== 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 y64si1781847pfj.47.2018.03.09.16.46.25; Fri, 09 Mar 2018 16:46:39 -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 S933495AbeCJAo2 (ORCPT + 99 others); Fri, 9 Mar 2018 19:44:28 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:39184 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933211AbeCJAUb (ORCPT ); Fri, 9 Mar 2018 19:20:31 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C4586F26; Sat, 10 Mar 2018 00:20:30 +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.4 34/36] dm io: fix duplicate bio completion due to missing ref count Date: Fri, 9 Mar 2018 16:18:50 -0800 Message-Id: <20180310001809.241968272@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180310001807.213987241@linuxfoundation.org> References: <20180310001807.213987241@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.4-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 @@ -300,6 +300,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; }