Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp888162ybv; Thu, 13 Feb 2020 11:23:23 -0800 (PST) X-Google-Smtp-Source: APXvYqyegdyN8B7vsDM6UFnkHEgCnAeoqw0vO2d+iK378ZOysGRO5QCFbSLKxNWsPW+Qc+Yz3Bcg X-Received: by 2002:a05:6830:610:: with SMTP id w16mr14864031oti.239.1581621803548; Thu, 13 Feb 2020 11:23:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581621803; cv=none; d=google.com; s=arc-20160816; b=VUoZLyoGNpdWI9WizvQLmvQOab/7R6+RruMnMC9Yx1Lo0amvZzNDev4amQ7lYv+iWv z4z6c8L+FlRNNXo3RUOQ7/uOn5wYpZ6j4wYb9NNv1Yq4SSHwVW+yHMi1wl/vTohbmmyF kTNfr0KmrOv1UpQ0RDZ7XOiisRYjVLFL9jZKbI92FE0rXRd/WAdilusi7BLuD6VtLBGf 7bkidGTz0i332YVs/1q3dEUYZaxzscEn6hVC2xPofmTw8P/bEGVguhYdylL7Tkc02h4S J63ntAaRS5n3Qz7zh30zEqCu8HRI1Q1f0u06rIj+ZZmvP/R91jepJk+3vBWSVCuksMYY EILA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=/QOUSXFhncnCv9tdGLgXn7t709p+c+vsJCaqhbGCgQg=; b=FHGJwwsV/Ma602yuYwvUwNeMH6pWQBgYoBKmUFGip9ggiw/Akm/8aqEDOGjaVICOSE BoWUdmd2XqcHl+i+QA63bp7a2iizgwy/JoqR2bb/Y4hJcYmp7y6UCY01zBFVW5UtjRyB u8OWgb6H/fPTiWBn6/5+zyHk55TIkb/sITNUUItxa+o88Y4q5UCv/Je5yOf/hu0d2lEd QOPLtGWwoXcg4LtOPvrooKCYoF1zsn4RcbiUtKMTufN9lf+nhjfbeqvjhCRjrSo2Q6Nu Kg388h+Ru0jyDYdp2N004UW1uv3QEbAQs3ELlMiNYw6TuuwNIU75AO3Zu1uJrsKiYAFS /2Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="pS/rA/XQ"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s22si1469115oij.35.2020.02.13.11.23.10; Thu, 13 Feb 2020 11:23:23 -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=@google.com header.s=20161025 header.b="pS/rA/XQ"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728591AbgBMTVu (ORCPT + 99 others); Thu, 13 Feb 2020 14:21:50 -0500 Received: from mail-io1-f68.google.com ([209.85.166.68]:32976 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728578AbgBMTVt (ORCPT ); Thu, 13 Feb 2020 14:21:49 -0500 Received: by mail-io1-f68.google.com with SMTP id z8so7817523ioh.0 for ; Thu, 13 Feb 2020 11:21:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/QOUSXFhncnCv9tdGLgXn7t709p+c+vsJCaqhbGCgQg=; b=pS/rA/XQrsxzALgzkkxUeROv/A+yx7tTwuLt9niMsfB6HwrxJMIlP3S2/4cJAI9Xxl FEwPSATlEOu0eg2zmBQmE+QLH8NFhPJGMSP43gExdI76wnbvkqAkqVwfXFs/8+X4+ZMP j9OHRJjNJPJf6srEwtDgNRoYZ2sM5AlxJ9JauV7+SkprHS0iAq04hzVRoYEkME95AMaA KWBQrY3h2AZsrbxjz6W33oBVnW+96Q/3aKr5x/uyP6f08CkG52DwaC/wKWy8OelXOhHG enBS8ih7VJX0/gHzC7y/6ktnVbeRNBA9p+kQy0prGSEVEFxHEx/6PeJiN5Xz0VnbYNg5 CaSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/QOUSXFhncnCv9tdGLgXn7t709p+c+vsJCaqhbGCgQg=; b=Kpsi3XwwPZvxMcfsjsCtndk6H9DQxpBSOH4y4kUUm+XlrB+cc9oIducXu7xoBq2lB9 so05zoo550BllKEztQfz0y/yuYgNsFM5qFNv4ah/1Dj/NdyauSv/m4Vkw4xFem8OOb9e iWqq8qNTGgVM1u1INMQiA+VhxA8kWSyR8OQKykZ3XK1D9fe857O6waOjcpEgdK7mvV96 6UuBBPoh3x1OiM6Fyul/MEVrPKWT8KWum49W6Wdc6RXvqPzQPIz93zEn4a0BZnQ3Lyd9 HZmWCpxMqdHFiZtCIzIkBDhL0NMjySVTKX8amWUBc3NVshlMkclGfgihQcg6pvwkKQxr OG3Q== X-Gm-Message-State: APjAAAWNGOrC/IEJvsYIZ/d+nuN15JPicc5irMRlsFZqpJQDrEm8OuUB INNUpwyxmvMWIfUDXEqU0/6GTdNAGdX2Q4HxbbaJ5Q== X-Received: by 2002:a5d:8c84:: with SMTP id g4mr23458168ion.289.1581621708984; Thu, 13 Feb 2020 11:21:48 -0800 (PST) MIME-Version: 1.0 References: <20200213082643.GB9144@ming.t460p> In-Reply-To: From: Salman Qazi Date: Thu, 13 Feb 2020 11:21:37 -0800 Message-ID: Subject: Re: BLKSECDISCARD ioctl and hung tasks To: Bart Van Assche Cc: Ming Lei , Jens Axboe , Christoph Hellwig , Linux Kernel Mailing List , linux-block@vger.kernel.org, Gwendal Grignou , Jesse Barnes 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 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. 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). Having said that, I don't like neutering the hung task timer either. > Thanks, > > Bart.