From nobody Wed Dec 17 04:11:31 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52FDA2D78A for ; Thu, 10 Jul 2025 01:47:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752112072; cv=none; b=Q+f+LUA1+BERqUt+y4q/Covn6+v/qp3ZfwR3h2QTGiIWyc8QIh7Ie+LrjcfDUxlKUk3EuXZK71Goxnq4xbhiiF9T6/35KSTSoVYvLbuDN5y+M9L5MtFb3kpxHVCWSg+6W3Erz+vZWBoN/yjBu2xz8K6eW0rvso7WMTavjwaApCY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752112072; c=relaxed/simple; bh=DQTD7y7cv7owoVXkdUip8vQLTuU6DMRTruw/sxIFpJQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=djuZ/WGuv4zdAc9eGhUgtLVTDOly/5jX+twVu9ktqWf5sA4M6fSsEFQxV9hcdb7+WkDOmXHi1+dmnI4aZZo286bZ/jJZE1+MvHeb9hnLET1DxedDPrzkPZlhfBYlwqW/zqpftm74gIDqHM9a5qB7XeougVUCjxe2P/5mNIB4Cvo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=InfpT0wU; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="InfpT0wU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752112069; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Jh0rx+XXfIHWexmg7+WdmaTwcOzgWBvsa/tZ8r1I2KA=; b=InfpT0wUM5vz3HpfrnxgJcwe7BJzjYe8Dr0jNu9EFgYPPkPm7MnVCz+NiI6za4OLfkVYSc +uoL8Njp6OpqxKZmPIywW0V13uc4zXw220Zg/LQkntMem9Twu96X81pVOnuE21mR9fuW4/ 8pTQb/HlWT5xzbj6lvC87vnP6lBpNKM= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-590-IUdYY6naM1mIRWJqS1IxGQ-1; Wed, 09 Jul 2025 21:47:47 -0400 X-MC-Unique: IUdYY6naM1mIRWJqS1IxGQ-1 X-Mimecast-MFC-AGG-ID: IUdYY6naM1mIRWJqS1IxGQ_1752112066 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 787051944A82; Thu, 10 Jul 2025 01:47:46 +0000 (UTC) Received: from bcodding.csb.redhat.com (unknown [10.22.74.5]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E52F6195608F; Thu, 10 Jul 2025 01:47:44 +0000 (UTC) From: Benjamin Coddington To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Laurence Oberman , Jeff Layton Subject: [PATCH v3] NFS: Fixup allocation flags for nfsiod's __GFP_NORETRY Date: Wed, 9 Jul 2025 21:47:43 -0400 Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" If the NFS client is doing writeback from a workqueue context, avoid using __GFP_NORETRY for allocations if the task has set PF_MEMALLOC_NOIO or PF_MEMALLOC_NOFS. The combination of these flags makes memory allocation failures much more likely. We've seen those allocation failures show up when the loopback driver is doing writeback from a workqueue to a file on NFS, where memory allocation failure results in errors or corruption within the loopback device's filesystem. Suggested-by: Trond Myklebust Fixes: 0bae835b63c5 ("NFS: Avoid writeback threads getting stuck in mempool= _alloc()") Signed-off-by: Benjamin Coddington Reviewed-by: Laurence Oberman Tested-by: Laurence Oberman Reviewed-by: Jeff Layton --- On V3: fix ugly return (Thanks Paulo), add Jeff's R-b On V2: add missing 'Fixes' and Laurence's R-b T-b fs/nfs/internal.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 69c2c10ee658..d8f768254f16 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -671,9 +671,12 @@ nfs_write_match_verf(const struct nfs_writeverf *verf, =20 static inline gfp_t nfs_io_gfp_mask(void) { - if (current->flags & PF_WQ_WORKER) - return GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN; - return GFP_KERNEL; + gfp_t ret =3D current_gfp_context(GFP_KERNEL); + + /* For workers __GFP_NORETRY only with __GFP_IO or __GFP_FS */ + if ((current->flags & PF_WQ_WORKER) && ret =3D=3D GFP_KERNEL) + ret |=3D __GFP_NORETRY | __GFP_NOWARN; + return ret; } =20 /* --=20 2.47.0