From patchwork Mon Jan 29 14:34:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535766 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 DC54FC47DB3 for ; Mon, 29 Jan 2024 14:35:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 719286B00A8; Mon, 29 Jan 2024 09:35:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A3326B00AA; Mon, 29 Jan 2024 09:35:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5436B6B00AB; Mon, 29 Jan 2024 09:35:39 -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 3F17B6B00A8 for ; Mon, 29 Jan 2024 09:35:39 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 08D0F140993 for ; Mon, 29 Jan 2024 14:35:39 +0000 (UTC) X-FDA: 81732597198.26.74B0563 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf14.hostedemail.com (Postfix) with ESMTP id 5D945100027 for ; Mon, 29 Jan 2024 14:35:37 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=L2PzvqZt; dmarc=none; spf=none (imf14.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706538937; 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=pWiZ+uq6s6Jb8DG5zpX+nOBm/9LHv3+s4Lx1umDyLlU=; b=AbV6T05elPiI9P77gGIvEILbU31ZJa7Ayjv3jjJGnWyEafGNzRx3ewePU9RTXvxIYyBiCd q0ePd+qt3ajNH3Ep2jMUCLXmoPdbo2gHmvjilKWvbxhzTe43BR367o9otoArZleVVf9Yi0 7334LiTiccDBqdhTaBgsV+WnPlUFTak= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=L2PzvqZt; dmarc=none; spf=none (imf14.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538937; a=rsa-sha256; cv=none; b=1THLyfF6N2l+hIn4axvFHTAH0UsxaMqJ2HYuzLNAfn4513bDkR2Mhy9tHWK7o8etcAJ9/w 13o80Q1WP+nY+nOckpd0LIHC6ieNoDAnU4knVHG0Ro///eXBdqlfXafk8/UwnUgTBfUWQt A5tDmaddkTaL2vOedFhd9alHEohpDdo= 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=pWiZ+uq6s6Jb8DG5zpX+nOBm/9LHv3+s4Lx1umDyLlU=; b=L2PzvqZtdHLlDmsn1Il9cy+nDe 33Z/k4DnFusZdlkgk7o1WMaM+JjhkvPjuHjksPmkaszuM/qr0hY3b6K6jcdh435GnWDDEBoXm1DJz 3Z069uj1FWEicDamc9lxzxxkIvpZfax4bKr5J/CXRDsqVaxhgSaEPHrtcJue0yAeXDqJ3i+KQ3Z9O ihyotPV1PqEO6aWU/fHDNXNAf1dwKRm7TDan9E3DNZNPwtZrV0prrLZdm36MWkqFToeZgVaquorRk YOvKfYr9Q8Cspp9CyaXy6ts2+IjLpQqLYLzo0IYdVCXTiepTXSn8vgtpstmPD3YFT1pKoKnFUv6FV DV8DQaOw==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSjW-0000000D6EG-0AtQ; Mon, 29 Jan 2024 14:35:34 +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/20] xfs: remove xfile_stat Date: Mon, 29 Jan 2024 15:34:50 +0100 Message-Id: <20240129143502.189370-9-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 5D945100027 X-Stat-Signature: nngtaw5h7sgjb9rmj78rgcfj6mjwba4s X-Rspam-User: X-HE-Tag: 1706538937-603781 X-HE-Meta: U2FsdGVkX19RxAmevF3rl69kRex5f7qz8RcqpAnEyEXWl1ZRq6SLvBNvOL/xhfX5R7G/C5hhGWxH/mnIpoxv0MXgVWVCowjpu0bkim/C3Yx6gvAXmunVqMX0xx/AOr6C3UeUF88DzCaXS8uQTkn+JJKod6P2+E0ThoV0wbkSqOU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wJsQEauU7A8vvdiJXlNhWzRNwSznGLs5wfsLMT90QcNZB8pedHeBOn3hCnRHgKP0I124cappHw1FrxCVGnmv0aT3SG1ku0hz+q9L08zncTrK1xoUSLjJUlEW/DczcD9o/G4Tdqv0MfDlwlA4OyM3aN4H0uj0iYJq4h/6jPQHUFoW93D4GpkpnLniO4BqQ3jfHFJhmvXcpTCTvJycxWAEObWJsbTxZ9WzZaGdqieqqij0zHZFkEx4xb5L1u1S+ERNfb92VbQvCwWlt+taMI= 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 Reviewed-by: Darrick J. Wong --- 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..260b8fe0a80296 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_blocks << SECTOR_SHIFT; + __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_blocks << SECTOR_SHIFT; __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);