@@ -367,18 +367,18 @@ static int erofs_read_superblock(struct super_block *sb)
367
367
return ret ;
368
368
}
369
369
370
- static void erofs_default_options (struct erofs_fs_context * ctx )
370
+ static void erofs_default_options (struct erofs_sb_info * sbi )
371
371
{
372
372
#ifdef CONFIG_EROFS_FS_ZIP
373
- ctx -> opt .cache_strategy = EROFS_ZIP_CACHE_READAROUND ;
374
- ctx -> opt .max_sync_decompress_pages = 3 ;
375
- ctx -> opt .sync_decompress = EROFS_SYNC_DECOMPRESS_AUTO ;
373
+ sbi -> opt .cache_strategy = EROFS_ZIP_CACHE_READAROUND ;
374
+ sbi -> opt .max_sync_decompress_pages = 3 ;
375
+ sbi -> opt .sync_decompress = EROFS_SYNC_DECOMPRESS_AUTO ;
376
376
#endif
377
377
#ifdef CONFIG_EROFS_FS_XATTR
378
- set_opt (& ctx -> opt , XATTR_USER );
378
+ set_opt (& sbi -> opt , XATTR_USER );
379
379
#endif
380
380
#ifdef CONFIG_EROFS_FS_POSIX_ACL
381
- set_opt (& ctx -> opt , POSIX_ACL );
381
+ set_opt (& sbi -> opt , POSIX_ACL );
382
382
#endif
383
383
}
384
384
@@ -423,17 +423,17 @@ static const struct fs_parameter_spec erofs_fs_parameters[] = {
423
423
static bool erofs_fc_set_dax_mode (struct fs_context * fc , unsigned int mode )
424
424
{
425
425
#ifdef CONFIG_FS_DAX
426
- struct erofs_fs_context * ctx = fc -> fs_private ;
426
+ struct erofs_sb_info * sbi = fc -> s_fs_info ;
427
427
428
428
switch (mode ) {
429
429
case EROFS_MOUNT_DAX_ALWAYS :
430
430
warnfc (fc , "DAX enabled. Warning: EXPERIMENTAL, use at your own risk" );
431
- set_opt (& ctx -> opt , DAX_ALWAYS );
432
- clear_opt (& ctx -> opt , DAX_NEVER );
431
+ set_opt (& sbi -> opt , DAX_ALWAYS );
432
+ clear_opt (& sbi -> opt , DAX_NEVER );
433
433
return true;
434
434
case EROFS_MOUNT_DAX_NEVER :
435
- set_opt (& ctx -> opt , DAX_NEVER );
436
- clear_opt (& ctx -> opt , DAX_ALWAYS );
435
+ set_opt (& sbi -> opt , DAX_NEVER );
436
+ clear_opt (& sbi -> opt , DAX_ALWAYS );
437
437
return true;
438
438
default :
439
439
DBG_BUGON (1 );
@@ -448,7 +448,7 @@ static bool erofs_fc_set_dax_mode(struct fs_context *fc, unsigned int mode)
448
448
static int erofs_fc_parse_param (struct fs_context * fc ,
449
449
struct fs_parameter * param )
450
450
{
451
- struct erofs_fs_context * ctx = fc -> fs_private ;
451
+ struct erofs_sb_info * sbi = fc -> s_fs_info ;
452
452
struct fs_parse_result result ;
453
453
struct erofs_device_info * dif ;
454
454
int opt , ret ;
@@ -461,26 +461,26 @@ static int erofs_fc_parse_param(struct fs_context *fc,
461
461
case Opt_user_xattr :
462
462
#ifdef CONFIG_EROFS_FS_XATTR
463
463
if (result .boolean )
464
- set_opt (& ctx -> opt , XATTR_USER );
464
+ set_opt (& sbi -> opt , XATTR_USER );
465
465
else
466
- clear_opt (& ctx -> opt , XATTR_USER );
466
+ clear_opt (& sbi -> opt , XATTR_USER );
467
467
#else
468
468
errorfc (fc , "{,no}user_xattr options not supported" );
469
469
#endif
470
470
break ;
471
471
case Opt_acl :
472
472
#ifdef CONFIG_EROFS_FS_POSIX_ACL
473
473
if (result .boolean )
474
- set_opt (& ctx -> opt , POSIX_ACL );
474
+ set_opt (& sbi -> opt , POSIX_ACL );
475
475
else
476
- clear_opt (& ctx -> opt , POSIX_ACL );
476
+ clear_opt (& sbi -> opt , POSIX_ACL );
477
477
#else
478
478
errorfc (fc , "{,no}acl options not supported" );
479
479
#endif
480
480
break ;
481
481
case Opt_cache_strategy :
482
482
#ifdef CONFIG_EROFS_FS_ZIP
483
- ctx -> opt .cache_strategy = result .uint_32 ;
483
+ sbi -> opt .cache_strategy = result .uint_32 ;
484
484
#else
485
485
errorfc (fc , "compression not supported, cache_strategy ignored" );
486
486
#endif
@@ -502,27 +502,27 @@ static int erofs_fc_parse_param(struct fs_context *fc,
502
502
kfree (dif );
503
503
return - ENOMEM ;
504
504
}
505
- down_write (& ctx -> devs -> rwsem );
506
- ret = idr_alloc (& ctx -> devs -> tree , dif , 0 , 0 , GFP_KERNEL );
507
- up_write (& ctx -> devs -> rwsem );
505
+ down_write (& sbi -> devs -> rwsem );
506
+ ret = idr_alloc (& sbi -> devs -> tree , dif , 0 , 0 , GFP_KERNEL );
507
+ up_write (& sbi -> devs -> rwsem );
508
508
if (ret < 0 ) {
509
509
kfree (dif -> path );
510
510
kfree (dif );
511
511
return ret ;
512
512
}
513
- ++ ctx -> devs -> extra_devices ;
513
+ ++ sbi -> devs -> extra_devices ;
514
514
break ;
515
515
#ifdef CONFIG_EROFS_FS_ONDEMAND
516
516
case Opt_fsid :
517
- kfree (ctx -> fsid );
518
- ctx -> fsid = kstrdup (param -> string , GFP_KERNEL );
519
- if (!ctx -> fsid )
517
+ kfree (sbi -> fsid );
518
+ sbi -> fsid = kstrdup (param -> string , GFP_KERNEL );
519
+ if (!sbi -> fsid )
520
520
return - ENOMEM ;
521
521
break ;
522
522
case Opt_domain_id :
523
- kfree (ctx -> domain_id );
524
- ctx -> domain_id = kstrdup (param -> string , GFP_KERNEL );
525
- if (!ctx -> domain_id )
523
+ kfree (sbi -> domain_id );
524
+ sbi -> domain_id = kstrdup (param -> string , GFP_KERNEL );
525
+ if (!sbi -> domain_id )
526
526
return - ENOMEM ;
527
527
break ;
528
528
#else
@@ -578,28 +578,14 @@ static const struct export_operations erofs_export_ops = {
578
578
static int erofs_fc_fill_super (struct super_block * sb , struct fs_context * fc )
579
579
{
580
580
struct inode * inode ;
581
- struct erofs_sb_info * sbi ;
582
- struct erofs_fs_context * ctx = fc -> fs_private ;
581
+ struct erofs_sb_info * sbi = EROFS_SB (sb );
583
582
int err ;
584
583
585
584
sb -> s_magic = EROFS_SUPER_MAGIC ;
586
585
sb -> s_flags |= SB_RDONLY | SB_NOATIME ;
587
586
sb -> s_maxbytes = MAX_LFS_FILESIZE ;
588
587
sb -> s_op = & erofs_sops ;
589
588
590
- sbi = kzalloc (sizeof (* sbi ), GFP_KERNEL );
591
- if (!sbi )
592
- return - ENOMEM ;
593
-
594
- sb -> s_fs_info = sbi ;
595
- sbi -> opt = ctx -> opt ;
596
- sbi -> devs = ctx -> devs ;
597
- ctx -> devs = NULL ;
598
- sbi -> fsid = ctx -> fsid ;
599
- ctx -> fsid = NULL ;
600
- sbi -> domain_id = ctx -> domain_id ;
601
- ctx -> domain_id = NULL ;
602
-
603
589
sbi -> blkszbits = PAGE_SHIFT ;
604
590
if (erofs_is_fscache_mode (sb )) {
605
591
sb -> s_blocksize = PAGE_SIZE ;
@@ -703,9 +689,9 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
703
689
704
690
static int erofs_fc_get_tree (struct fs_context * fc )
705
691
{
706
- struct erofs_fs_context * ctx = fc -> fs_private ;
692
+ struct erofs_sb_info * sbi = fc -> s_fs_info ;
707
693
708
- if (IS_ENABLED (CONFIG_EROFS_FS_ONDEMAND ) && ctx -> fsid )
694
+ if (IS_ENABLED (CONFIG_EROFS_FS_ONDEMAND ) && sbi -> fsid )
709
695
return get_tree_nodev (fc , erofs_fc_fill_super );
710
696
711
697
return get_tree_bdev (fc , erofs_fc_fill_super );
@@ -715,19 +701,19 @@ static int erofs_fc_reconfigure(struct fs_context *fc)
715
701
{
716
702
struct super_block * sb = fc -> root -> d_sb ;
717
703
struct erofs_sb_info * sbi = EROFS_SB (sb );
718
- struct erofs_fs_context * ctx = fc -> fs_private ;
704
+ struct erofs_sb_info * new_sbi = fc -> s_fs_info ;
719
705
720
706
DBG_BUGON (!sb_rdonly (sb ));
721
707
722
- if (ctx -> fsid || ctx -> domain_id )
708
+ if (new_sbi -> fsid || new_sbi -> domain_id )
723
709
erofs_info (sb , "ignoring reconfiguration for fsid|domain_id." );
724
710
725
- if (test_opt (& ctx -> opt , POSIX_ACL ))
711
+ if (test_opt (& new_sbi -> opt , POSIX_ACL ))
726
712
fc -> sb_flags |= SB_POSIXACL ;
727
713
else
728
714
fc -> sb_flags &= ~SB_POSIXACL ;
729
715
730
- sbi -> opt = ctx -> opt ;
716
+ sbi -> opt = new_sbi -> opt ;
731
717
732
718
fc -> sb_flags |= SB_RDONLY ;
733
719
return 0 ;
@@ -758,12 +744,15 @@ static void erofs_free_dev_context(struct erofs_dev_context *devs)
758
744
759
745
static void erofs_fc_free (struct fs_context * fc )
760
746
{
761
- struct erofs_fs_context * ctx = fc -> fs_private ;
747
+ struct erofs_sb_info * sbi = fc -> s_fs_info ;
748
+
749
+ if (!sbi )
750
+ return ;
762
751
763
- erofs_free_dev_context (ctx -> devs );
764
- kfree (ctx -> fsid );
765
- kfree (ctx -> domain_id );
766
- kfree (ctx );
752
+ erofs_free_dev_context (sbi -> devs );
753
+ kfree (sbi -> fsid );
754
+ kfree (sbi -> domain_id );
755
+ kfree (sbi );
767
756
}
768
757
769
758
static const struct fs_context_operations erofs_context_ops = {
@@ -775,21 +764,22 @@ static const struct fs_context_operations erofs_context_ops = {
775
764
776
765
static int erofs_init_fs_context (struct fs_context * fc )
777
766
{
778
- struct erofs_fs_context * ctx ;
767
+ struct erofs_sb_info * sbi ;
779
768
780
- ctx = kzalloc (sizeof (* ctx ), GFP_KERNEL );
781
- if (!ctx )
769
+ sbi = kzalloc (sizeof (* sbi ), GFP_KERNEL );
770
+ if (!sbi )
782
771
return - ENOMEM ;
783
- ctx -> devs = kzalloc (sizeof (struct erofs_dev_context ), GFP_KERNEL );
784
- if (!ctx -> devs ) {
785
- kfree (ctx );
772
+
773
+ sbi -> devs = kzalloc (sizeof (struct erofs_dev_context ), GFP_KERNEL );
774
+ if (!sbi -> devs ) {
775
+ kfree (sbi );
786
776
return - ENOMEM ;
787
777
}
788
- fc -> fs_private = ctx ;
778
+ fc -> s_fs_info = sbi ;
789
779
790
- idr_init (& ctx -> devs -> tree );
791
- init_rwsem (& ctx -> devs -> rwsem );
792
- erofs_default_options (ctx );
780
+ idr_init (& sbi -> devs -> tree );
781
+ init_rwsem (& sbi -> devs -> rwsem );
782
+ erofs_default_options (sbi );
793
783
fc -> ops = & erofs_context_ops ;
794
784
return 0 ;
795
785
}
0 commit comments