On 2024/10/25 23:42, Theodore Ts'o wrote: > On Fri, Oct 25, 2024 at 03:06:07PM +0800, Zhang Yi wrote: >> >> Now it seems to be able to handle all the necessary metadata in the >> query range here, can we remove the processing of info->gfi_meta_list >> in ext4_getfsmap_datadev_helper() as well? > > Not without further code refactoring; we still need it if there are > metadata blocks in the middle of the block group. IIRC, at the moment, fixed metadata does not appear in the middle of the block group. > My main emphasis > was keeping the code changes as simple so it would be easy to > backport, and so I didn't do further optimizations. OK. > > As a related observation, I'm not entirely sure the current set of > abstractions, where we pass exactly one set of helper/callback > functions down through multiple functions is the best match for ext4. > It should be possible to significantly simplify the call stack by > reworking the GETFSMAP support. Yeah, I have the same feeling too. > > On the other hand, the current, more complicated design might be > useful if at some point in the future, we were to add support for > reverse mapping for online fsck and/or if we add reflink support. > (See how Darrick implemented GETFSMAP for xfs.) > Yes, the current GETFSMAP implementation on ext4 is incomplete and has many limitations. If we had reserved mapping, we could achieve more; for example, we could accurately query the inode to which a block belongs, and the query efficiency would improve. As Baokun mentioned earlier, we will take the time to look into the reverse mapping first to hope to support it and maybe online fsck in the future. Thanks, Yi.