From patchwork Mon Feb 19 06:27:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562217 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 69902C5475B for ; Mon, 19 Feb 2024 06:28:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8190D8D0013; Mon, 19 Feb 2024 01:28:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A2798D0007; Mon, 19 Feb 2024 01:28:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F4D48D0013; Mon, 19 Feb 2024 01:28:06 -0500 (EST) 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 429F48D0007 for ; Mon, 19 Feb 2024 01:28:06 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1498380215 for ; Mon, 19 Feb 2024 06:28:06 +0000 (UTC) X-FDA: 81807573372.12.563F8CA Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf25.hostedemail.com (Postfix) with ESMTP id 9D05AA0009 for ; Mon, 19 Feb 2024 06:28:04 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=l7PjhVSO; dmarc=none; spf=none (imf25.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324084; 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=vMzRny256EkGSWXtzu6dkmMncaSoQLHVAAjTF+P8DPU=; b=1Y9jB9js3daain7z6CDj9+ePKaCUX5EEQoFkjIP+i2HI4fDn7w29hw6LToNCK98p2hLGvr TyOzi9AwXLjXpKFrtRAsHjzqSS9LTIrMdd37WNEVhNylJcsG3sIf69Wb8Sxj8HgkV/nOcc ipU+itakdtLsiDLRCH1FgZBucJIIM/Y= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=l7PjhVSO; dmarc=none; spf=none (imf25.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324084; a=rsa-sha256; cv=none; b=KL/+auZZkNgNCigBhecmN7AXmytwEj0Rf3qLAGqw/se3hVBboTXenwSHo1MTbSrbDoMpNu Foc3M8i6CzrMbMyi6cKDeC1IN/pBXjAUb/C0ZMXWvUK4apMUFmc5Dqq1UvBnZ8l1nuOXU4 ayH0oab0aSGEWaifa+oaax4wx/kWiyE= 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=vMzRny256EkGSWXtzu6dkmMncaSoQLHVAAjTF+P8DPU=; b=l7PjhVSObLkfcFoqyT6zY51FWo 13Kloz7QLofMNe0OIsIR/0qVXE3WbIp5jV9zl1I3LG3WVI9ekTkreKtlRH59ecJQO2RXyaFMcNKcK FznVdfnTKaC9yqaH0ImYO17FuUHECDFQjhmEEmiRh/8gfs62BYynfCCSMmaBg1z/RgmcLSrC4iilT YFo5kbXNiW88gPCpO7YaTbesY8BXgM3OS+eiUkPEj+YAboum47aRQkucmi/zdx+k+tOeuBJOpj1Hp Av9yzSMWXNX2woXEb0JM0mcnFwEdK6dTzafn/t4DYeIEuLAyAUeC5Y4/OGiv0AuX63sc/3NIwjzQ3 H07cnAtg==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx8D-00000009FJ8-1eHT; Mon, 19 Feb 2024 06:28:01 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 15/22] xfs: don't allow highmem pages in xfile mappings Date: Mon, 19 Feb 2024 07:27:23 +0100 Message-Id: <20240219062730.3031391-16-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: fix6zrqkbrexytqgrigk4ike9kawgjs7 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 9D05AA0009 X-HE-Tag: 1708324084-156209 X-HE-Meta: U2FsdGVkX19dYazq19CoYwfxhKNCMzbTISEZCtJcTEnZf6n/t/H0xaHAGrHXy9w+L9U2yAlnCfQG/iYmGxtRAd2w+JQCCjiFzuU+b1R686qiLc936ZFaZZc3ALLu0s8E/b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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 4ec975977dcd4c..009a760cb690a0 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); }