Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1059466ybx; Wed, 30 Oct 2019 09:14:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEo8KTNuIiQOjBxFSCYhg5UmPUgPU3Cimis6qNyLt2IMC9/3IPqdgfCimLDjwYQJ7syFvs X-Received: by 2002:aa7:dc44:: with SMTP id g4mr510920edu.266.1572452064175; Wed, 30 Oct 2019 09:14:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572452064; cv=none; d=google.com; s=arc-20160816; b=tSjsnci5sZ9iCgRRKxL5be2yrMF6Z7SJzBRhYw7pOjfNLewgL3GdXjzfBjUGNGrLWb Lgwr0N9GSxZyh1uW25gEr8RsTxCqAfxM4X/w6ITx9kBiMxOd9QiyHQW/W8WPl/pr9GFC nsKzJmx8l24Rvpq+U84C4C/JaTUFvUyPmUxBCW69yE+nVYrGDuBkHa2Ah6AvDs37gY5r Kwfcr4bgHkzBhiLA8BGAITEbLqwM45WnWaJlbZzi6LUldoBIvGhwVtgA1kybtTVxY4hr fI/1gridhp1Kyvu4OGgdFunHbW3QHRMDFLZXdTjcMWBaFLFllbA8fXJZIzna2Rg5XfA0 U14Q== 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=S/ZDvmEPfSmBt4lxF3DnDhcZlHbW70loQ/lD49ODK0I=; b=0xrBm6DtxPWjHnBk2zEIHGoCMXeaQcSVpvog0287JtAP+auYzJnNDB2i/dZNrI9B8W xkghdas5YVUuim2OWn6q5dkOrIG/GfzqA1EOLXziERUZxVYct55vZQb15R4FxftwvHQc eVys3w6hNmbJY+kQfkvsFF9SgHMv1KddmvTlCJn4qve3YC9ofTIPz96J3grLixdGFSyt Wadk46dATHG+lFC3KdLNMBX+M1AEe6osECIb5KUbm67drjae51LYh3J0txyTcr6G2gUp 6kpAIEEsrop/uFyMSTaHwTXycQogbOa358rjG3KyI3EBiUroA84iuqohBXcCugRP4rKo p6ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=QMBsrUOA; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f6si1868583edl.442.2019.10.30.09.13.47; Wed, 30 Oct 2019 09:14:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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=@aol.com header.s=a2048 header.b=QMBsrUOA; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726840AbfJ3QNC (ORCPT + 99 others); Wed, 30 Oct 2019 12:13:02 -0400 Received: from sonic313-19.consmr.mail.gq1.yahoo.com ([98.137.65.82]:34818 "EHLO sonic313-19.consmr.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726475AbfJ3QNC (ORCPT ); Wed, 30 Oct 2019 12:13:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1572451981; bh=S/ZDvmEPfSmBt4lxF3DnDhcZlHbW70loQ/lD49ODK0I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject; b=QMBsrUOAQVdL2w29pwAQaHcD6kp2e/RxIp85wI+KnwsKuWxiqcJd8pATRVM9juGX5aZ/M7Buy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HWs11RBUNpiMuhAXEHFwyQQNxEq9sC0JyIZqejGhOv mi8r2eK3P8dEhDy5eX4EeWXinlzC1RG.KX4oqqBt1U85ALfe877Kq1qzxyzOFE9Atv22PxWqNbKM iLkBUqEizY8iFKZ8vZaBmdClhopDxeCmZrdSimesgEWCQjTKvrRhuSu0aLGjx42_jXxUTcOEbauc 6LZblcrM_54LoUOnQE8gCBcALNL2j5VUklssHHu8tbSNAmY2_LbkMQxB4ni2rbCd2z89la..ojMB JQCUkH3Dyfudae9CqZNIGztmvD4fwf.wn4p_krKtkiFusiiskMiaLsXNvXujMv6yXR5bk1SR4B6a zJfQ4V60duEOpO0XFgCd5Bzq0doRP6R6zJVzpSJZH4BDNb_qq4KqOKPtJvTyQLer9b7YIcYdLtBi Nt4Z2xs.KOYNhiQxc0Vrpjo0aWUwDzmjReN0SkgkmOt3FhPovo0oA3KcgN_cRDyV4CjGSvoKTqUA JhAVJ_wtD0hLl6umTyuUGUUJHnRkx9a1PK2v_LtCx8uvFRRMmBHs2F__keJdEBI0gc.6dzatprPn NYs.w_VYphckCWYGa1zNGZ_d1E2n3DqcQfYweifeee2FaOf8Z2j_nlc3sZihMdvquuwbJCzslQON RPKNRTQ-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.gq1.yahoo.com with HTTP; Wed, 30 Oct 2019 16:13:01 +0000 Received: by smtp431.mail.ir2.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 5bc5368066fdcbc1af6a611a83615b01; Wed, 30 Oct 2019 16:12:59 +0000 (UTC) Date: Thu, 31 Oct 2019 00:12:52 +0800 From: Gao Xiang To: "Theodore Y. Ts'o" Cc: Ritesh Harjani , Gao Xiang , Andreas Dilger , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH] ext4: bio_alloc never fails Message-ID: <20191030161244.GB3953@hsiangkao-HP-ZHAN-66-Pro-G1> References: <20191030042618.124220-1-gaoxiang25@huawei.com> <20191030101311.2175EA4055@d06av23.portsmouth.uk.ibm.com> <20191030150437.GB16197@mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191030150437.GB16197@mit.edu> User-Agent: Mutt/1.9.4 (2018-02-28) X-Mailer: WebService/1.1.14593 hermes Apache-HttpAsyncClient/4.1.4 (Java/1.8.0_181) Content-Length: 2467 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Hi Ted, On Wed, Oct 30, 2019 at 11:04:37AM -0400, Theodore Y. Ts'o wrote: > On Wed, Oct 30, 2019 at 03:43:10PM +0530, Ritesh Harjani wrote: > > > > > > On 10/30/19 9:56 AM, Gao Xiang wrote: > > > Similar to [1] [2], it seems a trivial cleanup since > > > bio_alloc can handle memory allocation as mentioned in > > > fs/direct-io.c (also see fs/block_dev.c, fs/buffer.c, ..) > > > > > > > AFAIU, the reason is that, bio_alloc with __GFP_DIRECT_RECLAIM > > flags guarantees bio allocation under some given restrictions, > > as stated in fs/direct-io.c > > So here it is ok to not check for NULL value from bio_alloc. > > > > I think we can update above info too in your commit msg. > > Please also add a short comment in the code itself, so it's clear why > it's OK to skip the error check, and reference the comments for > bio_alloc_bioset(). This is the fairly subtle bit which makes this > change not obvious: OK, I will add short comments in code then, and tidy up later since it's not urgent (but I'm surprised that so many in-kernel code handles that, those also makes me misleaded before, but I think mempool back maybe better since the total efficient path is shorter compared with error handling path)... and I'd like to know the f2fs side as well :-) > > * When @bs is not NULL, if %__GFP_DIRECT_RECLAIM is set then bio_alloc will > * always be able to allocate a bio. This is due to the mempool guarantees. > * To make this work, callers must never allocate more than 1 bio at a time > * from this pool. Callers that need to allocate more than 1 bio must always > * submit the previously allocated bio for IO before attempting to allocate > * a new one. Failure to do so can cause deadlocks under memory pressure. > * > * Note that when running under generic_make_request() (i.e. any block > * driver), bios are not submitted until after you return - see the code in > * generic_make_request() that converts recursion into iteration, to prevent > * stack overflows. > * > * This would normally mean allocating multiple bios under > * generic_make_request() would be susceptible to deadlocks, but we have > * deadlock avoidance code that resubmits any blocked bios from a rescuer > * thread. > > Otherwise, someone else may not understand why it's safe to not check > the error return then submit cleanup patch to add the error checking > back. :-) Got it. Thanks, Gao Xiang > > - Ted >