在Linux上使用FUSE实现异步文件系统

时间:2021-10-30 08:52:10

I tried to ask on FUSE's mailing list but I haven't received any response so far... I have a couple of questions. I'm going to implement a low-level FUSE file system and watch over fuse_chan's descriptor with epoll.

我试着询问FUSE的邮件列表,但到目前为止我还没有收到任何回复......我有几个问题。我将实现一个低级别的FUSE文件系统,并使用epoll监视fuse_chan的描述符。

  1. I have to fake inodes for all objects in my file system right? Are there any rules about choosing inodes for objects in VFS (e.g. do I have to use only positive values or can I use values in some range)?

    我必须为我的文件系统中的所有对象伪造inode吗?是否有关于为VFS中的对象选择inode的规则(例如,我是否必须仅使用正值,还是可以在某个范围内使用值)?

  2. Can I make fuse_chan's descriptor nonblocking? If yes, please tell me whether I can assume that fuse_chan_recv()/fuse_chan_send() will receive/send a whole request structure, or do I have to override them with functions handling partial send and receive?

    我可以使fuse_chan的描述符无阻塞吗?如果是,请告诉我是否可以假设fuse_chan_recv()/ fuse_chan_send()将接收/发送整个请求结构,或者我是否必须使用处理部分发送和接收的函数覆盖它们?

  3. What about buffer size? I see that in fuse_loop() a new buffer is allocated for each call, so I assume that the buffer size is not fixed. However maybe there is some maximum possible buffer size? I can then allocate a larger buffer and reduce memory allocation operations.

    缓冲区大小怎么样?我看到在fuse_loop()中为每个调用分配了一个新缓冲区,所以我假设缓冲区大小不固定。但是,可能有一些最大可能的缓冲区大小?然后,我可以分配更大的缓冲区并减少内存分配操作。

1 个解决方案

#1


2  

(1) Inodes are defined as unsigned integers, so in theory, you could use any values. However, since there could be programs which are not careful, I'd play it safe and only use non-zero, positive integers up to INT_MAX.

(1)Inode被定义为无符号整数,因此理论上,您可以使用任何值。但是,由于可能有不小心的程序,我会安全地使用它,并且只使用非零,正整数,直到INT_MAX。

(2) Fuse uses a special kernel device. While fuse_chan_recv() do not support partial reads, this may not be required, as kernel should not return partial packets anyway.

(2)Fuse使用特殊的内核设备。虽然fuse_chan_recv()不支持部分读取,但这可能不是必需的,因为内核不应该返回部分数据包。

(3) Filenames in Linux are max 4096 chars. This puts a limit on a buffer size:

(3)Linux中的文件名最多为4096个字符。这限制了缓冲区大小:

$ grep PATH_MAX /usr/include/linux/limits.h
#define PATH_MAX        4096    /* # chars in a path name including nul */

#1


2  

(1) Inodes are defined as unsigned integers, so in theory, you could use any values. However, since there could be programs which are not careful, I'd play it safe and only use non-zero, positive integers up to INT_MAX.

(1)Inode被定义为无符号整数,因此理论上,您可以使用任何值。但是,由于可能有不小心的程序,我会安全地使用它,并且只使用非零,正整数,直到INT_MAX。

(2) Fuse uses a special kernel device. While fuse_chan_recv() do not support partial reads, this may not be required, as kernel should not return partial packets anyway.

(2)Fuse使用特殊的内核设备。虽然fuse_chan_recv()不支持部分读取,但这可能不是必需的,因为内核不应该返回部分数据包。

(3) Filenames in Linux are max 4096 chars. This puts a limit on a buffer size:

(3)Linux中的文件名最多为4096个字符。这限制了缓冲区大小:

$ grep PATH_MAX /usr/include/linux/limits.h
#define PATH_MAX        4096    /* # chars in a path name including nul */