tech-kern archive

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

Re: mount_union(8) vs. open(O_RDWR)



> On 5. Dec 2021, at 08:52, Greg A. Woods <woods%planix.ca@localhost> wrote:
> 
> At Sat, 4 Dec 2021 10:25:27 +0100, "J. Hannken-Illjes" <hannken%mailbox.org@localhost> wrote:
> Subject: Re: mount_union(8) vs. open(O_RDWR)
>> 
>> Ok some comments:
>> 
>> - union_copyup() works and is needed for regular nodes only.
>> 
>> - it copies the node attributes up so checking the access on
>>  the (copied) upper node should be sufficient.
>> 
>> - the switch() on top checks for read-only mounted upper layer,
>>  not the lower layer.
> 
> Ah ha!  That was not obvious to me at all.
> 
> I assumed, incorrectly apparently, that (struct vop_access_args).a_vp
> would be the vnode for the lower layer in the case I was interested in
> since the upper one did not yet exist.
> 
> So what is "a_vp" pointing to in the case where the file does not yet
> exist in the upper layer?  vnodeops(9) says (for VOP_ACCESS) "The
> argument vp is the vnode of the file to check", but if it doesn't exist
> yet (i.e. hasn't been copied up yet)???  (in the "recursive" calls made
> by union_access() it is indeed either the upper vnode or lower vnode,
> depending on what is going to be used)

There are (up to) three vnodes involved:

- The union vnode attached to the union mount.

- The upper vnode (if it exists) attached to the upper mount.

- The lower vnode (if it exists) attached to the lower mount.

When it comes to union_access() a_vp points to the union vnode
which points to upper and lower vnode via un_XXXvp.  At least
one of un_XXXvp may not exist.

Operation union_access() reuses "vp", it starts as union vnode
and then gets assigned the upper and then the lower vnode making
this operation difficult to read.

>> The attached diff just copies up in the VWRITE/VREG case and
>> this should be sufficient -- please give it a try.
> 
> It works perfectly, thank you very much!<woods%avoncote.ca@localhost>

--
J. Hannken-Illjes - hannken%mailbox.org@localhost

Attachment: signature.asc
Description: Message signed with OpenPGP



Home | Main Index | Thread Index | Old Index