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).

Thanks,
Hongbo

+    file_accessed(iocb->ki_filp);

I don't think it's useful in practice.


Just keep in consistent with filemap_read?


+    return nread;
+}
+
+static int erofs_ishare_mmap(struct file *file, struct vm_area_struct *vma)
+{
+    struct file *realfile = file->private_data;
+
+    vma_set_file(vma, realfile);
+    return generic_file_readonly_mmap(file, vma);
+}
+

...

@@ -649,6 +659,16 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
      sb->s_maxbytes = MAX_LFS_FILESIZE;
      sb->s_op = &erofs_sops;
+    if (sbi->domain_id &&
+        (!sbi->fsid && !test_opt(&sbi->opt, INODE_SHARE))) {
+        errorfc(fc, "domain_id should be with fsid or inode_share option");
+        return -EINVAL;
+    }

Is that really needed?


Ok, I will remove it in next version.

Thanks,
Hongbo



+    if (test_opt(&sbi->opt, DAX_ALWAYS) && test_opt(&sbi->opt, INODE_SHARE)) {
+        errorfc(fc, "dax is not allowed when inode_share is on");

         errorfc(fc, "FSDAX is not allowed when inode_share is on");

Thanks,
Gao Xiang

Reply via email to