Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1127568ybv; Thu, 13 Feb 2020 16:27:36 -0800 (PST) X-Google-Smtp-Source: APXvYqy8RF+dikwGdnS16jXpVH1pVyJQCB9rLrwGCWVcELLeulTsTsk9TSG7CaORFQfNqwNTvN5i X-Received: by 2002:a05:6830:1:: with SMTP id c1mr137066otp.254.1581640055826; Thu, 13 Feb 2020 16:27:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581640055; cv=none; d=google.com; s=arc-20160816; b=bzfUvj65L6Tnyoy0vk2Ys3jm1b6ihB+ORvmI/KG6l4zCmvsUFJ88vMYM/MxlbSND96 fGPy81lznadBNjG3evzt6EW4l1gEVeRWUnMbXUgQu3mHdF7HLTcPfwPpG1NcXJvEJ2mr ZYB2M0QopmSVozvYamJPMAxfbgseLeNstRm5FHOUVD9Q4xsb1Qd7R7jShtvAqP+3ycTg 3OkylAnqZGOd2y3M3qDZ3Ap7+RgsoWAeBCYZtzqqX9ye/O1RUOwH0tziSDXcPR1IqkpE nMtJZVoq2gL1uVHpvdBd7qmOAW7FwD8g94MqGHcRVdQlbuZfzRJ3++URej+Eg3n8lKyt H7bQ== 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:dkim-signature; bh=qOuyJfMfPTaKw6DAz8xXan7RlS4xgiXwLj+Ny+dnSmo=; b=ygDKX1TCWjo7S8aBuQOjR8sljr6lwklsDON99osQi6H9qs+4s1Elld1r9OD8PU2hPB 3IUVt6naSN8iplXM90F1cgoNzlFI9uADw0Kjhil1Mbrb4O0Rqsg5Jnu8RcAMnlT+Hnp2 SzgtUdb+ktho9qsVFJTayo7OfKe+PK5/cbJ0X/f9cxUULF0P0yGFh33p36RYph6Gypi4 D8e3ZN1JrG0xk9OWC8p+FyXHXAsVHycHBpm90DEdTf6rw056ssgRbI1v5M/4qcv2K3LN HFxLonxiTilsvsC/HelGJakL6aViFIr3hJmQP9qVwquanh4k6b6HcnMhTJeKDgBOmgFr 2LOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eOPZJgj7; 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=pass (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 v3si1960843otn.140.2020.02.13.16.27.22; Thu, 13 Feb 2020 16:27:35 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eOPZJgj7; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728004AbgBNA0A (ORCPT + 99 others); Thu, 13 Feb 2020 19:26:00 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:32128 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727594AbgBNA0A (ORCPT ); Thu, 13 Feb 2020 19:26:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581639959; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qOuyJfMfPTaKw6DAz8xXan7RlS4xgiXwLj+Ny+dnSmo=; b=eOPZJgj7UL+o3Tm51Dl4XlWWzJ5xfwZAxsOvzy/bvlWyAnJFgWwxaRF1wkYojceV/hXJEl /QWQjQUxyumi/R0R/BgiaZokRt3ZAY/6840fwvlSYmpdSbW55KUme8KuLQMOSozB0TLO0H XiP/IQBCaHsNGsRMHoqYzz3J7iElU7U= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-371-BM4H64XGMuWV1aBsm-tH9A-1; Thu, 13 Feb 2020 19:25:51 -0500 X-MC-Unique: BM4H64XGMuWV1aBsm-tH9A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 507FE1851FC2; Fri, 14 Feb 2020 00:25:49 +0000 (UTC) Received: from ming.t460p (ovpn-8-16.pek2.redhat.com [10.72.8.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA18219C70; Fri, 14 Feb 2020 00:25:42 +0000 (UTC) Date: Fri, 14 Feb 2020 08:25:38 +0800 From: Ming Lei To: Salman Qazi Cc: Bart Van Assche , Jens Axboe , Christoph Hellwig , Linux Kernel Mailing List , linux-block@vger.kernel.org, Gwendal Grignou , Jesse Barnes Subject: Re: BLKSECDISCARD ioctl and hung tasks Message-ID: <20200214002538.GA4907@ming.t460p> References: <20200213082643.GB9144@ming.t460p> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 13, 2020 at 11:21:37AM -0800, Salman Qazi wrote: > On Thu, Feb 13, 2020 at 9:48 AM Bart Van Assche wrote: > > > > On 2/13/20 12:26 AM, Ming Lei wrote: > > > The approach used in blk_execute_rq() can be borrowed for workaround the > > > issue, such as: > > > > > > diff --git a/block/bio.c b/block/bio.c > > > index 94d697217887..c9ce19a86de7 100644 > > > --- a/block/bio.c > > > +++ b/block/bio.c > > > @@ -17,6 +17,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > > > > #include > > > #include "blk.h" > > > @@ -1019,12 +1020,19 @@ static void submit_bio_wait_endio(struct bio *bio) > > > int submit_bio_wait(struct bio *bio) > > > { > > > DECLARE_COMPLETION_ONSTACK_MAP(done, bio->bi_disk->lockdep_map); > > > + unsigned long hang_check; > > > > > > bio->bi_private = &done; > > > bio->bi_end_io = submit_bio_wait_endio; > > > bio->bi_opf |= REQ_SYNC; > > > submit_bio(bio); > > > - wait_for_completion_io(&done); > > > + > > > + /* Prevent hang_check timer from firing at us during very long I/O */ > > > + hang_check = sysctl_hung_task_timeout_secs; > > > + if (hang_check) > > > + while (!wait_for_completion_io_timeout(&done, hang_check * (HZ/2))); > > > + else > > > + wait_for_completion_io(&done); > > > > > > return blk_status_to_errno(bio->bi_status); > > > } > > > > Instead of suppressing the hung task complaints, has it been considered > > to use the bio splitting mechanism to make discard bios smaller? Block > > drivers may set a limit by calling blk_queue_max_discard_segments(). > > From block/blk-settings.c: > > > > /** > > * blk_queue_max_discard_segments - set max segments for discard > > * requests > > * @q: the request queue for the device > > * @max_segments: max number of segments > > * > > * Description: > > * Enables a low level driver to set an upper limit on the number of > > * segments in a discard request. > > **/ > > void blk_queue_max_discard_segments(struct request_queue *q, > > unsigned short max_segments) > > { > > q->limits.max_discard_segments = max_segments; > > } > > EXPORT_SYMBOL_GPL(blk_queue_max_discard_segments); > > > > AFAICT, This is not actually sufficient, because the issuer of the bio > is waiting for the entire bio, regardless of how it is split later. Right. > But, also there isn't a good mapping between the size of the secure > discard and how long it will take. If given the geometry of a flash > device, it is not hard to construct a scenario where a relatively > small secure discard (few thousand sectors) will take a very long time > (multiple seconds). It isn't strange to see such implementation, and I also see discard request timeout. > > Having said that, I don't like neutering the hung task timer either. But it does fix the hung warning, doesn't it? thanks, Ming