Jan Kara <jack@xxxxxxx> 于2024年6月4日周二 17:27写道: > > On Tue 04-06-24 14:54:01, JunChao Sun wrote: > > Miklos Szeredi <miklos@xxxxxxxxxx> 于2024年6月4日周二 14:40写道: > > > > > > On Mon, 3 Jun 2024 at 13:37, JunChao Sun <sunjunchao2870@xxxxxxxxx> wrote: > > > > > > > Given these challenges, I would like to inquire about the community's > > > > perspective on implementing quota functionality at the FUSE kernel > > > > part. Is it feasible to implement quota functionality in the FUSE > > > > kernel module, allowing users to set quotas for FUSE just as they > > > > would for ext4 (e.g., using commands like quotaon /mnt/fusefs or > > > > quotaset /mnt/fusefs)? Would the community consider accepting patches > > > > for this feature? > > > > > > > > > > I would say yes, but I have no experience with quota in any way, so > > > > cannot help with the details. > > > > Thanks for your reply. I'd like try to implement this feature. > > Nice idea! But before you go and spend a lot of time trying to implement > something, I suggest that you write down a design how you imagine all this > to work and we can talk about it. Questions like: Do you have particular > usecases in mind? Where do you plan to perform the accounting / > enforcement? Where do you want to store quota information? How do you want > to recover from unclean shutdowns? Etc... > > Honza > > -- > Jan Kara <jack@xxxxxxxx> > SUSE Labs, CR Thanks a lot for your suggestions. I am reviewing the quota code of ext4 and the fuse code to determine if the implementation method used in ext4 can be ported to fuse. Based on my current understanding, the key issue is that ext4 reserves several inodes for quotas and can manage the disk itself, allowing it to directly flush quota data to the disk blocks corresponding to the quota inodes within the kernel. However, fuse does not seem to manage the disk itself; it sends all read and write requests to user space for completion. Therefore, it may not be possible to directly flush the data in the quota inode to the disk in fuse. I am considering whether it would be feasible to implement the quota inode in user space in a similar manner. For example, users could reserve a few regular files that are invisible to actual file system users to store the contents of quota. When updating the quota, the user would be notified to flush the quota data to the disk. The benefit of this approach is that it can directly reuse the quota metadata format from the kernel, users do not need to redesign metadata. However, performance might be an issue with this approach. And if fuse could reserve some disk blocks to save contents of quota inode, that would be better, but as far as my current understanding goes, it seems that this is not possible. I haven't finalized the design yet and still need to look at the code and related documents. Best regards -- Junchao Sun <sunjunchao2870@xxxxxxxxx>