Re: [PATCH] ovl: add ioctls to retrieve layer file descriptors
Amir Goldstein <[email protected]> Thu, 9 Jul 2026 16:32:02 +0200
| Newsgroups | org.kernel.vger.linux-unionfs,org.kernel.vger.linux-api,org.kernel.vger.linux-fsdevel |
|---|---|
| Message-ID | <CAOQ4uxgZuJ+=RQDh3577H7PFAfYyF=wRJ55aPuuUW814Htrmbw@mail.gmail.com> |
On Wed, Jul 8, 2026 at 9:45=E2=80=AFPM Miklos Szeredi <[email protected]> w= rote: > > On Wed, 8 Jul 2026 at 17:55, Giuseppe Scrivano <[email protected]> wrot= e: > > > > Miklos Szeredi <[email protected]> writes: > > > > > On Wed, 8 Jul 2026 at 16:32, Giuseppe Scrivano <[email protected]> = wrote: > > > > > >> Amir suggested to add that functionality when I've asked for some > > >> feedback before sending the patch here. I am fine to drop it if thi= s is > > >> the consensus although I see its utility from user space. > > > > > > How about a completely different interface: > > > > > > int get_fd_opt(const char *name, unsigned int index, unsigned int fla= gs); > > > > > > Enumerating layers would be as easy as passing an index stating from > > > zero and stopping when -ERANGE is received. > > > > > > It would work for all filesystems that use files as options. No more > > > fs specific ioctls. > > > > Is a new syscall really justified for such a narrow use case? > > That's the reason I advocate pseudo fs based solutions. Let's see, we > had a proposal to use openat(), something. like: > > openat(base_fd, "mount/options/lowerdir+/0", O_ALT | O_PATH); > Ack for this, but please don't use mount/options/... it's a bit ugly because most mount options are not opan-able. Please stick to something logical like "fs/layers/N" corresponding to ovl_fs::layers, where layer 0 is reserved for upper. We could also support opening by aliases fs/layers/upper->0 etc, but no rush IMO. What I am contemplating is whether we should implement introspection of the ovl_entry stack for merge dirs in addition or instead introspection of fs/layers. IIRC, the root dir stack does NOT hold references to lowerdata dirs, so support for "fs/layers/N" is still needed. For directories we could implement "real/0..N" with aliases real/upper->0 real/origin->1. For a regular file we could have constant aliases real/upper->0 real/lower->1 real/lowerdata->2 and/or dynamic aliases real/data->{0,1,2}, real/metadata->{0,1}, real/origin->{0,1}. Those could be used to implement "revert to origin". Specifically, I think Daan asked for it during the last LSFMM. Although I don't think we currently store the original lowerdata in ovl_entry when lookup is done post data copy up. Thanks, Amir.