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 C5EECC433EF for ; Thu, 16 Jun 2022 07:00:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 373426B0072; Thu, 16 Jun 2022 03:00:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FB4F6B0073; Thu, 16 Jun 2022 03:00:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 174756B0074; Thu, 16 Jun 2022 03:00:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 058FA6B0072 for ; Thu, 16 Jun 2022 03:00:32 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BEFD334BE7 for ; Thu, 16 Jun 2022 07:00:31 +0000 (UTC) X-FDA: 79583200662.19.F876495 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf05.hostedemail.com (Postfix) with ESMTP id 1D462100092 for ; Thu, 16 Jun 2022 07:00:29 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LNtLB2TVCz1KB2f; Thu, 16 Jun 2022 14:58:26 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 16 Jun 2022 15:00:24 +0800 Subject: Re: [PATCH v2 2/2] mm/swapfile: release swap info when swap device is unpluged To: Christoph Hellwig CC: , , , , , , , , , , , , , liubo References: <20220615070228.2858170-1-liubo254@huawei.com> <20220615070228.2858170-3-liubo254@huawei.com> From: Miaohe Lin Message-ID: <94b554c5-50cc-141c-c494-14005425930a@huawei.com> Date: Thu, 16 Jun 2022 15:00:24 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655362831; 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=6+SL803wERBcuUltMYFG+neazXzMGLBQJewTmmNat+c=; b=zKRRytJOW1o+y+8Vw8PGYiKhiL0xh9XMdyLgBgkcHSJTivjs4GqEeetGjbKOmUDjyOo7n+ mPSb1FXcXhYXbgrH9TSeh7m4ckVooOjhC+3SnmR7+ntORya22wAYwlwUmyJvZumyKlC0HD rzqNP40/9ytcwnRc2c+KDOGXRg88dcY= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655362831; a=rsa-sha256; cv=none; b=dgemdbtDFsdaYl80TZCUo0ip652k84ao66t/lgG5YCnmS6VbmX/GjZHEhtQx8bHR9p5BHC RihOiwlQ8IpmCoiAtvV15kMBodXhYbrPXP8PebbzUL791HV6pwjmlSLQOs0BAa5cT2TFm5 pSQbs42j1A95+ABXDWh01h6vBm7nLHw= X-Stat-Signature: 5n174bui9buushqzwkjqjutz9ubjw5ep X-Rspamd-Queue-Id: 1D462100092 X-Rspam-User: X-Rspamd-Server: rspam05 Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-HE-Tag: 1655362829-679690 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: On 2022/6/15 19:22, Christoph Hellwig wrote: > Sorry, but this is simply broken. We can't just do d_path magic > here. That being said the problem is real, and I think the right > answer is to offer a swapoff variant that doesn't need to open the > underlying device or file, but useѕ some kind of handle. I'm just When swap device is unplugged, the swap_file->f_path.dentry will be in the d_unlinked() status. Could we use it to detect the problem instead? IMHO, we can found the unplugged swap devices this way and further get the right swap device to swapoff through comparing the swap device name with @specialfile. Or am I miss something? > not sure what would be a good handle here. Using handle sounds like a good idea too. :) But can the above solution be acceptable? > . > Thanks!