Re: [PATCH v2] ovl: provide real_file() and overlayfs get_unmapped_area()

From: Mike Kravetz
Date: Wed Jun 10 2020 - 20:14:16 EST


On 6/4/20 2:16 AM, Miklos Szeredi wrote:
> On Thu, May 28, 2020 at 11:01 PM Mike Kravetz <mike.kravetz@xxxxxxxxxx> wrote:
>>
>> Well yuck! get_unmapped_area is not part of mm_struct if !CONFIG_MMU.
>>
>> Miklos, would adding '#ifdef CONFIG_MMU' around the overlayfs code be too
>> ugly for you? Another option is to use real_file() in the mmap code as
>> done in [1].
>
> I think the proper fix is to add an inline helper
> (call_get_unmapped_area()?) in linux/mm.h, and make that work properly
> for the NOMMU case as well.
>

I'm ignoring the above issue for now. There may be a more fundamental issue
that I do not know how to solve without adding another memeber to
file_operations. Why?

In order to go from file -> realfile, one needs to do something like the
code you provided.

while (file->f_op == &ovl_file_operations)
file = file->private_data;
return file;

The problem is that this needs to be called from core kernel code
(is_file_hugepages in mmap). ovl_file_operations is obviously only defined
in the overlayfs code. Since overlayfs can be built as a module, I do not
know of a way to reference ovl_file_operations which will only become available
when/if overlayfs is loaded. Is there a way to do that?

If there is no other way to do this, then I think we need to add another
member to file_operations as is done in the following patch. I hope there
is another way, because adding another file_op seems like overkill.