@@ -370,18 +370,18 @@ static int erofs_read_superblock(struct super_block *sb)
370
370
return ret ;
371
371
}
372
372
373
- static void erofs_default_options (struct erofs_fs_context * ctx )
373
+ static void erofs_default_options (struct erofs_sb_info * sbi )
374
374
{
375
375
#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 ;
379
379
#endif
380
380
#ifdef CONFIG_EROFS_FS_XATTR
381
- set_opt (& ctx -> opt , XATTR_USER );
381
+ set_opt (& sbi -> opt , XATTR_USER );
382
382
#endif
383
383
#ifdef CONFIG_EROFS_FS_POSIX_ACL
384
- set_opt (& ctx -> opt , POSIX_ACL );
384
+ set_opt (& sbi -> opt , POSIX_ACL );
385
385
#endif
386
386
}
387
387
@@ -426,16 +426,16 @@ static const struct fs_parameter_spec erofs_fs_parameters[] = {
426
426
static bool erofs_fc_set_dax_mode (struct fs_context * fc , unsigned int mode )
427
427
{
428
428
#ifdef CONFIG_FS_DAX
429
- struct erofs_fs_context * ctx = fc -> fs_private ;
429
+ struct erofs_sb_info * sbi = fc -> s_fs_info ;
430
430
431
431
switch (mode ) {
432
432
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 );
435
435
return true;
436
436
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 );
439
439
return true;
440
440
default :
441
441
DBG_BUGON (1 );
@@ -450,7 +450,7 @@ static bool erofs_fc_set_dax_mode(struct fs_context *fc, unsigned int mode)
450
450
static int erofs_fc_parse_param (struct fs_context * fc ,
451
451
struct fs_parameter * param )
452
452
{
453
- struct erofs_fs_context * ctx = fc -> fs_private ;
453
+ struct erofs_sb_info * sbi = fc -> s_fs_info ;
454
454
struct fs_parse_result result ;
455
455
struct erofs_device_info * dif ;
456
456
int opt , ret ;
@@ -463,26 +463,26 @@ static int erofs_fc_parse_param(struct fs_context *fc,
463
463
case Opt_user_xattr :
464
464
#ifdef CONFIG_EROFS_FS_XATTR
465
465
if (result .boolean )
466
- set_opt (& ctx -> opt , XATTR_USER );
466
+ set_opt (& sbi -> opt , XATTR_USER );
467
467
else
468
- clear_opt (& ctx -> opt , XATTR_USER );
468
+ clear_opt (& sbi -> opt , XATTR_USER );
469
469
#else
470
470
errorfc (fc , "{,no}user_xattr options not supported" );
471
471
#endif
472
472
break ;
473
473
case Opt_acl :
474
474
#ifdef CONFIG_EROFS_FS_POSIX_ACL
475
475
if (result .boolean )
476
- set_opt (& ctx -> opt , POSIX_ACL );
476
+ set_opt (& sbi -> opt , POSIX_ACL );
477
477
else
478
- clear_opt (& ctx -> opt , POSIX_ACL );
478
+ clear_opt (& sbi -> opt , POSIX_ACL );
479
479
#else
480
480
errorfc (fc , "{,no}acl options not supported" );
481
481
#endif
482
482
break ;
483
483
case Opt_cache_strategy :
484
484
#ifdef CONFIG_EROFS_FS_ZIP
485
- ctx -> opt .cache_strategy = result .uint_32 ;
485
+ sbi -> opt .cache_strategy = result .uint_32 ;
486
486
#else
487
487
errorfc (fc , "compression not supported, cache_strategy ignored" );
488
488
#endif
@@ -504,27 +504,27 @@ static int erofs_fc_parse_param(struct fs_context *fc,
504
504
kfree (dif );
505
505
return - ENOMEM ;
506
506
}
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 );
510
510
if (ret < 0 ) {
511
511
kfree (dif -> path );
512
512
kfree (dif );
513
513
return ret ;
514
514
}
515
- ++ ctx -> devs -> extra_devices ;
515
+ ++ sbi -> devs -> extra_devices ;
516
516
break ;
517
517
#ifdef CONFIG_EROFS_FS_ONDEMAND
518
518
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 )
522
522
return - ENOMEM ;
523
523
break ;
524
524
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 )
528
528
return - ENOMEM ;
529
529
break ;
530
530
#else
@@ -581,28 +581,14 @@ static const struct export_operations erofs_export_ops = {
581
581
static int erofs_fc_fill_super (struct super_block * sb , struct fs_context * fc )
582
582
{
583
583
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 );
586
585
int err ;
587
586
588
587
sb -> s_magic = EROFS_SUPER_MAGIC ;
589
588
sb -> s_flags |= SB_RDONLY | SB_NOATIME ;
590
589
sb -> s_maxbytes = MAX_LFS_FILESIZE ;
591
590
sb -> s_op = & erofs_sops ;
592
591
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
-
606
592
sbi -> blkszbits = PAGE_SHIFT ;
607
593
if (erofs_is_fscache_mode (sb )) {
608
594
sb -> s_blocksize = PAGE_SIZE ;
@@ -706,9 +692,9 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
706
692
707
693
static int erofs_fc_get_tree (struct fs_context * fc )
708
694
{
709
- struct erofs_fs_context * ctx = fc -> fs_private ;
695
+ struct erofs_sb_info * sbi = fc -> s_fs_info ;
710
696
711
- if (IS_ENABLED (CONFIG_EROFS_FS_ONDEMAND ) && ctx -> fsid )
697
+ if (IS_ENABLED (CONFIG_EROFS_FS_ONDEMAND ) && sbi -> fsid )
712
698
return get_tree_nodev (fc , erofs_fc_fill_super );
713
699
714
700
return get_tree_bdev (fc , erofs_fc_fill_super );
@@ -718,19 +704,19 @@ static int erofs_fc_reconfigure(struct fs_context *fc)
718
704
{
719
705
struct super_block * sb = fc -> root -> d_sb ;
720
706
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 ;
722
708
723
709
DBG_BUGON (!sb_rdonly (sb ));
724
710
725
- if (ctx -> fsid || ctx -> domain_id )
711
+ if (new_sbi -> fsid || new_sbi -> domain_id )
726
712
erofs_info (sb , "ignoring reconfiguration for fsid|domain_id." );
727
713
728
- if (test_opt (& ctx -> opt , POSIX_ACL ))
714
+ if (test_opt (& new_sbi -> opt , POSIX_ACL ))
729
715
fc -> sb_flags |= SB_POSIXACL ;
730
716
else
731
717
fc -> sb_flags &= ~SB_POSIXACL ;
732
718
733
- sbi -> opt = ctx -> opt ;
719
+ sbi -> opt = new_sbi -> opt ;
734
720
735
721
fc -> sb_flags |= SB_RDONLY ;
736
722
return 0 ;
@@ -761,12 +747,15 @@ static void erofs_free_dev_context(struct erofs_dev_context *devs)
761
747
762
748
static void erofs_fc_free (struct fs_context * fc )
763
749
{
764
- struct erofs_fs_context * ctx = fc -> fs_private ;
750
+ struct erofs_sb_info * sbi = fc -> s_fs_info ;
765
751
766
- erofs_free_dev_context (ctx -> devs );
767
- kfree (ctx -> fsid );
768
- kfree (ctx -> domain_id );
769
- kfree (ctx );
752
+ if (!sbi )
753
+ return ;
754
+
755
+ erofs_free_dev_context (sbi -> devs );
756
+ kfree (sbi -> fsid );
757
+ kfree (sbi -> domain_id );
758
+ kfree (sbi );
770
759
}
771
760
772
761
static const struct fs_context_operations erofs_context_ops = {
@@ -778,38 +767,35 @@ static const struct fs_context_operations erofs_context_ops = {
778
767
779
768
static int erofs_init_fs_context (struct fs_context * fc )
780
769
{
781
- struct erofs_fs_context * ctx ;
770
+ struct erofs_sb_info * sbi ;
782
771
783
- ctx = kzalloc (sizeof (* ctx ), GFP_KERNEL );
784
- if (!ctx )
772
+ sbi = kzalloc (sizeof (* sbi ), GFP_KERNEL );
773
+ if (!sbi )
785
774
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 );
789
779
return - ENOMEM ;
790
780
}
791
- fc -> fs_private = ctx ;
781
+ fc -> s_fs_info = sbi ;
792
782
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 );
796
786
fc -> ops = & erofs_context_ops ;
797
787
return 0 ;
798
788
}
799
789
800
790
static void erofs_kill_sb (struct super_block * sb )
801
791
{
802
- struct erofs_sb_info * sbi ;
792
+ struct erofs_sb_info * sbi = EROFS_SB ( sb ) ;
803
793
804
- if (erofs_is_fscache_mode ( sb ) )
794
+ if (IS_ENABLED ( CONFIG_EROFS_FS_ONDEMAND ) && sbi -> fsid )
805
795
kill_anon_super (sb );
806
796
else
807
797
kill_block_super (sb );
808
798
809
- sbi = EROFS_SB (sb );
810
- if (!sbi )
811
- return ;
812
-
813
799
erofs_free_dev_context (sbi -> devs );
814
800
fs_put_dax (sbi -> dax_dev , NULL );
815
801
erofs_fscache_unregister_fs (sb );
0 commit comments