Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2387677pxp; Mon, 21 Mar 2022 18:48:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyO4gNtzi5vgQdHAik1HlBc+l1lNtlIcsobksMyBSwsvTvYka/IM+M7BFMoMdQzACmfP9Pc X-Received: by 2002:a17:90a:1a:b0:1c6:c1ee:c3fb with SMTP id 26-20020a17090a001a00b001c6c1eec3fbmr2226823pja.50.1647913722372; Mon, 21 Mar 2022 18:48:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647913722; cv=none; d=google.com; s=arc-20160816; b=gdEZTiKkrtHweDwFpvFy7i4PONMeEUl9zdl7waOPIRVsTm0B0yS5/mdD8md1//aGgR yt9uKfIl7kbktVHb8zufpW1rnFjzlH7uFITRhyTHtTYozyJXsbAOVM7FqTSZfvz50q/6 GIoIpNVN8NJCVhBfKgRAkevTM//Wn6cIgQbT+0TF2z9j3OmQpQXYw37lIxKFfMn9JKkx 6VxMuXIGW75owenD2LaCfjgEAfyMJHaMKW5kXB/2eZFCJqS1nRB4PgRpLY7mBNy3FFJe tNoo/OXHV9U3/kuUOISbPxkK32sxbKPSdzT6eCIJUUwBMSwLdSzp0EBvBK0mOtrygbep giaw== 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=q5Eo+PfZLYHW2sAPuOUIJHic3sdyCkJ5EAdu9g0a1IA=; b=rN0WBvSVgzWtu12KgS5u3D1fYTAQr0aQcqnN3ayqH7hn/mOjR+0BS4pf9viiTWvu3P dpn5FxkjuMsEec/E1+CCApKynyFhfEV/Wh6GzGPF7YPDGY9VVs7JvcJaAXl71sdVBst6 s7YtfSl7WRRSRa7pIpTb6gLE8I51gNx3QzVt+stfTk7L2psdrUhNbxu+IfoRN3bBqWOL Km8BAjzmxBem0FudFJMQySyQL/jZsd7PojWR5JGLqhuZe7/9zym6jLnw75b2gw42QL1F KQd6guIW+tPNKWisdYl6ahXn8ETO9tIUDZ5RN4jGOrcKNZMml86lsEXEEt0GVCeVO3vU 6P8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GTEfe9X1; 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 x19-20020a17090a8a9300b001bd14e01fa6si854205pjn.148.2022.03.21.18.48.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 18:48:42 -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=GTEfe9X1; 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 BBA4F2CE13; Mon, 21 Mar 2022 18:22:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234649AbiCVBX7 (ORCPT + 99 others); Mon, 21 Mar 2022 21:23:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234637AbiCVBX4 (ORCPT ); Mon, 21 Mar 2022 21:23:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6072D1D0D4 for ; Mon, 21 Mar 2022 18:22:30 -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 EA218615E5 for ; Tue, 22 Mar 2022 01:22:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14645C340E8; 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=1647912149; bh=eD2KQYnN8f7Yvi+SCRjQOL9lO3dzZe1LYm9ivcVGoCw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GTEfe9X12Y/ltRILgQhfV1hbB1jLGGM7rzpKqGSgC/7tAtUt1urLckF3Z4KqtFMen wvSHkEd1IWL1SwiMV04p03+/lKy1huYiGjAy02yXj6qevUbqn4Lj/Hbrz9EOeVIf7x 0Q9i7WmXNkfvnubOo6beEbbrH4uRWcnJOaPeOEEXn2QacnUBiYVcohdH7q6MBw4ZG7 B9+5lHSLXb+IkAyMxfRopofIgv+Gm6W+K2AUyQazIAJ/U1CFBQ0XubJ8Q13Mq0lL2T lQVqsAcsWab6yAX2Hn8iZgn+JCFqUWGFb1UEu8+UNNjJxBJto87Q+jLhy49B+m7mI6 hVV1ZdPmYk0kA== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Cc: Neil Brown Subject: [PATCH v2 8/9] pNFS/flexfiles: Ensure pNFS allocation modes are consistent with nfsiod Date: Mon, 21 Mar 2022 21:16:17 -0400 Message-Id: <20220322011618.1052288-9-trondmy@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220322011618.1052288-8-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> <20220322011618.1052288-8-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 flexfile allocations in rpciod/nfsiod callbacks can fail in low memory mode, so that the threads don't block and loop forever. Signed-off-by: Trond Myklebust --- fs/nfs/flexfilelayout/flexfilelayout.c | 50 +++++++++++--------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c index e28f2177afb7..604be402ae13 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c @@ -663,7 +663,7 @@ nfs4_ff_layout_stat_io_start_read(struct inode *inode, spin_unlock(&mirror->lock); if (report) - pnfs_report_layoutstat(inode, GFP_KERNEL); + pnfs_report_layoutstat(inode, nfs_io_gfp_mask()); } static void @@ -694,7 +694,7 @@ nfs4_ff_layout_stat_io_start_write(struct inode *inode, spin_unlock(&mirror->lock); if (report) - pnfs_report_layoutstat(inode, GFP_KERNEL); + pnfs_report_layoutstat(inode, nfs_io_gfp_mask()); } static void @@ -806,13 +806,10 @@ ff_layout_pg_get_read(struct nfs_pageio_descriptor *pgio, bool strict_iomode) { pnfs_put_lseg(pgio->pg_lseg); - pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, - nfs_req_openctx(req), - req_offset(req), - req->wb_bytes, - IOMODE_READ, - strict_iomode, - GFP_KERNEL); + pgio->pg_lseg = + pnfs_update_layout(pgio->pg_inode, nfs_req_openctx(req), + req_offset(req), req->wb_bytes, IOMODE_READ, + strict_iomode, nfs_io_gfp_mask()); if (IS_ERR(pgio->pg_lseg)) { pgio->pg_error = PTR_ERR(pgio->pg_lseg); pgio->pg_lseg = NULL; @@ -894,13 +891,10 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio, retry: ff_layout_pg_check_layout(pgio, req); if (!pgio->pg_lseg) { - pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, - nfs_req_openctx(req), - req_offset(req), - req->wb_bytes, - IOMODE_RW, - false, - GFP_KERNEL); + pgio->pg_lseg = + pnfs_update_layout(pgio->pg_inode, nfs_req_openctx(req), + req_offset(req), req->wb_bytes, + 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; @@ -953,13 +947,10 @@ ff_layout_pg_get_mirror_count_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req) { if (!pgio->pg_lseg) { - pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, - nfs_req_openctx(req), - req_offset(req), - req->wb_bytes, - IOMODE_RW, - false, - GFP_KERNEL); + pgio->pg_lseg = + pnfs_update_layout(pgio->pg_inode, nfs_req_openctx(req), + req_offset(req), req->wb_bytes, + 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; @@ -1258,7 +1249,7 @@ static void ff_layout_io_track_ds_error(struct pnfs_layout_segment *lseg, mirror = FF_LAYOUT_COMP(lseg, idx); err = ff_layout_track_ds_error(FF_LAYOUT_FROM_HDR(lseg->pls_layout), mirror, offset, length, status, opnum, - GFP_KERNEL); + nfs_io_gfp_mask()); switch (status) { case NFS4ERR_DELAY: @@ -1973,7 +1964,8 @@ ff_layout_setup_ds_info(struct pnfs_ds_commit_info *fl_cinfo, struct inode *inode = lseg->pls_layout->plh_inode; struct pnfs_commit_array *array, *new; - new = pnfs_alloc_commit_array(flseg->mirror_array_cnt, GFP_KERNEL); + new = pnfs_alloc_commit_array(flseg->mirror_array_cnt, + nfs_io_gfp_mask()); if (new) { spin_lock(&inode->i_lock); array = pnfs_add_commit_array(fl_cinfo, new, lseg); @@ -2152,10 +2144,10 @@ ff_layout_prepare_layoutreturn(struct nfs4_layoutreturn_args *args) struct nfs4_flexfile_layoutreturn_args *ff_args; struct nfs4_flexfile_layout *ff_layout = FF_LAYOUT_FROM_HDR(args->layout); - ff_args = kmalloc(sizeof(*ff_args), GFP_KERNEL); + ff_args = kmalloc(sizeof(*ff_args), nfs_io_gfp_mask()); if (!ff_args) goto out_nomem; - ff_args->pages[0] = alloc_page(GFP_KERNEL); + ff_args->pages[0] = alloc_page(nfs_io_gfp_mask()); if (!ff_args->pages[0]) goto out_nomem_free; @@ -2193,7 +2185,7 @@ ff_layout_send_layouterror(struct pnfs_layout_segment *lseg) return; errors = kmalloc_array(NFS42_LAYOUTERROR_MAX, sizeof(*errors), - GFP_KERNEL); + nfs_io_gfp_mask()); if (errors != NULL) { const struct nfs4_ff_layout_ds_err *pos; size_t n = 0; @@ -2445,7 +2437,7 @@ ff_layout_prepare_layoutstats(struct nfs42_layoutstat_args *args) /* For now, send at most PNFS_LAYOUTSTATS_MAXDEV statistics */ args->devinfo = kmalloc_array(dev_count, sizeof(*args->devinfo), - GFP_KERNEL); + nfs_io_gfp_mask()); if (!args->devinfo) return -ENOMEM; -- 2.35.1