@@ -370,18 +370,18 @@ static int erofs_read_superblock(struct super_block *sb)
370370 return ret ;
371371}
372372
373- static void erofs_default_options (struct erofs_fs_context * ctx )
373+ static void erofs_default_options (struct erofs_sb_info * sbi )
374374{
375375#ifdef CONFIG_EROFS_FS_ZIP
376- ctx -> opt .cache_strategy = EROFS_ZIP_CACHE_READAROUND ;
377- ctx -> opt .max_sync_decompress_pages = 3 ;
378- ctx -> opt .sync_decompress = EROFS_SYNC_DECOMPRESS_AUTO ;
376+ sbi -> opt .cache_strategy = EROFS_ZIP_CACHE_READAROUND ;
377+ sbi -> opt .max_sync_decompress_pages = 3 ;
378+ sbi -> opt .sync_decompress = EROFS_SYNC_DECOMPRESS_AUTO ;
379379#endif
380380#ifdef CONFIG_EROFS_FS_XATTR
381- set_opt (& ctx -> opt , XATTR_USER );
381+ set_opt (& sbi -> opt , XATTR_USER );
382382#endif
383383#ifdef CONFIG_EROFS_FS_POSIX_ACL
384- set_opt (& ctx -> opt , POSIX_ACL );
384+ set_opt (& sbi -> opt , POSIX_ACL );
385385#endif
386386}
387387
@@ -426,16 +426,16 @@ static const struct fs_parameter_spec erofs_fs_parameters[] = {
426426static bool erofs_fc_set_dax_mode (struct fs_context * fc , unsigned int mode )
427427{
428428#ifdef CONFIG_FS_DAX
429- struct erofs_fs_context * ctx = fc -> fs_private ;
429+ struct erofs_sb_info * sbi = fc -> s_fs_info ;
430430
431431 switch (mode ) {
432432 case EROFS_MOUNT_DAX_ALWAYS :
433- set_opt (& ctx -> opt , DAX_ALWAYS );
434- clear_opt (& ctx -> opt , DAX_NEVER );
433+ set_opt (& sbi -> opt , DAX_ALWAYS );
434+ clear_opt (& sbi -> opt , DAX_NEVER );
435435 return true;
436436 case EROFS_MOUNT_DAX_NEVER :
437- set_opt (& ctx -> opt , DAX_NEVER );
438- clear_opt (& ctx -> opt , DAX_ALWAYS );
437+ set_opt (& sbi -> opt , DAX_NEVER );
438+ clear_opt (& sbi -> opt , DAX_ALWAYS );
439439 return true;
440440 default :
441441 DBG_BUGON (1 );
@@ -450,7 +450,7 @@ static bool erofs_fc_set_dax_mode(struct fs_context *fc, unsigned int mode)
450450static int erofs_fc_parse_param (struct fs_context * fc ,
451451 struct fs_parameter * param )
452452{
453- struct erofs_fs_context * ctx = fc -> fs_private ;
453+ struct erofs_sb_info * sbi = fc -> s_fs_info ;
454454 struct fs_parse_result result ;
455455 struct erofs_device_info * dif ;
456456 int opt , ret ;
@@ -463,26 +463,26 @@ static int erofs_fc_parse_param(struct fs_context *fc,
463463 case Opt_user_xattr :
464464#ifdef CONFIG_EROFS_FS_XATTR
465465 if (result .boolean )
466- set_opt (& ctx -> opt , XATTR_USER );
466+ set_opt (& sbi -> opt , XATTR_USER );
467467 else
468- clear_opt (& ctx -> opt , XATTR_USER );
468+ clear_opt (& sbi -> opt , XATTR_USER );
469469#else
470470 errorfc (fc , "{,no}user_xattr options not supported" );
471471#endif
472472 break ;
473473 case Opt_acl :
474474#ifdef CONFIG_EROFS_FS_POSIX_ACL
475475 if (result .boolean )
476- set_opt (& ctx -> opt , POSIX_ACL );
476+ set_opt (& sbi -> opt , POSIX_ACL );
477477 else
478- clear_opt (& ctx -> opt , POSIX_ACL );
478+ clear_opt (& sbi -> opt , POSIX_ACL );
479479#else
480480 errorfc (fc , "{,no}acl options not supported" );
481481#endif
482482 break ;
483483 case Opt_cache_strategy :
484484#ifdef CONFIG_EROFS_FS_ZIP
485- ctx -> opt .cache_strategy = result .uint_32 ;
485+ sbi -> opt .cache_strategy = result .uint_32 ;
486486#else
487487 errorfc (fc , "compression not supported, cache_strategy ignored" );
488488#endif
@@ -504,27 +504,27 @@ static int erofs_fc_parse_param(struct fs_context *fc,
504504 kfree (dif );
505505 return - ENOMEM ;
506506 }
507- down_write (& ctx -> devs -> rwsem );
508- ret = idr_alloc (& ctx -> devs -> tree , dif , 0 , 0 , GFP_KERNEL );
509- up_write (& ctx -> devs -> rwsem );
507+ down_write (& sbi -> devs -> rwsem );
508+ ret = idr_alloc (& sbi -> devs -> tree , dif , 0 , 0 , GFP_KERNEL );
509+ up_write (& sbi -> devs -> rwsem );
510510 if (ret < 0 ) {
511511 kfree (dif -> path );
512512 kfree (dif );
513513 return ret ;
514514 }
515- ++ ctx -> devs -> extra_devices ;
515+ ++ sbi -> devs -> extra_devices ;
516516 break ;
517517#ifdef CONFIG_EROFS_FS_ONDEMAND
518518 case Opt_fsid :
519- kfree (ctx -> fsid );
520- ctx -> fsid = kstrdup (param -> string , GFP_KERNEL );
521- if (!ctx -> fsid )
519+ kfree (sbi -> fsid );
520+ sbi -> fsid = kstrdup (param -> string , GFP_KERNEL );
521+ if (!sbi -> fsid )
522522 return - ENOMEM ;
523523 break ;
524524 case Opt_domain_id :
525- kfree (ctx -> domain_id );
526- ctx -> domain_id = kstrdup (param -> string , GFP_KERNEL );
527- if (!ctx -> domain_id )
525+ kfree (sbi -> domain_id );
526+ sbi -> domain_id = kstrdup (param -> string , GFP_KERNEL );
527+ if (!sbi -> domain_id )
528528 return - ENOMEM ;
529529 break ;
530530#else
@@ -581,28 +581,14 @@ static const struct export_operations erofs_export_ops = {
581581static int erofs_fc_fill_super (struct super_block * sb , struct fs_context * fc )
582582{
583583 struct inode * inode ;
584- struct erofs_sb_info * sbi ;
585- struct erofs_fs_context * ctx = fc -> fs_private ;
584+ struct erofs_sb_info * sbi = EROFS_SB (sb );
586585 int err ;
587586
588587 sb -> s_magic = EROFS_SUPER_MAGIC ;
589588 sb -> s_flags |= SB_RDONLY | SB_NOATIME ;
590589 sb -> s_maxbytes = MAX_LFS_FILESIZE ;
591590 sb -> s_op = & erofs_sops ;
592591
593- sbi = kzalloc (sizeof (* sbi ), GFP_KERNEL );
594- if (!sbi )
595- return - ENOMEM ;
596-
597- sb -> s_fs_info = sbi ;
598- sbi -> opt = ctx -> opt ;
599- sbi -> devs = ctx -> devs ;
600- ctx -> devs = NULL ;
601- sbi -> fsid = ctx -> fsid ;
602- ctx -> fsid = NULL ;
603- sbi -> domain_id = ctx -> domain_id ;
604- ctx -> domain_id = NULL ;
605-
606592 sbi -> blkszbits = PAGE_SHIFT ;
607593 if (erofs_is_fscache_mode (sb )) {
608594 sb -> s_blocksize = PAGE_SIZE ;
@@ -706,9 +692,9 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
706692
707693static int erofs_fc_get_tree (struct fs_context * fc )
708694{
709- struct erofs_fs_context * ctx = fc -> fs_private ;
695+ struct erofs_sb_info * sbi = fc -> s_fs_info ;
710696
711- if (IS_ENABLED (CONFIG_EROFS_FS_ONDEMAND ) && ctx -> fsid )
697+ if (IS_ENABLED (CONFIG_EROFS_FS_ONDEMAND ) && sbi -> fsid )
712698 return get_tree_nodev (fc , erofs_fc_fill_super );
713699
714700 return get_tree_bdev (fc , erofs_fc_fill_super );
@@ -718,19 +704,19 @@ static int erofs_fc_reconfigure(struct fs_context *fc)
718704{
719705 struct super_block * sb = fc -> root -> d_sb ;
720706 struct erofs_sb_info * sbi = EROFS_SB (sb );
721- struct erofs_fs_context * ctx = fc -> fs_private ;
707+ struct erofs_sb_info * new_sbi = fc -> s_fs_info ;
722708
723709 DBG_BUGON (!sb_rdonly (sb ));
724710
725- if (ctx -> fsid || ctx -> domain_id )
711+ if (new_sbi -> fsid || new_sbi -> domain_id )
726712 erofs_info (sb , "ignoring reconfiguration for fsid|domain_id." );
727713
728- if (test_opt (& ctx -> opt , POSIX_ACL ))
714+ if (test_opt (& new_sbi -> opt , POSIX_ACL ))
729715 fc -> sb_flags |= SB_POSIXACL ;
730716 else
731717 fc -> sb_flags &= ~SB_POSIXACL ;
732718
733- sbi -> opt = ctx -> opt ;
719+ sbi -> opt = new_sbi -> opt ;
734720
735721 fc -> sb_flags |= SB_RDONLY ;
736722 return 0 ;
@@ -761,12 +747,15 @@ static void erofs_free_dev_context(struct erofs_dev_context *devs)
761747
762748static void erofs_fc_free (struct fs_context * fc )
763749{
764- struct erofs_fs_context * ctx = fc -> fs_private ;
750+ struct erofs_sb_info * sbi = fc -> s_fs_info ;
751+
752+ if (!sbi )
753+ return ;
765754
766- erofs_free_dev_context (ctx -> devs );
767- kfree (ctx -> fsid );
768- kfree (ctx -> domain_id );
769- kfree (ctx );
755+ erofs_free_dev_context (sbi -> devs );
756+ kfree (sbi -> fsid );
757+ kfree (sbi -> domain_id );
758+ kfree (sbi );
770759}
771760
772761static const struct fs_context_operations erofs_context_ops = {
@@ -778,21 +767,22 @@ static const struct fs_context_operations erofs_context_ops = {
778767
779768static int erofs_init_fs_context (struct fs_context * fc )
780769{
781- struct erofs_fs_context * ctx ;
770+ struct erofs_sb_info * sbi ;
782771
783- ctx = kzalloc (sizeof (* ctx ), GFP_KERNEL );
784- if (!ctx )
772+ sbi = kzalloc (sizeof (* sbi ), GFP_KERNEL );
773+ if (!sbi )
785774 return - ENOMEM ;
786- ctx -> devs = kzalloc (sizeof (struct erofs_dev_context ), GFP_KERNEL );
787- if (!ctx -> devs ) {
788- kfree (ctx );
775+
776+ sbi -> devs = kzalloc (sizeof (struct erofs_dev_context ), GFP_KERNEL );
777+ if (!sbi -> devs ) {
778+ kfree (sbi );
789779 return - ENOMEM ;
790780 }
791- fc -> fs_private = ctx ;
781+ fc -> s_fs_info = sbi ;
792782
793- idr_init (& ctx -> devs -> tree );
794- init_rwsem (& ctx -> devs -> rwsem );
795- erofs_default_options (ctx );
783+ idr_init (& sbi -> devs -> tree );
784+ init_rwsem (& sbi -> devs -> rwsem );
785+ erofs_default_options (sbi );
796786 fc -> ops = & erofs_context_ops ;
797787 return 0 ;
798788}
0 commit comments