Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fuse.getattr called by every block when do DIRECT_IO read with 4K block #5155

Open
kk47 opened this issue Sep 11, 2024 · 2 comments
Open

fuse.getattr called by every block when do DIRECT_IO read with 4K block #5155

kk47 opened this issue Sep 11, 2024 · 2 comments
Labels
kind/question Further information is requested

Comments

@kk47
Copy link

kk47 commented Sep 11, 2024

When I use the fio to test the 4k read performance, I found the getattr was called in every block read, it seems the fuse filesystem with c++ libfuse do not have this question.

The fio command:
fio -numjobs=1 -iodepth=1 -ioengine=libaio -direct=1 -rw=read -size=4M -bs=4K -time_based -runtime=20 -name=Fio-1 -directory=/mnt

and the dd command got the same result
dd if=/mnt/testfile of=/dev/null bs=4K count=10 iflag=direct

cat /mnt/.accesslog

2024.09.11 09:25:42.345608 [uid:0,gid:0,pid:874844] read (1026,4096,1122304): (4096) - OK <0.000028>
2024.09.11 09:25:42.350034 [uid:0,gid:0,pid:874844] getattr (1026): (1026,[-rw-r--r--:0100644,1,0,0,1726017921,1726017922,1726017922,4194304]) - OK <0.004051>
2024.09.11 09:25:42.354292 [uid:0,gid:0,pid:874844] read (1026,4096,1126400): (4096) - OK <0.000031>
2024.09.11 09:25:42.362388 [uid:0,gid:0,pid:874844] getattr (1026): (1026,[-rw-r--r--:0100644,1,0,0,1726017921,1726017922,1726017922,4194304]) - OK <0.005230>
2024.09.11 09:25:42.363005 [uid:0,gid:0,pid:874844] read (1026,4096,1130496): (4096) - OK <0.000017>
2024.09.11 09:25:42.373989 [uid:0,gid:0,pid:874844] getattr (1026): (1026,[-rw-r--r--:0100644,1,0,0,1726017921,1726017922,1726017922,4194304]) - OK <0.010789>
2024.09.11 09:25:42.375317 [uid:0,gid:0,pid:874844] read (1026,4096,1134592): (4096) - OK <0.000024>
2024.09.11 09:25:42.394042 [uid:0,gid:0,pid:874844] getattr (1026): (1026,[-rw-r--r--:0100644,1,0,0,1726017921,1726017922,1726017922,4194304]) - OK <0.016077>
2024.09.11 09:25:42.394414 [uid:0,gid:0,pid:874844] read (1026,4096,1138688): (4096) - OK <0.000048>
2024.09.11 09:25:42.400903 [uid:0,gid:0,pid:874844] getattr (1026): (1026,[-rw-r--r--:0100644,1,0,0,1726017921,1726017922,1726017922,4194304]) - OK <0.005750>
2024.09.11 09:25:42.401618 [uid:0,gid:0,pid:874844] read (1026,4096,1142784): (4096) - OK <0.000017>
2024.09.11 09:25:42.407509 [uid:0,gid:0,pid:874844] getattr (1026): (1026,[-rw-r--r--:0100644,1,0,0,1726017921,1726017922,1726017922,4194304]) - OK <0.005622>
2024.09.11 09:25:42.408256 [uid:0,gid:0,pid:874844] read (1026,4096,1146880): (4096) - OK <0.000024>
2024.09.11 09:25:42.409010 [uid:0,gid:0,pid:874844] flush (1026,9,CAE4DB8115C4BE94) - OK <0.000004>

I want to known which component called the getattr, go-fuse, vfs, or someone else, and why the getattr before block read is necessary.

@kk47 kk47 added the kind/question Further information is requested label Sep 11, 2024
@davies
Copy link
Contributor

davies commented Sep 12, 2024

it's called by kfuse kernel module.

@kk47
Copy link
Author

kk47 commented Sep 13, 2024

it's called by kfuse kernel module.
Thanks for your reply, I have checked the source code of Linux-4.19 kernel fs/fuse and found these codes:

 fs/fuse/file.c

static ssize_t __fuse_direct_read(struct fuse_io_priv *io,
				  struct iov_iter *iter,
				  loff_t *ppos)
{
	ssize_t res;
	struct inode *inode = file_inode(io->iocb->ki_filp);

	if (is_bad_inode(inode))
		return -EIO;

	res = fuse_direct_io(io, iter, ppos, 0);

	fuse_invalidate_attr(inode); 

	return res;
}


fs/fuse/dir.c
/*
 * Mark the attributes as stale, so that at the next call to
 * ->getattr() they will be fetched from userspace
 */
void fuse_invalidate_attr(struct inode *inode)
{
	get_fuse_inode(inode)->i_time = 0;
}

is the fuse_invalidate_attr function cause the GetAttr called after every 4k block read ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants