Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2387672pxp; Mon, 21 Mar 2022 18:48:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKgnougtgMrGFvCpw17TVE1Z+n3aiSExZNhTirzA7hBeQF0knEiA3l6r911giV/OiPMqvx X-Received: by 2002:a17:90a:4bc5:b0:1c6:cfcf:82a2 with SMTP id u5-20020a17090a4bc500b001c6cfcf82a2mr2210248pjl.140.1647913721755; Mon, 21 Mar 2022 18:48:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647913721; cv=none; d=google.com; s=arc-20160816; b=Hrcq/abid8p24ZRgQVGsshY8EyAEqOl2XuA1eYC11p+Xu7F4QGlSMyGoGpWDwcfMMK dY7Ak8T1rRxhX07455lFFPSk9AreFWkQAvkKNXCKrC//yugobJFJgBPXiYaNEPSFF0IX 66y7WDK7/mToBihZhDi0XbwcCM2eDlZvwvH1TRWQAyv0DBSWAY0d3Kx9yuF+fQZZDrJB LF28UbBaaxNS2BX/OJFf2wImFKvFs40B/lUUDPgTQxnoxEz7KD7284vzJLdHs8rrfVIz vdEwyRxlitSv7smui69xBstg7WlKzlpIPyaxRqhX3V/TrMAFc/jZNXHLCRZ9EXRFxZkU DvFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AiY9LKtA9X43X9R6hPTjQtc6jCmWU0TQNMJJXbq3C8I=; b=cZK17hgZcrzDZiplGA/KLdiRdEjoSo4EemvhpsTWJeWjnRoCss2IVzurqW2EFIX6Za 3ZTqlUmbSra5MvNKC0dTg5Ezp/64oecIBuuWM6voPdmzqom5Dg+u2M2VG2hUxRhKDdD3 pUuAM0Lz8gFHR7k0pl3PpMdUz6MsRsfg+PX2s1iPonMaDn/sxtxpPb8T54nHqF40jm3j FE/uhs9G9vqxjYN6Io7jRzfgw8iZ5UgXED75givBcQDRg91I+/77ZHT+dC3IkQ3j55Jw +IpIMjIV1PFbFSg7m/RNN0O0o9ZBXsLcjZTtcEY+rZI298Ab/NpZvHY6luvLRRLwzUIO c1LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Hl7HLJ+u; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y24-20020a170902d65800b00153b2d1647csi12264627plh.132.2022.03.21.18.48.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 18:48:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Hl7HLJ+u; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 99C0E2B278; Mon, 21 Mar 2022 18:22:35 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234641AbiCVBX6 (ORCPT + 99 others); Mon, 21 Mar 2022 21:23:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234634AbiCVBX4 (ORCPT ); Mon, 21 Mar 2022 21:23:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC146289BC for ; Mon, 21 Mar 2022 18:22:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 01DEC615E3 for ; Tue, 22 Mar 2022 01:22:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91E06C340EE; Tue, 22 Mar 2022 01:22:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647912148; bh=cCVkVoMAlDQfoVIQE3s7VVfidrskFyjLShmlmXXc8Qw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hl7HLJ+ujM+5MJX5sP2ypWpaP31Uv5VU/e3Uni7R7mnxkZir6nFufgIqtZeiZvErJ UiqXlLDU4fQoDCEfuw8xHuCp491yBcyJ7dMgET6li0fasbyAhUOAT2klYav5omKboL M4SM2mW7tSgJ+4lTYPL46yE5m9LdLtyAURZPvn7ywzpcuAG2zyKgHsazZdxUsaaAeC wmjSWBmMuGWfGFenTE5+buLwxM7ryGIICnkEs6SQrsYPss9sPziUBS2dcz4ljkF1qn 1KVbDH+nRNFOOdNj4wnMNxIBSxMTWtwGDC4N65eDssaJgC67ec8V6ho8+ue9a4RlkY d1LS1YBkSYBVg== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Cc: Neil Brown Subject: [PATCH v2 7/9] NFSv4/pnfs: Ensure pNFS allocation modes are consistent with nfsiod Date: Mon, 21 Mar 2022 21:16:16 -0400 Message-Id: <20220322011618.1052288-8-trondmy@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220322011618.1052288-7-trondmy@kernel.org> References: <20220322011618.1052288-1-trondmy@kernel.org> <20220322011618.1052288-2-trondmy@kernel.org> <20220322011618.1052288-3-trondmy@kernel.org> <20220322011618.1052288-4-trondmy@kernel.org> <20220322011618.1052288-5-trondmy@kernel.org> <20220322011618.1052288-6-trondmy@kernel.org> <20220322011618.1052288-7-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: Trond Myklebust Ensure that pNFS allocations that can be called from rpciod/nfsiod callback can fail in low memory mode, so that the threads don't block and loop forever. Signed-off-by: Trond Myklebust --- fs/nfs/nfs42proc.c | 2 +- fs/nfs/pnfs.c | 39 +++++++++++++++++---------------------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 882bf84484ac..b841e267b764 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -1017,7 +1017,7 @@ int nfs42_proc_layouterror(struct pnfs_layout_segment *lseg, return -EOPNOTSUPP; if (n > NFS42_LAYOUTERROR_MAX) return -EINVAL; - data = nfs42_alloc_layouterror_data(lseg, GFP_KERNEL); + data = nfs42_alloc_layouterror_data(lseg, nfs_io_gfp_mask()); if (!data) return -ENOMEM; for (i = 0; i < n; i++) { diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index f089e11fd001..de318bb5d349 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1233,7 +1233,7 @@ pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo, int status = 0; *pcred = NULL; - lrp = kzalloc(sizeof(*lrp), GFP_KERNEL); + lrp = kzalloc(sizeof(*lrp), nfs_io_gfp_mask()); if (unlikely(lrp == NULL)) { status = -ENOMEM; spin_lock(&ino->i_lock); @@ -2206,7 +2206,7 @@ _pnfs_grab_empty_layout(struct inode *ino, struct nfs_open_context *ctx) struct pnfs_layout_hdr *lo; spin_lock(&ino->i_lock); - lo = pnfs_find_alloc_layout(ino, ctx, GFP_KERNEL); + lo = pnfs_find_alloc_layout(ino, ctx, nfs_io_gfp_mask()); if (!lo) goto out_unlock; if (!test_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags)) @@ -2249,8 +2249,8 @@ static void _lgopen_prepare_attached(struct nfs4_opendata *data, lo = _pnfs_grab_empty_layout(ino, ctx); if (!lo) return; - lgp = pnfs_alloc_init_layoutget_args(ino, ctx, ¤t_stateid, - &rng, GFP_KERNEL); + lgp = pnfs_alloc_init_layoutget_args(ino, ctx, ¤t_stateid, &rng, + nfs_io_gfp_mask()); if (!lgp) { pnfs_clear_first_layoutget(lo); nfs_layoutget_end(lo); @@ -2275,8 +2275,8 @@ static void _lgopen_prepare_floating(struct nfs4_opendata *data, }; struct nfs4_layoutget *lgp; - lgp = pnfs_alloc_init_layoutget_args(ino, ctx, ¤t_stateid, - &rng, GFP_KERNEL); + lgp = pnfs_alloc_init_layoutget_args(ino, ctx, ¤t_stateid, &rng, + nfs_io_gfp_mask()); if (!lgp) return; data->lgp = lgp; @@ -2691,13 +2691,11 @@ pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *r else rd_size = nfs_dreq_bytes_left(pgio->pg_dreq); - pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, - nfs_req_openctx(req), - req_offset(req), - rd_size, - IOMODE_READ, - false, - GFP_KERNEL); + pgio->pg_lseg = + pnfs_update_layout(pgio->pg_inode, nfs_req_openctx(req), + req_offset(req), rd_size, + IOMODE_READ, false, + nfs_io_gfp_mask()); if (IS_ERR(pgio->pg_lseg)) { pgio->pg_error = PTR_ERR(pgio->pg_lseg); pgio->pg_lseg = NULL; @@ -2718,13 +2716,10 @@ pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, pnfs_generic_pg_check_layout(pgio); pnfs_generic_pg_check_range(pgio, req); if (pgio->pg_lseg == NULL) { - pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, - nfs_req_openctx(req), - req_offset(req), - wb_size, - IOMODE_RW, - false, - GFP_KERNEL); + pgio->pg_lseg = + pnfs_update_layout(pgio->pg_inode, nfs_req_openctx(req), + req_offset(req), wb_size, IOMODE_RW, + false, nfs_io_gfp_mask()); if (IS_ERR(pgio->pg_lseg)) { pgio->pg_error = PTR_ERR(pgio->pg_lseg); pgio->pg_lseg = NULL; @@ -3183,7 +3178,7 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync) status = -ENOMEM; /* Note kzalloc ensures data->res.seq_res.sr_slot == NULL */ - data = kzalloc(sizeof(*data), GFP_NOFS); + data = kzalloc(sizeof(*data), nfs_io_gfp_mask()); if (!data) goto clear_layoutcommitting; @@ -3250,7 +3245,7 @@ struct nfs4_threshold *pnfs_mdsthreshold_alloc(void) { struct nfs4_threshold *thp; - thp = kzalloc(sizeof(*thp), GFP_KERNEL); + thp = kzalloc(sizeof(*thp), nfs_io_gfp_mask()); if (!thp) { dprintk("%s mdsthreshold allocation failed\n", __func__); return NULL; -- 2.35.1