On Thu, Apr 26, 2018 at 5:13 PM, Vivek Goyal <vgoyal@xxxxxxxxxx> wrote: > Aha, cool. thanks. While I am at it, let me just ask one more stupid > question. > > I am wondering while opening the underlying realfile, why do we pass > in the path/dentry of ovl layer (and not underlying real layer). > > realfile = path_open(&file->f_path, file->f_flags | O_NOATIME, > realinode, current_cred(), false); > > This forces us to do file_dentry() in ovl_open() later to map top level > dentry to underlying dentry. > > We know the realinode and should be figure out real dentry. Can't we > construct path from underlying dentry and mount point and use that > to open underlying real file. I am sure there is some reason for doing > this way, just trying to understand it. The logical thing would be to just use the real path (as returned by ovl_path_real()). The reason we don't do that is because mmap stores the real file in vma->vm_file and vm_file->f_path is used in various places (e.g. /proc/PID/maps). We could have a separate realfile for mmap, but that would be additional complexity and memory use, so I don't think it makes sense. Thanks, Miklos