From patchwork Mon Feb 19 06:27: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: 13562214 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 35669C48260 for ; Mon, 19 Feb 2024 06:28:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29CF88D0011; Mon, 19 Feb 2024 01:27:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 227708D0008; Mon, 19 Feb 2024 01:27:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0786C8D0011; Mon, 19 Feb 2024 01:27:58 -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 E07778D0008 for ; Mon, 19 Feb 2024 01:27:58 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C119EC024C for ; Mon, 19 Feb 2024 06:27:58 +0000 (UTC) X-FDA: 81807573036.12.88CD902 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf03.hostedemail.com (Postfix) with ESMTP id 4CA5A20007 for ; Mon, 19 Feb 2024 06:27:57 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Ylps9fj9; spf=none (imf03.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324077; a=rsa-sha256; cv=none; b=F+sm8ERDQKeW2O28L675EFDUqEia9EwMslm1ZBw3jJzHfwFm+7x50kkpFuj7iQNMcYvdFs h69F83PxLkSQWBYWIUyldrwjChsroOvThUWxPnB8c+K+MjC6i4BSCFo7DgGNfMD8L/lmVf ZJW+LzaRnlEO8TCwVhDNnqMRBI3MRnY= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Ylps9fj9; spf=none (imf03.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708324077; 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=4/RzxoU6qCYdRXE8FBWrLOZ1ZhnSkg1CJzUAgg76AuQ=; b=ruPllQbguWXxZ9X5t360XqVyXhT1PH/M/f7oCl8ivQhQW1wSbshrx3WsgPWR65p+GX2D0c 8rmvE3BBkDrSn0J9oOmhE6XRecQBnaUhbswt3sEaexEEwRrX8OuyiyvhlBddbb5KP3eUh9 tt59anWPClLFuCvHwjAyuyjyNTbuRIE= 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=4/RzxoU6qCYdRXE8FBWrLOZ1ZhnSkg1CJzUAgg76AuQ=; b=Ylps9fj9kWswSH/VAjHL0D99wO ZtNrfmMTyxBNhCzdsrb+GHan1koTpZ+48krwxaSBys3nUG5nU4YfcUcY+QEK+BqOvThIq6hWCoE1g TVqt5cwjhleyjDv4UoIz6SGk3Z4Iq9+zTUT762u9Iigm4yJ/lNSvEXE1surrmYKXZCI5Q4LQ9tfF0 23Pku9TH5bSskgXJEMhsBM97A9sdfYcsSLuWXDPuS7eVXTGnYz5+uhgKYjEU1vrZbSb0IZNrX9kWI Lk8xqb3R5ZDqlqJQABoseBufqf0Qxsy8s7f5lcnOGmUi7dhmoiMp/EXyqoI5rHPzWs0bJw7TrmVox DWV2VB8A==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx86-00000009FFe-27dM; Mon, 19 Feb 2024 06:27:54 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 12/22] xfs: remove xfile_stat Date: Mon, 19 Feb 2024 07:27:20 +0100 Message-Id: <20240219062730.3031391-13-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 4CA5A20007 X-Stat-Signature: syifpisp9bzwuau3zo3wrstjg55cmo7i X-Rspam-User: X-HE-Tag: 1708324077-899622 X-HE-Meta: U2FsdGVkX19zGRharwPI7AGV+sObzKJBzBGOKnYy2j99PtvrXgNxVxYKqj1GWmTPZF4vL3E+EuPGXZ9Z7PgspBQKEI5xwDTGZc2RAdS4dZZu2nFUUIwrQPkHZzK5HRN87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osity: 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 95250db81981ab..b212d4a9c78028 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -274,25 +274,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);