Received: by 10.192.165.148 with SMTP id m20csp2533059imm; Sun, 22 Apr 2018 09:01:35 -0700 (PDT) X-Google-Smtp-Source: AIpwx49pNv86NBzAZbSFtaei5AxzYHPJXofp4c3UhDxAhNdHvzyR0HQk8A26S/OmA9TQxBdOmDTa X-Received: by 10.98.102.221 with SMTP id s90mr13423919pfj.123.1524412895456; Sun, 22 Apr 2018 09:01:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524412895; cv=none; d=google.com; s=arc-20160816; b=Xoq3TBqhi3qWOIAr4KvVPWyhkUdPT8M4oLKPWBPZweQy/EA4CQGD1QH90pIuznnC4+ hNWxDGaaq9xYf36qFYbC6Xxew9r7+q8N/cbCLBgKSBWsM6kgqYpmnf1JtNZjQLLn3Q35 L5XY+0jYlgOHDtfZRXFHDqhJxzeUwH23/TDsx8jI+vxcVZ12HMTs+nyALCetM4aDPrdE hhIFNp3PPwHYni9w2oCqly9IaKcjoxdrRMZajbEFdUPnzF7pS0ytMBRr90rLd+87287y nzCKBibRHnTWBCZ6QT7cero9BgeaamSAAICrl5L6M2F5xKjnN4ztv15t0eaZtGFhO+uR yoag== 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=8++761NPdX7XpMt6d46q5KoV+anPNz2XB6TJvTpXXEM=; b=u6gQ6qQni82DokX4A9ieO1+tYlH+mKrYXo8GoG+PDWYCTLhvVXvGAv2wwqWXP62Fn1 hf0UHHkWZi/PUoMiO6eWocDN8IZcVyKN1UNi/7NutlDbHFd7EtTNF8NPcDNg4lUIWBvC WVH/c8EJpcV+R7wyGAfqk4OsToMNa//pwaxlzVnXujpcx3tLoZzRkvZD+hHzotsQqauj NAkUKpazttBvAFJ5UlqEkqFQZh1r3dEHgoGCtnUwglznh6t9TzUvcxD4Aq4jFSzAMK94 Fov4q+CDi9hRqSvoXgraPVA+rrT9eyjfIfE88tQLNA0VZ/dSVXE6pjzwtKfCETqzXh8R my1w== 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 l12-v6si10142740plt.336.2018.04.22.09.01.21; Sun, 22 Apr 2018 09:01:35 -0700 (PDT) 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 S1753892AbeDVP77 (ORCPT + 99 others); Sun, 22 Apr 2018 11:59:59 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46362 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753565AbeDVN6r (ORCPT ); Sun, 22 Apr 2018 09:58:47 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4D98ECE4; Sun, 22 Apr 2018 13:58:46 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Snitzer Subject: [PATCH 4.16 100/196] dm: backfill abnormal IO support to non-splitting IO submission Date: Sun, 22 Apr 2018 15:52:00 +0200 Message-Id: <20180422135109.425346976@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@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.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mike Snitzer commit 0519c71e8d461ac3ef9a555bb7339243c9128d37 upstream. Otherwise, these abnormal IOs would be sent to the DM target regardless of whether the target advertised support for them. Factor out __process_abnormal_io() from __split_and_process_non_flush() so that discards, write same, etc may be conditionally processed. Fixes: 978e51ba3 ("dm: optimize bio-based NVMe IO submission") Cc: stable@vger.kernel.org # 4.16 Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1477,6 +1477,23 @@ static int __send_write_zeroes(struct cl return __send_changing_extent_only(ci, ti, get_num_write_zeroes_bios, NULL); } +static bool __process_abnormal_io(struct clone_info *ci, struct dm_target *ti, + int *result) +{ + struct bio *bio = ci->bio; + + if (bio_op(bio) == REQ_OP_DISCARD) + *result = __send_discard(ci, ti); + else if (bio_op(bio) == REQ_OP_WRITE_SAME) + *result = __send_write_same(ci, ti); + else if (bio_op(bio) == REQ_OP_WRITE_ZEROES) + *result = __send_write_zeroes(ci, ti); + else + return false; + + return true; +} + /* * Select the correct strategy for processing a non-flush bio. */ @@ -1491,12 +1508,8 @@ static int __split_and_process_non_flush if (!dm_target_is_valid(ti)) return -EIO; - if (unlikely(bio_op(bio) == REQ_OP_DISCARD)) - return __send_discard(ci, ti); - else if (unlikely(bio_op(bio) == REQ_OP_WRITE_SAME)) - return __send_write_same(ci, ti); - else if (unlikely(bio_op(bio) == REQ_OP_WRITE_ZEROES)) - return __send_write_zeroes(ci, ti); + if (unlikely(__process_abnormal_io(ci, ti, &r))) + return r; if (bio_op(bio) == REQ_OP_ZONE_REPORT) len = ci->sector_count; @@ -1617,9 +1630,12 @@ static blk_qc_t __process_bio(struct map goto out; } - tio = alloc_tio(&ci, ti, 0, GFP_NOIO); ci.bio = bio; ci.sector_count = bio_sectors(bio); + if (unlikely(__process_abnormal_io(&ci, ti, &error))) + goto out; + + tio = alloc_tio(&ci, ti, 0, GFP_NOIO); ret = __clone_and_map_simple_bio(&ci, tio, NULL); } out: