From patchwork Fri Jan 26 13:28: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: 13532576 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 86D90C47422 for ; Fri, 26 Jan 2024 13:30:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 22C7F6B0088; Fri, 26 Jan 2024 08:30:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DC666B008A; Fri, 26 Jan 2024 08:30:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A4F16B008C; Fri, 26 Jan 2024 08:30:10 -0500 (EST) 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 EA3E66B0088 for ; Fri, 26 Jan 2024 08:30:09 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C26FDA0FAB for ; Fri, 26 Jan 2024 13:30:09 +0000 (UTC) X-FDA: 81721545738.13.BFD8AC7 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf28.hostedemail.com (Postfix) with ESMTP id 46C48C0013 for ; Fri, 26 Jan 2024 13:30:08 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="QHu/d9AT"; spf=none (imf28.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275808; a=rsa-sha256; cv=none; b=QRNcLLxU02KZuShfxC7c7sG28TxMdIFZqYvREqLKk1QoNC37Arm7fOxjPjuk8wNYeqs6v0 Xv8ozFKdeF/BM3TOUY/D6jn68q8sCYsNqkyyD+zJsS12dvKtvfHCfA0BBCu3XH6imp9FaQ NewXv+KW4IN/IiWnqlC9S/wnYz4XaFs= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="QHu/d9AT"; spf=none (imf28.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275808; 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=sf3jM42VSS5lq6M4a06uH+ctEmnHV/8RQw6R+NlmD18=; b=RbNO9+0pfJQCo1Jwpz18zOV2nnV4IHyFt+/befLhMSnqzFXWP3Am7XbES7ZsJl2IqvmGk5 E+hEahY7TGURcHYyJ/dSOSWWGniSEFwrYRi+4p90tkX1NREJl2UOlxnFAVrqwJ6VKDY3E9 UTqqiZY+Ta1ctM0AQbEqNGzjAc68YzM= 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=sf3jM42VSS5lq6M4a06uH+ctEmnHV/8RQw6R+NlmD18=; b=QHu/d9ATjk8ngW++aVNk58xD4m WCtoflSjasmfKaq9+PwqNFLLqo7o6ZDNehgioZY+k2QmbbAR8fSLNMe8JrDsHbPNifQkdSHIoPHA1 abMYA2YfBPIISehCz4grqvAEv0Zrcb/of7nNML1rnosa6VeuWRG9QrmKBtEuUyMMVLf1pZgxQ935+ fcAMlMp/eUh0/leU4UpZzFsp2xW8IVs7KZvMC9WRV7f4qqgDo9odHXSKiDRYd5tQ4qNtbmmak/jQj lHG9sCYLL/tJXIyIdCJNLvLf19Jvne4AdmQ7tW0zo+zaqE3gjqdEKE+6JKIcE89Uqqg5CssXRT/l5 fnsrli/Q==; 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 1rTMHV-00000004Cq7-29PL; Fri, 26 Jan 2024 13:30:06 +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/21] xfs: don't allow highmem pages in xfile mappings Date: Fri, 26 Jan 2024 14:28:55 +0100 Message-Id: <20240126132903.2700077-14-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 46C48C0013 X-Stat-Signature: ndeociq34pedqohdtkhfz391a1w571tg X-Rspam-User: X-HE-Tag: 1706275808-371743 X-HE-Meta: U2FsdGVkX181PhhBNmcY6PdvtLE7Bk1+T0zuQKxFzyPuSWb2C8eTZqG+c6t6z4YTfHNZpM4VWuZBLcCTkLXVrfKGj1+iQABXKe3m0KxXC54WdMnO66E20d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.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..623bbde91ae3fe 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_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); }