Skip to contentSkip to conversation

erofs: set SB_I_ALLOW_HSM for bdev-based mounts

PATCH In review Friendy Su 2 participants 2 messages Nov 20 EROFS file system

lore
Share & tools
lore

Friendy Su

author
#0 lore raw

PATCH v3 1/1 erofs: set SB_I_ALLOW_HSM for bdev-based mounts

Set SB_I_ALLOW_HSM to enable fanotify FAN_PRE_ACCESS events for bdev-backed mounts. File-backed mounts are not supported.

This allows EROFS to handle cases where file data is not available locally at mount time and needs to be fetched on demand by a FAN_PRE_ACCESS event handler.

For example, an EROFS image can use blob mode with metadata stored on /dev/pmem0 and file data on /dev/pmem1, where the latter initially contains dummy data.

The filesystem can be mounted with:

mount -o dax,device=/dev/pmem1 /dev/pmem0 /mnt/erofs

On receiving a FAN_PRE_ACCESS event, the handler fetches the actual file data from a remote source and fills the corresponding blocks on /dev/pmem1 before access proceeds.

---
 fs/erofs/super.c | 8 ++++++++
 1 file changed, 8 insertions(+)
fs/erofs/super.c +8 -0
index ce05557bd998..4ef4c8ce1240 100644
@@ -684,6 +684,14 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
 		errorfc(fc, "superblock_share does not support extra devices");
 		return -EINVAL;
 	}
+	if (!erofs_is_fileio_mode(sbi)) {
+		/*
+		 * Follow other filesystems by supporting FAN_PRE_ACCESS events
+		 * only on bdev-backed mount. Don't bother with file-backed
+		 * mounts.
+		 */
+		sb->s_iflags |= SB_I_ALLOW_HSM;
+	}
 
 	sbi->blkszbits = PAGE_SHIFT;
 	if (erofs_is_fileio_mode(sbi)) {
Signature · 1 line
2.34.1
maintainer Reviewed-by on v3 1/1
#1 lore raw
Quoted 15 lines · Friendy Su

Set SB_I_ALLOW_HSM to enable fanotify FAN_PRE_ACCESS events for bdev-backed mounts. File-backed mounts are not supported.

This allows EROFS to handle cases where file data is not available locally at mount time and needs to be fetched on demand by a FAN_PRE_ACCESS event handler.

For example, an EROFS image can use blob mode with metadata stored on /dev/pmem0 and file data on /dev/pmem1, where the latter initially contains dummy data.

The filesystem can be mounted with:

mount -o dax,device=/dev/pmem1 /dev/pmem0 /mnt/erofs

Quoted 7 lines

On receiving a FAN_PRE_ACCESS event, the handler fetches the actual file data from a remote source and fills the corresponding blocks on /dev/pmem1 before access proceeds.

Thanks,
Gao Xiang