Re: [PATCH v12 14/17] ovl: Set redirect on metacopy files upon rename

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 7, 2018 at 10:43 PM, Vivek Goyal <vgoyal@xxxxxxxxxx> wrote:
[...]
>> >>
>> >> Q: why do you set samedir: = false here?
>> >> A: because other hardlink aliasses cannot follow a relative redirect, right?
>> >
>> > Right. If we create a hardlink later then it will need absolute redirect
>> > if both dentries are not in same dir.
>> >
>> >>
>> >> This is a subtle detail that should be documented,
>> >
>> > Ok, will do.
>> >
>> >> but also
>> >> maybe do use samedir if nlink == 1?
>> >
>> > Hmm.., so initially we could put a relative redirct (if nlink=1) and later
>> > if we create a link, we could replace relative redirect with an absolute
>> > redirect? I see we already have logic to do that for the case of rename.
>> >
>> > Now only thing I need to figure out in ovl_link() whethre two dentries
>> > are in same dir or not. I am assuming I can just check parent dentry
>> > pointers and see if these two have same parent or not.
>>
>> Yes or we can just convert to absolute path anyway for nlink > 1.
>> >
>> > In fact, we probably don't even have to check for nlink=1. Only when
>> > we create a upper hard link, then we need to make sure we replace relative
>> > hardlink with absolute one. I will play with it and see how it goes.
>> >
>>
>> Yes. alomst true. but we do need to check for lower nlink > 1,
>> because in that case (when index=on) upper hardlinks are created on
>> copy up not only on ovl_link(), so easiest is to just start with
>> absolute redirect
>> on rename of lower hardlink.
>
> Hmm..., even in that case it should work. For example, say foo.txt and
> bar.txt are hardlinked in lower. hence nlink=2. And now I rename foo.txt
> to foo-upper.txt, then it will be copied up (with index hardlinked) and
> then a redirect will be set (foo.txt). And now, bar.txt can be looked up
> without redirct and foo-upper.txt can be looked up with redirect. So it
> should work even in nlink>1 in lower. Can you give a specific example
> where it will be broken.
>

Suppose bar/bar.txt and foo/foo.txt. On metacopy up of bar.txt you need
to convert to absolute redirect. Because (with index=on) bar.txt will be
"linked up" to foo-upper.txt, which has a redirect xattr of "foo.txt".
On cold cache lookup of bar/bar.txt, metacopy lookup will follow "foo.txt"
redirect to "bar/foo.txt", which does not exist.

> Having said that I don't mind to always set absolute redirect whenever
> nlink > 1 (both in lower and upper) and that simplifies the logic a bit.
>

Yeh, we optimize the common case of nlink == 1 and same dir, because
absolute redirect is heavy on lookup, and we leave the less common case
of upper or lower hardlink simple and not optimized.

Thanks,
Amir.
--
To unsubscribe from this list: send the line "unsubscribe linux-unionfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux