From mboxrd@z Thu Jan 1 00:00:00 1970 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 BAF95C3DA6E for ; Wed, 3 Jan 2024 23:45:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D0DC6B008A; Wed, 3 Jan 2024 18:45:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 059C36B0099; Wed, 3 Jan 2024 18:45:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3C746B009D; Wed, 3 Jan 2024 18:45:41 -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 D22626B008A for ; Wed, 3 Jan 2024 18:45:41 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A92D71A022F for ; Wed, 3 Jan 2024 23:45:41 +0000 (UTC) X-FDA: 81639634482.24.0102C19 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf14.hostedemail.com (Postfix) with ESMTP id 84252100008 for ; Wed, 3 Jan 2024 23:45:38 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=l+aKQmV2; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf14.hostedemail.com: domain of djwong@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=djwong@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704325539; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=T/rtzKsoLsKosMuvy9CyS4VNPVibc38qpnBnlFiOGBg=; b=c1N/poEDui7FcN8hKd2w+0WnPsH+VzkGDQDCnwKNom2mdPn8DTrkD876TIyG1I+w3Q2F7C PDllhT5zBucY5S9qDStxQ85m1NtWblEmxcKUmPhrv5JExm1MulimqCBxOnMIfbXdhQDVzu xRtSUPqsSaLyLLkVjH1eDVEySeYaMak= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=l+aKQmV2; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf14.hostedemail.com: domain of djwong@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=djwong@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704325539; a=rsa-sha256; cv=none; b=2q5RdOKkeI8MEwF7Q8ANCgBzLOjMNafi2KhVUNEMS26fZP/sqmAssQZM7hKhrK8CkzS4xX C0vfCxqdp5dmROeAyrKbIOswFxllLyYEFqxMr51P3PIOU8tYwW+4NbPlRNV1J0mwfIo798 RUbmGq82BHwomFuOdkrua/cItpu+URk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B9434CE16F3; Wed, 3 Jan 2024 23:45:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00C25C433C8; Wed, 3 Jan 2024 23:45:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704325534; bh=+Web8xkZaS1KX/ZP5BaYyZG69RzbOJE8V1JknxDSl28=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=l+aKQmV2gjiZ6ppZVojvSMgE+QeU45tcHEcpwI64nnkzyVWYQjm5zgPeO7KSOGOVq Pot/EkcTYyC07jRj4kKkJ6o7wZqWpsrywIRyl7ih8CzA9EpqMTHmHL5Z7AnZJ7iwkS 7cLcuzzI7yO+Ur0IfRiIgxr7LfLHIGyK3grG+pBoyWeGMckBPZPN+tHGJIFVZj4FeY 8Z5Dq9QfJ/vtT6ZIzPPzDV8HUnd2pKrvmWgeDqAYcnQNHlEKkp/sZxO07JRRgAayNn czHiIFxBnCg2VF+kK+IejeDyjBW5FNU2i22Gl4KHpRaKtpEmTY+aFu5iXbvs+pqYj0 73d5gz32KRL+w== Date: Wed, 3 Jan 2024 15:45:33 -0800 From: "Darrick J. Wong" To: Christoph Hellwig Cc: Chandan Babu R , Hugh Dickins , Andrew Morton , linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 04/15] xfs: remove xfile_stat Message-ID: <20240103234533.GX361584@frogsfrogsfrogs> References: <20240103084126.513354-1-hch@lst.de> <20240103084126.513354-5-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240103084126.513354-5-hch@lst.de> X-Rspam-User: X-Stat-Signature: s8h9xeqix81jqfnmkn5onk9rifi1x91g X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 84252100008 X-HE-Tag: 1704325538-278313 X-HE-Meta: U2FsdGVkX19vSNdIp8AX3QuEAyQAfSWXQpASfJcx8Bybu5F00gHsinsvrk7Vy9dueD9QS0kiZaRhcf2chFp5Ic1Njq7I+qPQeTckWTp+VRzyFo2SRHJaEgAlbDLDJWFY6ho/EunINLcZAlJJJ3/cr+SrybkHP2yLXyl33YezrZ+65SH11mWqvQxBRqQjFIRdbolCABhElRuELzkmeJx5Z2tWAYurSTI1gWhpaL2kBIVzyCuP+OcrSY7WOALNQ7z3dsbGgJtH+iiJ0HaJK1oCZGQq1HeFrLz0C26XwhGJ1YsUB82VVkAZCmIiEL24nkstLvcujI3J7tOi4z6VHYA4UL/wYBUPsAbPuYnthKRpis1yhvghYSm4DPqyYZ2bnk1Ds4g0kg9sNcRmmc+9P8PUphCF7KCRKkV/qgdE4DC19MhfS794bOT2xX52YYRVlQykekuCDhpBMngVJtJQPkJGGD3voOC7wv6OEqa5cotzOyPqXYH2JhUafuJQsTBmmrajTsl3+HAzwljKZ2fNnCjYBTF5e9o4G9JtIiEELEfBeMsO9NU7hmii4o/nxczgYFj0irp9dsKFDhfm6B4Haaz1HJ+Hw94GkGPozwakiMORczPhzk5St7zC2ukhiXTFSD7ENKsef6/F+xO3JFGAsXG/0OSL278ZWXDUb+MYBOpodcC+bUVW6//HBieR6t9taa3vXl7vUeQKpJMES6foRFS35z263xDMif67o+sY4MDuNITorpdVqRETV22D62+uYhmpgTSzQ3rU8onn3HJNc6KyZkz9g9CJnuOI5Gsiyh0IylUzEQZGr8Bc5ImFm/SWPWS7CIMxKD0VTn6kz1QOENbdikm1wrjj4iNPurTZIMR7RioYjChyzqfjmWVhPY8njyzp78PcD9ybqvivlCHOIrg3BfXBAUAuF7hNBJiNIS8KH/m6gAht2bjzCw== 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: On Wed, Jan 03, 2024 at 08:41:15AM +0000, Christoph Hellwig wrote: > 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; Shouldn't this be (i_blocks << 9) + 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; Here too. > __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); Removing this function will put some distance between the kernel and xfsprogs xfile implementations, since userspace can't do failure-free fstat. OTOH I guess if xfile_stat fails in userspace, our xfile is screwed and we probably have to abort the whole program anyway. For the kernel I like getting rid of this clutter, modulo the question above. --D > - > 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); > -- > 2.39.2 > >