]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: remove xfile_stat
authorChristoph Hellwig <hch@lst.de>
Mon, 19 Feb 2024 06:27:20 +0000 (07:27 +0100)
committerChandan Babu R <chandanbabu@kernel.org>
Wed, 21 Feb 2024 06:06:52 +0000 (11:36 +0530)
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 <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
fs/xfs/scrub/trace.h
fs/xfs/scrub/xfile.c
fs/xfs/scrub/xfile.h

index 6bbb4e8639dca69a30bc3449dfeb9fe28b5741ea..260b8fe0a80296f9ec3215f8dc98e04ed23b0e76 100644 (file)
@@ -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",
index 95250db81981ab241405008320e6fce9a81cd52b..b212d4a9c7802857f6142ee69199793ddb7ab73c 100644 (file)
@@ -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
index d56643b0f429e119dea21fe911b64889148f8bf4..c602d11560d8ee6ab4af0f789c0b9b278cbb72ec 100644 (file)
@@ -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);