Re: [PATCH 1/6] kernfs: create vm_operations_struct without page_mkwrite()

Logan Gunthorpe
2024-06-07T16:17:27Z

On 2024-06-06 23:03, Christoph Hellwig wrote:
> On Thu, Jun 06, 2024 at 10:54:06PM +0200, Greg Kroah-Hartman wrote:
>> On Wed, Jun 05, 2024 at 01:29:29PM -0600, Martin Oliveira wrote:
>>> The standard kernfs vm_ops installs a page_mkwrite() operator which
>>> modifies the file update time on write.
>>>
>>> This not always required (or makes sense), such as in the P2PDMA, which
>>> uses the sysfs file as an allocator from userspace.
>>
>> That's not a good idea, please don't do that. sysfs binary files are
>> "pass through", why would you want to use this as an allocator?
>
> I think the real question is why sysfs binary files implement
> page_mkwrite by default. page_mkwrite is needed for file systems that
> need to allocate space from a free space pool, which seems odd for
> sysfs.

The default page_mkwrite in kernfs just calls file_update_time() but, as
I understand it, the fault code should call file_update_time() if
page_mkwrite isn't set. So perhaps the easiest thing is to simply not
add a page_mkwrite unless the vm_ops adds one.

It's not the easiest thing to trace, but as best as I can tell there are
no kernfs binary attributes that use page_mkwrite. So alternatively,
perhaps we could just disallow page_mkwrite in kernfs entirely?

Logan