From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 390CDD1AD39 for ; Wed, 16 Oct 2024 09:44:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C3E6C6B007B; Wed, 16 Oct 2024 05:44:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BEEA26B0082; Wed, 16 Oct 2024 05:44:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ADD286B0083; Wed, 16 Oct 2024 05:44:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 939326B007B for ; Wed, 16 Oct 2024 05:44:16 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 650331C5FC6 for ; Wed, 16 Oct 2024 09:44:05 +0000 (UTC) X-FDA: 82678979544.04.2B99796 Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 6C1D3A001B for ; Wed, 16 Oct 2024 09:44:03 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b="P5AFO/Zg"; spf=pass (imf15.hostedemail.com: domain of jefflexu@linux.alibaba.com designates 115.124.30.124 as permitted sender) smtp.mailfrom=jefflexu@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729071710; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9ItjDkcA8lZDnqyxHAXggmLuWPrWEQeSROmFdmxwZxQ=; b=lV8uKF6I6NCQ2eFFDh+pvhSQmWLJm2TX0Jfv/HypTA1993DxhUlhl3vxBoAt8PirBz36Yp sf8+08MmuFxssuiTw9tbOLnT3LbJqEaiBEbwUPC/VpmT7cHy827Nh4cR+8NJirweCb6V2u 5k2dC9GPS00WgCQY2EYBRXHJydoFL4U= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729071710; a=rsa-sha256; cv=none; b=RXTEHGeFiwfdLxVdK0D0ZjVlIZEFfFjdkfDFXvGs/7jThqnNqwXILUM+7GdIuzdJpFe4hz ujxIxSDcDPWWBxocUQlNImxX5ON53LQPMM3mnAf5H2C3Kavl937wCGElN+MFxDAqUsnuCt taYaK7VgyIGoA9DWw6TFX0NfB1HapVs= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b="P5AFO/Zg"; spf=pass (imf15.hostedemail.com: domain of jefflexu@linux.alibaba.com designates 115.124.30.124 as permitted sender) smtp.mailfrom=jefflexu@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1729071849; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=9ItjDkcA8lZDnqyxHAXggmLuWPrWEQeSROmFdmxwZxQ=; b=P5AFO/ZgqH9W2ZL6RTLz9EL1rjoNLHkMSn85sRxvqF/N/S5m8Z2RZ3LOrwaCJjwUUhm0jA8FcxtrPo8Cal7VkCdcvM7CQ2OCRs1VsEq/RHcWg8DFUOgkOxf3uznucK91eWWT2ds+UaMNn5U3JS++kIps2IQvQesoV8VPsCvi1ZY= Received: from 30.221.144.185(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0WHH-KKw_1729071846 cluster:ay36) by smtp.aliyun-inc.com; Wed, 16 Oct 2024 17:44:07 +0800 Message-ID: <8eec0912-7a6c-4387-b9be-6718f438a111@linux.alibaba.com> Date: Wed, 16 Oct 2024 17:44:05 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/2] fuse: remove tmp folio for writebacks and internal rb tree To: Shakeel Butt , Joanne Koong Cc: Miklos Szeredi , linux-fsdevel@vger.kernel.org, josef@toxicpanda.com, bernd.schubert@fastmail.fm, hannes@cmpxchg.org, linux-mm@kvack.org, kernel-team@meta.com References: <20241014182228.1941246-1-joannelkoong@gmail.com> <20241014182228.1941246-3-joannelkoong@gmail.com> Content-Language: en-US From: Jingbo Xu In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Stat-Signature: wu7194bije8mfmd9nk4egyi5e9qjczht X-Rspamd-Queue-Id: 6C1D3A001B X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1729071843-451900 X-HE-Meta: U2FsdGVkX18mH5DUWWuOHQi9eI1Ec297l+M+LBHCY+KBejVzL76dwF4iVOFIR4+2BlZD74PsjakB/7eHjXhi7wMMRMxWATSnn+3OKW8m+SJCCPOCxD06D9OX2K5ThPJNd3dNJAeHZVrqxbmzg6d7BKlJ1a4G6auGkv0SqJJs0I+DvDPBCMNCqYxSfqvhl3L2D9BTxyNaSqMSD1UwNptYOyhwEoSkV4lKGWqtaFHQvxeLtsGRJUiMewtl6RzgfuaCV5bh3GbV8rmwa6Kny2xgsoeYApjlxCHVjR+g1O7zpA0fRzyxajTvl7cjYPESOdBkbaW98Z1XDEeTdimp2pG3iNnX8wkDBUFhCGUToABnfbfqzX0pDkB5+ZnTte2RZQLglcFOqstz0v90wZJEdhLi43BOW1WdXs+EWdoWxxmQA/1Bf04/tAN6VddH0AYOiJps4w+nOhFaTzTm3Lgkf5TX6MzjCYes1igvwpWOd0s78Ok8y224fQA8e41qQtsNy1rZzD0ai5A2vly7xCatI+GuxSUkXMj97QtwbZ0keew6QFVnwvJK5iioJm1Cji3YfxWHsjlTh/B9x65GY4WI5u4G0kspbAhtOEhLVQ+fPgvsDX37gf/eQeMAdXufTv+nQd4rtq8WEBL5n+7tCPqTVdj14R38UQnyhQbQDaUvSJR/1q4N9ZQR5GRXWT3W04twix2gd85gDjDdIYZiO3s3jHypjJRXCtFHwKBsjoxYuRlHd8ckACcv7LUDpItCTeGZg8mlp9PSx9IPCyGhKfUMckIRPKnooNCptyqkB6Gqbk9rXGWF0Y7zCZiN1w91ZqLyRAC3Nz755R4Fiv0/3ng2SJgv7ko+rTwMecvywt3bv5xJr8GPwNHuf4aH/BALgEuyH+jzgA5UIl7H4mC1o1OQbtOv2pyeypl4HkTAPOk/tGoFfVkQjqZSic52v5eHWHve8+Ef7gVH3u9Zwl1VmXrbqY0 GHRVwsvV Wl6eDeeAhp2cG5BOiSJIsM6mWvQZVNWsFh4hlQI5L6BJC4rdOzJn5aY4ZqPOrGtCxO4UYXJbi8vyYtH5jujvApkTqkw370Afk6DJgu2TGtcBYv7havljDZswZvWjy3DEXQDa7PziuRwtCAfCYaCZt7vEVzTJsiOsL4umQQO6iO98iu8tpCbKS7VfqJ0N+gj34JTyKR4ECOKUaxjwnIP0KV/FgvFPW+bWn3CgeCrwhk3JRkBCeck3I+KrIp1Es6YoT4M5R8Rch/iGUGxDZylprNZwq5BwcrEArGASChVyklrWNsSw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 10/16/24 3:17 AM, Shakeel Butt wrote: > On Tue, Oct 15, 2024 at 10:06:52AM GMT, Joanne Koong wrote: >> On Tue, Oct 15, 2024 at 3:01 AM Miklos Szeredi wrote: >>> >>> On Mon, 14 Oct 2024 at 20:23, Joanne Koong wrote: >>> >>>> This change sets AS_NO_WRITEBACK_RECLAIM on the inode mapping so that >>>> FUSE folios are not reclaimed and waited on while in writeback, and >>>> removes the temporary folio + extra copying and the internal rb tree. >>> >>> What about sync(2)? And page migration? >>> >>> Hopefully there are no other cases, but I think a careful review of >>> places where generic code waits for writeback is needed before we can >>> say for sure. >> >> Sounds good, that's a great point. I'll audit the other places in the >> mm code where we might call folio_wait_writeback() and report back >> what I find. >> >> > > So, any operation that the fuse server can do which can cause wait on > writeback on the folios backed by the fuse is problematic. We know about > one scenario i.e. memory allocation causing reclaim which may do the > wait on unrelated folios which may be backed by the fuse server. > > Now there are ways fuse server can shoot itself on the foot. Like sync() > syscall or accessing the folios backed by itself. The quesion is should > we really need to protect fuse from such cases? I think there are several scenarios shall be evaluated case by case: 1) a non-malicious fuse daemon wants to allocate some memory when processing a fuse request, which in turn leads to memory reclaim and thus waiting on the writeback of fuse dirty pages - a deadlock here. This is reasonable and also the target scenario that this series wants to fix. 2) a malicious fuse daemon refuses to process any request; or a buggy or not well-written fuse daemon as you described, e.g. may call sync(2) itself or access page cache backed by itself, then 2.1) any unrelated user process attempting to initiate a sync(2) itself, will hang there. This scenario is also unexpected and shall be fixed. 2.2) any direct user of fuse filesystem (e.g. access files backed by fuse filesystem) will hang in this case. IMHO this is expected, and the impact is affordable as it is controlled within certain range (the direct user of the fs). -- Thanks, Jingbo