Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp118766pxb; Wed, 23 Mar 2022 14:24:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4SXmajsth7FfvNU8SjyexhEkkXCBhm9pnkXwTtdNCnBi3GCiVOr0RDdYbcRay1Iz+l3EB X-Received: by 2002:a17:906:730e:b0:6e0:2ad8:12c8 with SMTP id di14-20020a170906730e00b006e02ad812c8mr2199704ejc.623.1648070665448; Wed, 23 Mar 2022 14:24:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648070665; cv=none; d=google.com; s=arc-20160816; b=o4q+PDj9PTD2rJTpSbQpnnsDKlZGX+T3uitPmH9U/CUiuyPNW31aBa7K+QLGuHGbkW PzzaPAZhkaRDIbavHepzqSfpO0RIL00OZVMh0rhqRWo3BvODPTwx4GOOt6R0D6qjiLtB 5UmB5VQntp/UztlaOCdL54qqmhma3tNCTdBuMgGPHoANt0lx8WTkCQZlnEg2HVZcrXPb cGXjaZvgtOBJS41/m0BD27JTMl9oih/9IvfeDlzR58iH3Ys6HzpZhKI5gDsXFfSHT2Sp IRtm1MbTZUuME7UV14JpioB+w5OFMiFupsRf9GFd+FxGiVW0XzV07Z0rwX6AvJfCLTmA egLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:references:in-reply-to:subject :cc:to:from:mime-version:content-transfer-encoding:dkim-signature :dkim-signature; bh=ZQRFIvMYPa57E8vs5yQx5fBF8QSVW2wkNB0Ft3IVHkg=; b=y936g0TUwxSWDXA/Eludjb9RjRPlzOlB87YyncQ05+uXRV6L9eiq58WI8iXAf2ldQB zjtogJlmg3QJMJrRNCJX4PkozpXuzd81Sz9P9/h/sYxvPMhyOiwL+gfnPdpelPu2+Whq pxZNw143T3jty9qr1xlduKsDvFcYv/76rMRRz1yCWDedKZWtf0U041TJTMBTQwcbKzbV eRPhHByq2ZyaWgxiSfy+Goh8tVFlgfF4u91oZys+TycZmuZfR9k0CyeHdTcJPR1Mthek A6chP1ACGl0TEFeTb1xrKX1eDbviVyvQwFW3rgLFYX8zNAs1y48vRBAoYMKUOgJo9sQC Gu8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=hUPA4AfH; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=ebx4g8z+; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q23-20020a50c357000000b00418c2b5beeasi16314929edb.460.2022.03.23.14.23.51; Wed, 23 Mar 2022 14:24:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=hUPA4AfH; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=ebx4g8z+; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235391AbiCWVGU (ORCPT + 99 others); Wed, 23 Mar 2022 17:06:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235540AbiCWVGU (ORCPT ); Wed, 23 Mar 2022 17:06:20 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9E853122E; Wed, 23 Mar 2022 14:04:49 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6057F1F387; Wed, 23 Mar 2022 21:04:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1648069488; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZQRFIvMYPa57E8vs5yQx5fBF8QSVW2wkNB0Ft3IVHkg=; b=hUPA4AfHH40LrLy7/afNuEXl3ZSmwWmLp5N8L4vWyy4uDG3LZjrrBdJIMAJMH4DsGmEquz UQ6MKVTtH91xo15DCiU0edkhR+MBnlWOTPAARbOWUHBVPdofhMHr2EzGNTveoALQa66KJw ISUr/uiq9UmAxPsZQ+SHgQlSrdE7pXk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1648069488; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZQRFIvMYPa57E8vs5yQx5fBF8QSVW2wkNB0Ft3IVHkg=; b=ebx4g8z+Yz2YE2VTtZLhKFXsf1MiAaeq5J9BhH2AkGiRXYd7fdpfHSDMCj/qdFlvyt30vh e9x5ncED9Oe8LVBA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B02F313302; Wed, 23 Mar 2022 21:04:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id aD1FGm6LO2KobwAAMHmgww (envelope-from ); Wed, 23 Mar 2022 21:04:46 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 From: "NeilBrown" To: xkernel.wang@foxmail.com Cc: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, "Xiaoke Wang" Subject: Re: [PATCH] NFS: check the return value of mempool_alloc() In-reply-to: References: Date: Thu, 24 Mar 2022 08:04:41 +1100 Message-id: <164806948116.6096.12331736937963571485@noble.neil.brown.name> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, 23 Mar 2022, xkernel.wang@foxmail.com wrote: > From: Xiaoke Wang > > The check was first removed in 518662e ("NFS: fix usage of mempools.") > as the passed GFP flags is `GFP_NOIO`. > While now the flag is changed to `GFP_KERNEL` by 2b17d72 ("NFS: Clean > up writeback code"), so it is better to check it. no. GFP_KERNEL is not that different from GFP_NOIO. mempool_alloc() can only fail with __GFP_DIRECT_RECLAIM is not passed. Please try to understand the code before you change it. NeilBrown > > Signed-off-by: Xiaoke Wang > --- > fs/nfs/write.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/fs/nfs/write.c b/fs/nfs/write.c > index eae9bf1..831fad9 100644 > --- a/fs/nfs/write.c > +++ b/fs/nfs/write.c > @@ -106,8 +106,10 @@ static struct nfs_pgio_header *nfs_writehdr_alloc(void) > { > struct nfs_pgio_header *p = mempool_alloc(nfs_wdata_mempool, GFP_KERNEL); > > - memset(p, 0, sizeof(*p)); > - p->rw_mode = FMODE_WRITE; > + if (p) { > + memset(p, 0, sizeof(*p)); > + p->rw_mode = FMODE_WRITE; > + } > return p; > } > > -- > >