[Virtio-fs] Ways to uniquely and persistently identify nodes

Max Reitz mreitz at redhat.com
Wed Jan 15 15:52:22 UTC 2020


On 15.01.20 16:46, Miklos Szeredi wrote:
> On Wed, Jan 15, 2020 at 4:23 PM Max Reitz <mreitz at redhat.com> wrote:
>>
>> On 15.01.20 15:58, Miklos Szeredi wrote:
>>> On Wed, Jan 15, 2020 at 1:51 PM Max Reitz <mreitz at redhat.com> wrote:
>>>>
>>>> On 15.01.20 12:51, Miklos Szeredi wrote:
>>>>> On Wed, Jan 15, 2020 at 11:10 AM Miklos Szeredi <mszeredi at redhat.com> wrote:
>>>>>
>>>>>> New operations needed:
>>>>>>
>>>>>> LOOKUP_WITH_HANDLE: same as LOOKUP, but returns handle in addition to
>>>>>> fuse_ino_t and attributes.
>>>>>> LOOKUP_BY_HANDLE: same as LOOKUP, but gets a handle as input.
>>>>>
>>>>> And that can be reduced further to a single extended LOOKUP_HANDLE,
>>>>> which takes a handle as input and returns a handle in addition to the
>>>>> usual stuff.  The lookup-by-handle case can be done with a special
>>>>> name.  Currently "." is used for this purpose in the fuse protocol,
>>>>> which is a bit confusing since it has nothing to do the "." directory
>>>>> entry, but at least we don't have to introduce a new concept for this.
>>>>
>>>> I’m afraid I don’t quite understand.  What handle would LOOKUP_HANDLE
>>>> take as input when I want to open a new file (as in, LOOKUP_WITH_HANDLE)?
>>>
>>> For example open("/foo/bar", ...) would do:
>>>
>>> lookup_handle($ROOT_HANDLE, "foo") -> { FOO_HANDLE, FOO_NODEID }
>>> lookup_handle($FOO_HANDLE, "bar") -> { BAR_HANDLE, BAR_NODEID }
>>> open($BAR_NODEID, ...)
>>
>> OK.  It seems a bit weird to me because if all other commands used a
>> fuse_ino_t to identify nodes, I think lookup should be no different.
>>
>> Sure, we’d only need one new command instead of two, but naively just
>> adding two commands doesn’t seem fundamentally more difficult to me.
>>
>> Specifically, what seems a bit problematic to me is that for virtiofsd
>> we’d probably want fuse_ino_t to stay as it is: An index into a vector.
>>  We probably don’t want to store the handle in virtiofsd at all.
>>
>> So whenever a handle comes in, we’d first need to open it with
>> open_by_handle_at().  That’s OK if handles only come in through
>> lookup_by_handle(), i.e. when there is no valid fuse_ino_t value anyway.
>>  But it seems a bit cumbersome if all lookups are based on handles.
>>
>> OTOH, we could keep the handles around, but that would probably require
>> a hash map with the handle as a key (so we can let lookup() find the
>> existing fd without having to open a new one).  Doable, sure, but I
>> wonder whether it wouldn’t be just easier to have two separate commands.
> 
> So, let's modify that to
> 
>>> lookup_handle($ROOT_HANDLE, $ROOT_NODEID, "foo") -> { FOO_HANDLE, FOO_NODEID }
>>> lookup_handle($FOO_HANDLE, $FOO_NODEID, "bar") -> { BAR_HANDLE, BAR_NODEID }
>>> open($BAR_NODEID, ...)
> 
> I think that fixes your concern.  Implementation is free to use either
> the nodeid or the handle.

Works for me. :-)

Max

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/virtio-fs/attachments/20200115/6995fc67/attachment.sig>


More information about the Virtio-fs mailing list