From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 CC61A376A1F for ; Mon, 6 Jul 2026 14:18:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783347541; cv=none; b=j/SLJvf9c1CPlkv9dizpOK03cJDXIB6zCKpDNe+gMEYArnqpS/BaOn9p4DNIZQxMgL9fIqsXofRxkiTkrJSqfkIX6a1jP5uOLBoQ3/Ely74q80nGyR18AbY+kpxWIIXZtzXbbfYkhDCmbErYytjPMNbFwC4Uglk5niUuxBzUiMU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783347541; c=relaxed/simple; bh=iHo7h2YGmpYKaEHwYvS0xYC3bpLn+lsB99h+9Ucm67U=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YMxFjvAekgbDeiffvRKXSts5sev7l63sPMUpwev8sVHOoB34jEYLpnbnvodxeV8e30JHXd9AOKuP7FXz4EqNQIvf6XgWNzNGQD4QHxFNHvhuiFARa8TNCizGdF3PMLSjaadZ24T7w5rxz6ermGkn/2RPaN8TTQJx1NDi77YJpcs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=pass smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=Y9KfOoib; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Y9KfOoib" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=xruYhMX6XX22knH4dR2Q9nFX7MPsNbx/yLiH/Ump/1U=; b=Y9KfOoib1Cxi1vPI4E9MKAbpaL zUimUmxxxnEFvcRVDHoq2WN6qYt83bSRv25BZnNBYgw9/40exA4r0KvD8DoiCGndI9Ri23a6Tqvgp a3f5LsZBXda+ghWn6mDW/Ib3EDFnV1aHAi6WV6npGGn0NQ+ggTWCDupfipShjNV8txupcq14ArTDI PSLdfa76k00085yPi/DkRuPi5uwGjMsOAzQDqSZbnwdnPYGgVP3GYbs03MBtEfqvUaMHImxzcVhln JwQ3D5o5lGyCIKLqGPagTmvO8Bps2EejvgUzdSAbzQCvX6xtY84uFynv9tz/JxTw5k7v2GNwgh3lw NdLKlDQA==; Received: from willy by casper.infradead.org with local (Exim 4.99.1 #2 (Red Hat Linux)) id 1wgk9v-0000000G1qi-1F2s; Mon, 06 Jul 2026 14:18:55 +0000 Date: Mon, 6 Jul 2026 15:18:55 +0100 From: Matthew Wilcox To: Chao Yu Cc: jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] f2fs: quota: use memalloc_nofs_{save,restore} instead of FGP_NOFS Message-ID: References: <20260706095943.2560208-1-chao@kernel.org> <20260706095943.2560208-2-chao@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260706095943.2560208-2-chao@kernel.org> On Mon, Jul 06, 2026 at 05:59:43PM +0800, Chao Yu wrote: > FGP_NOFS could be removed later, let's use memalloc_nofs_{save,restore} > instead, which is recommended to be used to avoid potential deadlock > when memory allocation in f2fs_quota_write() will call into filesystem > interface again, e.g. .writepages, evict_inode, shrinker due to > complicated lock race condition. I think we need to be clear on why we need the memalloc_nofs_save() call here. What problem would it cause if we did call into the filesystem to reclaim memory? I suspect this is the wrong place to insert this call and it should be near the lock that causes the problem. I've attempted a rewrite of the memalloc_nofs_save documentation; let me know what you think: /** * memalloc_nofs_save - Prevent recursion into the filesystem. * * All memory allocations between calling this function and calling * memalloc_nofs_restore() will be prevented from calling into filesystems * to reclaim memory. Clean page cache memory can still be reclaimed, * but (for example) inodes will not be. * * The primary reason to do this is that the caller has taken a lock * which would be needed by FS reclaim. While we could theoretically * call into a different filesystem in this case, it can be a deep call * stack so it is better to avoid all filesystems. * * Filesystems often choose to incorporate a call to this function as part * of starting a journal transaction. While not a lock in the normal * sense, it has much the same effect as nested journal transactions * are either prohibited or expensive. * * Also call this function if you need to allocate memory while holding * a file folio locked. High order allocations (such as those requested * by slab) can trigger compaction which will attempt to lock the folio. * * Context: This function is safe to be used from any context. * Return: The saved flags to be passed to memalloc_nofs_restore. */