From patchwork Wed Jan 3 08:41:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13509718 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 5FC0FC47079 for ; Wed, 3 Jan 2024 08:41:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E817D6B0327; Wed, 3 Jan 2024 03:41:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E2DE06B0328; Wed, 3 Jan 2024 03:41:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C57E96B0329; Wed, 3 Jan 2024 03:41:44 -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 B58ED6B0327 for ; Wed, 3 Jan 2024 03:41:44 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8B0C38022D for ; Wed, 3 Jan 2024 08:41:44 +0000 (UTC) X-FDA: 81637356528.16.99B8A51 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf15.hostedemail.com (Postfix) with ESMTP id ED881A0017 for ; Wed, 3 Jan 2024 08:41:42 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=D9eZc7RV; dmarc=none; spf=none (imf15.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704271303; a=rsa-sha256; cv=none; b=xo1QlP67nTL0RQb8HK9rm2vofOsTjPkHImFn2K6FDsvhqWgx0Ti7ZDErSwHOQRhbsvwwGD gcaHCHAthcv+ZXvh3PSwRawOUi0/+nh2ThjnqxHJ51HWBG7WU0P1JYOQed+oK0E0lHoTUt D/tUEJVgE8ZN3MmvNzv/yHNgDwAjHG4= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=D9eZc7RV; dmarc=none; spf=none (imf15.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704271303; 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=MnEk4kJaE+n+b3v1j4i9S3VKDanv67ejVN4lnTe2Pcw=; b=H8j9B9GxHX6rCuXb9yMnc7Nyc5GN5K4VAMRgu1QYu6/fyCv4rqVjnCdtQSGKaCyVk4/DWZ abS5zze55wbXpHHdWx6tqzawUpmMkeeO9Sl0LzfQI4WL21jUhkzi9kWcjeYI7h4Umiouvf tKmXtST/d64BP3OrFyMv68Gssof4qFQ= 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=MnEk4kJaE+n+b3v1j4i9S3VKDanv67ejVN4lnTe2Pcw=; b=D9eZc7RVxxXXOXkgoj7zZ58Fl0 jMw2mz7+rfptKsKGD2aMtn4h2BUSroL0SOyvQ/wIomLgwWbFAlMztnWTc0uKonXjwdsaB3ObGgJW1 hvFV+kBeNG78FsfdgR9MYcsJFW9ssjZRpVhKYz/54DGPEF53EfXnSnl/VO+vZ/vRrR+fi9m5Er8W6 JWo3lelBuE2aKxAETb4bvr+f+lyoSO0Pw6asoiRKV/gaasS256KHO2aMX5jYNBWPg0JUl7w1bhHSH q/QnhPhcZPaClOC8i3T5qgcJ+N4L/tl4GbrVW3otEMtx6boSodtS7BsbP8ro8gr/p81k9i0f/jJe/ hSkg/fEg==; Received: from [89.144.222.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rKwoi-00A6WW-1d; Wed, 03 Jan 2024 08:41:37 +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 01/15] shmem: move the shmem_mapping assert into shmem_get_folio_gfp Date: Wed, 3 Jan 2024 08:41:12 +0000 Message-Id: <20240103084126.513354-2-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-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: ED881A0017 X-Stat-Signature: p6hy4gjt6b1huxy3gzt41ki4fnj6woiy X-HE-Tag: 1704271302-993968 X-HE-Meta: U2FsdGVkX19CdTp6jL/wl74VVdG+s2xA3aAD/1oN7ySA+pXXE4Dv0KDJUUpG1W2akm+EEjOV5X87Y42uBx+1oy2BJ61+vt2LzPwp53nUJukuMWE/4TN+MPHiDlyWDMp33aLSbYmLaquRWR+eSgaK0+sb55R10i00hRn7R/iZzS6rVe5O5hgSm2VdViwEVSWs/WdEg8tEJAPA9mmD5K3h+epMyajUwtGYPT7JtHJO0/JCesg8v2frZhmy2o86xYA4Dge2HKfz3UGfCTH82QYxwCuoAIxjuJbeDuJ8r3oqsF2Y2Hx47soVTbXHkIjV+82TgPEdxoYCbkEiA5IBjDopPAc1sDuNk82NzAVgpTQFZqrIGPGiWdDLZN3GxPtgyEGQqy/XON7BX/9aydVedYwLIxcXALWezNS8plGEixAOIEs+Uz4Bzv3BP1+TwuNm7IZFYGuh9nVujmmuM09BWQ0My3/WEyAgIJhmR/6ReBdwIzVpKp/S0S3q1+SLWDt+KNqA762F/6fb4784xz418BC6emOGptNzDcXZ1x+RgLq3PaX/lt0UIdOdeKSwGx4jlsxuysx+TZ1kJCBPhZFQNv25nErVnmXGBwKp9VkDIem+zqOeRej7XBeqceAPCLD22QqBzjuKB2kgaG+mtZOOp3SgUnbODrlN9JNQsOmkOTeJbCCxRhPeOsBNZ533fKf1dqWwGAzxKjM1QOapJQupuaRsp5xs4OBohHGW1BiQzpsKDB8y1i0JO973D/uKrfYd+3y+Tf2JIOVHYTF6mgpntAsbfwTymME9LubxufsoIULMLhicT8q7OnxgC4C0lQu8bbmkgdJMGf+CfPdR3sbNeoT/Mva3yzyj7jFit+qqIPjoGSnZZnZMdBvpjYKSLrtXFPbWyjI0YVRSxRPAnQRDJ6/zeKKcye2YRFHmPTaz9dZ6KvixY46LS16Rw7ctuvO7BgN8U20eCoIfas2bY9M22RP lxSHKFix SzJBZLw53Jdskykkmc8v5GjTtK6unxMONKDDDlGAifmgDVCMZGUMgYI6VEZ9s5qr6N7JF7UFA0FZdnXCWDScjCbuLEN0g0wfe1pNTttPNyxdw2DCfu2HBFsB6cHtLqpyzUMgGLlXW/48NJk62Mr4xoN/egwVcJ3JuYD2JejT81gPFAYdku63ODoIwqcUyl+na6TdtVJPU4Y1R3KUk4nGFAtFsu+4cBUyGEz4/XSXzK5mCKVCyadRQt6vccjNkkj5sXO4VLaHRG6J7tafKp5CiDpJ0XQJcdtI9iEBgjB72FYrWM/AgA0uPeLCMFTtqGwxi8AMa8ke3hoeh9pFm3530Ja84i6YTsWbQdSpqMJFQ8iKqTsUVoJqEES7aEEWewSWn2UPIjwiX1yX8PqYYM/9DlGrne9hcp+cW8VLgBCTh9DVjAvVfy5MaoT9qnw== 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: Move the check that the inode really is a shmemfs one from shmem_read_folio_gfp to shmem_get_folio_gfp given that shmem_get_folio can also be called from outside of shmem.c. Also turn it into a WARN_ON_ONCE and error return instead of BUG_ON to be less severe. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- mm/shmem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index 91e2620148b2f6..3349df6d4e0360 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1951,6 +1951,9 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, int error; bool alloced; + if (WARN_ON_ONCE(!shmem_mapping(inode->i_mapping))) + return -EINVAL; + if (index > (MAX_LFS_FILESIZE >> PAGE_SHIFT)) return -EFBIG; repeat: @@ -4895,7 +4898,6 @@ struct folio *shmem_read_folio_gfp(struct address_space *mapping, struct folio *folio; int error; - BUG_ON(!shmem_mapping(mapping)); error = shmem_get_folio_gfp(inode, index, &folio, SGP_CACHE, gfp, NULL, NULL); if (error) From patchwork Wed Jan 3 08:41:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13509719 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 51A9CC3DA6E for ; Wed, 3 Jan 2024 08:41:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2F458D0034; Wed, 3 Jan 2024 03:41:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DDEE26B032A; Wed, 3 Jan 2024 03:41:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CCE4A8D0034; Wed, 3 Jan 2024 03:41:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id BDD036B0329 for ; Wed, 3 Jan 2024 03:41:48 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8AC55A1289 for ; Wed, 3 Jan 2024 08:41:48 +0000 (UTC) X-FDA: 81637356696.19.549A74B Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf03.hostedemail.com (Postfix) with ESMTP id D01522000A for ; Wed, 3 Jan 2024 08:41:46 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=XniNRlGp; dmarc=none; 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704271306; 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=JlH8UoH4gf0aBQ2yCBHbzkzUIg8ZGDdici8nR6/XNN8=; b=Az7HhHj+S0CeifASTHzBNMdjsO2or9yDSCQ0typ3XMQdhuXmVv1aIpInvmi4KtwSxneudv 36wPqhN3Fr0d0ej0CJbTvOl5xEVAERQ0Lz2P8umiQ3XTz4+Kqkhp1oVI/DyQmfzjsQJgQR 2w/cwUUHWrNkJHukuPHhnlKHr50UgYA= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=XniNRlGp; dmarc=none; 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704271306; a=rsa-sha256; cv=none; b=e5RMhxoZlqswgkbdxdXZBLbOmpOyQUR0iW7Ax//IuBRChJBt6Y8s2sD2wrQprwnl81T40N 6vpx4YJ7atHJc8r9VPw3fknG6kU/u4DFUKgKXX5lPkh/mYNP17K742NZOE5F+vm0w7vAG4 Z1s29KEZMoYzATTYXrsOKsBmB/PnV/M= 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=JlH8UoH4gf0aBQ2yCBHbzkzUIg8ZGDdici8nR6/XNN8=; b=XniNRlGp7AkbZwALFoj2xvXQnH vPjeUfHlMb/q3zWmlZnIKQd2+AhipEq0AZ6VRzSPPbH4l2wvCPEMVQr0UsJxiri77g/VS34FQSX1g dqGZOGTTWh1fIa1XiGqZ8nADwC/L5Yq1PgFG7fQq650+EypgpZITgP2HmrqKmQW34myrNmhghWcrO vPH+ufeoy3igPt4HF8hdf8dvxVi0qWJR8/hCnwMS0IKq3NFrXsekcarEER0wl4iGHtcVOWkZ8rahz tyuiw6lyqNOWyU4JmZU2z5COeDjvufmF+I9E7j8rpm1wJgxv3NNducuerNKI09/fVpdEh6zprmnTA 7Ic53zBg==; Received: from [89.144.222.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rKwon-00A6Y4-0n; Wed, 03 Jan 2024 08:41:41 +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 02/15] shmem: export shmem_get_folio Date: Wed, 3 Jan 2024 08:41:13 +0000 Message-Id: <20240103084126.513354-3-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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: D01522000A X-Stat-Signature: fu3aebjkghtku5q8txt5ye55tqjdbb4j X-HE-Tag: 1704271306-851001 X-HE-Meta: U2FsdGVkX18rSuMzGClD0GJXja47IIZK18fxDHJWpbUiH52ErcO16/Osl8TeR6Djd6ZTDtWH4YQ/a2cmCbhn5O+p7O3bAtbmD1ZPyMOewZPcsolwK/sE622nI9DZLVmmaM7/mmWr/jn02p3SsdKUjB1r8V9Dn2+/PgQPQMtOEExWvl0tIZWeAIT+OGMegD8A2n8QUD7yupFcDBzfzM6CitBrPcvyDGcSz8pMPDsvIuW+zTRstoJnqQck9voQ1uacQhZaUdoQqMoNJdGRny6BNuLVor3mSTHorJIIj8jhRwVoVHFVGwUDzhcbfk1deD3daNSCMZl4TEANNeclyuVYnFDWZO4CAVuUkDafWaDOjdmLM2GAcAgu3KU6MVQrZZ7fwvzF8tuuGxB0tRxsQHvxk9dDqnFdAPbIOMNJ5B1YHzo24NFdxYLETHSCRetS6adXqUgcOb38rE20XzkBgWv6b3QMA0hVS/rP2eO+YJzqdEqQtgNxq5lDUJuZri4tilxh+Z8iBsaSD4X1j+KMa2bRZO+NZeKEKGZFq5uY+xZVjQnMdKUtqYoNcC/HWiQVV+0NmNaGhXO07o+qgFnlNK123nirIbpJxKTObovOX9nY3ZOayLn2/U/yCcY4gRkOfJPLlBGqrYSfzKHn7aZreSgBaW/nuCjCTdRqMk/9GxH+htnPn3EW4kuaWOXRpQQCpO1YKcaMXooTfVsToRTf9I4oC0vdaUDPIVZ2yWrr0fo6J4HtplcZXH6FVi3qXScS5SN+dlHmnKDKieQx9KYp2VelpS9KFxmGk3pgWz/fx7VqhbAY6+MJYGqQ6jXqMWPoO0ubd/d5Z1Np6KmVNrSUIPuqJKT87aOyZDJqRJ6O24EqlRE4clLMbtJpgPsQUK1ZctLJ3kHkNIQ0mGDGT0p2KtY5Z93oyA5UmAsHhEMgJVSGaUVjCPc2mKW/j54C4esuh3Rrd6R8Qv6hr3T3tZafKMU faSxtgp0 oJibLw/PoKeyeBursundlw1dqXpFVPf4GhmKi/uEeR4ofYXR0vHlzx3e9RZPndEb6gqfpcSdUnmvnlaJhh1n3nE+QPUq+DCi7+SG6rcSin+I6GVh22xT+x7Nuog33ukpIgkQKi/NdsczqMvPhXeK4Kpm9h0jBpMhsHi9FLiTC0adAlQlqsFvLHlIDVZo7RRgNGbmTbdc41XTOPR13SOATaHGO7c6nEpZSitBdY1Xxofv8CUixEI57AEZeds/3d5ouxiFK9QOjCYY3oMadsPnXU51sBDMCxPLJFQZjwVcISom1CH3sP6hl0PX4h/KdZKMqvrlodCb7Kh6HlWEWngJqdSnSp/tasvz7/7GGHDF1wTbuyrp8p6o8HSt5g5WjTkTp4UQVB1fthMm1Cpwt55KkezlHDKUujKUzoUqzAbG/HF79BdqHvn0qkuVbxQ== 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: Export shmem_get_folio as a slightly lower-level variant of shmem_read_folio_gfp. This will be useful for XFS xfile use cases that want to pass SGP_NOALLOC or get a locked page, which the thin shmem_read_folio_gfp wrapper can't provide. Signed-off-by: Christoph Hellwig --- mm/shmem.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index 3349df6d4e0360..328eb3dbea9f1c 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2116,12 +2116,27 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, return error; } +/** + * shmem_get_folio - find and get a reference to a shmem folio. + * @inode: inode to search + * @index: the page index. + * @foliop: pointer to the found folio if one was found + * @sgp: SGP_* flags to control behavior + * + * Looks up the page cache entry at @inode & @index. + * + * If this function returns a folio, it is returned with an increased refcount. + * + * Return: The found folio, %NULL if SGP_READ or SGP_NOALLOC was passed in @sgp + * and no folio was found at @index, or an ERR_PTR() otherwise. + */ int shmem_get_folio(struct inode *inode, pgoff_t index, struct folio **foliop, enum sgp_type sgp) { return shmem_get_folio_gfp(inode, index, foliop, sgp, mapping_gfp_mask(inode->i_mapping), NULL, NULL); } +EXPORT_SYMBOL_GPL(shmem_get_folio); /* * This is like autoremove_wake_function, but it removes the wait queue From patchwork Wed Jan 3 08:41:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13509720 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 A074FC3DA6E for ; Wed, 3 Jan 2024 08:41:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E61D6B029A; Wed, 3 Jan 2024 03:41:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 21F1F6B029C; Wed, 3 Jan 2024 03:41:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A2A36B0293; Wed, 3 Jan 2024 03:41:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id EB9416B028F for ; Wed, 3 Jan 2024 03:41:52 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C7E361C08CF for ; Wed, 3 Jan 2024 08:41:52 +0000 (UTC) X-FDA: 81637356864.23.7B24F53 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf16.hostedemail.com (Postfix) with ESMTP id 3A61518001C for ; Wed, 3 Jan 2024 08:41:51 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=lwuKokl9; spf=none (imf16.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704271311; a=rsa-sha256; cv=none; b=y/fJjY2BGhuD+N4EegNETvkvvPHKYzT8n4izNGF1I9QR3NPR92GqDvBHcIqP57hJEJahHy gi3udYi4dT5BHoUbbTxw2QuJnlEcRLQAmaXi3iDgTJemzMN+3JQz7QbN8w9Djpcq1EACZU s/5+UFaAM3HrQ0PH4S/MK0oPyWT9BDI= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=lwuKokl9; spf=none (imf16.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=1704271311; 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=lo04JMqhsFGkQ8TlRgHQOmhRNZvE2v0cppmArCUs8rY=; b=mJbZ8xzdPg2BjoOi9097ixXd8LBCbWMrLzUKN/VVDjGAwSY0m9/aOENxBjqAjgcZ6hj1QD H2ubn9MLpr/A+bqafN/lEWTxvHeljdu5HDLv3ExUPRx2/IJUMBeJ+Kt0M/atJ/69jpZUzX CIsEeZPC5ya/sL4K4gwa6ZFCOUZFvkw= 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=lo04JMqhsFGkQ8TlRgHQOmhRNZvE2v0cppmArCUs8rY=; b=lwuKokl9u6QXkYesoWSmuTt3UM 28rIQJEb0WRqGFlb4Uvq1J6D6VRwtf7PQ0nPrU3NIuIp277ZHrHJ1PMbR0r/rU1GgTzu+NOeSFjzl fFdobPKyYC7J6D82wluQHy9jQcPXz9GG77j49J8FiiKSTtzLknJhoLprAerz59Y7zb+eJV52dGWvs G09csf6c7y1coPI9VcSuLeofiCD+iu8I9Zb2xlGSx/MfWcccYiTw7t0Cny0uaVK7wySSMEcVpMfXE Bp1Svfq81sdy0WIl5WUrUr0asyTG/+SZY/jGo8mKwa2NPojfx9cKBlYyC8pvz/y1x1XoyMFEYrdud Ja8t42fA==; Received: from [89.144.222.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rKwoq-00A6ZS-33; Wed, 03 Jan 2024 08:41:45 +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 03/15] shmem: document how to "persist" data when using shmem_*file_setup Date: Wed, 3 Jan 2024 08:41:14 +0000 Message-Id: <20240103084126.513354-4-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-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 3A61518001C X-Stat-Signature: sm41pqebo87eppgbwcoujhx5tzcxg13g X-Rspam-User: X-HE-Tag: 1704271311-947593 X-HE-Meta: U2FsdGVkX18Lc6U1n6JQDGe65OHbsshpDTfAnRl/eQOcvgk0rrq27jhnX/bafk91Qld/CYJrLqgVrY9xFWBLju1dX+G2wve2UgFnasLjpEXEgPlst+IRsnTrzIBVPsnJdYU+Ic4W6/vNIqQpXLaegn9i6QEMUuk6LfUIZOKHuEdNujpSRhNEAm6O6DwynKD/9NwZ1Q66gN6Rb7aFkSbikde5uOyHQSwF7mNgV6f/Kc/1N4PI0BSX5KL8ANz3zmMMGXXrZ+3r+2bmsqVchHXqv2M1NtVxcBhcYmDLuljM6mxlj/xTqV2M0P/ePE1t76s8HyK7ao1AWYILoE8uosKnpuhyUD6bof/wSgysE1D7Hbn8xq8c+CpKB4WlXAc8HM/xWaTN4e2NCNgFN7zLju5oCKa84e7esz1yryjTTZpe5V/gZ25tUrpXWnZj4bGGJ/1tRHd8iHs4O3r2LQjlYgvKSKJjgzUYpC1ZKCIIekYVnTtM202U3rDwU76ia86nueOrAhB5cCS2O1Je2M26XOCYeo5lIJQuVGm54DN6iNp3ynD+7Ct8MK1tTcQLpT+8TJX7E7JG4iY/canyCegyLkxbhVoawJIqCZr3lE94z8VzswqdVO41xlm2/tpin2wC8Ewqj4Jb/iqpTw2SlS55Q0ofyhoexK33SerGtAzpPMakP/N+tX9EMW/7hq8tYQR1QHoZYFR1e4DGnGerb8yEXb7PZgdZQcNs8ll7qn+4VcCy93ojrxlLKdICdHDdURedZzrliskuvFeg9mKk+yuiB+XdScTmvr1Sc5GnVn9Oxt3tBBywc9tZz703ms6ZBOaVlgnvy5c4gT31W7gbD7izaXczMMfQbh49pcTXr7Sw90r1yh59rOz8WjN51x02kFyguBDrFyFUG7ynGxZ73aZyaZIkjab6HiRXpEAgQhCFcD21YeBxqa6bwAjimArQmBl5CTtOD2e1RYta9Ih7dCZlarG lDLKapq2 oTeY8cXmHYqRjFCZitQxPTtgvF8+Lchm5wWli7HR+qdDHXM6rfNCAX1PZl4i/kxXo0hceL9C6rFn5bIXF5p7BIB72Ap+cXd8ZnGGHwEgJLeEDRGCJtgMcp5NSM3AX/63QN2t6DmyqEWz7wdIVsIieOiEpfZ6IWu8J/VDVCDQcv8cE632PJehy+h8JxRS6cI/6AvIaoeSf2wvoVzPFunHrknXL9DF5w7PdNADUMIE1XG+IFNUL2f/xVC+fYEGlRZB0yHWxvET8CXXlRgqVjMPrs5NzRCKhsbPH5F8ZiE4VxGJ1OX5sh1y9+gVLc303zeXLZJt92VfX8IBHjpEeMjwWpUn2srEIKQLHk+UQldgIAkX4ovyJ7iAqYkCwcLeBClvtPIH1WLRtq52Pxt1i7MsNTFfwGEO75l14BbAq6G4rFoMwXQS8ykCpdABsGQ== 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: Add a blurb that simply dirtying the folio will persist data for in-kernel shmem files. This is what most of the callers already do. Signed-off-by: Christoph Hellwig --- mm/shmem.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index 328eb3dbea9f1c..235fac6dc53a0b 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2129,6 +2129,11 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, * * Return: The found folio, %NULL if SGP_READ or SGP_NOALLOC was passed in @sgp * and no folio was found at @index, or an ERR_PTR() otherwise. + * + * If the caller modifies data in the returned folio, it must call + * folio_mark_dirty() on the locked folio before dropping the reference to + * ensure the folio is not reclaimed. Unlike for normal file systems there is + * no need to reserve space for users of shmem_*file_setup(). */ int shmem_get_folio(struct inode *inode, pgoff_t index, struct folio **foliop, enum sgp_type sgp) From patchwork Wed Jan 3 08:41:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13509721 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 C034DC3DA6E for ; Wed, 3 Jan 2024 08:41:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DFF46B032D; Wed, 3 Jan 2024 03:41:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 441D48D0035; Wed, 3 Jan 2024 03:41:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 309FA6B032E; Wed, 3 Jan 2024 03:41:57 -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 1F0F66B032C for ; Wed, 3 Jan 2024 03:41:57 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E279A80226 for ; Wed, 3 Jan 2024 08:41:56 +0000 (UTC) X-FDA: 81637357032.09.8E36DE3 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf05.hostedemail.com (Postfix) with ESMTP id 51E9A100015 for ; Wed, 3 Jan 2024 08:41:55 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Wr7P7dZc; dmarc=none; spf=none (imf05.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704271315; 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=gccidn5f1g0i1fYsvQcyie7MyTTk/hQFlVMXwFY3vVk=; b=2ZaP8CBr23Wkh1aXpdqXd6ghvgmDfnnFokMfTkyih7tUDd7ehPVTrAQqtnBf2uUrzfx4J2 JJID2bJE2dLX5goQo4DYsItKm27txiLQ3zqwr0HGXe66BXYY4n7D2p+AW3eUiyjrF963w1 eyyo8kYAhSGqBZ9fcW7MYLA+yEJZQH8= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Wr7P7dZc; dmarc=none; spf=none (imf05.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704271315; a=rsa-sha256; cv=none; b=qI7vELht5pS4jxZ35eb03ivpwfXN58qYPx0MMwzyOTawiQLuDg4/52U9ReuCqOK+gR/vAR TDWlBoVVvVuIDF30KFe12UcgCVlidqkW7uW6RiPkVTPRRPrKFsoXbyitsym5NlS8Y14Bhx lfzvsYwqJK87SolGkSJ4jN3SNVfE8yk= 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=gccidn5f1g0i1fYsvQcyie7MyTTk/hQFlVMXwFY3vVk=; b=Wr7P7dZcpevM+eMB5xo39Ltk4n pA70tRCaoJl4lPTsEExNBpd3OQwVjmMBX369i0850YW6oiszU2iNh6eJ757etaMPq8HJ2U+W+Tiqz SNKbAzq95Ssw/VUjWT1aOGgS5maez+iiXrDF5e4zgH6c519czY77Tj4JMoM6+7DIjIcbykslnmzNu h2++TECOXvFTkpJbQnXlTMfGVpoiYzlnSO7122nmP22uEQOnUFb3KTSWAa4E4ASxP4iKje+pcLggt YRmvSy4Hrv9G9XNi9mYpCcdekJrKJRmC4iHq0I744Jh2jylflLQ5zO8cKkhZBUffeWunygETkQTGc 9oGgZdIw==; Received: from [89.144.222.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rKwov-00A6bu-1d; Wed, 03 Jan 2024 08:41:50 +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 04/15] xfs: remove xfile_stat Date: Wed, 3 Jan 2024 08:41:15 +0000 Message-Id: <20240103084126.513354-5-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-Rspamd-Queue-Id: 51E9A100015 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 1zyjsu1dmhg49nyim9a4mq8x461nywes X-HE-Tag: 1704271315-751064 X-HE-Meta: U2FsdGVkX1/tH7dYOP/XE004ilUN4crLNHt0OlmUXRgemM/C/2ag0K9P2D+gOSnudQn++eOxQ7sXUppt+tfsxUlIOWRvVBQzvySo4sjP4ARyGGatdZNycYeLcsoI653PCupQGvBJ/HMNHfEuhzvWJPE/B81i1cpI+6uIcQBZRUFexRvZhjNf5OJZJf8nqED7tBBzpiwM634ypyuNW+9U+NDC31Ff2rXQwqldoBVcIXOfqh4ZkcjSE/TAV4tpdIv7xQbHKYMxakji7uW5i0oTT613MKd99/qGA3xXSMCDZcOkF7bxAhxTu3qJPoXnro7UDW4QBRsBBGVIsimLdA5kuynFq3zgeNMhlJS3eGuljJj5MpTY1rrhqbQs7j8y/1I4Fy2O0LwOvTF7SiaFPYfKy1CRSRux0bxrPiyo1S7xOK8fPKxYr2Xny/IcyVFmUu6EOA+yoHBacqZ9UNeiVK8q3R8KK6A3BQ13meOlGjVuv9ookwqYkmQcLAQXMFlUSW/9F3nn7dN86ZCIb6P02wPAYBF0KAuYBs0lLT3wqEXNGhGLpsmIMhr0O3kOrkcqsdABd6WCW/C+9ToKT824DxwzybN/veCWVB4wtfYh7hxc3jfkz4S/yYxK2weK6csIG/XQ663X7/opss9NKlFksTdbQOw5/JESXX9YjnpETl2+KZYMgREarNeK8yv78lN/lWSZnR14CivxHQc7k0sPT+vawYKwvnfBQOVYjV+QxmlidPGzpORThshXOtXaDjHo9gcwPZ9L+gGnSNMESbqW6AQOIrW2yyDOMF4ydXffXxmPbqUSg2v3ze9DMfHs06z/h6FM0v7I0BIf1Sih2yGag7GCEWiB1tSVrDkacrgTrWmZAfOm+0WxXpklpwSWEr6FhtFXMboQBNX2EuMZcFIlNVZC9O0tNh48lrNEwFN36cjgyIAuLWpjoTL2x21q8u5G19jGXqzuCBOqKe1HC66W3yV hhmI7hKF FUhZktMRaCZoo5+Qijoae1iwEHwJRMhUG3Fi3CigFE5j2vl5vUsNdaCIou0M7Uj4UAT9j/oL990dorW+gR+JzVDrTGSZgBadywyTpT6Bn/pjCgWnEmcr6OQoXc5iF3xKndp7q/SQYBItuR1mullfYHWf3kPDULcJMNfDW9UjPAaYO+/BZ5wozWOTFHaBS0VTcwwAf5Sj4Q1x/CXA7u9IOSPS3SMpDWfWF+qhTES1zHjNE7jZGMh3WToNJJsc0TfUu7SJI+Qyy04gJ//OausJFWxYjsQIqwR4iwNM2T/uX+UAwc/fU7G7tybJPXAgqetm33ikH+AJy+twk+wB1wS84lIq4GzCR8h753BfZ/DjBrQA3AptTvxPQjF7pYzhzWHOfnj1NIGbajEf7I3M0Ij9x2zRArns0RrdTbREnKxsQQ9Bvyacqj3gKQRg8Fw== 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: vfs_getattr is needed to query inode attributes for unknown underlying file systems. But shmemfs is well known for users of shmem_file_setup and shmem_read_mapping_page_gfp that rely on it not needing specific inode revalidation and having a normal mapping. Remove the detour through the getattr method and an extra wrapper, and just read the inode size and i_bytes directly in the scrub tracing code. Signed-off-by: Christoph Hellwig --- fs/xfs/scrub/trace.h | 34 ++++++++++------------------------ fs/xfs/scrub/xfile.c | 19 ------------------- fs/xfs/scrub/xfile.h | 7 ------- 3 files changed, 10 insertions(+), 50 deletions(-) diff --git a/fs/xfs/scrub/trace.h b/fs/xfs/scrub/trace.h index 6bbb4e8639dca6..ed9e044f6d603c 100644 --- a/fs/xfs/scrub/trace.h +++ b/fs/xfs/scrub/trace.h @@ -861,18 +861,11 @@ TRACE_EVENT(xfile_destroy, __field(loff_t, size) ), TP_fast_assign( - struct xfile_stat statbuf; - int ret; - - ret = xfile_stat(xf, &statbuf); - if (!ret) { - __entry->bytes = statbuf.bytes; - __entry->size = statbuf.size; - } else { - __entry->bytes = -1; - __entry->size = -1; - } - __entry->ino = file_inode(xf->file)->i_ino; + struct inode *inode = file_inode(xf->file); + + __entry->ino = inode->i_ino; + __entry->bytes = inode->i_bytes; + __entry->size = i_size_read(inode); ), TP_printk("xfino 0x%lx mem_bytes 0x%llx isize 0x%llx", __entry->ino, @@ -891,19 +884,12 @@ DECLARE_EVENT_CLASS(xfile_class, __field(unsigned long long, bytecount) ), TP_fast_assign( - struct xfile_stat statbuf; - int ret; - - ret = xfile_stat(xf, &statbuf); - if (!ret) { - __entry->bytes_used = statbuf.bytes; - __entry->size = statbuf.size; - } else { - __entry->bytes_used = -1; - __entry->size = -1; - } - __entry->ino = file_inode(xf->file)->i_ino; + struct inode *inode = file_inode(xf->file); + + __entry->ino = inode->i_ino; + __entry->bytes_used = inode->i_bytes; __entry->pos = pos; + __entry->size = i_size_read(inode); __entry->bytecount = bytecount; ), TP_printk("xfino 0x%lx mem_bytes 0x%llx pos 0x%llx bytecount 0x%llx isize 0x%llx", diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 090c3ead43fdf1..87654cdd5ac6f9 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -291,25 +291,6 @@ xfile_seek_data( return ret; } -/* Query stat information for an xfile. */ -int -xfile_stat( - struct xfile *xf, - struct xfile_stat *statbuf) -{ - struct kstat ks; - int error; - - error = vfs_getattr_nosec(&xf->file->f_path, &ks, - STATX_SIZE | STATX_BLOCKS, AT_STATX_DONT_SYNC); - if (error) - return error; - - statbuf->size = ks.size; - statbuf->bytes = ks.blocks << SECTOR_SHIFT; - return 0; -} - /* * Grab the (locked) page for a memory object. The object cannot span a page * boundary. Returns 0 (and a locked page) if successful, -ENOTBLK if we diff --git a/fs/xfs/scrub/xfile.h b/fs/xfs/scrub/xfile.h index d56643b0f429e1..c602d11560d8ee 100644 --- a/fs/xfs/scrub/xfile.h +++ b/fs/xfs/scrub/xfile.h @@ -63,13 +63,6 @@ xfile_obj_store(struct xfile *xf, const void *buf, size_t count, loff_t pos) loff_t xfile_seek_data(struct xfile *xf, loff_t pos); -struct xfile_stat { - loff_t size; - unsigned long long bytes; -}; - -int xfile_stat(struct xfile *xf, struct xfile_stat *statbuf); - int xfile_get_page(struct xfile *xf, loff_t offset, unsigned int len, struct xfile_page *xbuf); int xfile_put_page(struct xfile *xf, struct xfile_page *xbuf); From patchwork Wed Jan 3 08:41:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13509722 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 AD05EC3DA6E for ; Wed, 3 Jan 2024 08:42:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F51A8D0036; Wed, 3 Jan 2024 03:42:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A5BD8D0035; Wed, 3 Jan 2024 03:42:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26CCF8D0036; Wed, 3 Jan 2024 03:42:02 -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 121258D0035 for ; Wed, 3 Jan 2024 03:42:02 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B4E6080226 for ; Wed, 3 Jan 2024 08:42:01 +0000 (UTC) X-FDA: 81637357242.13.5B6A0A5 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf10.hostedemail.com (Postfix) with ESMTP id 12E55C000E for ; Wed, 3 Jan 2024 08:41:59 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="dUSkxd/d"; spf=none (imf10.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=1704271320; 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=b93/M7KvmPyl4jPI9oxcGL2Bib7PXsqhEgUZrUOfkIw=; b=1mkEb7jHsiAwXnAUZjyQB6wBDA8VHPF+wsLGrhWp2M9AFGkyM7D7Scq698RIrerXhwrmXF glTw6gSjkek51rTXzbY9QF81QHmeCdpnggAeTMZNDCSLZJnHndDFxqm7ghTcSFVfPjnCEn gFROS9jhyJt28gMGScIag0MeMWW9oCg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704271320; a=rsa-sha256; cv=none; b=TTFroC9bIT/liscDryNYkp+XYuoI5vYgjN1HaD1R3vVK44hU9zhO189caDp+NoqCdSAj4x 3wN2TPr7KTZx2UQOnMlMsh/uR6um8laNeto8w+GVHKvQbZ8QCLA2gkx82r3fzLDHpJRxAu XpNvBzEungTTbdaqbUMAKP3PDifoVeQ= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="dUSkxd/d"; spf=none (imf10.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=b93/M7KvmPyl4jPI9oxcGL2Bib7PXsqhEgUZrUOfkIw=; b=dUSkxd/dCW07qs9PzajUk/WjjV d9ViqcXB4FFSd15FXoDZ9vylViiKXA6FF9DxHp0M8lIxQBuHLFjHZnoan3oCUHkwx9M3DwHKqw93f 4ic/+RILkLbLMo5GxOkI0vuAaR4JCCirY4vhyEwSoyQNM9PUwY8d1oshN1+h5m4FVtUgi9PoZ9ETC 7tBhBtJobEdUQG7hyrnDKpfIX5u2tBdaXGrmI2Jkxj9LpelR74uysEc2CINIjxAEm01VqBg5wuj7Y qLArRanujMU6tjrp/5y8yCHI1lsqOSPoZrhclB0usJ4Uv72iTVj5ALWTQelVkLBD8HAZTDnDWWb7L 9EAgLcHg==; Received: from [89.144.222.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rKwoz-00A6ek-35; Wed, 03 Jan 2024 08:41:54 +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 05/15] xfs: remove the xfile_pread/pwrite APIs Date: Wed, 3 Jan 2024 08:41:16 +0000 Message-Id: <20240103084126.513354-6-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-Rspamd-Queue-Id: 12E55C000E X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ey6swpxspj1yoq49zikkfse5oori9os1 X-HE-Tag: 1704271319-196713 X-HE-Meta: U2FsdGVkX1/ijqzMW/475HPifeOHX015t3ALLeXCbdeRAIh2HgFMYWMAud1pFwsXliyflRPtrzB8VSiYGzhpqM6eQzBGE71W05cectz9pn09KOYi8Vuq7IT6iEduq7HC6PLTjPewpRw6jPnFPA4qfTXTELJUi0E5G/SaizRKn5wIMFdx36XyMO3OpZxLzj8tGNku8+k5CA0tV6vuIPtt28vDPLUk6ijOF9obK6PVdDkl2HJyEIV3slBN06F+5Ivk23JH26otfLnYEbtSOHqfmjYxZG0mO84N7TCB6+3geKvK1B0gmVKMs5RixAFawlkBzM90/73BKIZeteg1qqiwWWlvzIUPmEm2iLwEkS5h0PU3hPu5k5epjAKjv30WqCYVWfpA+L9noz2RQYtjl7wcpbMLvj06dyCsnq9r4yUak1U/W3S4oMbo+4VU8znlDOKKK4rS+ZIoxBgCGsiOTLfAMcCs6OsMv9XAQZHIcVSXFuE9Ev1/nYJh8XVWsOw0G1gaTD8GnbopxLnnMCWooH55rmclJLjDIKE4v0pKdU9JXmRxzAwhj3ssWmOTDPgggc+XIFgpOHL10QkjaPapOVZyDarJt3WYG2c1HCtnE8MvFTym/kegzlcbmJfhP+MRqRt6hOnPW/bimY5Z9QiZkPWwPq32AXtCxE7MAOMUu13qnKjuqQImv5Wf9KrsZytaZdJoKCtp6A2ma/K8EsFSNDDkDsC/jhquUqQ8n3gzt68T7UPCnj6xZ8L13W/6XgJmIlgC01x0EcLUIDyXEVP6yTjxhqXd1LguCEYuKBJqO4JRr9nTojw/FJegr/Y1QSBn1OXXiJFyRRLei4m37WK2FNggQypndmG+TKVZZOWiRF2hJuhdFcFSH8Oa/y8D5hmzQlXuwmWpvWQZTNtMjhd+tDkZSS13dqM+15HBDFqSZHXaZrkeuDHZ0hmM02JO9VffNDKyuEM4+Oimm217oJApoti vcgHGwzt tT8Z+YqAFisRptw48/+cwBzViH8WOv16gNmYZlPUf9xX3BIgYA48dZNVAVOF5QWMoFdvLAFLXtzbArwLn6QrVXK063IoRy18zbK/jxwy/rTFy+2lJlKI+dd0SA4jmfTkrZ+2ED8H6tIVfIo11BWL3h9+3r99NE7jBPdbPGih7eEF9iraCU+aOJzX+1xJoYvutEBUHSFnJjD6GISEWXRhbF5T02SD0kTrEZeg2ehM/YL7SC9CjODjmr/eB0JNZri9dflkELLvV/dmvZEnGuOI001wQNeubRCgnttE9O4rc8MRVtPckIewpoI5cvdpQ1B6Gxx/8C0B+XCu3WB+5HffX9XwnxFOXwIP/XHNZaTs27Zi7ElzaTGYKWFnSYV9KLU7vTnvck0XvEouYSqBhJa3ciEk+jpYscvObphuAkx0P0/WAKMrENHIWJhvZ6g== 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: All current and pending xfile users use the xfile_obj_load and xfile_obj_store API, so make those the actual implementation. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- .../xfs/xfs-online-fsck-design.rst | 10 +--- fs/xfs/scrub/trace.h | 4 +- fs/xfs/scrub/xfile.c | 54 +++++++++---------- fs/xfs/scrub/xfile.h | 32 +---------- 4 files changed, 30 insertions(+), 70 deletions(-) diff --git a/Documentation/filesystems/xfs/xfs-online-fsck-design.rst b/Documentation/filesystems/xfs/xfs-online-fsck-design.rst index 352516feef6ffe..324d5ec921e8e5 100644 --- a/Documentation/filesystems/xfs/xfs-online-fsck-design.rst +++ b/Documentation/filesystems/xfs/xfs-online-fsck-design.rst @@ -1915,19 +1915,13 @@ four of those five higher level data structures. The fifth use case is discussed in the :ref:`realtime summary ` case study. -The most general storage interface supported by the xfile enables the reading -and writing of arbitrary quantities of data at arbitrary offsets in the xfile. -This capability is provided by ``xfile_pread`` and ``xfile_pwrite`` functions, -which behave similarly to their userspace counterparts. XFS is very record-based, which suggests that the ability to load and store complete records is important. To support these cases, a pair of ``xfile_obj_load`` and ``xfile_obj_store`` -functions are provided to read and persist objects into an xfile. -They are internally the same as pread and pwrite, except that they treat any -error as an out of memory error. +functions are provided to read and persist objects into an xfile that unlike +the pread and pwrite system calls treat any error as an out of memory error. For online repair, squashing error conditions in this manner is an acceptable behavior because the only reaction is to abort the operation back to userspace. -All five xfile usecases can be serviced by these four functions. However, no discussion of file access idioms is complete without answering the question, "But what about mmap?" diff --git a/fs/xfs/scrub/trace.h b/fs/xfs/scrub/trace.h index ed9e044f6d603c..e6156d000fc615 100644 --- a/fs/xfs/scrub/trace.h +++ b/fs/xfs/scrub/trace.h @@ -903,8 +903,8 @@ DECLARE_EVENT_CLASS(xfile_class, DEFINE_EVENT(xfile_class, name, \ TP_PROTO(struct xfile *xf, loff_t pos, unsigned long long bytecount), \ TP_ARGS(xf, pos, bytecount)) -DEFINE_XFILE_EVENT(xfile_pread); -DEFINE_XFILE_EVENT(xfile_pwrite); +DEFINE_XFILE_EVENT(xfile_obj_load); +DEFINE_XFILE_EVENT(xfile_obj_store); DEFINE_XFILE_EVENT(xfile_seek_data); DEFINE_XFILE_EVENT(xfile_get_page); DEFINE_XFILE_EVENT(xfile_put_page); diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 87654cdd5ac6f9..9e25ecf3dc2fec 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -118,13 +118,11 @@ xfile_destroy( } /* - * Read a memory object directly from the xfile's page cache. Unlike regular - * pread, we return -E2BIG and -EFBIG for reads that are too large or at too - * high an offset, instead of truncating the read. Otherwise, we return - * bytes read or an error code, like regular pread. + * Load an object. Since we're treating this file as "memory", any error or + * short IO is treated as a failure to allocate memory. */ -ssize_t -xfile_pread( +int +xfile_obj_load( struct xfile *xf, void *buf, size_t count, @@ -133,16 +131,15 @@ xfile_pread( struct inode *inode = file_inode(xf->file); struct address_space *mapping = inode->i_mapping; struct page *page = NULL; - ssize_t read = 0; unsigned int pflags; int error = 0; if (count > MAX_RW_COUNT) - return -E2BIG; + return -ENOMEM; if (inode->i_sb->s_maxbytes - pos < count) - return -EFBIG; + return -ENOMEM; - trace_xfile_pread(xf, pos, count); + trace_xfile_obj_load(xf, pos, count); pflags = memalloc_nofs_save(); while (count > 0) { @@ -160,8 +157,10 @@ xfile_pread( __GFP_NOWARN); if (IS_ERR(page)) { error = PTR_ERR(page); - if (error != -ENOMEM) + if (error != -ENOMEM) { + error = -ENOMEM; break; + } memset(buf, 0, len); goto advance; @@ -185,23 +184,18 @@ xfile_pread( count -= len; pos += len; buf += len; - read += len; } memalloc_nofs_restore(pflags); - if (read > 0) - return read; return error; } /* - * Write a memory object directly to the xfile's page cache. Unlike regular - * pwrite, we return -E2BIG and -EFBIG for writes that are too large or at too - * high an offset, instead of truncating the write. Otherwise, we return - * bytes written or an error code, like regular pwrite. + * Store an object. Since we're treating this file as "memory", any error or + * short IO is treated as a failure to allocate memory. */ -ssize_t -xfile_pwrite( +int +xfile_obj_store( struct xfile *xf, const void *buf, size_t count, @@ -211,16 +205,15 @@ xfile_pwrite( struct address_space *mapping = inode->i_mapping; const struct address_space_operations *aops = mapping->a_ops; struct page *page = NULL; - ssize_t written = 0; unsigned int pflags; int error = 0; if (count > MAX_RW_COUNT) - return -E2BIG; + return -ENOMEM; if (inode->i_sb->s_maxbytes - pos < count) - return -EFBIG; + return -ENOMEM; - trace_xfile_pwrite(xf, pos, count); + trace_xfile_obj_store(xf, pos, count); pflags = memalloc_nofs_save(); while (count > 0) { @@ -239,8 +232,10 @@ xfile_pwrite( */ error = aops->write_begin(NULL, mapping, pos, len, &page, &fsdata); - if (error) + if (error) { + error = -ENOMEM; break; + } /* * xfile pages must never be mapped into userspace, so we skip @@ -259,13 +254,14 @@ xfile_pwrite( ret = aops->write_end(NULL, mapping, pos, len, len, page, fsdata); if (ret < 0) { - error = ret; + error = -ENOMEM; break; } - written += ret; - if (ret != len) + if (ret != len) { + error = -ENOMEM; break; + } count -= ret; pos += ret; @@ -273,8 +269,6 @@ xfile_pwrite( } memalloc_nofs_restore(pflags); - if (written > 0) - return written; return error; } diff --git a/fs/xfs/scrub/xfile.h b/fs/xfs/scrub/xfile.h index c602d11560d8ee..f0e11febf216a7 100644 --- a/fs/xfs/scrub/xfile.h +++ b/fs/xfs/scrub/xfile.h @@ -29,38 +29,10 @@ struct xfile { int xfile_create(const char *description, loff_t isize, struct xfile **xfilep); void xfile_destroy(struct xfile *xf); -ssize_t xfile_pread(struct xfile *xf, void *buf, size_t count, loff_t pos); -ssize_t xfile_pwrite(struct xfile *xf, const void *buf, size_t count, +int xfile_obj_load(struct xfile *xf, void *buf, size_t count, loff_t pos); +int xfile_obj_store(struct xfile *xf, const void *buf, size_t count, loff_t pos); -/* - * Load an object. Since we're treating this file as "memory", any error or - * short IO is treated as a failure to allocate memory. - */ -static inline int -xfile_obj_load(struct xfile *xf, void *buf, size_t count, loff_t pos) -{ - ssize_t ret = xfile_pread(xf, buf, count, pos); - - if (ret < 0 || ret != count) - return -ENOMEM; - return 0; -} - -/* - * Store an object. Since we're treating this file as "memory", any error or - * short IO is treated as a failure to allocate memory. - */ -static inline int -xfile_obj_store(struct xfile *xf, const void *buf, size_t count, loff_t pos) -{ - ssize_t ret = xfile_pwrite(xf, buf, count, pos); - - if (ret < 0 || ret != count) - return -ENOMEM; - return 0; -} - loff_t xfile_seek_data(struct xfile *xf, loff_t pos); int xfile_get_page(struct xfile *xf, loff_t offset, unsigned int len, From patchwork Wed Jan 3 08:41:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13509723 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 2C1E4C3DA6E for ; Wed, 3 Jan 2024 08:42:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B974E6B0300; Wed, 3 Jan 2024 03:42:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B46416B0301; Wed, 3 Jan 2024 03:42:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A363E8D0035; Wed, 3 Jan 2024 03:42:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 925B56B0300 for ; Wed, 3 Jan 2024 03:42:08 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 689D940335 for ; Wed, 3 Jan 2024 08:42:08 +0000 (UTC) X-FDA: 81637357536.06.C2088BC Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf08.hostedemail.com (Postfix) with ESMTP id C0308160010 for ; Wed, 3 Jan 2024 08:42:06 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=29MO4YRf; spf=none (imf08.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=1704271326; 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=JyTeuU47XuQs/S1QReYYzbLy/yqaC4/phAnhRBZRZ6E=; b=mHHgBllAbxaLoeokvVgtT5upMNErjHjwYYpMJo8Gs3nm+vMilZGrkQL/9vFqlq/tWJa+5c c/W/2CjNwN0ZgXnAuV9TkHR/dhTA8WrXNEqoLxkabVvuX/E4V9rxbkX6JQyF1pvhIbjigA dU6C7ogwYexdFu3PvwrYloxRsVBt/TM= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=29MO4YRf; spf=none (imf08.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704271326; a=rsa-sha256; cv=none; b=vCR8VPvzaZBxvBoedmTe1GJTPfU5pj8CfL60ljuw5RGoo/Dzbt5ADarBDG02Tw8VBPtStI ld91aXdW2gpq01HFHXsSEaUGapPoZB6cR4Pq+y5qwAoGKeJYmz/33xLVufrVPN3a60tHXe szFyDE8c3ZHtlCaTt+r/unkLr7zUTcE= 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=JyTeuU47XuQs/S1QReYYzbLy/yqaC4/phAnhRBZRZ6E=; b=29MO4YRfLExY/z1gx34n+St5Br wJZHtdNQtl7aItiOb0oXEIRfoH77oZEj6VqZCdqTihnqysV86tOwebaFr4XtebXskmXpABjpN5iHg FTkxaiBPVS3V0RTS9P62FJ0a8mRD01IcBfTKTeSnIQ8VQJukz3PObvmp8irOlj05rOIaMBdbdZN96 AT3mXCLOqZI5bA3JbFwLfQyabOUueuB0rkBXaFVYeJXVYMdshaOVXLOhK1hS4mACw9NSXR2I+KzSo ZYDLD6apY6ZRNWfjHxq/hBJp2mzMncRy9GPLUE2XPE6GVUffy+N/HxSFGIBXD/AslTzka8xOS9dBE OmeEuniA==; Received: from [89.144.222.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rKwp6-00A6gR-2s; Wed, 03 Jan 2024 08:42:01 +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 06/15] xfs: don't try to handle non-update pages in xfile_obj_load Date: Wed, 3 Jan 2024 08:41:17 +0000 Message-Id: <20240103084126.513354-7-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-Rspamd-Queue-Id: C0308160010 X-Rspam-User: X-Stat-Signature: fp9pu9xu1b58i54p81dys66zi3z37dod X-Rspamd-Server: rspam01 X-HE-Tag: 1704271326-326285 X-HE-Meta: U2FsdGVkX1+MBbxwtZFfNx0jRJa3/qSWUFpiFRSLViGx1adoLVi728t3NJSBqe5DW1lMw0l1NzSp3hbDyH3NS8mRN6z4UYinHuBjMEBp05QU3mIZWol3oWDZ4CWmV4NkINPJfyMcipUqVq4yTo7toXUYnhK47Cg03EB3yQXhGrSmK0F4FPfvpzqd7uva1+AiDLR2Bex1fFkJ2gL8u2vtBR2gRdkUtT6kTGhQA6487kEV9rOauZp8csEL4KzRprStO8XNSVembTi619kT7T6rm1kllBiEHyCrhyuzNSWR5wXztzMgRWmioFySnTrOKEMu4tDJjonuBT7CYb9bV8Zx5TQY3TUtAvvQunivfCfMGHGC0CgiApi9AJvqfRlJUOmydbWYyR+dDcGpDjYlKSYG7+NtVwZeXU+5xZgeA10E9vyms9IlDw00Uop787mVFdFVBjS3B35GE9DEheu8MlZUpq0ziOj97oYZDiFdc1UvsZdad4kEgSvHFb51pt5e6J6x/HR5wuaIJ1EyBTerOjrEnQlI/0g5YrOYSnk2a8yiOJp1j+uNThKbFDdbqJ1TvNEgzqMo9NIXxS1+FzAjC7d8JD8d2COUZ8HkKL0ubsh75+pTOwkX/4x2zH3cFT9KinwNZgpgLSmvOqkGMpxNUSQr62zqEX+5MZsce569SZIDk589yxV9GNtnP68ZGLXLxLKjskX/R5GQqLhQgW17qS/ew8MsR/EpOio8bDiQvdTc9r9gb7YnZpy7+T7uDLJILSRlLbI5Q+jUQ/xJgcQuABhLPc2pnAeFY5YT0gnorzOe2udZXK1GUnZfPvJSnEUcxtd+vUxMcvPS8IzDxIwztDJkuMArwUBnCxggSfnCfi3y3v52/Uc/2T3//S/xEHsyTUUzUBFzy/HLmaIbUq0hpEXoEPkCtidXRht2Xfc13/yNUEiuVQSdYtC6+H8mSQcpdvVXYAcQGC/nnoRzYcWDrRO lab3Q7G9 53kcrS4AlcT8bXIAIQQ6Ueh+WMGRZnFfgcFSGhuKqhde7fR0g7RrihL0aM2bBNRcrL1NrSuzvhU7iFXd2Qo0D/xcbJwcBSi8Zl5ntj+XrgSX3GhFC8MVO+hdQ82gIgeqQOjiE58L0V6HkRGvHJH8AvU3lWVr4BgAlUMCrWHl1aSCNeeY73iCtEZ0d6ns+hwu6BGTCG9EI3Nixtjf873Se6oIofCyqWGdoG6jJKRG0MuPCB++S1B20k9U//cKQiFb6HWtGV40f8tEikQXFRn5SIn2zIteflaSmMlyLI57GDBFCLPTmOhaunleZVcB4pR2J0O4gwtMyhMpfbgNsL2AzjRYk9DjGXS0UcKZ9BDYneb1HpFA4DoE+BENHF8eSEWZczYy9seUxltpwSQMjSDFgSWR4lRr8a1MEovOrFoTrMZrymxaLs7WzgHmc2g== 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: shmem_read_mapping_page_gfp always returns an uptodate page or an ERR_PTR. Remove the code that tries to handle a non-uptodate page. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfile.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 9e25ecf3dc2fec..46f4a06029cd4b 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -166,18 +166,14 @@ xfile_obj_load( goto advance; } - if (PageUptodate(page)) { - /* - * 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); - } else { - memset(buf, 0, len); - } + /* + * 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); put_page(page); advance: From patchwork Wed Jan 3 08:41:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13509724 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 770FEC3DA6E for ; Wed, 3 Jan 2024 08:42:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C09E8D0037; Wed, 3 Jan 2024 03:42:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 072D88D0035; Wed, 3 Jan 2024 03:42:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA2338D0037; Wed, 3 Jan 2024 03:42:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D878E8D0035 for ; Wed, 3 Jan 2024 03:42:15 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B4DC91C08CF for ; Wed, 3 Jan 2024 08:42:15 +0000 (UTC) X-FDA: 81637357830.11.1FB47CD Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf14.hostedemail.com (Postfix) with ESMTP id 1F99410000F for ; Wed, 3 Jan 2024 08:42:13 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="Uh/+t2WV"; spf=none (imf14.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=1704271334; 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=JhCgkrtHibPlII0BBIGAXVuHhyHzEnEyi2A+L2TpO4Q=; b=w2Wy5jxc6heMBT48ma+4onZNQCtWFWsFZ3XDsjkjkniSQ5XIrO0LM0kWfS1ezQh8ANrKuL UsLK1QaxtPveC2BR/sgZNirbiYp45OP1ICxupGk7dZPsjefRexa5z/9Xy5ZhFE8SEUq8m1 wCI64olzz048EFV+4xDCAjCK3mVmPmQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704271334; a=rsa-sha256; cv=none; b=RmI8fAbIqi1Jvah/pLMFRn/Yw3Q2aDKpg41qjV2CvrEROKldENU21dnDV+wJs451MeCdLa Aqp0JMSw02KTBLdgjilm9KZk2h9z0KDOtbTQwo0TGDazbPdgwRNoP1B9+9HRTCeMUoFoWk UkNcMH6b9nx0YtA1ecCTLZwVEEWrC9g= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="Uh/+t2WV"; spf=none (imf14.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=JhCgkrtHibPlII0BBIGAXVuHhyHzEnEyi2A+L2TpO4Q=; b=Uh/+t2WVVTHbFcu65yNj5HGXPK zr8p8kjN9KsH0QOA8lxX9z5fe+eeSKdYu7nQs3+OXY1A84yOx0Da7bKN0XNxHdLodl0526xyQ2EO+ rXJXZws2yBC2UGMDliAgkm1/CidU/9FYNm/TyF8zq+U74MB2lSSl8FLqZRT6aPkvn8/miiRalE9R+ eIZzGNoPa08YzIS5boiamaolADs2FaUaAXCf5txRfEGkBML26JrKk60OnIPuIAvpQn1Vf5P5E3546 UwDis5w7hc1hc3V+dNzVZh1fGq3zEZATbYEkryOpz1s6Ezt0mIoDvmJD/Of76BP87WeQjw3RAsF4h BAA367CQ==; Received: from [89.144.222.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rKwpD-00A6iS-2k; Wed, 03 Jan 2024 08:42:08 +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 07/15] xfs: shmem_file_setup can't return NULL Date: Wed, 3 Jan 2024 08:41:18 +0000 Message-Id: <20240103084126.513354-8-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: wuek6fr9nt8qzw9mohd8dcs5yjse5efh X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 1F99410000F X-Rspam-User: X-HE-Tag: 1704271333-27672 X-HE-Meta: U2FsdGVkX19AKp2T+UbsOIz4s2IJAGcvAPD1e4LSHqnEeN6bIZMoCnItecQgcsmpYwHDWnJtAb3aJRLpKUobmTw0WJY8UEyJFE4GKhM6Av+hTi2oUmgnlj/uSA/XBdXnRNerrDcWVIDSsNb9vsKR7GOcth/K2ZUkjWTcZLoKotEL8/Q5SkWd6lf4SMmx4gKQc/oQfycoSjlyNcnG6o+0UoF91w7Nbi0hjpoUYr/KOPgS82H4EOOzoD2WR1HnBMnPwhKvLluEZzSQbW1y7EFs70vpIi8kRZbYh5bXChN9gTuy8RZGYP+daVsD4DUygOO+4rCgW5RpyBALMWEGf5icB26FgisYz6+pn/iO8OwufqU/kzhDqB9FR8rbho9gEm1nmGcjt08fgYt/iz+fDqRRxrip1fChZs5NF1sXPU6SY2HXtsE8+LEX88OL2J9/tzEOzHgEgGo2zxX0PihE9abNStnXG8KcKXIbYXF6IIGUxLKUfmEuvKSZc83VKT+53H13z47Sgez7z4eGxMXlyPlflarFV6o5H+RdVA0YjBIAXYdCAYIB449Yx5Yi8/nzwJp+IdfmNNTCLI0Piu5+rvx/K7TcJEYqKcnR7g5XrrVuGSTSmH1xeDFB3IxeF367BXrwmxdsfQHdxknAoAMEQhwX6Hi6nwlAsR7b+puq9VCTj+UIYPBnqy/qy2RGrPJtajXD2+chSf7SVtN8+IV5jbOgJ3UH69+gEsLuUXNlq1nsgHBiMzFBfNiDtcejE0hT8gVayKroyUP4bx6ef1jSZjWIWBbKI68hqtwRHLWod53zX0MWLpAsk7TItHpfgGQmmLYYSuN/EH62dn39iluz2wdWvvNP32HbtYisddO/gHbNiKo2TDr4JOikhZdHJgZ/34Ma1kaASGBGfbjZzeY9kZvfzhxrHerWOPvFMEakJMtRCp/qmhwyGEuXGEKwKV7862LuRAehQKzLL0J5RzLzSpI nE9BDMUr y5qAAvC8JXvhxS1O9xmftyMkCNJPTf2qZFiLwvus4dCzc9CXdnz/TF4JdD8D8M3sYsO2g4lXR9VdkWsTyRKRpw5Q53BWdhykpjEtBFyQtwleN5sgVg2NskP5LlAuk8R3IPILgS4zFPrfDn8qdKFZvPcqKAAnSEgCMq8jUyZZHY7NDwfDzvj/dKd1PYxBXP0Zk7hFK9JTNl9e8jAVZEMzpXOY7MtgjU75LUu1Bv8NVnSjbvyBBZskHwJ3XZOIbjbiaSmE3DGC/uteBF8gPuGta+OnhCyq9P5OcUEH4hRHNvVQpYy/8f02hx/BNdbKe+azDbKuXSTLRaryORwJ9BxhaGjf3Q67dvaGfPR4FZlYHGR4xz8mEDJhc+VsvlOR+lvI5DK/hTxdn8N483G7upfuTLekfHFaCFx4mlIKTHhWV+/+VHRP97TsB+3OH5g== 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: shmem_file_setup always returns a struct file pointer or an ERR_PTR, so remove the code to check for a NULL return. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfile.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 46f4a06029cd4b..ec1be08937977a 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -62,15 +62,13 @@ xfile_create( { struct inode *inode; struct xfile *xf; - int error = -ENOMEM; + int error; xf = kmalloc(sizeof(struct xfile), XCHK_GFP_FLAGS); if (!xf) return -ENOMEM; xf->file = shmem_file_setup(description, isize, 0); - if (!xf->file) - goto out_xfile; if (IS_ERR(xf->file)) { error = PTR_ERR(xf->file); goto out_xfile; From patchwork Wed Jan 3 08:41:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13509725 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 C597BC3DA6E for ; Wed, 3 Jan 2024 08:42:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5562C8D0038; Wed, 3 Jan 2024 03:42:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5061D8D0035; Wed, 3 Jan 2024 03:42:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3CE0F8D0038; Wed, 3 Jan 2024 03:42:20 -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 2BB6E8D0035 for ; Wed, 3 Jan 2024 03:42:20 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0932D1A0277 for ; Wed, 3 Jan 2024 08:42:19 +0000 (UTC) X-FDA: 81637358040.18.7194E67 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf04.hostedemail.com (Postfix) with ESMTP id 5FC7940016 for ; Wed, 3 Jan 2024 08:42:18 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=dIo4HWAQ; dmarc=none; spf=none (imf04.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704271338; 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=vVoQtZKk55rO4xv81RRfDMeBVcwce9ZJZyjeyjkymuE=; b=IIpVBzErKg/pGJbeQE4qQo4F1isEUQnIiu+4J10sW83tuqSAs/Di/XITfPJMLorpp0i/Ou WVY7jMKsr7PJdXPLIYG1CwLr+fenOX+LWkfBcvxu7TImeOXOfDRKG4/R1Ne9qB8eeyP1YT hm7Z6UgmJWxxx/0QSzpYOPXsb2bVtUw= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=dIo4HWAQ; dmarc=none; spf=none (imf04.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704271338; a=rsa-sha256; cv=none; b=KXmVPCtmlyEvhSYeXy/Jaj/gUu5tOjkFoeDBEMh/xeGbZ7wMMC4RwvQjaxipEmwQERrN8d ddeId5oreDpFjgjcDH/zEdTMzXCOF2bz9IweIeQPWkXEcXHDMv160tMU/ApA+TlkVy/aJX VLrvOr4wokSDcpTzMinyXcw1XGmsw+I= 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=vVoQtZKk55rO4xv81RRfDMeBVcwce9ZJZyjeyjkymuE=; b=dIo4HWAQ4jBdBUrCa8HgcaHmqb cnkCOPKDa8/RKeP35BaIUuT3ZPL7yRiw4vyi8g0fGYsgR2JntH3l0eicoCFrDarQjT2QQ27wTl08Y NyMqFtK71zSKPu0wGjw+rHT9YJ6D5ABzxd5tMvd6Ih/QQtAuK3fdV66LvqtmwloHqXdnCu4y5nSEr g9jBFHyBsE6quFf9IL5MLZmx+gbrPk0rZ43mKr1/QPTNZtwoKxSNCwyZT6ZVSTqekcEyUrvDaCM1M DfJ/mYJbRXVn37v0wCL6kmSB21j9LGDfJBC0H+7xg4O691TOzLBvZn/rLkgxdNaTfpjEuS+N6HxHW HTzBi+bA==; Received: from [89.144.222.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rKwpJ-00A6jx-0n; Wed, 03 Jan 2024 08:42:13 +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 08/15] xfs: don't modify file and inode flags for shmem files Date: Wed, 3 Jan 2024 08:41:19 +0000 Message-Id: <20240103084126.513354-9-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-Rspamd-Queue-Id: 5FC7940016 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: ibbobe6s6jrbcz1paisx1u5xo43agfkn X-HE-Tag: 1704271338-988349 X-HE-Meta: U2FsdGVkX1+ELxGJ8GUXyWeLY+Bx6R+rR01DD01pgb0b3upMF65r5gg3/V8Aa4FNNyuO9YL/WEVI/pwf9S4wXq7ZBbKPV/yI+P9HR+cBiQ1yIDLJHmkWWFLxp/8O0otAACL5LrjFSMQJfEqg3qERLW39Ie5kTFx3uQNf8+h9jvhmVUkyiBPMFkA5GVrmCvZLElbPKrrhv2RL77ldML00SeAL53nzHfjurR15lEC/+6YTbJbCZmKFUa3ia/6qJveSpDmJfAqmom4iPotzi/5yqZXl3gALbUi/K8ptm512hvlFXCXwLyAAxLiPQlGCW4TB1xVA+tdZEACTlF0qH6YaFKBPLeaAk3IoX+3H5vnrVF5KJy7DdJ2QWBvYCk0rp/oqjoOTmhBbS5gHv4MRo2J+GZse8tfLLYrvCdT2VgMJPEXo6vllkbKeUo6W0UnxVYkJEJsFHcQFhhVhVJcaskf5et3xZ4iRiVvT+NPjPOgi57hZxIVxw/G7IkfrFN7Kr/97a2udhoezbsSbKd3ixtDCo7b73332rLnW0FeaCTBYGH5nIZUY7RZ9XCz/9WE8uKVIUwilzK5fx096icemlPcKIt90rMbb3gzgDxaTA4K6HaC3FYlh3esKkFxdwEEbTgH1eVO1BnNRGRZ2cY5IBex2qqS/2u4WmeVDa420OzVZvIidK4zUedIrIjmwKPn55lbBSNyrHFnRHIJ9q/epY5OtQTgXMsW/mHuVZGxgb2ebhO3uEtfilkciaQ3NTbzPvMNhaXUVJ0Lvwo2kyOtSrKsZO1vFfeyiFhJSwpB+E4XDJsI693bsdeLH/POTAWQzAdqnIfuGYEzqxRW/dsPbey18RM5TpAHf/OWFzMwvLhbmMzP79s4wpQf4icNAeMVzRUm06Br6NUyILOAr9beQNqbE+fxvLaPFkAXy/HBII2QFiiPxuy67wg4ciRIj83aIEyLO7tZeZIC7qCMH8UHtnPR v5pMpnPX op1GDIm7q9hArM3JR85uQsD8mBXBwXhSndu4FjbDSrcYm4V4J5YtuhQ5tx/OhA6NKAVZFdJoGJ6xZ8RDq6tDHJN634zqr+0wmwx8beygsn4jyj3VzL13avFB6qHjjGBwWdWzx2lb0zx3uxNMlB+HyPk0V/PWQL/85vguxDRaC7k7hjutbtH95dyl2QhBqrlpCVfoD6vRbg8h3K7q3mE89iscBIJtp4nXm3y2+AWiRRI7Xg4Osj4dp8Us8zwVnpZWp6LhA92AXtk/orI8urXk1xlxEaBBcZdwXVLDIDqcBhL62S5sJ8XVS294ICdai2zTrJgTIyIGf2x1/XuMGledzgDAlTiFKSz9aVMmikWoouA/vaa3q8F2QmcFCNWvJqU8CWzCu 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: shmem_file_setup is explicitly intended for a file that can be fully read and written by kernel users without restrictions. Don't poke into internals to change random flags in the file or inode. Signed-off-by: Christoph Hellwig --- fs/xfs/scrub/xfile.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index ec1be08937977a..e872f4f0263f59 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -74,22 +74,7 @@ xfile_create( goto out_xfile; } - /* - * We want a large sparse file that we can pread, pwrite, and seek. - * xfile users are responsible for keeping the xfile hidden away from - * all other callers, so we skip timestamp updates and security checks. - * Make the inode only accessible by root, just in case the xfile ever - * escapes. - */ - xf->file->f_mode |= FMODE_PREAD | FMODE_PWRITE | FMODE_NOCMTIME | - FMODE_LSEEK; - xf->file->f_flags |= O_RDWR | O_LARGEFILE | O_NOATIME; inode = file_inode(xf->file); - inode->i_flags |= S_PRIVATE | S_NOCMTIME | S_NOATIME; - inode->i_mode &= ~0177; - inode->i_uid = GLOBAL_ROOT_UID; - inode->i_gid = GLOBAL_ROOT_GID; - lockdep_set_class(&inode->i_rwsem, &xfile_i_mutex_key); trace_xfile_create(xf); 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/SMLguU6ZABkrLDolkxfjDrwz4ng1KWOqoO2ixPML9IChfjPn2u9Mh/FQ5kCsvF6xYkL46a1jLUM9Y1z9a3A5qGJmg5VaMfSgg9S/ibc8MVCmrlIfINZloa4PEW6dFPiArq/wTpZHEOP1rzekvrTYGsuMo9X3vrj941PZ3U2ps6cJjZdCRrWJb0FLoY8j1UDbAy8da8IBeswnONKiPrfaKVaDm/l9BhYfp6cJNU2GfzL74QEkjd8W2hOEIy9qp4b3LWn6G2ocdnbDLLuywWsVKHEf+yT/gWkUafvt+W7O0tdDaAgr7cVo7GujvUJGEq3TO5ilXAWDn63HlL6jn5TXBTNi96O2t0m7w1RQvCqemaARH7FOP7E4+cQAPl4315NJksnKRcPFt5tbvC7M/r1YWr9JEbcg7+Ls/fqg8Ss2v18LbkdRpkE/JcXfmZITMXrrYVYvA3Hv98EcKOfN3NzFzoRSAjhtks0na/kkL6kTN1QgkqNqSa+bLPSl5ZVyylooZ3BMSXkFtaM8bQpnFevEbeaA5tUK/j4K+Wtvsmtia/7AxycxF+Pje36kugKEPHnuKKIe2Pp/k3h/E/pA+KSh/5FK3sWIpBYnMsgMJkUjQPXd0UdUDDg8eANMPaLeBcZq+hXTO5R/6bh9rttQTbBrQsA3nnE5xQDlD6Vs8gqFx2KwwiI5ftLfzvL+9GZWKZQkfVpt4dp4u9bEVxxnHFULfX9ll85RhELUDG/dM6Aeyepur/m2EP3Iud5YGmwN86m8zsq2zhTNn4pVPuFmwn8JWQBzKWZYHxwrl+2u/tgEFZ/jiBN XlWmd8gT yZ6x7aTRRnNkZuxWPGbt4iNPaqpHsrrQhyOL2hMIeTb0F1pNXt9joQ/W3V2LvHxf7vNxsCOTXazC/nCkRTnkGH8YjJdlfH+8agnEySnYhBRP72vJyRngU81NLi509O76OBeB8+XB47DNVAQcWbJ9cFhHxTPnDvRwFmcWpT0Sx/SqZRWEphJsYRW/ouazE0Nb6RF6mTwHGn8eqREbC0yRwDUEUVD+phG5UEMBve0QthU2ZSKpFHJdzAH4HOFvm2HW7fpAMFrNEbcxwmnzZYXLXU2DR9R9ZSQFsSQqHN5WMVN/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); } From patchwork Wed Jan 3 08:41:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13509727 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 6D3D8C3DA6E for ; Wed, 3 Jan 2024 08:42:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 04CCC8D0040; Wed, 3 Jan 2024 03:42:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F3EBA8D0035; Wed, 3 Jan 2024 03:42:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E07308D0040; Wed, 3 Jan 2024 03:42:30 -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 CF5BD8D0035 for ; Wed, 3 Jan 2024 03:42:30 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A7910C029D for ; Wed, 3 Jan 2024 08:42:30 +0000 (UTC) X-FDA: 81637358460.16.3549E73 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf11.hostedemail.com (Postfix) with ESMTP id 0F29140027 for ; Wed, 3 Jan 2024 08:42:28 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=gRAjktk4; spf=none (imf11.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=1704271349; 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=ik7cnTIZhbznlyWw4+r3mPkuN44dpkXMWni2Aw4AUI0=; b=6bEG1YrSNBfhBN9abnL/BgAR0XFnKvqQHzbliRsZ/PiTuUqo3BjYfAKTSn/HdTpzfsZeOT CZl4/yFKYQg05kANLvrusGZFkopMA27w0g6xG9JtrInleoKAGw+6hiUGMvaiKJS3HcdCuG VMMjReD1rtdQ3yERLDOqJlj6RCIA+qI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704271349; a=rsa-sha256; cv=none; b=zyJZeCQmsypvky2XJhok+5cxT9bxbgI3nfMhRwGIStp4M6dXJhENwgeDH0CKlcbmdgDYc/ Z1kGye/KvGrqqg89I2/iPA7vr7gc22+6t8PlSbdzgbLBlkcTFgwFRlgiEDy/yMpEL605Lm PwJO5GGrIJY3JCI6/IhWxSYXJwMUP/0= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=gRAjktk4; spf=none (imf11.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=ik7cnTIZhbznlyWw4+r3mPkuN44dpkXMWni2Aw4AUI0=; b=gRAjktk4Su/8TshZNq2nC3vkT6 vMTgAMvHufHHwQsPb9PqatFRNAynJv19dDAEEFtS6L91vABcKdHXCvu7gPOgR4THSK6nNcLSLUFqi APq90y1U9oa7HazrKFy1RytPoRFNktNsgu2FPVux4Yos/evZbQciJqA81sHQhAeThcv5wXw6s/vs1 JRFlZobiatRk4kxHQWwXoY0bvTByfBFljw9C87awvr6xGl6RzL4/Mza5LK+fXjTsl93p1Vx5fS+Vb 5IkCtyVKbnYLVuEPBeomtD4W5cFN5xs2WKWOx2aG+qe3QekojXcshwZwjnLCf7CmdmM360+QolgJU 819dZ7xw==; Received: from [89.144.222.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rKwpT-00A6mu-2b; Wed, 03 Jan 2024 08:42:24 +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 10/15] xfs: remove xfarray_sortinfo.page_kaddr Date: Wed, 3 Jan 2024 08:41:21 +0000 Message-Id: <20240103084126.513354-11-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-Rspamd-Queue-Id: 0F29140027 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: bkqcot7kdizd5rjg1s85zpjwfo5w5i7r X-HE-Tag: 1704271348-365913 X-HE-Meta: U2FsdGVkX1+hPtd4ChqFkXwYJjI/FcfMMKhJf8+HGBGE8OOa+NcbI/2SggfT/R7ahIRT2DcRH816ASh19G7GMXVU+KdfllU20wXKinQzuaYOJE+OOuE4tGVZNg8OBzNqYnaJOIBxrZT2a3k+BJaji0pU6/7+NTfavOsxmGB+bq3guybbewWlF4+77A5zwjsLcuDpXSI1E5/NEuG2kKDgqDYAVJER+gpXFMcXsdFFsYEwEi/xKJjMrbqlNTdModA8ssCk0Wn6SOIOIdDExes0OFl4SpkaDc+jsEXfK8Ghwuf5X675CrEwVe5caFMbA0hScDrW1QbM72VYVknX12CThW1WSDMxZeSI4rv2RD8AN1RhPV6ySmEeEmbbsq7i2R093u3T0rEiqEzSsjbJEEG6wgjVyPXpczRIpygDGP74vjTtWwQOOsD35FmK4RU/orMnAtjkMlEpa7oKp/uOfUWNwd86KcllP4r+xiMrEGPuGLWEobQcJysGV8rWXAppTjYfGnQXf4/pmUoPjtVFgFAjVQhBoXPlxYywVF/2UWAXUHFzjzbw1f5luU57jS/AkC+wbrf6Ifac/IQm/MBOpmhlyAw6DPV/qnXPeINLR7XMQLDJ3qInV5bvQLKk9boM/kAgWVjUITlW4Arrht7OKgt3/Nt5Eu9XbhazhtanZpKIjRh5r7Pm6o+5Ub4E5+0yhDfkJZ7E0q6nkurAoqaikopF4ooR3KxrBj8wpwrr01vMH4HOLuMZoqt8LqpOAxWx8BsjzItJhLiRA7jByQ6r2NhHJrlJecs0UCDSUr2FxXGLsBtVvmeVhXTTudFoFcqxsqc8dhSwo8Odjg4jVj0o8RZINtRNG0UkHSUYaUpHQ87S7bc8IRT507Hdy2sNdEypYh6KDYaP41e/s9+hGyD3SBoe5DuhnIDuv8Ozli5o2uUZahI+HDu6toaFf+W94BshBxQFT4wvF0SU37bniu2zXqX OcxOpydJ bawKA4ng7plkTr+pr8/hALjNSZiTM3ggQ+jiycPmMPe43i2+sgTsaeOc1qy3YWCFQd5l0CNevuSPeFMoXUs5Gg0C+Rqlki+NFdYMBG+6hsMd+4II1yLM4BVIL0BMR6xAMfG6xDhtZnatrNaMeAbdwIjcl3rlQ0lebne+vb0FXWFWvTqg0BzoBFv87oqk3AqbzS7NaU13YQZFq+T3Jm9DFq009zCkVB77ZMPoW+i0Ff7XQ/qZu8DE8PGzlGpYCQQTpEWeRNOS1FApIJck/lszFPjRoxKZjDEmPazeRVUCrhzsc7z2NRezcdg0V+4oIBGqnmxieykmF9bH7dG0aaGEA7VT5z9zOvoAlJKTm3k8jyU1oCqsyPuJrhY6+gLn3TnXVV0yb7dLADFQal+dTfLIvNTWi7k66mNUgBmEBGyHQZDEyycjuCaxgZ7+GNw== 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: Now that xfile pages don't need kmapping, there is no need to cache the kernel virtual address for them. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfarray.c | 22 ++++------------------ fs/xfs/scrub/xfarray.h | 1 - 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/fs/xfs/scrub/xfarray.c b/fs/xfs/scrub/xfarray.c index 3a44700037924b..c29a240d4e25f4 100644 --- a/fs/xfs/scrub/xfarray.c +++ b/fs/xfs/scrub/xfarray.c @@ -570,18 +570,7 @@ xfarray_sort_get_page( loff_t pos, uint64_t len) { - int error; - - error = xfile_get_page(si->array->xfile, pos, len, &si->xfpage); - if (error) - return error; - - /* - * xfile pages must never be mapped into userspace, so we skip the - * dcache flush when mapping the page. - */ - si->page_kaddr = page_address(si->xfpage.page); - return 0; + return xfile_get_page(si->array->xfile, pos, len, &si->xfpage); } /* Release a page we grabbed for sorting records. */ @@ -589,11 +578,8 @@ static inline int xfarray_sort_put_page( struct xfarray_sortinfo *si) { - if (!si->page_kaddr) + if (!xfile_page_cached(&si->xfpage)) return 0; - - si->page_kaddr = NULL; - return xfile_put_page(si->array->xfile, &si->xfpage); } @@ -636,7 +622,7 @@ xfarray_pagesort( return error; xfarray_sort_bump_heapsorts(si); - startp = si->page_kaddr + offset_in_page(lo_pos); + startp = page_address(si->xfpage.page) + offset_in_page(lo_pos); sort(startp, hi - lo + 1, si->array->obj_size, si->cmp_fn, NULL); xfarray_sort_bump_stores(si); @@ -883,7 +869,7 @@ xfarray_sort_load_cached( return error; } - memcpy(ptr, si->page_kaddr + offset_in_page(idx_pos), + memcpy(ptr, page_address(si->xfpage.page) + offset_in_page(idx_pos), si->array->obj_size); return 0; } diff --git a/fs/xfs/scrub/xfarray.h b/fs/xfs/scrub/xfarray.h index 62b9c506fdd1b7..6f2862054e194d 100644 --- a/fs/xfs/scrub/xfarray.h +++ b/fs/xfs/scrub/xfarray.h @@ -107,7 +107,6 @@ struct xfarray_sortinfo { /* Cache a page here for faster access. */ struct xfile_page xfpage; - void *page_kaddr; #ifdef DEBUG /* Performance statistics. */ From patchwork Wed Jan 3 08:41:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13509728 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 92036C3DA6E for ; Wed, 3 Jan 2024 08:42:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 30C638D0041; Wed, 3 Jan 2024 03:42:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 293E78D0035; Wed, 3 Jan 2024 03:42:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15D8C8D0041; Wed, 3 Jan 2024 03:42:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 06FE58D0035 for ; Wed, 3 Jan 2024 03:42:37 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D18411C09A3 for ; Wed, 3 Jan 2024 08:42:36 +0000 (UTC) X-FDA: 81637358712.16.9C6ADFD Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf05.hostedemail.com (Postfix) with ESMTP id 2A6F7100010 for ; Wed, 3 Jan 2024 08:42:34 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="n+GzgA/k"; dmarc=none; spf=none (imf05.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704271355; 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=orc4sDPnUZ3Lccm/B6rTrhsCMlqZK+iu/EE2SUS4e2U=; b=qEkPnxJCycUq5/iQEiZ+9rc+IMqEecr8pqK9j+Fbo3NOcx4EQ64cvFPpY0s6sh/Qx92q3e 2OxRtFDz0lEuA5hU27qr9zgLdc27rQ24AazQEDlHp5B1Fgeret/X1y12w2goNqmQ3difs+ AFgS4ybeol+VrXbrktv+XnS+mQDWZTk= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="n+GzgA/k"; dmarc=none; spf=none (imf05.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704271355; a=rsa-sha256; cv=none; b=jdfAersQlK+95c991nqrC48b+FcD27Vlo2bsJmKE5RUCfJRJvCdLIiczEwOZSEu7RZEuWU +Nj/jSTNgSAyt4bSOXvLQXscwSCCGBbJybqzLWwuy+flDKY7r0VIwLTK1y3IUqKucxF0C+ 6K8jSq5OaoHwBr02hWeVLMGZeZD1v1g= 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=orc4sDPnUZ3Lccm/B6rTrhsCMlqZK+iu/EE2SUS4e2U=; b=n+GzgA/kQKjoT1o7TFuYb6U+mY 2r1k5HWS+z8KR+UrIMzGBOw/euuNtFAlFREzn90l7YxOS/oWws//aFDVedH7D/Y05nXAE4Rs0cwe6 xLRHrU74CmDqVaXe++XJ1uMS5VysD2wTcSMQ5boV4HocrbDxGKcJvwg6Pu/FVxlMVlPQ44izVghn+ CdJxq1rLrE6kyHh25rlH4D//HAhNUs9xma+lkEclJ7mNGsJHJjjVbg5Fj+EUvaXpzp8bqh7dhxMuW 522k/yfXroJDfUYjBQXugC/Sobix6H6s8ntMWHEHXSJxhuDlQwqtRCIY3reTFofafVYyCV66yi7AD WGB7pOaw==; Received: from [89.144.222.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rKwpZ-00A6r7-19; Wed, 03 Jan 2024 08:42:30 +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 11/15] xfs: use shmem_get_folio in xfile_get_page Date: Wed, 3 Jan 2024 08:41:22 +0000 Message-Id: <20240103084126.513354-12-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-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 2A6F7100010 X-Stat-Signature: 3sxzeqwxe6mxodcxhcbufepaxbttmzte X-Rspam-User: X-HE-Tag: 1704271354-199030 X-HE-Meta: U2FsdGVkX1/AYt1PlOohMPsVBeYB7m8QB43O54GQakKB3pTY+f/v80EbPQhPznqupQeSEVh2C+4ztGY8FIQGyIuxoadw5yQ3EGOmvaIKmqrcl7OGAGs+8sQvC8gxuKhKi3a18pLlSKL7f1nrnRJGO7FFpcAEqsTEYpW8kMq7m9GGgoy6mM/3IwYzTYtrQkLW0DMTitZiS71QLXnZw8dDnQgWUTyYgAVfi7YPylVqH6VN0odHH95yiQkPDkW707MuKcMR486wJ0lT2kInE1tHKkNXgD5AZ52k7dVFtdBgb6rHeKk5pG7CvyJpKggEArxpGZAX3+Yi+U/ZiSgJYH7w1bbiy3310geo5LPTlKzt3sbSZAMTIAZLXPHmrT63Kj56E1IAgdt/grbjgwYvKclY24lZU5BvPkURFHQrhq9o8UbRQad48u3P1twlzrz21n0fD7IL1Fm43CNGG90vQEHAY2LhB5uAWpHyM1KFV4Bb7MXq0xCIhEw6I9dA29p8/MBZpJz6JRMboBv+1Is5zTQwSbVLGT7RMxGXYW6JOz0GlOO4FQCvTZtY8piFK8U/jpKA7ou3k+8FJrEChG0iXdZb7ytBnkSovnlVYBpMQMY2ASFMgkvYDwL6oKM4HLMtlLlVi6nD+w0e35mRwIFMa4QTV+344INL3TicNnndLdCTQtp3hd2M7dtRA65oa0VEtBcqnFInSm49NqkwbUlcqiX2Qv/OPlSAryeOqjE5XOsVJ/danySWZHFclHdjlH9NcX0hvmzBzxgiOROWjmcqEprb182BFKo+DvwTH5R8UAksRioTeE/kv2KnHOMvvao7Kt1q7nVmfbLrQq6e0GZkmE92ONWK+tgbFPR123IM8aujr9PXrtL4Z/++fbgAJwlfDwdduewaZS3d0IzfnCyngz4w9azd79p2SxG2eYYhlzkDNWwzY9g1wiZJrrFXjeLM3cs5k9QVVeXs87xD//t6d8o 0UcEr/3B 9359i44UzxALUbi8YHeA4Ss/ln/ZcHKIUGM4jwAgR/7laYizKnbUB1KiZKRQWjqZ6BTNodFBOlm6ofhxdwN3BMDZkrUVdnE6iUuGgioZUvwnSEw05CQ7YbU38mEKp988WVvt2erI+C4xHNwJV0y+rd858Bgkw5db1h9VytFHeO7itKcQv6NGHgYsDYlDL/ZuP4WlMS9/VUXRV0ZNxG4u0FbnXoofk/7J1zhAt96fMXkABtCFdPIXV8H3sWJDCIVVwpT0hZ5Gpl9MP6BRjGq7QzVIOnAejw+W3F85Y/5loUx0IgFavz200G6KbWlyFBxEDhKk1mDE7/j0OU9BdRjmZihCjG/xxlBPwihzuF9WzewbrXsUuyMBik2ZhHo3+rgKfY3N9tTMmZrGBb9qQaFy8R0zAgWdGXNha7R7lkhbNfjBdkrGmXH4XN+QxXQ== 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: Switch to using shmem_get_folio and manually dirtying the page instead of abusing aops->write_begin and aops->write_end in xfile_get_page. This simplified the code by not doing indirect calls of not actually exported interfaces that don't really fit the use case very well. Signed-off-by: Christoph Hellwig --- fs/xfs/scrub/xfarray.c | 32 +++++----------- fs/xfs/scrub/xfile.c | 84 +++++++++++++----------------------------- fs/xfs/scrub/xfile.h | 2 +- 3 files changed, 37 insertions(+), 81 deletions(-) diff --git a/fs/xfs/scrub/xfarray.c b/fs/xfs/scrub/xfarray.c index c29a240d4e25f4..c6e62c119148a1 100644 --- a/fs/xfs/scrub/xfarray.c +++ b/fs/xfs/scrub/xfarray.c @@ -574,13 +574,12 @@ xfarray_sort_get_page( } /* Release a page we grabbed for sorting records. */ -static inline int +static inline void xfarray_sort_put_page( struct xfarray_sortinfo *si) { - if (!xfile_page_cached(&si->xfpage)) - return 0; - return xfile_put_page(si->array->xfile, &si->xfpage); + if (xfile_page_cached(&si->xfpage)) + xfile_put_page(si->array->xfile, &si->xfpage); } /* Decide if these records are eligible for in-page sorting. */ @@ -626,7 +625,8 @@ xfarray_pagesort( sort(startp, hi - lo + 1, si->array->obj_size, si->cmp_fn, NULL); xfarray_sort_bump_stores(si); - return xfarray_sort_put_page(si); + xfarray_sort_put_page(si); + return 0; } /* Return a pointer to the xfarray pivot record within the sortinfo struct. */ @@ -836,10 +836,7 @@ xfarray_sort_load_cached( startpage = idx_pos >> PAGE_SHIFT; endpage = (idx_pos + si->array->obj_size - 1) >> PAGE_SHIFT; if (startpage != endpage) { - error = xfarray_sort_put_page(si); - if (error) - return error; - + xfarray_sort_put_page(si); if (xfarray_sort_terminated(si, &error)) return error; @@ -849,11 +846,8 @@ xfarray_sort_load_cached( /* If the cached page is not the one we want, release it. */ if (xfile_page_cached(&si->xfpage) && - xfile_page_index(&si->xfpage) != startpage) { - error = xfarray_sort_put_page(si); - if (error) - return error; - } + xfile_page_index(&si->xfpage) != startpage) + xfarray_sort_put_page(si); /* * If we don't have a cached page (and we know the load is contained @@ -995,10 +989,7 @@ xfarray_sort( if (error) goto out_free; } - error = xfarray_sort_put_page(si); - if (error) - goto out_free; - + xfarray_sort_put_page(si); if (xfarray_sort_terminated(si, &error)) goto out_free; @@ -1024,10 +1015,7 @@ xfarray_sort( if (error) goto out_free; } - error = xfarray_sort_put_page(si); - if (error) - goto out_free; - + xfarray_sort_put_page(si); if (xfarray_sort_terminated(si, &error)) goto out_free; diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index afbd205289e9b0..2b4b0c4e8d2fb6 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -278,11 +278,8 @@ xfile_get_page( struct xfile_page *xfpage) { struct inode *inode = file_inode(xf->file); - struct address_space *mapping = inode->i_mapping; - const struct address_space_operations *aops = mapping->a_ops; - struct page *page = NULL; - void *fsdata = NULL; - loff_t key = round_down(pos, PAGE_SIZE); + struct folio *folio = NULL; + struct page *page; unsigned int pflags; int error; @@ -293,78 +290,49 @@ xfile_get_page( trace_xfile_get_page(xf, pos, len); - pflags = memalloc_nofs_save(); - /* - * We call write_begin directly here to avoid all the freezer - * protection lock-taking that happens in the normal path. shmem - * doesn't support fs freeze, but lockdep doesn't know that and will - * trip over that. + * Increase the file size first so that shmem_get_folio(..., SGP_CACHE), + * actually allocates a folio instead of erroring out. */ - error = aops->write_begin(NULL, mapping, key, PAGE_SIZE, &page, - &fsdata); - if (error) - goto out_pflags; - - /* We got the page, so make sure we push out EOF. */ - if (i_size_read(inode) < pos + len) + if (pos + len > i_size_read(inode)) i_size_write(inode, pos + len); - /* - * If the page isn't up to date, fill it with zeroes before we hand it - * to the caller and make sure the backing store will hold on to them. - */ - if (!PageUptodate(page)) { - memset(page_address(page), 0, PAGE_SIZE); - SetPageUptodate(page); + pflags = memalloc_nofs_save(); + error = shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio, SGP_CACHE); + memalloc_nofs_restore(pflags); + if (error) + return error; + + page = folio_file_page(folio, pos >> PAGE_SHIFT); + if (PageHWPoison(page)) { + folio_put(folio); + return -EIO; } /* - * Mark each page dirty so that the contents are written to some - * backing store when we drop this buffer, and take an extra reference - * to prevent the xfile page from being swapped or removed from the - * page cache by reclaim if the caller unlocks the page. + * Mark the page dirty so that it won't be reclaimed once we drop the + * (potentially last) reference in xfile_put_page. */ set_page_dirty(page); - get_page(page); xfpage->page = page; - xfpage->fsdata = fsdata; - xfpage->pos = key; -out_pflags: - memalloc_nofs_restore(pflags); - return error; + xfpage->fsdata = NULL; + xfpage->pos = round_down(pos, PAGE_SIZE); + return 0; } /* - * Release the (locked) page for a memory object. Returns 0 or a negative - * errno. + * Release the (locked) page for a memory object. */ -int +void xfile_put_page( struct xfile *xf, struct xfile_page *xfpage) { - struct inode *inode = file_inode(xf->file); - struct address_space *mapping = inode->i_mapping; - const struct address_space_operations *aops = mapping->a_ops; - unsigned int pflags; - int ret; - - trace_xfile_put_page(xf, xfpage->pos, PAGE_SIZE); + struct page *page = xfpage->page; - /* Give back the reference that we took in xfile_get_page. */ - put_page(xfpage->page); + trace_xfile_put_page(xf, page->index << PAGE_SHIFT, PAGE_SIZE); - pflags = memalloc_nofs_save(); - ret = aops->write_end(NULL, mapping, xfpage->pos, PAGE_SIZE, PAGE_SIZE, - xfpage->page, xfpage->fsdata); - memalloc_nofs_restore(pflags); - memset(xfpage, 0, sizeof(struct xfile_page)); - - if (ret < 0) - return ret; - if (ret != PAGE_SIZE) - return -EIO; - return 0; + unlock_page(page); + put_page(page); } diff --git a/fs/xfs/scrub/xfile.h b/fs/xfs/scrub/xfile.h index f0e11febf216a7..2f46b7d694ce99 100644 --- a/fs/xfs/scrub/xfile.h +++ b/fs/xfs/scrub/xfile.h @@ -37,6 +37,6 @@ loff_t xfile_seek_data(struct xfile *xf, loff_t pos); int xfile_get_page(struct xfile *xf, loff_t offset, unsigned int len, struct xfile_page *xbuf); -int xfile_put_page(struct xfile *xf, struct xfile_page *xbuf); +void xfile_put_page(struct xfile *xf, struct xfile_page *xbuf); #endif /* __XFS_SCRUB_XFILE_H__ */ From patchwork Wed Jan 3 08:41: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: 13509729 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 048F9C3DA6E for ; Wed, 3 Jan 2024 08:42:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 83B458D0047; Wed, 3 Jan 2024 03:42:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7ED698D0035; Wed, 3 Jan 2024 03:42:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68D298D0047; Wed, 3 Jan 2024 03:42:43 -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 570228D0035 for ; Wed, 3 Jan 2024 03:42:43 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 28555C07A1 for ; Wed, 3 Jan 2024 08:42:43 +0000 (UTC) X-FDA: 81637359006.14.D650EE0 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf23.hostedemail.com (Postfix) with ESMTP id 77618140005 for ; Wed, 3 Jan 2024 08:42:41 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=ASgrEkYJ; dmarc=none; spf=none (imf23.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704271361; 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=M25YP3MJC0WFFEaqgM6Rn4ZAWOo1a5MeaBp1CQxHNmw=; b=NEapyIKu5ayDRWSvpf00Fy8KI7lR7f+Toe7f3tKpMWboTZMBilwF6Rr17waK5CzA1SEwBo BQrTCiFm7uV9BBVjtjJ7SKIp02uFbpFkx+2OREYibZQIgwuu7wDrvuyk6WELqkr00frZ0C EM2VIDJnH7TugryR9AaGrI6LOMx1n00= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=ASgrEkYJ; dmarc=none; spf=none (imf23.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704271361; a=rsa-sha256; cv=none; b=nNLLNRzZ72cAHDdJMGaH+f87+uI1M0rhP4ubo9FUSZZgEgq/5L0PiL7G/0exHcxBVmnX0L Ar5vNcFxcqmuP1Kqb+PBAm9R8YevMzE4uvw85LWXmefUjlVkwZWAflhqo/DisvTtLU77VX OqkSH2i9T7S+YMc8Xx+gUFFc2Iv0ijI= 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=M25YP3MJC0WFFEaqgM6Rn4ZAWOo1a5MeaBp1CQxHNmw=; b=ASgrEkYJahD24JFHCFFv1risR2 oaQSwrUG1J3jk2Fby1ONeoxdFWtN3P7bJ3MCNz3X366hZyq+TY908FlopxKFeQZs9x0d85VR0xNgy 864Wa1ycDqTVMx2ogz1UxwnXGcE/9ZwcisG1gvLNIIeTGvTAa1X0NIDNnodkUgYDcr6tl7cPwFXkR OBj2j33t21gfgKbk6zEe+l0bGaksdiiccMBjUVUufMd6riDPp9S213QX1HCsouYfmphtDekvsQQts 6OAHzgyHvMEshN6L2LrR+P7FEJKXV9/CiQVtmZ8PmfX7LxIYzTz7jemrOdPj4UisT/fm/eXauy1qD YEeyz9Fg==; Received: from [89.144.222.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rKwpe-00A6sq-38; Wed, 03 Jan 2024 08:42:36 +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 12/15] xfs: remove struct xfile_page Date: Wed, 3 Jan 2024 08:41:23 +0000 Message-Id: <20240103084126.513354-13-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-Rspamd-Queue-Id: 77618140005 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: b3tpyqrtwdx7r57ofzk43od7is6qmg9u X-HE-Tag: 1704271361-365713 X-HE-Meta: U2FsdGVkX1+uLaHNoeve5/tWvByYsCtR3iL0rFS0CN70q/fOgMSyzKtViMlWDFzKcDCLNkVKqQvdECzMAvQAwi6LEDmDjt5NXMv7x1YDYpfk2PI5Ev+MhtnleK8qiSEZND/BYpUXc0uJpLEtMdnyC3qQB9AlnifMUrL49aolM6fx51gDTzXqobgQV1iFbisyYAkuZRJkJiQlWcrSxvVmJ/Vmq6/70IS7XYGzQa6u34YqQM/2hylKM2Ka5Z15RP2HrWuXTrirZYgb7zHVDVMBZXEK3A2+D1RHoRZe15uUu9u6Yg28e68XnIilzgH+1s+wGsXtxxQrgOH48V9tcOkEfIeSpKvYWAYj0Ty8nHdzLHNcru/TD50X2KLDKxmjd0+LXn1TgMnUsjid6esHBaYl9/esXu6dlFJzqb42K76wDzuzy7SGLq85ZVQJxSI4oWiB7BzUO+cZRUtr4t3nzzc/NGsrN2xygDzbY5Zaif/n7PsFj1J3D9/YtdeulxA4gID3rCdAfJ6vcWasX3zZyI4BqUj+CjgVdTf+etpo1L4PY6DPyHvE/SjiuO175T+YASpaAVoCykWic3m11RBcUjWFV5n0eOuO1x3Ks/0XI9Kk3/Bg5NnPsA0ntLL9caYnBpuvYt1r3fG24Woa27LYIIWM0DREhc1ycCInuujs83PuE7nqxfh5KIc0z9Jae+F2gBTaknQXIuZJ0n7yWahllhrAz9CFGv6H7vC7lA6gmccB4T9Wet6gXOt27i2aK8T2YI1fEoaUpY4SO4OwP29FiZLpUP2b90mAM52S1U/5HX3VKw5x/5i/jptej1JctvmhI5XSRZoPOsKlNPMhTwQGx93q0jLNbUE4k6VAiTguso/0Rbqour8ZF7hS2U9HXqLWtaauJUJeQs/4AvpXd/cn5FOI1jvn+3fVhh4NH/0Pc6LiedQzkxBH2pWFdlJzgeVPFE3oiIXxwo8ag4Dh83ZkSTy bHG1JFZg hhtNir4l2IOa25zUz2n1Zczrarn4Phb+4UnegNUAcvIAT+TGeAla2zoHekfwVeOlewETrXsWGS2iJ2pXxTIU4Auf9zuV45xP3PGQ1BDBVGiO+eA2OXxy31DnrcaGjE6Qn6fp4sz0+da8NunKFHQjVjM4lZCiK4K/+h1WUH7WpFf0iuESY1gdqJWubiW3GzfNQMZd8kRo6PHG/Ys/xVogF3dJCZx8eGR27WSZHmtUwwsK2ZNuUWb0P3+5IPHotI35S8TOzQxO/C3ONZcogir2d9uQ+DnzsvU2QtdNoLiEykcGVxstzway2z6uZmieTQIv5rBq2uSG4RX/XG4p5+7zuoShV7dQBBEY8keDPhT0EKAiNmzgURApUpaz7a8gkWD+WKrDLTKeT4j6MlOOyvHlyaSSfpwdBuq6f+/YZ9e1Oq/KrDdQhLKSXsQadPA== 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: Return the shmem page directly from xfile_page_get and pass it back to xfile_page. Signed-off-by: Christoph Hellwig --- fs/xfs/scrub/xfarray.c | 23 +++++++++++++++-------- fs/xfs/scrub/xfarray.h | 2 +- fs/xfs/scrub/xfile.c | 27 ++++++++++----------------- fs/xfs/scrub/xfile.h | 21 ++------------------- 4 files changed, 28 insertions(+), 45 deletions(-) diff --git a/fs/xfs/scrub/xfarray.c b/fs/xfs/scrub/xfarray.c index c6e62c119148a1..4f396462186793 100644 --- a/fs/xfs/scrub/xfarray.c +++ b/fs/xfs/scrub/xfarray.c @@ -570,7 +570,13 @@ xfarray_sort_get_page( loff_t pos, uint64_t len) { - return xfile_get_page(si->array->xfile, pos, len, &si->xfpage); + struct page *page; + + page = xfile_get_page(si->array->xfile, pos, len); + if (IS_ERR(page)) + return PTR_ERR(page); + si->page = page; + return 0; } /* Release a page we grabbed for sorting records. */ @@ -578,8 +584,10 @@ static inline void xfarray_sort_put_page( struct xfarray_sortinfo *si) { - if (xfile_page_cached(&si->xfpage)) - xfile_put_page(si->array->xfile, &si->xfpage); + if (si->page) { + xfile_put_page(si->array->xfile, si->page); + si->page = NULL; + } } /* Decide if these records are eligible for in-page sorting. */ @@ -621,7 +629,7 @@ xfarray_pagesort( return error; xfarray_sort_bump_heapsorts(si); - startp = page_address(si->xfpage.page) + offset_in_page(lo_pos); + startp = page_address(si->page) + offset_in_page(lo_pos); sort(startp, hi - lo + 1, si->array->obj_size, si->cmp_fn, NULL); xfarray_sort_bump_stores(si); @@ -845,15 +853,14 @@ xfarray_sort_load_cached( } /* If the cached page is not the one we want, release it. */ - if (xfile_page_cached(&si->xfpage) && - xfile_page_index(&si->xfpage) != startpage) + if (si->page && si->page->index != startpage) xfarray_sort_put_page(si); /* * If we don't have a cached page (and we know the load is contained * in a single page) then grab it. */ - if (!xfile_page_cached(&si->xfpage)) { + if (!si->page) { if (xfarray_sort_terminated(si, &error)) return error; @@ -863,7 +870,7 @@ xfarray_sort_load_cached( return error; } - memcpy(ptr, page_address(si->xfpage.page) + offset_in_page(idx_pos), + memcpy(ptr, page_address(si->page) + offset_in_page(idx_pos), si->array->obj_size); return 0; } diff --git a/fs/xfs/scrub/xfarray.h b/fs/xfs/scrub/xfarray.h index 6f2862054e194d..5765f2ad30d885 100644 --- a/fs/xfs/scrub/xfarray.h +++ b/fs/xfs/scrub/xfarray.h @@ -106,7 +106,7 @@ struct xfarray_sortinfo { unsigned int flags; /* Cache a page here for faster access. */ - struct xfile_page xfpage; + struct page *page; #ifdef DEBUG /* Performance statistics. */ diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 2b4b0c4e8d2fb6..715c4d10b67c14 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -267,15 +267,14 @@ xfile_seek_data( /* * Grab the (locked) page for a memory object. The object cannot span a page - * boundary. Returns 0 (and a locked page) if successful, -ENOTBLK if we - * cannot grab the page, or the usual negative errno. + * boundary. Returns 0 the locked page if successful, or an ERR_PTR on + * failure. */ -int +struct page * xfile_get_page( struct xfile *xf, loff_t pos, - unsigned int len, - struct xfile_page *xfpage) + unsigned int len) { struct inode *inode = file_inode(xf->file); struct folio *folio = NULL; @@ -284,9 +283,9 @@ xfile_get_page( int error; if (inode->i_sb->s_maxbytes - pos < len) - return -ENOMEM; + return ERR_PTR(-ENOMEM); if (len > PAGE_SIZE - offset_in_page(pos)) - return -ENOTBLK; + return ERR_PTR(-ENOTBLK); trace_xfile_get_page(xf, pos, len); @@ -301,12 +300,12 @@ xfile_get_page( error = shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio, SGP_CACHE); memalloc_nofs_restore(pflags); if (error) - return error; + return ERR_PTR(error); page = folio_file_page(folio, pos >> PAGE_SHIFT); if (PageHWPoison(page)) { folio_put(folio); - return -EIO; + return ERR_PTR(-EIO); } /* @@ -314,11 +313,7 @@ xfile_get_page( * (potentially last) reference in xfile_put_page. */ set_page_dirty(page); - - xfpage->page = page; - xfpage->fsdata = NULL; - xfpage->pos = round_down(pos, PAGE_SIZE); - return 0; + return page; } /* @@ -327,10 +322,8 @@ xfile_get_page( void xfile_put_page( struct xfile *xf, - struct xfile_page *xfpage) + struct page *page) { - struct page *page = xfpage->page; - trace_xfile_put_page(xf, page->index << PAGE_SHIFT, PAGE_SIZE); unlock_page(page); diff --git a/fs/xfs/scrub/xfile.h b/fs/xfs/scrub/xfile.h index 2f46b7d694ce99..993368b37b4b7c 100644 --- a/fs/xfs/scrub/xfile.h +++ b/fs/xfs/scrub/xfile.h @@ -6,22 +6,6 @@ #ifndef __XFS_SCRUB_XFILE_H__ #define __XFS_SCRUB_XFILE_H__ -struct xfile_page { - struct page *page; - void *fsdata; - loff_t pos; -}; - -static inline bool xfile_page_cached(const struct xfile_page *xfpage) -{ - return xfpage->page != NULL; -} - -static inline pgoff_t xfile_page_index(const struct xfile_page *xfpage) -{ - return xfpage->page->index; -} - struct xfile { struct file *file; }; @@ -35,8 +19,7 @@ int xfile_obj_store(struct xfile *xf, const void *buf, size_t count, loff_t xfile_seek_data(struct xfile *xf, loff_t pos); -int xfile_get_page(struct xfile *xf, loff_t offset, unsigned int len, - struct xfile_page *xbuf); -void xfile_put_page(struct xfile *xf, struct xfile_page *xbuf); +struct page *xfile_get_page(struct xfile *xf, loff_t offset, unsigned int len); +void xfile_put_page(struct xfile *xf, struct page *page); #endif /* __XFS_SCRUB_XFILE_H__ */ From patchwork Wed Jan 3 08:41:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13509730 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 D9350C47074 for ; Wed, 3 Jan 2024 08:42:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6DCE66B00D7; Wed, 3 Jan 2024 03:42:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 68E078D0035; Wed, 3 Jan 2024 03:42:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52D266B00D9; Wed, 3 Jan 2024 03:42:49 -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 419286B00D7 for ; Wed, 3 Jan 2024 03:42:49 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 241FDA1AA4 for ; Wed, 3 Jan 2024 08:42:49 +0000 (UTC) X-FDA: 81637359258.03.7547364 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf09.hostedemail.com (Postfix) with ESMTP id 8717814000B for ; Wed, 3 Jan 2024 08:42:47 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=xUQFbdpu; dmarc=none; spf=none (imf09.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704271367; 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=a2KU587OgqnObeCrGx0UU79uRQUUDAR8Cm6RFnFUOy8=; b=aLC6LG1wnbxA5/rCbf6YKFfrY32NfRhCuUBHUKgt8+/CrNjeClx2MMhOKWNMuIVMIAFAwR 7g+vFMVSCbyj3Gkm5eodA8MF4xbhRXAOHiNrs52LCDskwl51R680UIxnmjeGio1KU3k7VI y+KYLearVpE9pmnAcLlZ4067bpeoFxA= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=xUQFbdpu; dmarc=none; spf=none (imf09.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704271367; a=rsa-sha256; cv=none; b=e4BCkgI+WveJ8H2rHnd/Dkqm4V4h51ROaCRjProAa1zXnHqIjzK8rBB9MjVuEAC8OHI+Mh vaJ38FEaVvtmBhUqB84X3qMqxaXD87Fxn2l+PVZ4iRbGY4kSIhjljwFDlxspmUUiybY9eg wCbIGOVaSuKPvKY4QcTfehATtIqVIvU= 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=a2KU587OgqnObeCrGx0UU79uRQUUDAR8Cm6RFnFUOy8=; b=xUQFbdpubXfChe2Qx//ZD9lJ2P EeE0mcPqXp7XRhtFCs6ZAOL8/8PWfHGYYgHcgtGj+Fzgd7HuppaPAOICSanP3ICu3IBf8Gn46EDny vGtFDb4Jy5MWKnEPxQ5kfgpaNUvbPb4L/bHgjwkRmLkpTtVAPe7HS616Um4nVtGpQJdFYLmlUOkFD sbrY6co1D9btX06ldeHVaa0UyRZpOKdqP9J6HUa9NcP1TkCuYbPtpjOMShI8iUa3ET+CpxW8nxBKp nqXL4biGZR1oLOM2VZ3wLYrL0lr5RSL1190L0axmtIKXgaAQv0Gu83LaKNOR7W79v+U/uXOFXbGD/ MtlAnNtQ==; Received: from [89.144.222.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rKwpl-00A6wM-1M; Wed, 03 Jan 2024 08:42:42 +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/15] xfs: don't unconditionally allocate a new page in xfile_get_page Date: Wed, 3 Jan 2024 08:41:24 +0000 Message-Id: <20240103084126.513354-14-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-Rspam-User: X-Stat-Signature: 44zmzn6yi375doqwibjdm9p8permddm5 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8717814000B X-HE-Tag: 1704271367-827747 X-HE-Meta: U2FsdGVkX19/lfw3Xf6XFfQw4lpWnRmsYFUa2zqavK3G4Pf+vIaGyyqB86+eWnk3fr+lPt5gS1QLZXamiXnCk/aK82TEyGgCPaUG1OyJ6sJNNPGJEl86Bie/r/GyJa0ISRVzcufuhLFHVEUAVKpIu08M+RlmOR6SI1muQPcQ4PSU4VmclzyrcoL4ZPD9quaMtAMTqLUUsDOkXezOnEhbjijFjY8HUKqiUuU9+wAbhTdLGRcVu/XGTjVZk3efGko0XWRPUUefJQrau+P/zTpa03G5Ysmo7G+gN9VStFa8orNWh/gzWFr7iRGzCTpWFyMIp2hCWvx/f+hX/OgZL1E1VJa8Jdwg5oG1YenH8NgfBNKuPHWB6QP0C8LuPXkd5Vm1PI5q+CjE2Ou0DHrr/PCUYK2Sxzq3iIG3Ip3AgTxTiqcGGnvj8ynYerVhS7y5SvWcE2HvTr/Pnu1ZyRMoju/xGCfnq+CNs06MARPHqlAXj7wtq1Iiupuh9CWTGDdsbRF8ZsM27nOtarXybyrscaBF4E2e8/Mp5pu17hAjdBopJFf3c/sQnYz8BgzvE29t0PsMzIbvI9ae9y2oxDWEDKIf0ITqCk7i+Doffw6OVi4eUi0vmdNMAGGD8vzuPr6FB8jz6guo2GZdSdfdikvutoEnswBEhHRqyeZDU57F7q5oVCdIephhLoLCKHYvZ5kOn7fdfh5kYUKZYnlQqjzMXeTvHkIebNhzQFtaZRcWlTAMBN6fFwCV/rEQfd2XpiQ9eZdaZvdxNnygTb92KbiYDAA2JX/KK41x9lkHsncP52ao4UX17Nx33N+lfiyf3RSA/GPy6FDxFhG5DNlao2DK/YJ0YnU1OCpfIllrBzyXFHX6WVtZXaO+aXOSZuHdXHI9nx6QJ59scs1hGUiKVnq6EhUe8/vuBe4wjFYR6pVd1f4Qzd6jy+TrHzrdi0UFAfPbcMQgnDCrZdyFkZ0PRmPwVW+ XS7cpTq8 onmfmfq3qcHFNHybJ5A5ZTPoNp74kD38kE8K1iCuUONbAadLUcs0L5PYkeB4QX7zrqQOD6M5pIPcsrsKWrX0B0zX8oePHDLQvuO3NSZsE8BDFdetW8s1t5xtc5VaQRXHjlpOiHpAtZjbAUnTB6wYO16zjDB/N/4CWDdFa/MZob+CQ44R7HRq/D9E4gfALYmwQLrUODv+bKt52ImXQXnazJCS4vqbfL8T3m/XN96GkIBDKs0TwVkogmSeTJwSnbD4lKQ5PPvVO3WJRHxNFHYhYWU/Xb9DZBuRVcrdsk+EQ1o/y5r6BJAtph6RyQXM4mNDP1K2xfDK+3d30Nq+zw9/zyUqwSXaTSfkazw7TE0aOU7A005TD5AEKz2+8SjJqn8s2ORhAbNL+6BNB+u0iR57WAJQKGEjXW3RxSDBH0MyK0dXFgMIrvxILd0Uusg== 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: Pass a flags argument to xfile_get_page, and only allocate a new page if the XFILE_ALLOC flag is passed. This allows to also use xfile_get_page for pure readers that do not want to allocate a new page or dirty the existing one. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfarray.c | 2 +- fs/xfs/scrub/xfile.c | 14 ++++++++++---- fs/xfs/scrub/xfile.h | 4 +++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/fs/xfs/scrub/xfarray.c b/fs/xfs/scrub/xfarray.c index 4f396462186793..8543067d46366d 100644 --- a/fs/xfs/scrub/xfarray.c +++ b/fs/xfs/scrub/xfarray.c @@ -572,7 +572,7 @@ xfarray_sort_get_page( { struct page *page; - page = xfile_get_page(si->array->xfile, pos, len); + page = xfile_get_page(si->array->xfile, pos, len, XFILE_ALLOC); if (IS_ERR(page)) return PTR_ERR(page); si->page = page; diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 715c4d10b67c14..3ed7fb82a4497b 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -274,7 +274,8 @@ struct page * xfile_get_page( struct xfile *xf, loff_t pos, - unsigned int len) + unsigned int len, + unsigned int flags) { struct inode *inode = file_inode(xf->file); struct folio *folio = NULL; @@ -293,15 +294,19 @@ xfile_get_page( * Increase the file size first so that shmem_get_folio(..., SGP_CACHE), * actually allocates a folio instead of erroring out. */ - if (pos + len > i_size_read(inode)) + if ((flags & XFILE_ALLOC) && pos + len > i_size_read(inode)) i_size_write(inode, pos + len); pflags = memalloc_nofs_save(); - error = shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio, SGP_CACHE); + error = shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio, + (flags & XFILE_ALLOC) ? SGP_CACHE : SGP_READ); memalloc_nofs_restore(pflags); if (error) return ERR_PTR(error); + if (!folio) + return NULL; + page = folio_file_page(folio, pos >> PAGE_SHIFT); if (PageHWPoison(page)) { folio_put(folio); @@ -312,7 +317,8 @@ xfile_get_page( * Mark the page dirty so that it won't be reclaimed once we drop the * (potentially last) reference in xfile_put_page. */ - set_page_dirty(page); + if (flags & XFILE_ALLOC) + set_page_dirty(page); return page; } diff --git a/fs/xfs/scrub/xfile.h b/fs/xfs/scrub/xfile.h index 993368b37b4b7c..f0403ea869e4d0 100644 --- a/fs/xfs/scrub/xfile.h +++ b/fs/xfs/scrub/xfile.h @@ -19,7 +19,9 @@ int xfile_obj_store(struct xfile *xf, const void *buf, size_t count, loff_t xfile_seek_data(struct xfile *xf, loff_t pos); -struct page *xfile_get_page(struct xfile *xf, loff_t offset, unsigned int len); +#define XFILE_ALLOC (1 << 0) /* allocate page if not present */ +struct page *xfile_get_page(struct xfile *xf, loff_t offset, unsigned int len, + unsigned int flags); void xfile_put_page(struct xfile *xf, struct page *page); #endif /* __XFS_SCRUB_XFILE_H__ */ From patchwork Wed Jan 3 08:41:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13509731 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 80251C3DA6E for ; Wed, 3 Jan 2024 08:42:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 188976B0104; Wed, 3 Jan 2024 03:42:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1398D6B0111; Wed, 3 Jan 2024 03:42:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECA316B0104; Wed, 3 Jan 2024 03:42:55 -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 DCE1E6B00DD for ; Wed, 3 Jan 2024 03:42:55 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B3E0716023B for ; Wed, 3 Jan 2024 08:42:55 +0000 (UTC) X-FDA: 81637359510.25.96E1E10 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf05.hostedemail.com (Postfix) with ESMTP id 24331100016 for ; Wed, 3 Jan 2024 08:42:53 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="ushH/vho"; dmarc=none; spf=none (imf05.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704271374; 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=vsVwWXzNp/uF3VedPHiPLXVFz+eMZwvkb3rlfHln50o=; b=szYKvL9f9tJD8uHhcMKqeS+IyB4qud4eBGh9otfPXhTeIq/g2ytjbWAbAYSwpvOC1a3/6q qknOsBqsA0gjPAQ9MAHKM/COL0gvk+r44luaSEQ3gWnoT0g9QdUlPCj4GGBjIetxIFINNl 0usCye6WwDXctM1f4G0px7ekHK+2vbU= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="ushH/vho"; dmarc=none; spf=none (imf05.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704271374; a=rsa-sha256; cv=none; b=aTGZzNV7feSN6E1QIUgJqVUcwk7KeKcrO1/G2EURFXAokxgWTm2zrYR7sVqlu7G5am4R9N GjRrEejMnVJjBKGlwkNTTmy8WdfcqZVsc3h0wSccIkTf0nJcn5uP5N+683nJ3q+9HNRG7b CSySuw3nc5HsXC2ZEMAcfuyiwkwktj4= 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=vsVwWXzNp/uF3VedPHiPLXVFz+eMZwvkb3rlfHln50o=; b=ushH/vhogOKJM3dNcUq2jCv9IU q8maRJKSzV35pfdLYBkzK2kXNLfpfTFmJ0/yRj44opJilvDQZzZ7vWgMgeMgr8BqFr2kbeKm8/JuI tFGKIjSbiQprPzQvRjdG5OqHdBLexBDwTl25ZGYwXUMyvyMfx6L/W9C4fMccYIM2FySS3GHDwP03I Y2V9eFYKnpreihOWfze6ik5bw2PufxUXxUECRo+vlFR6JGaIUAs/nKiaTusk9tMckadbG9/R0IjW1 GvK1CFewMDD0bL5nII7yyovgXzFVM0kOIAMKmKnVUy+LbR0R2Duw8/zmq3keDLk2Lz0LEO/8VZosm rqFGj2Aw==; Received: from [89.144.222.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rKwpr-00A6zm-2U; Wed, 03 Jan 2024 08:42:48 +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 14/15] xfs: use xfile_get_page and xfile_put_page in xfile_obj_store Date: Wed, 3 Jan 2024 08:41:25 +0000 Message-Id: <20240103084126.513354-15-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-Rspamd-Queue-Id: 24331100016 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 7roo9ecqm1xejc8hk5jbbn49p6kuamq7 X-HE-Tag: 1704271373-765379 X-HE-Meta: U2FsdGVkX19KgGRGJz01KzbC4H/vlK9Qq9Q6t/9g6dh8HkFxjiAa6aw+aMNRj75kdPuTtKzHbByaz3tT6Kyg59fX/kWI6NROU0bnlkEyLxL77lVTWqbk4jLGoYjMqDTEfqHkCct0ws+hDLoAKP6s01roSp7LbyJ5vqXTb6Yob3z5IsvVirUiNsorgv0eD66OJDiPRF4AOmpd2uzvv4YjjX9sNe+J5IkqL+sVWL5jjyDC+haFn58uM8JOf9AV74X9PGz9uSg4pRWExvPi00abzjh3Ku63XN5F6wZTrkGd9i5TPWhFS9xef85REoQj9iwGCZwllRqqzdR04CfxMxfWu5DC9eoTJ9T0WnAJIIA6kvnRZCf3R3PCHn/5P01CVEkFifdjAs2Qvb1bpfS9XhIWi3meahZZk8w8Yb2n58LdNBxyyvM1TdO9MTdqklSA7oPvu9kivfZrZspEI0zEXuQEvW8m52XAr3CbeZBhWEyaXiuHT9XNJpy51a6BFnvPgZWPwtulB/9WSHhSBGiE0OE+EzLlJCD62FembD3xUhPZJwLlCT9jDt3iJh0tdZTQyVt0GO775GnCAvTHOxMyeUaMekIpCPLEPpJs9IyLiex+lBPgslcOBLE+4HU0R1saUunLmCNJS2A4wVNC75chf+2aA7XFtSxb0o27mDNZlG1uC4gVa388qt1JUZMbHNgRUdAb3tMKRyd6WPVXScneacXfdxC7UEE89GmF0jV1psKCs1zO28WyN7Re23U/4nW0krLoL8aOLe0iRDSwhzYD8SLDa6LtnHPujyyaIa97q+WjESM+jKMtX83pr0+TUwFUgrTbkQMYAIoRBsOCcKZe0rM4Q48cZNhPbewhPoJWbAZ26zhyJNwdatQMf2OJsfCx9oYiQfM/82jQpJpleGsufefBX3aNQn01fQ7ZAM0qPQFRSvyc+X2ZG/DbsxsinLMj68f2Ixwc5HoBtINImPEOYKw 7gvwU2mf MMgFhUb6iqSI4RWsM2GIiVXVWOKOWB1i/8rMoElV7Fcih93/mO5IY6gUlh42IQjT8LN8Yq4Xc5Kwn3mkmUvJqTraAlOSuoXk9o60x55Jbm1gzoa4cnom0F3yqmTgO582rE8uEEqg+LTd/RGzyrwyNlWeouSPRLjQ8bHju/kfKAo/RCZPdjOvc+RvHW4Lx0YMjEOFYvIin3ZQhmSs2IrHEufvmt/EzjmZb0Q9ExGE2ZgKUk4o4pDo+mT3bqnLq51PiI7kxJ7wmr0foips8l2t2/vQFhRuUL1AqaJ28dYm/qCLZoLZrxyqR0ZuVWXheDuwAKPMxTj613WCKQZWa0d9nc4BbdOHhPNXXZpe6/fq8vQepNmYvpKJDdIjAi8hmdya/XddkYOpt8yTLoGT8HDbeqhzGSIJEsmOrG+34CmK6zTdiplmNZ+p7zqdvbZAjIIi5NuKwamGMVqdKBsE= 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: Rewrite xfile_obj_store to use xfile_get_page and xfile_put_page to access the data in the shmem page cache instead of abusing the shmem write_begin and write_end aops. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfile.c | 66 ++++++++------------------------------------ 1 file changed, 11 insertions(+), 55 deletions(-) diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 3ed7fb82a4497b..987b03df241b02 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -182,74 +182,30 @@ xfile_obj_store( size_t count, loff_t pos) { - struct inode *inode = file_inode(xf->file); - struct address_space *mapping = inode->i_mapping; - const struct address_space_operations *aops = mapping->a_ops; - struct page *page = NULL; - unsigned int pflags; - int error = 0; - if (count > MAX_RW_COUNT) return -ENOMEM; - if (inode->i_sb->s_maxbytes - pos < count) + if (file_inode(xf->file)->i_sb->s_maxbytes - pos < count) return -ENOMEM; trace_xfile_obj_store(xf, pos, count); - pflags = memalloc_nofs_save(); while (count > 0) { - void *fsdata = NULL; - void *p, *kaddr; + struct page *page; unsigned int len; - int ret; len = min_t(ssize_t, count, PAGE_SIZE - offset_in_page(pos)); + page = xfile_get_page(xf, pos, len, XFILE_ALLOC); + if (IS_ERR(page)) + return -ENOMEM; + memcpy(page_address(page) + offset_in_page(pos), buf, len); + xfile_put_page(xf, page); - /* - * We call write_begin directly here to avoid all the freezer - * protection lock-taking that happens in the normal path. - * shmem doesn't support fs freeze, but lockdep doesn't know - * that and will trip over that. - */ - error = aops->write_begin(NULL, mapping, pos, len, &page, - &fsdata); - if (error) { - error = -ENOMEM; - break; - } - - /* - * xfile pages must never be mapped into userspace, so we skip - * the dcache flush. If the page is not uptodate, zero it - * before writing data. - */ - kaddr = page_address(page); - if (!PageUptodate(page)) { - memset(kaddr, 0, PAGE_SIZE); - SetPageUptodate(page); - } - p = kaddr + offset_in_page(pos); - memcpy(p, buf, len); - - ret = aops->write_end(NULL, mapping, pos, len, len, page, - fsdata); - if (ret < 0) { - error = -ENOMEM; - break; - } - - if (ret != len) { - error = -ENOMEM; - break; - } - - count -= ret; - pos += ret; - buf += ret; + count -= len; + pos += len; + buf += len; } - memalloc_nofs_restore(pflags); - return error; + return 0; } /* Find the next written area in the xfile data for a given offset. */ From patchwork Wed Jan 3 08:41:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13509732 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 B77DBC3DA6E for ; Wed, 3 Jan 2024 08:43:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 444908D0048; Wed, 3 Jan 2024 03:43:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F5EA8D0035; Wed, 3 Jan 2024 03:43:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 295F18D0048; Wed, 3 Jan 2024 03:43:01 -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 0CE668D0035 for ; Wed, 3 Jan 2024 03:43:01 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id DDDDA1A044B for ; Wed, 3 Jan 2024 08:43:00 +0000 (UTC) X-FDA: 81637359720.28.6859FA1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf03.hostedemail.com (Postfix) with ESMTP id 49A132000D for ; Wed, 3 Jan 2024 08:42:59 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=bkB1qm0Y; dmarc=none; 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704271379; 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=ZYCJ0kG+pWM4oodYCkxfKcpnYZVCJ8j75y4k6ct5MCQ=; b=H6dtjlrcmhHnxaOn/nUjpWL3NmQDJI6ydbF+EoiheUH6EEZYqzKXIlRuRMKkvj1v2ehv9W bzSCt1t4ObNhoLR+GWd9ML230RkyIL6XkkQQmbwTJ6/O6U8H1N3+zH3AEgbWEp0uCo6qG3 C7ukZsvfvkr9lc9Y061tBpqNKijKYGI= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=bkB1qm0Y; dmarc=none; 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704271379; a=rsa-sha256; cv=none; b=oXxMLVukv1p4T8plFBZH4kEqA3+Znbzuw/Q7f3pEf3V1qur3MTZyWUlL+Pnw/PNOLdMBq4 EtOZTdmN+DYbHNTqEP2ypF5kws1VxoCPYx8UPgWk4QzfTxJ3qVXuPodryXKr34hiHsQIgZ 8QIpW9bqePgNL/CfEqUIHuoXizCdK70= 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=ZYCJ0kG+pWM4oodYCkxfKcpnYZVCJ8j75y4k6ct5MCQ=; b=bkB1qm0YMsFr9mxnSj8PpONLuX W8YvxJ9YkL7XqHOWVDelz4YWiOsflj/EprYOJtVD26eZiLqKQTCLcTA2nSLjCR4ljXV+NMfLgJ8h4 +Gb+shJZiajQsbLyfOTRpIqcYs/BIMmn0wpVlhFqW+3HQTBHeDveywd49wXbzK2gGKgAoGDZMlqpq Q0OBOzrlMMIthj1gjoVudMddO4C1DGe1eu9CqqdddfBKj5wZU7ewftJ064MYHyFK8Vcfyei9/c9H9 svn45AkUgzb7RK6puDFlUk5hw7vMXPX7Hn0s01uzm16XIdlPrScFkBfoU6sGm4x9ZE7Se9spmgQ9h /6isd0SA==; Received: from [89.144.222.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rKwpx-00A72t-0z; Wed, 03 Jan 2024 08:42:54 +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 15/15] xfs: use xfile_get_page and xfile_put_page in xfile_obj_load Date: Wed, 3 Jan 2024 08:41:26 +0000 Message-Id: <20240103084126.513354-16-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-Rspamd-Queue-Id: 49A132000D X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: udnaakj5jzwq1amykk173ezomh89944f X-HE-Tag: 1704271379-712993 X-HE-Meta: U2FsdGVkX1+wvesQvVCVInIQd76KIih0ZKH1liqIt+6NZKm/3F+50//DgXVZ7Hvsnnm9zseVRt7rXp4oiQ1SzS2LHFS7BHOSmfar4UKaHFuLXp3fSX5QbUId6HJJ4i2g3/8JYV3l4ViCL+MioHePx5Dfo5Upjq8sHun6w6jR5rmdzVCUpZdGMeFEBtP/+RoeHRoQIFTDdF027u7syABV3XhPmeOIMQQAkCNtNLSQDkNYXokkmv7wAl0mWevjvKs3FvEPIV09H+X2Sr+zYcepLH3EsD816YiYYE1r5nIvVjjndKMKG6IATW7nuNCvSCHbIjySQ8IBhxykboVUwMobtYCmoEnM9T/9ITY/9mCYAeF4K17jgMTrWwvMSGROcIoYfUIqKtowDFiGVZ91Pm5IOtPXdLwOmiwM0sJ9Wsr9dIpX4wjyLy/qC1DaTrat8BcupxVZzZdrRezH+6pINfKZza8lq2QjnTULsMyMcABXS7GFHFrVCY5keo3VIzwPoNwmmBeWeoJk9t4f/vuFxIYz5rpVMvl4OXmCp+D50/lR4RHDBHKzY3wRbsGzUjvSvsmLnKMguL1tCDUyNDgq1H5RMXUOdsJEZac4ITBArhzMYg56X1UarV6Yw1z4zVzvZGCDkpQi7YGOGEPHtu+HkRfJdRNH9t04n4xGnO7qmxzykm+hHHBSFdgVQJlmO9Tp4b5OyLwRFs2axRPwWjn2WhChN3NeGBiZXgLUqcCuDg6ckoMDLv3/EBRdpPgp+OX0W+BcGZjsTYDvvLE1zX6X+CYiLi+K5WBe9AlRfF7Y7dkJoZfEp3z4pW7nrB7PRnKnCZCEa0nUOoJ5wxQ6b3Cfwz+FPdpydteBkQdkqg9tbAb4TWkqf7kHC5jDj8cZ9OCJXqAaPm3Wt4ZecFZbkk+0u8opPgFq+SrvKwg0UCRvjego8tuvYWbptYbxqMKYGDxRPOM3p7gnXEEkzt8QnBpyFAJ y6DSUeTO QTVkoYPp1AiGwIN2q8BDRBW6cRsPdNeGDXl/mYQcBXtVHEKAtay9u/ADi/G/6aXGXVZZuJkpkawRDCrHzbJtxRHr9DkLwiO76qGjEEvoMPB7ZNkx1i4Hya1jhUx8L1xn18z+sZqSPwttNkK9zXuBfnjxcFour/H5oKdZo6Q/ygtJZXtTF5s4k6aIfv/6LCQqy93tlQXny8cR9mJnBR0QIPaTZ89W4jsBN60Ir/oJ/uDdIRBt+mcgiLQ0qnZBEBce7oXClq/nYX1p1qREZm9chRFwo6qxExZYO+xI3EEFDnZVmLIN+a18gcafG0BoH5Ib6014CjfPxBmQHoFT7sI+5aF1M6X/snBt8epaY0/k1/kKQTS08AoTsPNGPvAiMFNZ5AqtnFvpHJs72fP9NpvZXWETQP+suAeJe8HMGv/MybDx4rpGcmgWsPRaF6g== 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: Switch xfile_obj_load to use xfile_get_page and xfile_put_page to access the shmem page cache. The former uses shmem_get_folio(..., SGP_READ), which returns a NULL folio for a hole instead of allocating one to optimize the case where the caller is reading from a whole and doesn't want to a zeroed folio to the page cache. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfile.c | 51 +++++++++++--------------------------------- 1 file changed, 12 insertions(+), 39 deletions(-) diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 987b03df241b02..3f9e416376d2f7 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -34,13 +34,6 @@ * xfiles assume that the caller will handle all required concurrency * management; standard vfs locks (freezer and inode) are not taken. Reads * and writes are satisfied directly from the page cache. - * - * NOTE: The current shmemfs implementation has a quirk that in-kernel reads - * of a hole cause a page to be mapped into the file. If you are going to - * create a sparse xfile, please be careful about reading from uninitialized - * parts of the file. These pages are !Uptodate and will eventually be - * reclaimed if not written, but in the short term this boosts memory - * consumption. */ /* @@ -117,58 +110,38 @@ xfile_obj_load( size_t count, loff_t pos) { - struct inode *inode = file_inode(xf->file); - struct address_space *mapping = inode->i_mapping; - struct page *page = NULL; - unsigned int pflags; - int error = 0; - if (count > MAX_RW_COUNT) return -ENOMEM; - if (inode->i_sb->s_maxbytes - pos < count) + if (file_inode(xf->file)->i_sb->s_maxbytes - pos < count) return -ENOMEM; trace_xfile_obj_load(xf, pos, count); - pflags = memalloc_nofs_save(); while (count > 0) { + struct page *page; unsigned int len; len = min_t(ssize_t, count, PAGE_SIZE - offset_in_page(pos)); - - /* - * In-kernel reads of a shmem file cause it to allocate a page - * if the mapping shows a hole. Therefore, if we hit ENOMEM - * we can continue by zeroing the caller's buffer. - */ - page = shmem_read_mapping_page_gfp(mapping, pos >> PAGE_SHIFT, - __GFP_NOWARN); - if (IS_ERR(page)) { - error = PTR_ERR(page); - if (error != -ENOMEM) { - error = -ENOMEM; - break; - } - + page = xfile_get_page(xf, pos, len, 0); + if (IS_ERR(page)) + return -ENOMEM; + if (!page) { + /* + * No data stored at this offset, just zero the output + * buffer. + */ memset(buf, 0, len); goto advance; } - - /* - * xfile pages must never be mapped into userspace, so - * we skip the dcache flush. - */ memcpy(buf, page_address(page) + offset_in_page(pos), len); - put_page(page); - + xfile_put_page(xf, page); advance: count -= len; pos += len; buf += len; } - memalloc_nofs_restore(pflags); - return error; + return 0; } /*