From patchwork Wed Jan 3 08:41:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13509726 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 0B975C3DA6E for ; Wed, 3 Jan 2024 08:42:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 925168D003B; Wed, 3 Jan 2024 03:42:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D69F8D0035; Wed, 3 Jan 2024 03:42:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79DCE8D003B; Wed, 3 Jan 2024 03:42:25 -0500 (EST) 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 694DA8D0035 for ; Wed, 3 Jan 2024 03:42:25 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3D7BBC0673 for ; Wed, 3 Jan 2024 08:42:25 +0000 (UTC) X-FDA: 81637358250.16.868458C Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf03.hostedemail.com (Postfix) with ESMTP id 954E320003 for ; Wed, 3 Jan 2024 08:42:23 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=AEOGE+RO; spf=none (imf03.hostedemail.com: domain of BATV+f852f126c6d693376302+7437+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+f852f126c6d693376302+7437+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704271343; 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=2KE1Kh+ZAgxqJkjsL++Zam+feO4h6BGJKXIVU+dtdSs=; b=MNEVJTV9eSqQe0o9/kpmZKptJMLYFC9ywRnbymhCU+9fWEj2wRIvTnbj2jM5AkB/SAI8ct 9ghvKmJi31HaXszDMF0QhZppHupEPCHC/TVEk5IpIHdfyH1LeOGSEqHn3/htDmo1lO1YnV RFnH0V2yaxfgH3tJRN6ajzBeCBoey9o= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704271343; a=rsa-sha256; cv=none; b=t8S3oT8DUOgoZ5XNzIz/l7ebJG2KVoRB6jFTlNjW3ecCIS35TpRGxG3UzGXi/1ttI/dQGz mNCLrTR0gNCJ3VoPc2liKszPf5RmUuVSCeI0692OJrdcuwONlNNwXq6lzIUQyq5QgTHqO8 t4KI3OPnFHFlEGhm0kRRVwuxR1Y3khw= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=AEOGE+RO; spf=none (imf03.hostedemail.com: domain of BATV+f852f126c6d693376302+7437+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+f852f126c6d693376302+7437+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none 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=2KE1Kh+ZAgxqJkjsL++Zam+feO4h6BGJKXIVU+dtdSs=; b=AEOGE+ROrm/TD6OfiPIJrXkOEK HfbsUiSffAfnMAir2ck8taGTe3HUcvNa0iluN4fBMlu4zoU13e4vFL5USf14JbdYS4kA7+UhQNn5X rVPDivxjVH4FHdcanzUmnFSJdFBxCyxVg7Leemv3G3Er5j2Ho/Bn2RqsLGLh1JdLVuT9LdDALipvW vnCLyUjM85qLbtiEXuLZ2FyaT+PuGqOl1DusLhtk+gLJO2CA7uH0Qc2mPvzxQrrXhaM7SU1h6rojm 21AtHUTi1DZ9xhxI194g2fME96ND+ZsV/OsP5B09kEGvW9xqm1KPps0Ao9v2E6zv11j6bR1Y1YLx0 3oISB21g==; Received: from [89.144.222.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rKwpO-00A6lI-0G; Wed, 03 Jan 2024 08:42:19 +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 09/15] xfs: don't allow highmem pages in xfile mappings Date: Wed, 3 Jan 2024 08:41:20 +0000 Message-Id: <20240103084126.513354-10-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240103084126.513354-1-hch@lst.de> References: <20240103084126.513354-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-Stat-Signature: hium7xp5tzk9zb9fbhw6c4c96wz4esqy X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 954E320003 X-Rspam-User: X-HE-Tag: 1704271343-637783 X-HE-Meta: U2FsdGVkX18ZXanju2iJefAGs6T5m+rNQqkbDCCgrZclgZ4kJQbhhwEYwyMUPTOtAXInbPuViS1Y87QKUSfROR4/q/QQcE+X8p4HvuIQ8nCDb0QSVKVi7iAy3EAeDw4boLZh4MTXmgK9e6EB1AMaW2Zl3XuZacWZ5f9/SMLguU6ZABkrLDolkxfjDrwz4ng1KWOqoO2ixPML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R9R9ZSQFsSQqHN5WMVN/FNWgEAouRQHFmX5bAOM/rcmsmmryKVTUei/qGHMm7aIFCKomZVkyqHfkgXoqqC8NJj8r7w62NX+8m5MqO56P8FhSI 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 --- 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 f0f532c10a5acc..3a44700037924b 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 e872f4f0263f59..afbd205289e9b0 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_HIGHUSER); + trace_xfile_create(xf); *xfilep = xf; @@ -126,7 +132,6 @@ xfile_obj_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_obj_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_obj_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); }