Re: [PATCH v1] erofs: enable SB_I_ALLOW_HSM to support fanotify pre access event
From: Amir Goldstein
Date: Wed Oct 21 2026 - 05:47:59 EST
On Wed, Oct 21, 2026 at 11:43 AM Friendy.Su@xxxxxxxx
<Friendy.Su@xxxxxxxx> wrote:
>
> Thanks for your comment.
>
> I will send patch v2.
>
> ________________________________________
> From: Gao Xiang <xiang@xxxxxxxxxx>
> Sent: Wednesday, October 21, 2026 16:05
> To: Su, Friendy
> Cc: Gao Xiang; chao@xxxxxxxxxx; linux-erofs@xxxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; Mo, Yuezhang; Palmer, Daniel (SGC); Amir Goldstein; Jan Kara
> Subject: Re: [PATCH v1] erofs: enable SB_I_ALLOW_HSM to support fanotify pre access event
>
> (+cc Amir, Jan) On Wed, Oct 21, 2026 at 07: 18: 06AM +0000, Friendy. Su@ sony. com wrote: > Hi Gao, > > Sorry for late reply. > > We have considered fanotify in erofs-utils. I think it must be used with > file-backend mount. It
>
>
> (+cc Amir, Jan)
>
> On Wed, Oct 21, 2026 at 07:18:06AM +0000, Friendy.Su@xxxxxxxx wrote:
> > Hi Gao,
> >
> > Sorry for late reply.
> >
> > We have considered fanotify in erofs-utils. I think it must be used with
> > file-backend mount. It actually utilizes FAN_PRE_ACCESS on ext4 or xfs.
> > Also file-backend mount can not support DAX mount.
> >
> > But for our case, file-backend mount can not be used. Firstly, there is no
> > ext4 or xfs file system in actual environment to put a sparse erofs image
> > file. We have to mount a normal block device. Secondly, mount must be DAX.
> >
> > The basic flow is file content is fetched from remote then filled into
> > local erofs file on the DAX mounted block device in FAN_PRE_ACCESS handler.
> >
> > "/dev/loop0" is just an example, not our actual use case. The actual block
> > device is something like /dev/pmem0.
> >
> > In order to make SB_I_ALLOW_HSM only set under block device backend,
> > we can do like this:
> >
> > if (!erofs_is_fileio_mode(sbi)) {
> > /*
> > * Allow HSM to support fanotify pre access event
> > */
>
> nit: single line /* Allow HSM to support fanotify pre access event */
> according to EROFS code style.
>
> > sb->s_iflags |= SB_I_ALLOW_HSM;
> > }
>
> I am fine with that as long as you limits SB_I_ALLOW_HSM **only if**
> s_bdev is valid (IOWs, I hope we don't need to bother it with EROFS
> SB_I_ALLOW_HSM + file-backed mounts; it aligns with other filesystems).
>
> Also I think it would be better to add a testcase to check the basic
> EROFS SB_I_ALLOW_HSM functionality in erofs-utils (see
> experimental-tests). You don't need to add support for EROFS
> SB_I_ALLOW_HSM directly in erofs-utils; but a basic functionality
> testcase for this is needed.
>
>
> BTW, for your use cases:
>
> > mount must be DAX.
>
> As for virtio-pmem, why not just use userfaultfd on the host for
> virtio-pmem lazy pulling? for example,
> https://urldefense.com/v3/__https://github.com/firecracker-microvm/firecracker/issues/5740__;!!O7_YSHcmd9jp3hj_4dEAcyQ!1I4HPp-ti8SbtdVUzxl0B0QuNCpDMYyUh1CGGxNZEvFSg_lZnXaDitDh6Clg2me7wzbPbUl2X5E_vw$
>
> Personally I still don't think monitoring FAN_PRE_ACCESS of EROFS for
> this kind of usage is a good idea.
Personally I agree that this is odd, but practically, this allows getting
FAN_PRE_ACCESS events with extra range info on erofs file's access.
I don't see the risk in allowing that so I have no reason to object.
Thanks,
Amir.