[PATCH v12 07/10] erofs: introduce the page cache share feature

Gao Xiang hsiangkao at linux.alibaba.com
Thu Jan 8 23:32:27 AEDT 2026



On 2026/1/8 20:20, Hongbo Li wrote:
> Hi, Xiang
> 
> On 2026/1/7 14:08, Gao Xiang wrote:
>>
>>
>> On 2025/12/31 17:01, Hongbo Li wrote:
> 
> ...
> 
>>> +
>>> +static int erofs_ishare_file_release(struct inode *inode, struct file *file)
>>> +{
>>> +    struct file *realfile = file->private_data;
>>> +
>>> +    iput(realfile->f_inode);
>>> +    fput(realfile);
>>> +    file->private_data = NULL;
>>> +    return 0;
>>> +}
>>> +
>>> +static ssize_t erofs_ishare_file_read_iter(struct kiocb *iocb,
>>> +                       struct iov_iter *to)
>>> +{
>>> +    struct file *realfile = iocb->ki_filp->private_data;
>>> +    struct kiocb dedup_iocb;
>>> +    ssize_t nread;
>>> +
>>> +    if (!iov_iter_count(to))
>>> +        return 0;
>>> +
>>> +    /* fallback to the original file in DIRECT mode */
>>> +    if (iocb->ki_flags & IOCB_DIRECT)
>>> +        realfile = iocb->ki_filp;
>>> +
>>> +    kiocb_clone(&dedup_iocb, iocb, realfile);
>>> +    nread = filemap_read(&dedup_iocb, to, 0);
>>> +    iocb->ki_pos = dedup_iocb.ki_pos;
>>
>> I think it will not work for the AIO cases.
>>
>> In order to make it simplified, how about just
>> allowing sync and non-direct I/O first, and
>> defering DIO/AIO support later?
>>
> 
> Ok, but what about doing the fallback logic:
> 
> 1. For direct io: fallback to the original file.
> 2. For AIO: initialize the sync io by init_sync_kiocb (May be we can just replace kiocb_clone with init_sync_kiocb).

No, I'd like to disallow these two types of I/Os
first and consider adding it later for simplicity.

> 
> Thanks,
> Hongbo
> 
>>> +    file_accessed(iocb->ki_filp);
>>
>> I don't think it's useful in practice.
>>
> 
> Just keep in consistent with filemap_read?

Just remove it since EROFS is an immutable fs so
there is nonsense to update atime.

Thanks,
Gao Xiang


More information about the Linux-erofs mailing list