From patchwork Mon Jan 29 14:34:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535771 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 B227AC47DB3 for ; Mon, 29 Jan 2024 14:35:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4381E6B00B1; Mon, 29 Jan 2024 09:35:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 370BD6B00B2; Mon, 29 Jan 2024 09:35:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C2D76B00B3; Mon, 29 Jan 2024 09:35:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 00C556B00B1 for ; Mon, 29 Jan 2024 09:35:55 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BD4F0120A6E for ; Mon, 29 Jan 2024 14:35:55 +0000 (UTC) X-FDA: 81732597870.04.296264C Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf19.hostedemail.com (Postfix) with ESMTP id 07D481A001D for ; Mon, 29 Jan 2024 14:35:53 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Ndx6oX0I; dmarc=none; spf=none (imf19.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706538954; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=UUGBMYNgAEuyMsH9DsEDC+bqyUdHBQHIt1xJzsh3ydM=; b=2J80lh1bWxHLof2UHNBBynFhdB2Ey9sRCAtWGvuHg/eavsn9SBjfPwe0AXvUEU3pmVXiB5 /jJ4viKPucS6thTm7W4D4WOJtBYglFeBIGIh+erryB7FX6vXaGW9DS7Ngus5apiXNTl7tE HqHYeaFHdnk0EMUDjL/BahFWnMVBzuA= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Ndx6oX0I; dmarc=none; spf=none (imf19.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538954; a=rsa-sha256; cv=none; b=w1hiEKIMpJXf8BiSWlIaDDwIOar1BkVOBQUMppwRVlXrXzxkJQ5NVdB9/SHvNwqrR2WR/s VxLsDkYF7k+6cYOxArNr9Ew+syVgzrzl8jV0cOzxii1wC8qS7EV2GHZqk1pVyD29tuZXdW 2LlzgfQFfXvykGqb6j6y4fE2TueHQqI= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=UUGBMYNgAEuyMsH9DsEDC+bqyUdHBQHIt1xJzsh3ydM=; b=Ndx6oX0IR1JD+I2qz/1pNNkhLa 1Rzbjm71jFKu/bjnfJYXhabmeWIaWIga7uoXTS9wR5HRnVP4lPTzCN+tRwXZ7CGUsrFvCHtSlh0nk sHU8jZcCtrRQO5Ljbbm7KOfQZltyrwKXCT/xo/CWlhLu9DLyRL0rfuA2fTFeV+JKUm7FEEBaV0972 lnWwfxK15CoEpvMUp9nuGPTxWNsWNbrcsYongV4qhHcTWmAc3fYccTitRt248escxK+suL8GqnB2C 9JVYMGS0ny5GVKHDbZxaiMgoCN0vyYFAMAngl8vV1VSeiBjTPSaRMtkR4ejo77dMZ72tMhWTceF8C LIhA55Mg==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSjn-0000000D6MX-1iHd; Mon, 29 Jan 2024 14:35:51 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 13/20] xfs: don't allow highmem pages in xfile mappings Date: Mon, 29 Jan 2024 15:34:55 +0100 Message-Id: <20240129143502.189370-14-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: X-Stat-Signature: f3ki5uiqc8ust65ius78b8ikwfr4a91a X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 07D481A001D X-HE-Tag: 1706538953-206814 X-HE-Meta: U2FsdGVkX18fQBUDIG4E1dbxOFSh01ZXDYJYLGLob0QxPC/qL5JX7N4h3pwNYKKTVvuintQer4s1MjEOrpYZjfHZu41WhXbMQdtvCbcGUjzNvWHVslfRFSCY27c0V541jcI7LRniXdZwmfXFlSruXXfqgBnVVaXpnJMe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U5buxg83cawZTSUH8ohCJvDAteMjzJRhS7WFzB0ZapOqyPwu7X4ISA59gSYMAHcrxpT4dfCxQeiiXeSDz9M7lf7+84zTD62DpClvUfHvHhvv3KuwoVZ2p4SKAOQYVUrE9basadunwb7L0zeMIbfKl6+kfcsL/8EylyDzV8IYhI0RXUiqDMM9YD4np3dmIgGpE/dG/ApggdEPX4Tg== 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: XFS is generally used on 64-bit, non-highmem platforms and xfile mappings are accessed all the time. Reduce our pain by not allowing any highmem mappings in the xfile page cache and remove all the kmap calls for it. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfarray.c | 3 +-- fs/xfs/scrub/xfile.c | 21 +++++++++------------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/fs/xfs/scrub/xfarray.c b/fs/xfs/scrub/xfarray.c index 95ac14bceeadd6..d0f98a43b2ba0a 100644 --- a/fs/xfs/scrub/xfarray.c +++ b/fs/xfs/scrub/xfarray.c @@ -580,7 +580,7 @@ xfarray_sort_get_page( * xfile pages must never be mapped into userspace, so we skip the * dcache flush when mapping the page. */ - si->page_kaddr = kmap_local_page(si->xfpage.page); + si->page_kaddr = page_address(si->xfpage.page); return 0; } @@ -592,7 +592,6 @@ xfarray_sort_put_page( if (!si->page_kaddr) return 0; - kunmap_local(si->page_kaddr); si->page_kaddr = NULL; return xfile_put_page(si->array->xfile, &si->xfpage); diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 7e915385ef0011..a669ebbbc02d1d 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -77,6 +77,12 @@ xfile_create( inode = file_inode(xf->file); lockdep_set_class(&inode->i_rwsem, &xfile_i_mutex_key); + /* + * We don't want to bother with kmapping data during repair, so don't + * allow highmem pages to back this mapping. + */ + mapping_set_gfp_mask(inode->i_mapping, GFP_KERNEL); + trace_xfile_create(xf); *xfilep = xf; @@ -126,7 +132,6 @@ xfile_load( pflags = memalloc_nofs_save(); while (count > 0) { - void *p, *kaddr; unsigned int len; len = min_t(ssize_t, count, PAGE_SIZE - offset_in_page(pos)); @@ -153,10 +158,7 @@ xfile_load( * xfile pages must never be mapped into userspace, so * we skip the dcache flush. */ - kaddr = kmap_local_page(page); - p = kaddr + offset_in_page(pos); - memcpy(buf, p, len); - kunmap_local(kaddr); + memcpy(buf, page_address(page) + offset_in_page(pos), len); put_page(page); advance: @@ -221,14 +223,13 @@ xfile_store( * the dcache flush. If the page is not uptodate, zero it * before writing data. */ - kaddr = kmap_local_page(page); + kaddr = page_address(page); if (!PageUptodate(page)) { memset(kaddr, 0, PAGE_SIZE); SetPageUptodate(page); } p = kaddr + offset_in_page(pos); memcpy(p, buf, len); - kunmap_local(kaddr); ret = aops->write_end(NULL, mapping, pos, len, len, page, fsdata); @@ -314,11 +315,7 @@ xfile_get_page( * to the caller and make sure the backing store will hold on to them. */ if (!PageUptodate(page)) { - void *kaddr; - - kaddr = kmap_local_page(page); - memset(kaddr, 0, PAGE_SIZE); - kunmap_local(kaddr); + memset(page_address(page), 0, PAGE_SIZE); SetPageUptodate(page); }