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 DAAA6C77B7C for ; Wed, 26 Apr 2023 02:28:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 22FEF6B007D; Tue, 25 Apr 2023 22:28:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1E04F6B007E; Tue, 25 Apr 2023 22:28:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 081126B0080; Tue, 25 Apr 2023 22:28:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id EC0CF6B007D for ; Tue, 25 Apr 2023 22:27:59 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id BC37C40358 for ; Wed, 26 Apr 2023 02:27:59 +0000 (UTC) X-FDA: 80721957078.27.6C07B75 Received: from mail1.bemta34.messagelabs.com (mail1.bemta34.messagelabs.com [195.245.231.1]) by imf07.hostedemail.com (Postfix) with ESMTP id 3E74740013 for ; Wed, 26 Apr 2023 02:27:56 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=170520fj header.b=y9XAIRO3; spf=pass (imf07.hostedemail.com: domain of ruansy.fnst@fujitsu.com designates 195.245.231.1 as permitted sender) smtp.mailfrom=ruansy.fnst@fujitsu.com; dmarc=pass (policy=none) header.from=fujitsu.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682476076; 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=SRX4u1hksNOjXaqCfLCkjPKJjm0vVvSWrZQKjRlWJBE=; b=FH6/OuzsOsDWgpOU6+dU1bjbFhZQ7y1Y/3DwGYhtgDefYMx0K+g5JnG05eOfx3W1thBGZM vzWli/M5Je4A2RN9XjXpqjIDU9OaD3D0rTDDiit069UMZSfxcxLiKeQBZaElQh3PFFeisT dMX1zMK46wkhjnV5XkNwwBJ1Isl42Fw= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=170520fj header.b=y9XAIRO3; spf=pass (imf07.hostedemail.com: domain of ruansy.fnst@fujitsu.com designates 195.245.231.1 as permitted sender) smtp.mailfrom=ruansy.fnst@fujitsu.com; dmarc=pass (policy=none) header.from=fujitsu.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682476076; a=rsa-sha256; cv=none; b=N0AQeXtB8IfTZU5qdQ5zhSmZDpk/iL3ic3inAzc22q/lxgUjOg2MARDCQcfch2sBHmLlT7 7yOdTGvOnR+UVpc/QT9Ry7kWnUsdSdQqTsZ8yS+DDeU5nymQIZ1tz6cWUopnOBJtbb/LHg qtMD/iYY0CgYx8iXzP332XSESUCitZg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1682476074; i=@fujitsu.com; bh=SRX4u1hksNOjXaqCfLCkjPKJjm0vVvSWrZQKjRlWJBE=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=y9XAIRO3UnvWls8edPx/JKSDG30bnlFMQTApijHQlM9c/PZEbb9kWZnAE6HHaax4H ytq7SGDlvynfydVZ8mHP3IV7VGIf4kQS0vIQOQXIlbq9FRAhK+nbQ/YJX5aEkS292a pOZEzLS48jBxUQVsC5wVe2D/0Wvds5Q3jV4VqItcuI5y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8rv/BPOqbpcHE5ywzmByZHNi2acqvOUuVKtcw Ej2X8ebJHXeRjJzNZdHcH/bBcftG19KVZ/4ovXE92Bu+Y3/ZrAt8vv3uu1x89KdtT93S36Xmj edb8fCUc6x3i7jb7/WE70HSr3z/0+b2OlQsihZ+8XHpawVNwatnvjFlrL156wDfXeptp/8cKo wiJqVsfzs9elH0vySh0acHk1IrI56eZ5vzy0UnIlvr178uq6zvSSxVtXnvZqF/d0fjGZpP1fM a5mrXuSizFGYmGWsxFxYkAIn4hIsoDAAA= X-Env-Sender: ruansy.fnst@fujitsu.com X-Msg-Ref: server-3.tower-571.messagelabs.com!1682476071!252115!1 X-Originating-IP: [62.60.8.97] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.105.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8290 invoked from network); 26 Apr 2023 02:27:52 -0000 Received: from unknown (HELO n03ukasimr01.n03.fujitsu.local) (62.60.8.97) by server-3.tower-571.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 26 Apr 2023 02:27:52 -0000 Received: from n03ukasimr01.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr01.n03.fujitsu.local (Postfix) with ESMTP id AFBBB100191; Wed, 26 Apr 2023 03:27:51 +0100 (BST) Received: from R01UKEXCASM223.r01.fujitsu.local (R01UKEXCASM223 [10.182.185.121]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr01.n03.fujitsu.local (Postfix) with ESMTPS id A214F10018D; Wed, 26 Apr 2023 03:27:51 +0100 (BST) Received: from [192.168.50.5] (10.167.234.230) by R01UKEXCASM223.r01.fujitsu.local (10.182.185.121) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 26 Apr 2023 03:27:47 +0100 Message-ID: Date: Wed, 26 Apr 2023 10:27:43 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [RFC PATCH v11.1 2/2] mm, pmem, xfs: Introduce MF_MEM_REMOVE for unbind To: "Darrick J. Wong" , Jan Kara , Luis Chamberlain CC: , , , , , , References: <1679996506-2-3-git-send-email-ruansy.fnst@fujitsu.com> <1681296735-2-1-git-send-email-ruansy.fnst@fujitsu.com> <0a53ee26-5771-0808-ccdc-d1739c9dacac@fujitsu.com> <20230420120956.cdxcwojckiw36kfg@quack3> <20230425132315.u5ocvbneeqzzbifl@quack3> <20230425151800.GS360889@frogsfrogsfrogs> From: Shiyang Ruan In-Reply-To: <20230425151800.GS360889@frogsfrogsfrogs> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.167.234.230] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM223.r01.fujitsu.local (10.182.185.121) X-Virus-Scanned: ClamAV using ClamSMTP X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 3E74740013 X-Stat-Signature: qm1qwotgfshwbms8x94dhac8ms7ibm7u X-Rspam-User: X-HE-Tag: 1682476076-463411 X-HE-Meta: U2FsdGVkX182Ql2bakQa7ILfmyuohuzpiNEDXbbO8P0ckcf4t/PlmVyKKSt8hEnlIGuhy+M+u8y/a9UlibHU04U3uNWNU44ZlOVPf+YzsDvKiWiQzoXALK8p0VhjxxFlVn0d39aUYKJZHvXVNSKZSPuszpDo6AuGfN/oeT1zjkLPynoav2BDQ315i0Dej3sCCxiT3CChjeFGIbRMavsPBeefX/bsFKiSqs97xDtOBUlyAj35NShxwkl5s/+Wna5qoEWfqwDUhMyjCIpO1ZOU2inaP3yo7LE9hbJfUE3mpIOyxarkM9e46SpKVjyuRn4P1/IpyTVUznwl+b2/8iiEQZbTImOe7aDa/pvC3kXezfajfWV4fF/obEDnYYmrrUDObTiPMbNdVyboG4/v8MOOdZN9N4RymipXS4HH8fd4fCmSmcHlPmnmbjf1eUNGjPDdg9We3AiWdsWKRGbxR2cTRIi6WOAxFvtwniRKBDVfuWH7qM7Ds6YlWodW+d0B0CxL2xbZvwrj12hr+hCXqAxPj62gNfxRCaWtaCeOxnJN5GDv0RWBHq/O9mwVkvR0cg7OkG4eSf0y4vDRmUfFn2RC9UpjC+z0ZiGABcmlUi+2nA/C/MT43CLqEagU7TpnnACj/u/iTggAymYz2vpkYfHb2VxyHPf+8F2zLx1WJucaKaa4KSTQrAw0hFiAVgiRDqdIqGSO3v5oFqzpAmtI5dlwZmU4LIsBbYIErdOD9GemTMbpqIWZb3NV4sp7ehMrzz6qJiojEUTHifZXC8oxMl/9O60FT3Qz4NlVK2qiQcwsdmv3X6kNC0FEa0JlVHDgGoDX1Na5gSx7ctBkdTwseY+MPeZb0Ie3GhqIbMXpYkjBT3wllXChG9TFVqUacswg/GV8QIlNq503MXRf7Wk4++V5IrOWbOD9LPP1gg9g1HZrA/+bJHfhPRF8wR7+OArLTgwnC4/2KauwqRGVAc/UqOu iR9++xTi dm9FeaEUpmSq5PusxZG+XDKx0S9Wg8hLck8pZughrWnmnRlCRNCfXNWCtZ+fuDmM9n4Sf/9EW/EUBFw/eYeW/0DjvNcnE8tfpU/tCdZ3c/5RXgg6YSvoNFp7SR25B4gtMLmIrlJA3ny2LgBds8uOq89a+GSs+ODCJUnyqhj4SNX7RopeKzUa2Gak8wiEDQRAlCvKKt1499GM9vAQ3qXLhEnurwSHvacnB3DrUfZ9iH45D0xFEz55ajrqrfWpXrxdyZxgcwEWiZgm0Y3oPd9CrhUUOPlf6D5jzhcaoXc++kVJfS6X+rwvqlROyrpQFBTVX+rEVHf8WFia5BBCe7GG5p2vMdg5R/4SnA+/amxOzs9NsPcL0/jcesNZLyw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000283, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 在 2023/4/25 23:18, Darrick J. Wong 写道: > On Tue, Apr 25, 2023 at 03:23:15PM +0200, Jan Kara wrote: >> On Tue 25-04-23 20:47:35, Shiyang Ruan wrote: >>> >>> >>> 在 2023/4/20 20:09, Jan Kara 写道: >>>> On Thu 20-04-23 10:07:39, Shiyang Ruan wrote: >>>>> 在 2023/4/12 18:52, Shiyang Ruan 写道: >>>>>> This is a RFC HOTFIX. >>>>>> >>>>>> This hotfix adds a exclusive forzen state to make sure any others won't >>>>>> thaw the fs during xfs_dax_notify_failure(): >>>>>> >>>>>> #define SB_FREEZE_EXCLUSIVE (SB_FREEZE_COMPLETE + 2) >>>>>> Using +2 here is because Darrick's patch[0] is using +1. So, should we >>>>>> make these definitions global? >>>>>> >>>>>> Another thing I can't make up my mind is: when another freezer has freeze >>>>>> the fs, should we wait unitl it finish, or print a warning in dmesg and >>>>>> return -EBUSY? >>>>>> >>>>>> Since there are at least 2 places needs exclusive forzen state, I think >>>>>> we can refactor helper functions of freeze/thaw for them. e.g. >>>>>> int freeze_super_exclusive(struct super_block *sb, int frozen); >>>>>> int thaw_super_exclusive(struct super_block *sb, int frozen); >>>>>> >>>>>> [0] https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git/commit/?h=repair-fscounters&id=c3a0d1de4d54ffb565dbc7092dfe1fb851940669 >>>> >>>> I'm OK with the idea of new freeze state that does not allow userspace to >>>> thaw the filesystem. But I don't really like the guts of filesystem >>>> freezing being replicated inside XFS. It is bad enough that they are >>>> replicated in [0], replicating them *once more* in another XFS file shows >>>> we are definitely doing something wrong. And Luis will need yet another >>>> incantation of the exlusive freeze for suspend-to-disk. So please guys get >>>> together and reorganize the generic freezing code so that it supports >>>> exclusive freeze (for in-kernel users) and works for your usecases instead >>>> of replicating it inside XFS... >>> >>> I agree that too much replicating code is not good. It's necessary to >>> create a generic exclusive freeze/thaw for all users. But for me, I don't >>> have the confidence to do it well, because it requires good design and code >>> changes will involve other filesystems. It's diffcult. >>> >>> However, I hope to be able to make progress on this unbind feature. Thus, I >>> tend to refactor a common helper function for xfs first, and update the code >>> later when the generic freeze is done. >> >> I think Darrick was thinking about working on a proper generic interface. >> So please coordinate with him. > > I'll post a vfs generic kernelfreeze series later today. > > One thing I haven't figured out yet is what's supposed to happen when > PREREMOVE is called on a frozen filesystem. call PREREMOVE when: 1. freezed by kernel: we wait unitl kernel thaws -> not sure 2. freezed by userspace: we take over the control of freeze state: a. userspace can't thaw before PREREMOVE is done b. kernel keeps freeze state after PREREMOVE is done and before userspace thaws Since the unbind interface doesn't return any other errcode except -ENODEV, the only thing I can think of to do is wait for the other one done? If another one doesn't thaw after a long time waitting, we print a "waitting too long" warning in dmesg. But I'm not sure if this is good. > We don't want userspace to > be able to thaw the fs while PREREMOVE is running, so I /guess/ that > means we need some method for the kernel to take over a userspace > freeze and then put it back when we're done? As is designed by Luis, we can add sb->s_writers.frozen_by_user flag to distinguish whether current freeze state is initiated by kernel or userspace. In his patch, userspace can take over kernel's freeze. We just need to switch the order. -- Thanks, Ruan. > > --D > >> Honza >> >> -- >> Jan Kara >> SUSE Labs, CR