From patchwork Fri Sep 2 10:35:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12964021 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 F341BECAAD5 for ; Fri, 2 Sep 2022 10:36:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5300B8D001F; Fri, 2 Sep 2022 06:36:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DEB98D001B; Fri, 2 Sep 2022 06:36:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A7498D001F; Fri, 2 Sep 2022 06:36:33 -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 28BAF8D001B for ; Fri, 2 Sep 2022 06:36:33 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F048FA05B8 for ; Fri, 2 Sep 2022 10:36:32 +0000 (UTC) X-FDA: 79866791424.02.B53E1ED Received: from mail1.bemta32.messagelabs.com (mail1.bemta32.messagelabs.com [195.245.230.66]) by imf19.hostedemail.com (Postfix) with ESMTP id 5A2A01A0041 for ; Fri, 2 Sep 2022 10:36:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1662114990; i=@fujitsu.com; bh=swdErYyi7Si91FvqA0QbntZe2uXVEMXrPiLsnL32AkU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AtAyGO1GHcar7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AwCDEU5BalJtZgir/ilGcg1FJmPcZyBSezLwSuH2vgE5hAjpl+kx+kFNKEhFSU g1M8/QL9V/Zzv54hSP9bGva24XmC6c8Xqe5ouSPn176KxWGueHPWOtCuGbf2axq3PqmJoJrZ5 TVgtKdb6fwT4pWs4xfIqBo2Oxn8zwtlXce3zbdsz8vJfJItGoZGsY4LdipxrwgQUrbvelm4i5 G8RObxNo1lSz7757QU20IT5Q8/uWN0RytF37zv4lKnWVLvHThcy1/pmGmyQOVgwZdG5zz167R ehW6xCa7JfxyxFHdF4wRystnbRTLkGOSSbg4Z0v4t68/tDhSOGyzfi2ZWcsY+a+ixvxRWNx5C W2Ojf/PVyccmfone8Oqu4LOJR42Ek88i498FPRd/4BtKbNA5BaNyTs619kGbmI5vDj04Bcllu KMREMt5qLiRADWYqdJuwMAAA== X-Env-Sender: ruansy.fnst@fujitsu.com X-Msg-Ref: server-6.tower-587.messagelabs.com!1662114989!100401!1 X-Originating-IP: [62.60.8.179] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.87.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28576 invoked from network); 2 Sep 2022 10:36:29 -0000 Received: from unknown (HELO n03ukasimr04.n03.fujitsu.local) (62.60.8.179) by server-6.tower-587.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 2 Sep 2022 10:36:29 -0000 Received: from n03ukasimr04.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr04.n03.fujitsu.local (Postfix) with ESMTP id 6AA3F7B; Fri, 2 Sep 2022 11:36:29 +0100 (BST) Received: from R01UKEXCASM121.r01.fujitsu.local (R01UKEXCASM121 [10.183.43.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr04.n03.fujitsu.local (Postfix) with ESMTPS id 5D4D173; Fri, 2 Sep 2022 11:36:29 +0100 (BST) Received: from localhost.localdomain (10.167.225.141) by R01UKEXCASM121.r01.fujitsu.local (10.183.43.173) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 2 Sep 2022 11:36:25 +0100 From: Shiyang Ruan To: , , , , CC: , , , , Subject: [PATCH 1/3] xfs: fix the calculation of length and end Date: Fri, 2 Sep 2022 10:35:59 +0000 Message-ID: <1662114961-66-2-git-send-email-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1662114961-66-1-git-send-email-ruansy.fnst@fujitsu.com> References: <9e9521a4-6e07-e226-2814-b78a2451656b@fujitsu.com> <1662114961-66-1-git-send-email-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.141] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM121.r01.fujitsu.local (10.183.43.173) X-Virus-Scanned: ClamAV using ClamSMTP ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662114992; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=swdErYyi7Si91FvqA0QbntZe2uXVEMXrPiLsnL32AkU=; b=2jvBbQyNkpa6KdPl551iRx/0/QxNrX84Z8C/lNUc8AIF+pNsxMHHdVvv7WnEbqtpbOP9+Z BN8UxC+QeWhv9donyd88Z7xyQLy/jf74B1onwx583XVPaM81X1bsZokIzB3KrW6rdb46DJ hTJE33bEexEyz2FRxMso0dbgKR1bMBg= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=170520fj header.b=AtAyGO1G; spf=pass (imf19.hostedemail.com: domain of ruansy.fnst@fujitsu.com designates 195.245.230.66 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=1662114992; a=rsa-sha256; cv=none; b=ofXDY7QjEPa59pxwtdBMz5ZryA+Lyw129h13RG7XwOw8a1d2/h4lUhl2/UvuuQ7eoSrrGg iXdkyH/B208OZJB3N7zFDxWDviYx1IPJ3p353SmI1Ey1cBlY+xliTerz1zj8StX8qAZhQM HdPJZ7TqRihE6U7igqY4KcRb5tCgl+8= X-Stat-Signature: bqwxmoa1qwsdw6cs3845exo7f3h8whwr X-Rspamd-Queue-Id: 5A2A01A0041 X-Rspam-User: Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=170520fj header.b=AtAyGO1G; spf=pass (imf19.hostedemail.com: domain of ruansy.fnst@fujitsu.com designates 195.245.230.66 as permitted sender) smtp.mailfrom=ruansy.fnst@fujitsu.com; dmarc=pass (policy=none) header.from=fujitsu.com X-Rspamd-Server: rspam01 X-HE-Tag: 1662114992-508091 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: The end should be start + length - 1. Also fix the calculation of the length when seeking for intersection of notify range and device. Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_notify_failure.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_notify_failure.c b/fs/xfs/xfs_notify_failure.c index c4078d0ec108..3830f908e215 100644 --- a/fs/xfs/xfs_notify_failure.c +++ b/fs/xfs/xfs_notify_failure.c @@ -114,7 +114,7 @@ xfs_dax_notify_ddev_failure( int error = 0; xfs_fsblock_t fsbno = XFS_DADDR_TO_FSB(mp, daddr); xfs_agnumber_t agno = XFS_FSB_TO_AGNO(mp, fsbno); - xfs_fsblock_t end_fsbno = XFS_DADDR_TO_FSB(mp, daddr + bblen); + xfs_fsblock_t end_fsbno = XFS_DADDR_TO_FSB(mp, daddr + bblen - 1); xfs_agnumber_t end_agno = XFS_FSB_TO_AGNO(mp, end_fsbno); error = xfs_trans_alloc_empty(mp, &tp); @@ -210,7 +210,7 @@ xfs_dax_notify_failure( ddev_end = ddev_start + bdev_nr_bytes(mp->m_ddev_targp->bt_bdev) - 1; /* Ignore the range out of filesystem area */ - if (offset + len < ddev_start) + if (offset + len - 1 < ddev_start) return -ENXIO; if (offset > ddev_end) return -ENXIO; @@ -222,8 +222,8 @@ xfs_dax_notify_failure( len -= ddev_start - offset; offset = 0; } - if (offset + len > ddev_end) - len -= ddev_end - offset; + if (offset + len - 1 > ddev_end) + len -= offset + len - 1 - ddev_end; return xfs_dax_notify_ddev_failure(mp, BTOBB(offset), BTOBB(len), mf_flags); From patchwork Fri Sep 2 10:36:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12964022 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 6A6E9C54EE9 for ; Fri, 2 Sep 2022 10:36:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E7F3B8D0020; Fri, 2 Sep 2022 06:36:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E2E138D001B; Fri, 2 Sep 2022 06:36:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CCF1A8D0020; Fri, 2 Sep 2022 06:36:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id BA9FD8D001B for ; Fri, 2 Sep 2022 06:36:36 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9403CC0F9F for ; Fri, 2 Sep 2022 10:36:36 +0000 (UTC) X-FDA: 79866791592.16.1D46A4C Received: from mail1.bemta34.messagelabs.com (mail1.bemta34.messagelabs.com [195.245.231.4]) by imf14.hostedemail.com (Postfix) with ESMTP id 1E9E110002B for ; Fri, 2 Sep 2022 10:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1662114994; i=@fujitsu.com; bh=DYnY13BY+5LEKC08gd8berTlSyYt18Bk3isUl+jAsE4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=wTun/xZBFA6GX3tQ518gmx/x0AmDK3NHrDbGAqOV6/to33OljX4kP43X+G6jdn+zy uokWVpEA35XEdUjqUpakePuNT1gc7mnyX+LwTEfGLKS8rbSsTVtK+PIZt/XotVoxnc Qs5To6MxknqZBqfeZ1YY6eoIkHhZIQssFfxtfzAJm2H/R2nMfHQD2FA13BajDSJsj6 eUr7Q6DnfbjssL85yg8wruhiORbbsxBwW/fIuWtgMg42L/e4cSyawxqsFr9jo00XCB tBy7C+FWEFiQLJ4jX+FT+QHrfpbK/i+luiHoC0fR7ATRbCI2NPGniTlHVXZQIZs0Cu K/IwzZTzLbYTQ== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprOKsWRWlGSWpSXmKPExsViZ8MxSXfjHcF kg0VrTS2mT73AaLHl2D1Gi8tP+CxOT1jEZLH79U02iz17T7JYXN41h83i3pr/rBa7/uxgt1j5 4w+rA5fHqUUSHptXaHks3vOSyWPTqk42j02fJrF7vNg8k9Hj49NbLB6fN8kFcESxZuYl5Vcks Gbc7GpkL2hQqLi4ditrA+M26S5GLg4hgS2MEs1X77JDOMuZJE6c2s8I4exhlHhwsZe1i5GTg0 1AR+LCgr+sIAkRgUmMEsdu3GQGSTALlEvs33iDDcQWFnCWuLmtkR3EZhFQkTi8pJsJxOYVcJG Yc2M6mC0hoCAx5eF7sF5OAVeJ7T23geIcQNsqJFZv54AoF5Q4OfMJC8R4CYmDL14wg5RICChJ zOyOh5hSIdE4/RDURDWJq+c2MU9gFJyFpHsWku4FjEyrGK2TijLTM0pyEzNzdA0NDHQNDU11j S10jQyN9BKrdBP1Ukt1y1OLS3SB3PJivdTiYr3iytzknBS9vNSSTYzA+EopVruyg3HPqp96hx glOZiURHkTbwkmC/El5adUZiQWZ8QXleakFh9ilOHgUJLg5QfJCRalpqdWpGXmAGMdJi3BwaM kwhsGkuYtLkjMLc5Mh0idYlSUEud9AZIQAElklObBtcHSyyVGWSlhXkYGBgYhnoLUotzMElT5 V4ziHIxKwrzPQKbwZOaVwE1/BbSYCWjx9Jn8IItLEhFSUg1Mxucie+dwiHxVD28RPr01SfPdp Hv3ayo3te5R2p4w6/w6+18ylnO/nU196JL0awZj5dbzaSl80hsObek5I2eXVzOxuXmn/Yn8eo 2wV499HwlVXNPKZPkx/1Hh5kqNyOfqNzO6/vRIxv56WxNf57X+3flFlw7MmXN2cknW6o6Vras eKagbPnsYynBWeK2yx9a1zW9PP/c4lZxy605fJNcFU8GEcqc51hvUanbx5VfMOyV68zyv6ymx YL8c1tgavkO1gRJC962180ImPpgykSdKpPjyZ7XTe8u0ni3+ul3TSeXOCqUe5g9/Zp8U+y/2s cbY58HF848rU6X2VvosW/xuDv/dubcZL9Yr2l1axrvbU4mlOCPRUIu5qDgRAHNmFQaqAwAA X-Env-Sender: ruansy.fnst@fujitsu.com X-Msg-Ref: server-12.tower-548.messagelabs.com!1662114993!2182!1 X-Originating-IP: [62.60.8.146] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.87.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17723 invoked from network); 2 Sep 2022 10:36:33 -0000 Received: from unknown (HELO n03ukasimr02.n03.fujitsu.local) (62.60.8.146) by server-12.tower-548.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 2 Sep 2022 10:36:33 -0000 Received: from n03ukasimr02.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr02.n03.fujitsu.local (Postfix) with ESMTP id 8153D1000CD; Fri, 2 Sep 2022 11:36:33 +0100 (BST) Received: from R01UKEXCASM121.r01.fujitsu.local (R01UKEXCASM121 [10.183.43.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr02.n03.fujitsu.local (Postfix) with ESMTPS id 6EE351000CC; Fri, 2 Sep 2022 11:36:33 +0100 (BST) Received: from localhost.localdomain (10.167.225.141) by R01UKEXCASM121.r01.fujitsu.local (10.183.43.173) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 2 Sep 2022 11:36:29 +0100 From: Shiyang Ruan To: , , , , CC: , , , , Subject: [PATCH 2/3] fs: move drop_pagecache_sb() for others to use Date: Fri, 2 Sep 2022 10:36:00 +0000 Message-ID: <1662114961-66-3-git-send-email-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1662114961-66-1-git-send-email-ruansy.fnst@fujitsu.com> References: <9e9521a4-6e07-e226-2814-b78a2451656b@fujitsu.com> <1662114961-66-1-git-send-email-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.141] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM121.r01.fujitsu.local (10.183.43.173) X-Virus-Scanned: ClamAV using ClamSMTP ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662114996; a=rsa-sha256; cv=none; b=m8iMlsVoaClAK1oGnUQ4+urWtVYM2BJCcik8IFM91XpyA8je5i2sAgYajgF/WTbCsFa3Ws FXdx3RuNsZE0r2iYgZz8F08zMmN/r1Js/aop5tTf7bR6gvx8y196oXw6rRcglRwsvDLlHf Y7Bq7Jm7OJaqY/YYdBO6BOGYHvOg3V0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=170520fj header.b="wTun/xZB"; spf=pass (imf14.hostedemail.com: domain of ruansy.fnst@fujitsu.com designates 195.245.231.4 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=1662114996; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DYnY13BY+5LEKC08gd8berTlSyYt18Bk3isUl+jAsE4=; b=GO91mSPNHtBG9Cb2o9XMmnyPtukI25GAHeFoCz39L9jVJD+P4MS/6g7d4RdrAQV4TCTOkC mHCk1zvvTarGjW3B/FG9otP2uzL4Sx0AVMKk4KSAo7Jh/nv+/o03nFkuwYwrafNKMaNm/f 6SlafyJx2PM9dce0KLGs9NB0v7FcZ/k= Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=170520fj header.b="wTun/xZB"; spf=pass (imf14.hostedemail.com: domain of ruansy.fnst@fujitsu.com designates 195.245.231.4 as permitted sender) smtp.mailfrom=ruansy.fnst@fujitsu.com; dmarc=pass (policy=none) header.from=fujitsu.com X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 1E9E110002B X-Stat-Signature: 6w7kprmos3w347rw9jzxr9n6zn6ufa33 X-HE-Tag: 1662114995-229286 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: xfs_notify_failure requires a method to invalidate all mappings. drop_pagecache_sb() can do this but it is a static function and only build with CONFIG_SYSCTL. Now, move it to super.c and make it available for others. Signed-off-by: Shiyang Ruan --- fs/drop_caches.c | 33 --------------------------------- fs/super.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/fs.h | 1 + 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/fs/drop_caches.c b/fs/drop_caches.c index e619c31b6bd9..5c8406076f9b 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c @@ -3,7 +3,6 @@ * Implement the manual drop-all-pagecache function */ -#include #include #include #include @@ -15,38 +14,6 @@ /* A global variable is a bit ugly, but it keeps the code simple */ int sysctl_drop_caches; -static void drop_pagecache_sb(struct super_block *sb, void *unused) -{ - struct inode *inode, *toput_inode = NULL; - - spin_lock(&sb->s_inode_list_lock); - list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { - spin_lock(&inode->i_lock); - /* - * We must skip inodes in unusual state. We may also skip - * inodes without pages but we deliberately won't in case - * we need to reschedule to avoid softlockups. - */ - if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) || - (mapping_empty(inode->i_mapping) && !need_resched())) { - spin_unlock(&inode->i_lock); - continue; - } - __iget(inode); - spin_unlock(&inode->i_lock); - spin_unlock(&sb->s_inode_list_lock); - - invalidate_mapping_pages(inode->i_mapping, 0, -1); - iput(toput_inode); - toput_inode = inode; - - cond_resched(); - spin_lock(&sb->s_inode_list_lock); - } - spin_unlock(&sb->s_inode_list_lock); - iput(toput_inode); -} - int drop_caches_sysctl_handler(struct ctl_table *table, int write, void *buffer, size_t *length, loff_t *ppos) { diff --git a/fs/super.c b/fs/super.c index 734ed584a946..bdf53dbe834c 100644 --- a/fs/super.c +++ b/fs/super.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include "internal.h" @@ -677,6 +678,39 @@ void drop_super_exclusive(struct super_block *sb) } EXPORT_SYMBOL(drop_super_exclusive); +void drop_pagecache_sb(struct super_block *sb, void *unused) +{ + struct inode *inode, *toput_inode = NULL; + + spin_lock(&sb->s_inode_list_lock); + list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { + spin_lock(&inode->i_lock); + /* + * We must skip inodes in unusual state. We may also skip + * inodes without pages but we deliberately won't in case + * we need to reschedule to avoid softlockups. + */ + if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) || + (mapping_empty(inode->i_mapping) && !need_resched())) { + spin_unlock(&inode->i_lock); + continue; + } + __iget(inode); + spin_unlock(&inode->i_lock); + spin_unlock(&sb->s_inode_list_lock); + + invalidate_mapping_pages(inode->i_mapping, 0, -1); + iput(toput_inode); + toput_inode = inode; + + cond_resched(); + spin_lock(&sb->s_inode_list_lock); + } + spin_unlock(&sb->s_inode_list_lock); + iput(toput_inode); +} +EXPORT_SYMBOL(drop_pagecache_sb); + static void __iterate_supers(void (*f)(struct super_block *)) { struct super_block *sb, *p = NULL; diff --git a/include/linux/fs.h b/include/linux/fs.h index 9eced4cc286e..5ded28c0d2c9 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3292,6 +3292,7 @@ extern struct super_block *get_super(struct block_device *); extern struct super_block *get_active_super(struct block_device *bdev); extern void drop_super(struct super_block *sb); extern void drop_super_exclusive(struct super_block *sb); +void drop_pagecache_sb(struct super_block *sb, void *unused); extern void iterate_supers(void (*)(struct super_block *, void *), void *); extern void iterate_supers_type(struct file_system_type *, void (*)(struct super_block *, void *), void *); From patchwork Fri Sep 2 10:36:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12964023 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 784F7C54EE9 for ; Fri, 2 Sep 2022 10:36:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 15F4F8D0022; Fri, 2 Sep 2022 06:36:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 10F358D001B; Fri, 2 Sep 2022 06:36:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECDBB8D0022; Fri, 2 Sep 2022 06:36:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D8A0D8D001B for ; Fri, 2 Sep 2022 06:36:40 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A55161C6019 for ; Fri, 2 Sep 2022 10:36:40 +0000 (UTC) X-FDA: 79866791760.19.987F857 Received: from mail3.bemta32.messagelabs.com (mail3.bemta32.messagelabs.com [195.245.230.82]) by imf29.hostedemail.com (Postfix) with ESMTP id 0A583120086 for ; Fri, 2 Sep 2022 10:36:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1662114998; i=@fujitsu.com; bh=FNSKVPiakbEzPRjuYrjQOYTkDqJpVisojC0UYVUlJhQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MrrhVO8PnBM/dpTrtHKX1dNzihkVeMlZTmc7ceJ3Eqtem7XpGWcu3DXdUM7b4+qBg kg8IQFuM8Px6xEg+hGrEDUgmM3fAGH47pb1h17fR2S+7N3d3vR9pysq7m+Fn7DMMDb NrlILK5j3gnaYVMVpRNLnrh5jJSSX6FnMcGaznSrq5dUhsw0fHqs2BEkOmVfOdx8Ge 1mdb22O0/obQn9sxdQC8Cgg92Onp2f0Jk9uS5GP/VzqxPoYMek9OMloexq7RGZM2PP VltNWCDyVLMFSR3zEe4+WuERrrWRPaxlyhi0TwzlC9AMiD3OzRArq3OIAi/jLwQmt/ 1ZGEhjFN73DMA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOKsWRWlGSWpSXmKPExsViZ8ORqLv1jmC ywZc11hbTp15gtNhy7B6jxeUnfBanJyxistj9+iabxZ69J1ksLu+aw2Zxb81/Votdf3aw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g-Ref: server-15.tower-585.messagelabs.com!1662114997!653077!1 X-Originating-IP: [62.60.8.97] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.87.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21403 invoked from network); 2 Sep 2022 10:36:37 -0000 Received: from unknown (HELO n03ukasimr01.n03.fujitsu.local) (62.60.8.97) by server-15.tower-585.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 2 Sep 2022 10:36:37 -0000 Received: from n03ukasimr01.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr01.n03.fujitsu.local (Postfix) with ESMTP id 7ECEA10019C; Fri, 2 Sep 2022 11:36:37 +0100 (BST) Received: from R01UKEXCASM121.r01.fujitsu.local (R01UKEXCASM121 [10.183.43.173]) (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 7BE3A10019B; Fri, 2 Sep 2022 11:36:37 +0100 (BST) Received: from localhost.localdomain (10.167.225.141) by R01UKEXCASM121.r01.fujitsu.local (10.183.43.173) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 2 Sep 2022 11:36:33 +0100 From: Shiyang Ruan To: , , , , CC: , , , , Subject: [PATCH 3/3] mm, pmem, xfs: Introduce MF_MEM_REMOVE for unbind Date: Fri, 2 Sep 2022 10:36:01 +0000 Message-ID: <1662114961-66-4-git-send-email-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1662114961-66-1-git-send-email-ruansy.fnst@fujitsu.com> References: <9e9521a4-6e07-e226-2814-b78a2451656b@fujitsu.com> <1662114961-66-1-git-send-email-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.141] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM121.r01.fujitsu.local (10.183.43.173) X-Virus-Scanned: ClamAV using ClamSMTP ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662115000; a=rsa-sha256; cv=none; b=Ek31iBZLTiF589oAIwNtVbNNncJHn0SJYsR4Wr1enTKjteYi1FZTK+AKyPiD+9k5JUmGm5 IgjAwSoKq8oMNt3c7VJnl20yAUicNRyMGmopcyVvBg66egcsaPwINtK51PL1DJTSeAgJhl i9Pi76lKrfJi+QdcgPgOROABTkCVB0U= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=170520fj header.b=MrrhVO8P; dmarc=pass (policy=none) header.from=fujitsu.com; spf=pass (imf29.hostedemail.com: domain of ruansy.fnst@fujitsu.com designates 195.245.230.82 as permitted sender) smtp.mailfrom=ruansy.fnst@fujitsu.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662115000; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FNSKVPiakbEzPRjuYrjQOYTkDqJpVisojC0UYVUlJhQ=; b=eJmNP+Qk+TRXb/0hUof7IKAWFJVYar9luq9Jw5TyU4AfC6eOQI2SFRUNHFKeHa2SLApmZQ UySq8J1Sb/pvVEzE12/Csz8mwWob+jP/7yo9U8sF7vtJVD+Vl8dcgOfew+M3zEwcRlTRC3 OJCxMy2/CO7VnEJDnUYvS6yQ8TyTlZw= X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 0A583120086 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=170520fj header.b=MrrhVO8P; dmarc=pass (policy=none) header.from=fujitsu.com; spf=pass (imf29.hostedemail.com: domain of ruansy.fnst@fujitsu.com designates 195.245.230.82 as permitted sender) smtp.mailfrom=ruansy.fnst@fujitsu.com X-Rspam-User: X-Stat-Signature: tithdgk1afz36qi97mso3jhdiafukbeu X-HE-Tag: 1662114999-358239 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: This patch is inspired by Dan's "mm, dax, pmem: Introduce dev_pagemap_failure()"[1]. With the help of dax_holder and ->notify_failure() mechanism, the pmem driver is able to ask filesystem (or mapped device) on it to unmap all files in use and notify processes who are using those files. Call trace: trigger unbind -> unbind_store() -> ... (skip) -> devres_release_all() # was pmem driver ->remove() in v1 -> kill_dax() -> dax_holder_notify_failure(dax_dev, 0, U64_MAX, MF_MEM_PRE_REMOVE) -> xfs_dax_notify_failure() Introduce MF_MEM_PRE_REMOVE to let filesystem know this is a remove event. So do not shutdown filesystem directly if something not supported, or if failure range includes metadata area. Make sure all files and processes are handled correctly. [1]: https://lore.kernel.org/linux-mm/161604050314.1463742.14151665140035795571.stgit@dwillia2-desk3.amr.corp.intel.com/ Signed-off-by: Shiyang Ruan --- drivers/dax/super.c | 3 ++- fs/xfs/xfs_notify_failure.c | 23 +++++++++++++++++++++++ include/linux/mm.h | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 9b5e2a5eb0ae..cf9a64563fbe 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -323,7 +323,8 @@ void kill_dax(struct dax_device *dax_dev) return; if (dax_dev->holder_data != NULL) - dax_holder_notify_failure(dax_dev, 0, U64_MAX, 0); + dax_holder_notify_failure(dax_dev, 0, U64_MAX, + MF_MEM_PRE_REMOVE); clear_bit(DAXDEV_ALIVE, &dax_dev->flags); synchronize_srcu(&dax_srcu); diff --git a/fs/xfs/xfs_notify_failure.c b/fs/xfs/xfs_notify_failure.c index 3830f908e215..5e04ba7fa403 100644 --- a/fs/xfs/xfs_notify_failure.c +++ b/fs/xfs/xfs_notify_failure.c @@ -22,6 +22,7 @@ #include #include +#include struct xfs_failure_info { xfs_agblock_t startblock; @@ -77,6 +78,9 @@ xfs_dax_failure_fn( if (XFS_RMAP_NON_INODE_OWNER(rec->rm_owner) || (rec->rm_flags & (XFS_RMAP_ATTR_FORK | XFS_RMAP_BMBT_BLOCK))) { + /* The device is about to be removed. Not a really failure. */ + if (notify->mf_flags & MF_MEM_PRE_REMOVE) + return 0; notify->want_shutdown = true; return 0; } @@ -182,12 +186,23 @@ xfs_dax_notify_failure( struct xfs_mount *mp = dax_holder(dax_dev); u64 ddev_start; u64 ddev_end; + int error; if (!(mp->m_super->s_flags & SB_BORN)) { xfs_warn(mp, "filesystem is not ready for notify_failure()!"); return -EIO; } + if (mf_flags & MF_MEM_PRE_REMOVE) { + xfs_info(mp, "device is about to be removed!"); + down_write(&mp->m_super->s_umount); + error = sync_filesystem(mp->m_super); + drop_pagecache_sb(mp->m_super, NULL); + up_write(&mp->m_super->s_umount); + if (error) + return error; + } + if (mp->m_rtdev_targp && mp->m_rtdev_targp->bt_daxdev == dax_dev) { xfs_debug(mp, "notify_failure() not supported on realtime device!"); @@ -196,6 +211,8 @@ xfs_dax_notify_failure( if (mp->m_logdev_targp && mp->m_logdev_targp->bt_daxdev == dax_dev && mp->m_logdev_targp != mp->m_ddev_targp) { + if (mf_flags & MF_MEM_PRE_REMOVE) + return 0; xfs_err(mp, "ondisk log corrupt, shutting down fs!"); xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_ONDISK); return -EFSCORRUPTED; @@ -209,6 +226,12 @@ xfs_dax_notify_failure( ddev_start = mp->m_ddev_targp->bt_dax_part_off; ddev_end = ddev_start + bdev_nr_bytes(mp->m_ddev_targp->bt_bdev) - 1; + /* Notify failure on the whole device */ + if (offset == 0 && len == U64_MAX) { + offset = ddev_start; + len = bdev_nr_bytes(mp->m_ddev_targp->bt_bdev); + } + /* Ignore the range out of filesystem area */ if (offset + len - 1 < ddev_start) return -ENXIO; diff --git a/include/linux/mm.h b/include/linux/mm.h index 21f8b27bd9fd..9122a1c57dd2 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3183,6 +3183,7 @@ enum mf_flags { MF_UNPOISON = 1 << 4, MF_SW_SIMULATED = 1 << 5, MF_NO_RETRY = 1 << 6, + MF_MEM_PRE_REMOVE = 1 << 7, }; int mf_dax_kill_procs(struct address_space *mapping, pgoff_t index, unsigned long count, int mf_flags);