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 0D797C3DA4A for ; Mon, 29 Jul 2024 13:54:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 995126B0093; Mon, 29 Jul 2024 09:54:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 91DC66B009A; Mon, 29 Jul 2024 09:54:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7BEBA6B009F; Mon, 29 Jul 2024 09:54:05 -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 5A08C6B0093 for ; Mon, 29 Jul 2024 09:54:05 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E38FC1403D4 for ; Mon, 29 Jul 2024 13:54:04 +0000 (UTC) X-FDA: 82392934008.23.4B5D1B2 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf01.hostedemail.com (Postfix) with ESMTP id 8F02140009 for ; Mon, 29 Jul 2024 13:54:01 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of yangerkun@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=yangerkun@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722261199; a=rsa-sha256; cv=none; b=JiYvl+p825N556l8Y5pyVOW9rWZ/YGzIrdzJZiCC0VkmIllKLypo7c5pZqHYzqDXH082CH EDWDs65imLwYGnOEBqAJPuQ5YcL5oZO3x0RiRgc+5kfCoti9vnl7wE+HKoAZhy2D29mzF+ 4HWW2oYu+sJ7PCwVUBRcEBEC9KQpCHo= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of yangerkun@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=yangerkun@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722261199; 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; bh=6F+1JmQOndNUexa/KNUfm+TWW22tW/I+U4mWwGkZRHE=; b=Sbff4n25lbqw4d1QGnZlrBi6AlogYukzFWvGgZUiyoXnrNMxqEhZXrBcBXNCpPvzc2O7A4 ANARyNYnM3s1zTNJuEkH0d+iIdFBtg+P+XpIL2wj+I4pNh8vXFtmxMu0VMVoG+KCfk7xdj UO5oqxDdpKgy+ZwAjbEIYY0USFKT2xc= Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4WXfqP0gDHzPtKQ; Mon, 29 Jul 2024 21:49:37 +0800 (CST) Received: from kwepemf100006.china.huawei.com (unknown [7.202.181.220]) by mail.maildlp.com (Postfix) with ESMTPS id 00D3E1402CA; Mon, 29 Jul 2024 21:53:54 +0800 (CST) Received: from [10.174.177.210] (10.174.177.210) by kwepemf100006.china.huawei.com (7.202.181.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 29 Jul 2024 21:53:53 +0800 Message-ID: <9514fd55-4f83-8e43-bdf7-925396ab5e48@huawei.com> Date: Mon, 29 Jul 2024 21:53:52 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH] generic/736: don't run it on tmpfs From: yangerkun To: Filipe Manana , Christoph Hellwig , CC: , , , , , linux-btrfs References: <20240720083538.2999155-1-yangerkun@huawei.com> <4188b7b5-3576-9e5f-6297-794558d7a01e@huawei.com> In-Reply-To: <4188b7b5-3576-9e5f-6297-794558d7a01e@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.210] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemf100006.china.huawei.com (7.202.181.220) X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 8F02140009 X-Stat-Signature: jdpropqmtqd4i6em888z9b6ifqf9y4br X-Rspam-User: X-HE-Tag: 1722261241-11718 X-HE-Meta: U2FsdGVkX19h/AUK4ORLFKilQbub8CiXFj4bOYSJmduGisFS8F4OqECqYbrzcSIlYgkqGqnnN4k69tFgIv9k5ouKXRli8BqtO+WdzB+LqTUuOBfVPZ0RV1utBStQB3YnZFMnzXZipbBuVuVQwuCak8B+o0XTpQw4UqC5InRh9vJY3GPwU7K3gqAuuCty7R616F6L2GPqqV8LPTiZDfB+xLSrcMhpDuZxKQP4Ti4uDrkhAN+VgHIKI8T/J2NuMmnsh6utsJNb8u+5ZDzQBdO6w9/GQ+SCNy9r5gk//UsyBhn1VdDJVfl7598nFD2ymRo5v554PPslujy6Vr3Wyg0jnHtw6mbOhon3Ij/DvzkvKAtesXrkjGAj2MNq6pFwM6q9U/uloZ1D+O3J4dYUVtj/6YidSgNjagzzGlPp04zAVaJQ6k+4lbTCPoChwWeYBxgX57X1gtym3t2AEi9AgWx09KbYZPVWhrfOy0tdiSjj6G4owNey1H/BULqQFFdty+hEJ3fRcUxXm3qKymgk0ZYk74ThLbcbztySyXnNY/Q3uYNRrltr32Zcsh4sxQQImbLiltwmPExuft7V68ZIL0LzFJgvUpjALAUP+68AXnFjiuYJHCCCnBlxYCiZKfBs/xL6sy/9pRQ/qfb7pw370lkXpo5x+X9Y/2c75zpozrFe/2O/DPUCKaFQ31eIjKqRufceUcpYl1vmwxVPQV0sfSh1ZKcb1qRJmUURMHsZd731ksVz7+p0mocVtkmZSvc5xbrG/LH+eMkB6gbL7uTYD5v5AjFYNcrMVJKyekS4F9R9a116m0/zD0+XryLEXK2rwWUG31pXPW9zojoetToM5eXRM1/kO5sN7gP2a5FqRxXbr6lzGwCQtA6M+3BUcHOJm6MEaRBvF4xvkzv+fhjFr8jouRpMAy9zYqbeg3cUnpw2seL3QqUnaETeTHNyIFp1DVRSrzi3VufDT6aba/1y4Bx EEWBptPL UUB65OR41Z/xhBj3GUScoZe2uKODSQ11lk08c12vyToysnD/rcznxVdE7hABklW1N1JY72J1ZIn7mmyAEKN/5crzGAFo953vr5z6hmGZg69be7Ge1xX38etOU4qCA2SITX3wSlLA1q51XfBiuS58vVYTCyEAZI1Xdsi8bhwI5b2yYfLKw2gyZmnnlivZg+Wq3C08/dJCLP3eTHVX6YLi+fKfjTagCzHLp48G3C2Np8DNEGZU1hTQvA9EPyj4pOb5azDqKiWn0pAOWryXNTL43eqHJvG3Ps7odd1NCooa7tJSqHIk= 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: Hi, 在 2024/7/24 21:30, yangerkun 写道: > Hi, All, > > Sorry for the delay relay(something happened, and cannot use pc > before...). > > 在 2024/7/21 1:26, Filipe Manana 写道: >> On Sat, Jul 20, 2024 at 9:38 AM Yang Erkun wrote: >>> >>> We use offset_readdir for tmpfs, and every we call rename, the offset >>> for the parent dir will increase by 1. So for tmpfs we will always >>> fail since the infinite readdir. >> >> Having an infinite readdir sounds like a bug, or at least an >> inconvenience and surprising for users. >> We had that problem in btrfs which affected users/applications, see: >> >> https://lore.kernel.org/linux-btrfs/2c8c55ec-04c6-e0dc-9c5c-8c7924778c35@landley.net/ >> >> which was surprising for them since every other filesystem they >> used/tested didn't have that problem. >> Why not fix tmpfs? > > Thanks for all your advise, I will give a detail analysis first(maybe > until last week I can do it), and after we give a conclusion about does > this behavior a bug or something expected to occur, I will choose the > next step! The case generic/736 do something like below: 1. create 5000 files(1 2 3 ...) under one dir(testdir) 2. call readdir(man 3 readdir) once, and get entry 3. rename(entry, "TEMPFILE"), then rename("TMPFILE", entry) 4. loop 2~3, until readdir return nothing of we loop too many times(15000) For tmpfs before a2e459555c5f("shmem: stable directory offsets"), every rename called, the new dentry will insert to d_subdirs *head* of parent dentry, and dcache_readdir won't reenter this dentry if we have already enter the dentry, so in step 4 we will break the test since readdir return nothing (I have try to change __d_move the insert to the "tail" of d_sub_dirs, problem can still happend). But after commit a2e459555c5f("shmem: stable directory offsets"), simple_offset_rename will just add the new dentry to the maple tree of &SHMEM_I(inode)->dir_offsets->mt with the key always inc by 1(since simple_offset_add we will find free entry start with octx->newx_offset, so the entry freed in simple_offset_remove won't be found). And the same case upper will be break since we loop too many times(we can fall into infinite readdir without this break). I prefer this is really a bug, and for the way to fix it, I think we can just use the same logic what 9b378f6ad48cf("btrfs: fix infinite directory reads") has did, introduce a last_index when we open the dir, and then readdir will not return the entry which index greater than the last index. Looking forward to your comments! Thanks, Erkun. > > Thanks again for all your advise! > > >> >> Thanks. >> >>> >>> Signed-off-by: Yang Erkun >>> --- >>>   tests/generic/736 | 2 +- >>>   1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/tests/generic/736 b/tests/generic/736 >>> index d2432a82..9fafa8df 100755 >>> --- a/tests/generic/736 >>> +++ b/tests/generic/736 >>> @@ -18,7 +18,7 @@ _cleanup() >>>          rm -fr $target_dir >>>   } >>> >>> -_supported_fs generic >>> +_supported_fs generic ^tmpfs >>>   _require_test >>>   _require_test_program readdir-while-renames >>> >>> -- >>> 2.39.2 >>> >>>