[Libguestfs] e2fsprogs concurrency questions
tytso at mit.edu
Mon Sep 20 02:40:38 UTC 2021
On Sun, Sep 19, 2021 at 01:35:23PM +0100, Richard W.M. Jones wrote:
> Are there structures shared between ext2_fs handles?
> I mean, if we had two concurrent threads using different ext2_fs
> handles, but open on the same file, is that going to be a problem?
> (It sounds like it would be, with conflicting access to the block
> allocation bitmap and so on.)
Yes, there's going to be a problem.
If you have two separate ext2fs_fs handles (each opened via a separate
call to ext2fs_open), they will not share any structures, nor is there
any locking for any of the data structures. So that means you could
use a single ext2s_fs handle, and share it across threads --- but you
need to make sure that only one thread is using the handle at a time,
and you can't have two file handles open to the same inode, or read an
inode twice, and then modify one, write it back, and expect the other
inode will magically be updated --- because they won't be.
Fundamentally, libext2fs was not designed for concurrent operation.
I suppose you could use fuse2fs, and then having the clients access
the file system via the FUSE interface. That might be more efficient.
More information about the Libguestfs