@@ -372,6 +372,8 @@ static int erofs_read_superblock(struct super_block *sb)
372
372
373
373
if (erofs_sb_has_ztailpacking (sbi ))
374
374
erofs_info (sb , "EXPERIMENTAL compressed inline data feature in use. Use at your own risk!" );
375
+ if (erofs_is_fscache_mode (sb ))
376
+ erofs_info (sb , "EXPERIMENTAL fscache-based on-demand read feature in use. Use at your own risk!" );
375
377
out :
376
378
erofs_put_metabuf (& buf );
377
379
return ret ;
@@ -400,6 +402,7 @@ enum {
400
402
Opt_dax ,
401
403
Opt_dax_enum ,
402
404
Opt_device ,
405
+ Opt_fsid ,
403
406
Opt_err
404
407
};
405
408
@@ -424,6 +427,7 @@ static const struct fs_parameter_spec erofs_fs_parameters[] = {
424
427
fsparam_flag ("dax" , Opt_dax ),
425
428
fsparam_enum ("dax" , Opt_dax_enum , erofs_dax_param_enums ),
426
429
fsparam_string ("device" , Opt_device ),
430
+ fsparam_string ("fsid" , Opt_fsid ),
427
431
{}
428
432
};
429
433
@@ -519,6 +523,16 @@ static int erofs_fc_parse_param(struct fs_context *fc,
519
523
}
520
524
++ ctx -> devs -> extra_devices ;
521
525
break ;
526
+ case Opt_fsid :
527
+ #ifdef CONFIG_EROFS_FS_ONDEMAND
528
+ kfree (ctx -> opt .fsid );
529
+ ctx -> opt .fsid = kstrdup (param -> string , GFP_KERNEL );
530
+ if (!ctx -> opt .fsid )
531
+ return - ENOMEM ;
532
+ #else
533
+ errorfc (fc , "fsid option not supported" );
534
+ #endif
535
+ break ;
522
536
default :
523
537
return - ENOPARAM ;
524
538
}
@@ -643,6 +657,7 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
643
657
644
658
sb -> s_fs_info = sbi ;
645
659
sbi -> opt = ctx -> opt ;
660
+ ctx -> opt .fsid = NULL ;
646
661
sbi -> devs = ctx -> devs ;
647
662
ctx -> devs = NULL ;
648
663
@@ -730,6 +745,11 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
730
745
731
746
static int erofs_fc_get_tree (struct fs_context * fc )
732
747
{
748
+ struct erofs_fs_context * ctx = fc -> fs_private ;
749
+
750
+ if (IS_ENABLED (CONFIG_EROFS_FS_ONDEMAND ) && ctx -> opt .fsid )
751
+ return get_tree_nodev (fc , erofs_fc_fill_super );
752
+
733
753
return get_tree_bdev (fc , erofs_fc_fill_super );
734
754
}
735
755
@@ -779,6 +799,7 @@ static void erofs_fc_free(struct fs_context *fc)
779
799
struct erofs_fs_context * ctx = fc -> fs_private ;
780
800
781
801
erofs_free_dev_context (ctx -> devs );
802
+ kfree (ctx -> opt .fsid );
782
803
kfree (ctx );
783
804
}
784
805
@@ -819,7 +840,10 @@ static void erofs_kill_sb(struct super_block *sb)
819
840
820
841
WARN_ON (sb -> s_magic != EROFS_SUPER_MAGIC );
821
842
822
- kill_block_super (sb );
843
+ if (erofs_is_fscache_mode (sb ))
844
+ generic_shutdown_super (sb );
845
+ else
846
+ kill_block_super (sb );
823
847
824
848
sbi = EROFS_SB (sb );
825
849
if (!sbi )
@@ -829,6 +853,7 @@ static void erofs_kill_sb(struct super_block *sb)
829
853
fs_put_dax (sbi -> dax_dev );
830
854
erofs_fscache_unregister_cookie (& sbi -> s_fscache );
831
855
erofs_fscache_unregister_fs (sb );
856
+ kfree (sbi -> opt .fsid );
832
857
kfree (sbi );
833
858
sb -> s_fs_info = NULL ;
834
859
}
@@ -978,6 +1003,10 @@ static int erofs_show_options(struct seq_file *seq, struct dentry *root)
978
1003
seq_puts (seq , ",dax=always" );
979
1004
if (test_opt (opt , DAX_NEVER ))
980
1005
seq_puts (seq , ",dax=never" );
1006
+ #ifdef CONFIG_EROFS_FS_ONDEMAND
1007
+ if (opt -> fsid )
1008
+ seq_printf (seq , ",fsid=%s" , opt -> fsid );
1009
+ #endif
981
1010
return 0 ;
982
1011
}
983
1012
0 commit comments