Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1091780lqt; Fri, 7 Jun 2024 07:50:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXG7sJDFRSqCyTrT2bqCZjqqHECiRHsdM70MuqbMsSU2VLzCY9AvhvuQiV6n8FGRLC3mQ3q28csLwLhm9Ke23R8m/4ToVbfduPvHcaV5g== X-Google-Smtp-Source: AGHT+IHte375AWw+E4mhtNGwdyu3j21HwaTaUcEguFmbVCIvC3BBSgiKYJqOzuTO8T3lkb1lz2Vd X-Received: by 2002:a17:90a:ec06:b0:2c2:792c:b60f with SMTP id 98e67ed59e1d1-2c2bcaf96dbmr2786053a91.11.1717771836122; Fri, 07 Jun 2024 07:50:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717771836; cv=pass; d=google.com; s=arc-20160816; b=nJWp74nsCVK/+AXTQg3fctBOK2oI1B1Vj5UWPZtxheHNHdDs/vH5eYTS9WQBZ+H6jE tDcPzrFTT9i7ZmdP6GKfENNbpm0aSDh7duyGK046Bw9ERQYt9tUErTA1n45uZO2nQpjc uQ0Oo/ThR0ALB7SyMFCAupIdeRci7nB7kvs/hQ7SNqpPa/VqL3qwVDlQEGhXAP0fCPTp qSt8Ro4WKE1sihE2wGuIYKfV/Gb6Z55HvNItrA62bCdHsU+F4V0o7Zhx2jRu3pPc1QyI Hvwc2u+l38NDBgcq0igL0oJmHVjO9Z+VzmJir/3OyP1VQiBhxnOGbLml2jt+HKWoAQ4a vNlQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=4UMN+ZOHwnD3QK3Nchwp5ADELYSCP19Cxy87zfC5aUo=; fh=OUKZWod6C22emJS3X689dwhO5bDgGbDS06P/Z6+EGqk=; b=is2BF0X5Lo7WoeOjyUbQfMnWetJnmmRkqa/ZwedB8V34/Rz/36xFap0XPnZF5BmdjY 1lgsr98VESMaVoyEOwDL748UnRoz0nclwV/s0WgCnnfMP2SY5L2hqHpt9+EIAUysI3s/ uXNppY3V+vPz/NpfOnar6iVRaOqE4BhFbMF5JjZKBAzjrOmqJwAp5vEzd0535UaN98bt ecDirDc7VdSgLQUEBP3VoD8awNlNBy6lLQ37C6nlf3DrsVAz2LHaqD8WmcGQN90OwEgp tUD8NmyLvUjLfkDmZwdtyTon+QHBhQYjTkacQPRtUFHQ5jWSmNlRVMNw1NyaEs8ZVIxP ZnQQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-nfs+bounces-3603-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3603-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c2d1133bd1si429275a91.129.2024.06.07.07.50.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 07:50:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-3603-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-nfs+bounces-3603-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3603-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 85FAEB286F6 for ; Fri, 7 Jun 2024 14:28:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C0541196C72; Fri, 7 Jun 2024 14:27:18 +0000 (UTC) X-Original-To: linux-nfs@vger.kernel.org Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5710919643F for ; Fri, 7 Jun 2024 14:27:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717770438; cv=none; b=q9OmjrsnjG0OW28hAyjTq9gbbVfDiRGx6fV9TResj3+fa0COz6EJf7RRPTU5Wj2B72rkiEzvN4bihiwwIy0danmXAVh1dOFYFDZF7vHkRFxZ4Bgk8tgiFG3WJawZCbBb8b57AX+ZphJ+39tLekXFhFTqBW3BH0Ee3S+aygKjCTU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717770438; c=relaxed/simple; bh=PGs9SM9c5btXCQBTo2cCE424URKl7TWd+mAF0O8hqjI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V0Q4bwzOTUjfSpiF63eR2declaW4tjtKaHbbUve8hQgMcp0VsbS4ud99rpxX5jmuPCDwOOgoV6GP1uT9diNbW936NXPQdoW5QTsLMIFtcLSItnIMCLb0GCIUVfPLzkZDVzc7wH4dvx2mFB8ZOtX9r8Jw+twxI5e4XkYe3Ez8wJQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=none smtp.mailfrom=snitzer.net; arc=none smtp.client-ip=209.85.222.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=snitzer.net Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-79535efc9d8so115163185a.0 for ; Fri, 07 Jun 2024 07:27:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717770436; x=1718375236; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4UMN+ZOHwnD3QK3Nchwp5ADELYSCP19Cxy87zfC5aUo=; b=olKZNIvvt8M9iwIbOHkqde+lbwz2x2xic2y1PACWZDnNph8QzAkynl6yFvZGpKl5hN LzETKv6t+b/EET05uib+mp8vqs0UX9dfXwtDhm6q4gzgQQhsClHt1yOx3//VhiD7pWFl eg33XcXl7YhH2op3xa5F6Xd+5wjbKpSl9izgHK/mNWaAUAw00JIzVzd30wDt4vYnb53V Hek+65ODSs9qnzyHqP0Z4HcwEc/I6Qcf7q7unDO4KCjLCsa6UL2PkZmEbWL7KAdw7jdn 40ZfjU7PQtshreDMN+gzEv2RghWOnsfuo+15P79lNO+u4LiqxfgOcVV5uj8GEXabfAp/ Y+lw== X-Gm-Message-State: AOJu0YwzKXxa0OE+z8iwW/EAyRQSEJjcQ2mMNzACZ/R7JQ0DgjWskJ+f YXrIwhN7sWI1F7TvR11/PPTNZaEanQxFMJL44FxVaoUMvy1iAn78Fds+Y/eRqUVRQ6V2xcCH1qb AbsI= X-Received: by 2002:a05:6214:3d9d:b0:6af:c66a:d5a8 with SMTP id 6a1803df08f44-6b059f65400mr30137846d6.51.1717770435388; Fri, 07 Jun 2024 07:27:15 -0700 (PDT) Received: from localhost (pool-68-160-141-91.bstnma.fios.verizon.net. [68.160.141.91]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b04f9f7c64sm17455016d6.119.2024.06.07.07.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 07:27:14 -0700 (PDT) From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Trond Myklebust , snitzer@hammerspace.com Subject: [for-6.11 PATCH 18/29] NFS: localio writes need to use a normal workqueue Date: Fri, 7 Jun 2024 10:26:35 -0400 Message-ID: <20240607142646.20924-19-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240607142646.20924-1-snitzer@kernel.org> References: <20240607142646.20924-1-snitzer@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Trond Myklebust When we start getting low on space, XFS goes and calls flush_work() on a non-memreclaim work queue, which causes a priority inversion problem. Signed-off-by: Trond Myklebust Signed-off-by: Mike Snitzer --- fs/nfs/inode.c | 24 +++++++++++++++++++----- fs/nfs/internal.h | 1 + fs/nfs/localio.c | 4 ++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 4f88b860494f..b80469bce8df 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -2394,6 +2394,7 @@ static void nfs_destroy_inodecache(void) kmem_cache_destroy(nfs_inode_cachep); } +struct workqueue_struct *nfssync_workqueue; struct workqueue_struct *nfsiod_workqueue; EXPORT_SYMBOL_GPL(nfsiod_workqueue); @@ -2404,9 +2405,17 @@ static int nfsiod_start(void) { struct workqueue_struct *wq; dprintk("RPC: creating workqueue nfsiod\n"); + wq = alloc_workqueue("nfs-sync", WQ_UNBOUND, 0); + if (wq == NULL) + return -ENOMEM; + nfssync_workqueue = wq; wq = alloc_workqueue("nfsiod", WQ_MEM_RECLAIM | WQ_UNBOUND, 0); - if (wq == NULL) + if (wq == NULL) { + wq = nfssync_workqueue; + nfsiod_workqueue = NULL; + destroy_workqueue(wq); return -ENOMEM; + } nfsiod_workqueue = wq; return 0; } @@ -2419,10 +2428,15 @@ static void nfsiod_stop(void) struct workqueue_struct *wq; wq = nfsiod_workqueue; - if (wq == NULL) - return; - nfsiod_workqueue = NULL; - destroy_workqueue(wq); + if (wq != NULL) { + nfsiod_workqueue = NULL; + destroy_workqueue(wq); + } + wq = nfssync_workqueue; + if (wq != NULL) { + nfssync_workqueue = NULL; + destroy_workqueue(wq); + } } unsigned int nfs_net_id; diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 67b348447a40..0927a1704bbb 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -446,6 +446,7 @@ int nfs_check_flags(int); /* inode.c */ extern struct workqueue_struct *nfsiod_workqueue; +extern struct workqueue_struct *nfssync_workqueue; extern struct inode *nfs_alloc_inode(struct super_block *sb); extern void nfs_free_inode(struct inode *); extern int nfs_write_inode(struct inode *, struct writeback_control *); diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c index d7918e26aeb6..d724f8d4dd65 100644 --- a/fs/nfs/localio.c +++ b/fs/nfs/localio.c @@ -511,7 +511,7 @@ static int nfs_do_local_read(struct nfs_pgio_header *hdr, struct file *filp, args.done = &done; INIT_WORK_ONSTACK(&args.work, nfs_local_call_read); - queue_work(nfsiod_workqueue, &args.work); + queue_work(nfssync_workqueue, &args.work); wait_for_completion(&done); destroy_work_on_stack(&args.work); return 0; @@ -682,7 +682,7 @@ static int nfs_do_local_write(struct nfs_pgio_header *hdr, struct file *filp, args.done = &done; INIT_WORK_ONSTACK(&args.work, nfs_local_call_write); - queue_work(nfsiod_workqueue, &args.work); + queue_work(nfssync_workqueue, &args.work); wait_for_completion(&done); destroy_work_on_stack(&args.work); return 0; -- 2.44.0