Re: Any better way to interact with xfs?

Amir Goldstein
2016-07-30T14:26:13Z

On Fri, Jul 29, 2016 at 5:25 AM, Dave Chinner <david@fromorbit.com> wrote:
> On Thu, Jul 28, 2016 at 09:48:07AM +0300, Amir Goldstein wrote:
>> Hi Ryan,
>>
>> You could use the XFS_IOC_FSINUMBERS/XFS_IOC_FSBULKSTAT API to iterate
>> over all inodes in the fs.
>
> That's a read-only API - you can't use it to change the inodes
> on disk.
>
>> not having to readdir and recourse the directory tree should safe you
>> some time (much less i/o).
>> Also, the interface can be used to make your conversion work parallel
>> by working on different inode ranges.
>
> It cannot be used to make coherent, atomic changes to the inode
> state.
>

I'm curios: In theory, one can construct a file_handle from bulkstat
info. correct?
and one could use that handle to open_by_handle_at() and fchown(). right?
I realize that both APIs were not intended for this use case, but I wonder:
1. can it be done?
2. what are the possible consequences?
3. what do you mean by "coherent, atomic changes to the inode state"?
does it not play well with the dentry/inode cache?

>> You can use xfsdump/xfsrestore code as reference.
>
> xfsdump uses bulkstat scan and read inodes, not change anything on
> disk.
>
> Cheers,
>
> Dave.
> --
> Dave Chinner
> david@fromorbit.com