From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lars Ellenberg Subject: Re: [RFC] block: fix blk_queue_split() resource exhaustion Date: Mon, 4 Jul 2016 10:20:07 +0200 Message-ID: <20160704082006.GN3239@soda.linbit> References: <1466583730-28595-1-git-send-email-lars.ellenberg@linbit.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-bcache-owner@vger.kernel.org To: Ming Lei Cc: linux-block , Roland Kammerer , Jens Axboe , NeilBrown , Kent Overstreet , Shaohua Li , Alasdair Kergon , Mike Snitzer , "open list:DEVICE-MAPPER (LVM)" , Ingo Molnar , Peter Zijlstra , Takashi Iwai , Jiri Kosina , Zheng Liu , Keith Busch , "Martin K. Petersen" , "Kirill A. Shutemov" , Linux Kernel Mailing List , "open list:BCACHE (BLOCK LAYER CACHE)" , "open list:SOFTWARE RAID (Multiple Disks) SUPPORT" List-Id: linux-raid.ids On Sat, Jul 02, 2016 at 06:28:29PM +0800, Ming Lei wrote: > The idea looks good, but not sure it can cover all cases of > dm over brbd or brbd over dm and maintaining two lists > becomes too complicated. > > One clean solution may be to convert the loop of generic_make_request() > into the following way: > > do { > struct bio *splitted, *remainder = NULL; > struct request_queue *q = bdev_get_queue(bio->bi_bdev); > > blk_queue_split(q, &bio, &remainder, q->bio_split); > > ret = q->make_request_fn(q, bio); > > if (remainder) > bio_list_add(current->bio_list, remainder); > bio = bio_list_pop(current->bio_list); > } while (bio) Not good enough. Consider DRBD on device-mapper on device-mapper on scsi, or insert multipath and / or md raid into the stack. The iterative call to q->make_request_fn() in the second iteration may queue bios after the remainder. Goal was to first process all "deeper level" bios before processing the remainder. You can achieve this by doing last-in-first-out on bio_list, or by using two lists, as I suggested in the original post. Lars From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753347AbcGDIUS (ORCPT ); Mon, 4 Jul 2016 04:20:18 -0400 Received: from zimbra13.linbit.com ([212.69.166.240]:52501 "EHLO zimbra13.linbit.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750895AbcGDIUM (ORCPT ); Mon, 4 Jul 2016 04:20:12 -0400 Date: Mon, 4 Jul 2016 10:20:07 +0200 From: Lars Ellenberg To: Ming Lei Cc: linux-block , Roland Kammerer , Jens Axboe , NeilBrown , Kent Overstreet , Shaohua Li , Alasdair Kergon , Mike Snitzer , "open list:DEVICE-MAPPER (LVM)" , Ingo Molnar , Peter Zijlstra , Takashi Iwai , Jiri Kosina , Zheng Liu , Keith Busch , "Martin K. Petersen" , "Kirill A. Shutemov" , Linux Kernel Mailing List , "open list:BCACHE (BLOCK LAYER CACHE)" , "open list:SOFTWARE RAID (Multiple Disks) SUPPORT" Subject: Re: [RFC] block: fix blk_queue_split() resource exhaustion Message-ID: <20160704082006.GN3239@soda.linbit> References: <1466583730-28595-1-git-send-email-lars.ellenberg@linbit.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 02, 2016 at 06:28:29PM +0800, Ming Lei wrote: > The idea looks good, but not sure it can cover all cases of > dm over brbd or brbd over dm and maintaining two lists > becomes too complicated. > > One clean solution may be to convert the loop of generic_make_request() > into the following way: > > do { > struct bio *splitted, *remainder = NULL; > struct request_queue *q = bdev_get_queue(bio->bi_bdev); > > blk_queue_split(q, &bio, &remainder, q->bio_split); > > ret = q->make_request_fn(q, bio); > > if (remainder) > bio_list_add(current->bio_list, remainder); > bio = bio_list_pop(current->bio_list); > } while (bio) Not good enough. Consider DRBD on device-mapper on device-mapper on scsi, or insert multipath and / or md raid into the stack. The iterative call to q->make_request_fn() in the second iteration may queue bios after the remainder. Goal was to first process all "deeper level" bios before processing the remainder. You can achieve this by doing last-in-first-out on bio_list, or by using two lists, as I suggested in the original post. Lars