Received: by 10.223.164.202 with SMTP id h10csp1704270wrb; Mon, 27 Nov 2017 06:24:42 -0800 (PST) X-Google-Smtp-Source: AGs4zMbf4Ws0fU7XgWWG4Aq7FTC6EmMu929c4cf6YQ5RMdl7aa1DoLpFhlOqwpl+1/3HQWmcB8R9 X-Received: by 10.98.79.152 with SMTP id f24mr37631780pfj.143.1511792681879; Mon, 27 Nov 2017 06:24:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511792681; cv=none; d=google.com; s=arc-20160816; b=ffLUCmpQuir8ecnXT2+tBhZ6zBBvAMiTcLsOp8E0GiHaKGmMSc1K7iPuQY2NIEdj9W Wlgzc5FIHC/pHCgxPfKDZ/CkBLp/i/yM6ZLPt3YG6fVxvglqHlOiAireU+BaiCgqy0E8 q9Tfsk25BoZd83w/RH6gqWyPLFhXJG7d7YX0Rj/jKrWMAIeHqOUmdGW3CPGeZG6bhwLo pkI78dgisrcchACnY5gNKta8jfChvc4d7sajhyu0wqMSMQ6LaxF+mzpYx6JCZvtZmgHc UiIYbGhyEE3bKJPIDvK2Ql+PjMNp5VetG6EIptPVtH/Y3ERRDFRol8dEnC2GQoF9n3bh oA0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=1JYy4r2uQuceZS+7Ddf8+A7ESzmi3EKrq8BiOqsXgN0=; b=hLBdX40trHs1clePvn+dOMRZvO/+py2nNDCPVooScGwr39uC3Cqbx6Oak2TSyBE0Lb 4E31YpDh7WFl3BiDDquC9a9I4SkN3tbW6U6Xv7tmnIvNv1uDzqV61qX/8ZeqbdKbSqhR MpSTBXdsbMDhNY4j3gx8Hm0Hym7DN1dsxnXDY2ztuT+B0CXEs6UtdMGVe5blfWXhA3Ay +An71QXGox7t8A6RNJOXCxQIegoCQDKczlsAyAOVnM0sJhfpM3x8x4arPvQQHAyQ+lrH XS4iKyBkfzXUWDoMJ5xz+jKyRFY+vi+50ciy3wZ/HDseOky3F5ad5OMIe3kW2eQZjvWm xL3A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m68si6059003pgm.360.2017.11.27.06.24.29; Mon, 27 Nov 2017 06:24:41 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752570AbdK0OXw (ORCPT + 77 others); Mon, 27 Nov 2017 09:23:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45914 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752470AbdK0OXs (ORCPT ); Mon, 27 Nov 2017 09:23:48 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D8AFB13AA2; Mon, 27 Nov 2017 14:23:47 +0000 (UTC) Received: from localhost (unknown [10.18.25.149]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E1D65EDE8; Mon, 27 Nov 2017 14:23:45 +0000 (UTC) Date: Mon, 27 Nov 2017 09:23:44 -0500 From: Mike Snitzer To: NeilBrown Cc: Mikulas Patocka , Jens Axboe , "linux-kernel@vger.kernel.org" , linux-block@vger.kernel.org, device-mapper development , Zdenek Kabelac Subject: Re: dm: use cloned bio as head, not remainder, in __split_and_process_bio() Message-ID: <20171127142344.GA25881@redhat.com> References: <20171121013533.GA14520@redhat.com> <20171121121049.GA17014@redhat.com> <20171121124311.GA17243@redhat.com> <20171121194709.GA18903@redhat.com> <20171121225119.GA19630@redhat.com> <87bmjv0xos.fsf@notabene.neil.brown.name> <878tewzjz3.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <878tewzjz3.fsf@notabene.neil.brown.name> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 27 Nov 2017 14:23:47 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 23 2017 at 5:52pm -0500, NeilBrown wrote: > > When we use bio_clone_bioset() to split off the front part of a bio > and chain the two together and submit the remainder to > generic_make_request(), it is important that the newly allocated > bio is used as the head to be processed immediately, and the original > bio gets "bio_advance()"d and sent to generic_make_request() as the > remainder. > > If the newly allocated bio is used as the remainder, and if it then > needs to be split again, then the next bio_clone_bioset() call will > be made while holding a reference a bio (result of the first clone) > from the same bioset. This can potentially exhaust the bioset mempool > and result in a memory allocation deadlock. > > So the result of the bio_clone_bioset() must be attached to the new > dm_io struct, and the original must be resubmitted. The current code > is backwards. > > Note that there is no race caused by reassigning cio.io->bio after already > calling __map_bio(). This bio will only be dereferenced again after > dec_pending() has found io->io_count to be zero, and this cannot happen > before the dec_pending() call at the end of __split_and_process_bio(). > > Reported-by: Mikulas Patocka > Signed-off-by: NeilBrown > --- > > Hi, > I think this should resolve the problem Mikulas noticed that the > bios form a deep chain instead of a wide tree. I'm inclined to just fold this into the original commit. I'd update that header to make mention of the details captured in this header. Would you be OK with that? Mike From 1584899141692712738@xxx Thu Nov 23 22:53:25 +0000 2017 X-GM-THRID: 1584899141692712738 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread