@@ -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,17 +426,17 @@ 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
433
warnfc (fc , "DAX enabled. Warning: EXPERIMENTAL, use at your own risk" );
434
- set_opt (& ctx -> opt , DAX_ALWAYS );
435
- clear_opt (& ctx -> opt , DAX_NEVER );
434
+ set_opt (& sbi -> opt , DAX_ALWAYS );
435
+ clear_opt (& sbi -> opt , DAX_NEVER );
436
436
return true;
437
437
case EROFS_MOUNT_DAX_NEVER :
438
- set_opt (& ctx -> opt , DAX_NEVER );
439
- clear_opt (& ctx -> opt , DAX_ALWAYS );
438
+ set_opt (& sbi -> opt , DAX_NEVER );
439
+ clear_opt (& sbi -> opt , DAX_ALWAYS );
440
440
return true;
441
441
default :
442
442
DBG_BUGON (1 );
@@ -451,7 +451,7 @@ static bool erofs_fc_set_dax_mode(struct fs_context *fc, unsigned int mode)
451
451
static int erofs_fc_parse_param (struct fs_context * fc ,
452
452
struct fs_parameter * param )
453
453
{
454
- struct erofs_fs_context * ctx = fc -> fs_private ;
454
+ struct erofs_sb_info * sbi = fc -> s_fs_info ;
455
455
struct fs_parse_result result ;
456
456
struct erofs_device_info * dif ;
457
457
int opt , ret ;
@@ -464,26 +464,26 @@ static int erofs_fc_parse_param(struct fs_context *fc,
464
464
case Opt_user_xattr :
465
465
#ifdef CONFIG_EROFS_FS_XATTR
466
466
if (result .boolean )
467
- set_opt (& ctx -> opt , XATTR_USER );
467
+ set_opt (& sbi -> opt , XATTR_USER );
468
468
else
469
- clear_opt (& ctx -> opt , XATTR_USER );
469
+ clear_opt (& sbi -> opt , XATTR_USER );
470
470
#else
471
471
errorfc (fc , "{,no}user_xattr options not supported" );
472
472
#endif
473
473
break ;
474
474
case Opt_acl :
475
475
#ifdef CONFIG_EROFS_FS_POSIX_ACL
476
476
if (result .boolean )
477
- set_opt (& ctx -> opt , POSIX_ACL );
477
+ set_opt (& sbi -> opt , POSIX_ACL );
478
478
else
479
- clear_opt (& ctx -> opt , POSIX_ACL );
479
+ clear_opt (& sbi -> opt , POSIX_ACL );
480
480
#else
481
481
errorfc (fc , "{,no}acl options not supported" );
482
482
#endif
483
483
break ;
484
484
case Opt_cache_strategy :
485
485
#ifdef CONFIG_EROFS_FS_ZIP
486
- ctx -> opt .cache_strategy = result .uint_32 ;
486
+ sbi -> opt .cache_strategy = result .uint_32 ;
487
487
#else
488
488
errorfc (fc , "compression not supported, cache_strategy ignored" );
489
489
#endif
@@ -505,27 +505,27 @@ static int erofs_fc_parse_param(struct fs_context *fc,
505
505
kfree (dif );
506
506
return - ENOMEM ;
507
507
}
508
- down_write (& ctx -> devs -> rwsem );
509
- ret = idr_alloc (& ctx -> devs -> tree , dif , 0 , 0 , GFP_KERNEL );
510
- up_write (& ctx -> devs -> rwsem );
508
+ down_write (& sbi -> devs -> rwsem );
509
+ ret = idr_alloc (& sbi -> devs -> tree , dif , 0 , 0 , GFP_KERNEL );
510
+ up_write (& sbi -> devs -> rwsem );
511
511
if (ret < 0 ) {
512
512
kfree (dif -> path );
513
513
kfree (dif );
514
514
return ret ;
515
515
}
516
- ++ ctx -> devs -> extra_devices ;
516
+ ++ sbi -> devs -> extra_devices ;
517
517
break ;
518
518
#ifdef CONFIG_EROFS_FS_ONDEMAND
519
519
case Opt_fsid :
520
- kfree (ctx -> fsid );
521
- ctx -> fsid = kstrdup (param -> string , GFP_KERNEL );
522
- if (!ctx -> fsid )
520
+ kfree (sbi -> fsid );
521
+ sbi -> fsid = kstrdup (param -> string , GFP_KERNEL );
522
+ if (!sbi -> fsid )
523
523
return - ENOMEM ;
524
524
break ;
525
525
case Opt_domain_id :
526
- kfree (ctx -> domain_id );
527
- ctx -> domain_id = kstrdup (param -> string , GFP_KERNEL );
528
- if (!ctx -> domain_id )
526
+ kfree (sbi -> domain_id );
527
+ sbi -> domain_id = kstrdup (param -> string , GFP_KERNEL );
528
+ if (!sbi -> domain_id )
529
529
return - ENOMEM ;
530
530
break ;
531
531
#else
@@ -582,28 +582,14 @@ static const struct export_operations erofs_export_ops = {
582
582
static int erofs_fc_fill_super (struct super_block * sb , struct fs_context * fc )
583
583
{
584
584
struct inode * inode ;
585
- struct erofs_sb_info * sbi ;
586
- struct erofs_fs_context * ctx = fc -> fs_private ;
585
+ struct erofs_sb_info * sbi = EROFS_SB (sb );
587
586
int err ;
588
587
589
588
sb -> s_magic = EROFS_SUPER_MAGIC ;
590
589
sb -> s_flags |= SB_RDONLY | SB_NOATIME ;
591
590
sb -> s_maxbytes = MAX_LFS_FILESIZE ;
592
591
sb -> s_op = & erofs_sops ;
593
592
594
- sbi = kzalloc (sizeof (* sbi ), GFP_KERNEL );
595
- if (!sbi )
596
- return - ENOMEM ;
597
-
598
- sb -> s_fs_info = sbi ;
599
- sbi -> opt = ctx -> opt ;
600
- sbi -> devs = ctx -> devs ;
601
- ctx -> devs = NULL ;
602
- sbi -> fsid = ctx -> fsid ;
603
- ctx -> fsid = NULL ;
604
- sbi -> domain_id = ctx -> domain_id ;
605
- ctx -> domain_id = NULL ;
606
-
607
593
sbi -> blkszbits = PAGE_SHIFT ;
608
594
if (erofs_is_fscache_mode (sb )) {
609
595
sb -> s_blocksize = PAGE_SIZE ;
@@ -707,9 +693,9 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
707
693
708
694
static int erofs_fc_get_tree (struct fs_context * fc )
709
695
{
710
- struct erofs_fs_context * ctx = fc -> fs_private ;
696
+ struct erofs_sb_info * sbi = fc -> s_fs_info ;
711
697
712
- if (IS_ENABLED (CONFIG_EROFS_FS_ONDEMAND ) && ctx -> fsid )
698
+ if (IS_ENABLED (CONFIG_EROFS_FS_ONDEMAND ) && sbi -> fsid )
713
699
return get_tree_nodev (fc , erofs_fc_fill_super );
714
700
715
701
return get_tree_bdev (fc , erofs_fc_fill_super );
@@ -719,19 +705,19 @@ static int erofs_fc_reconfigure(struct fs_context *fc)
719
705
{
720
706
struct super_block * sb = fc -> root -> d_sb ;
721
707
struct erofs_sb_info * sbi = EROFS_SB (sb );
722
- struct erofs_fs_context * ctx = fc -> fs_private ;
708
+ struct erofs_sb_info * new_sbi = fc -> s_fs_info ;
723
709
724
710
DBG_BUGON (!sb_rdonly (sb ));
725
711
726
- if (ctx -> fsid || ctx -> domain_id )
712
+ if (new_sbi -> fsid || new_sbi -> domain_id )
727
713
erofs_info (sb , "ignoring reconfiguration for fsid|domain_id." );
728
714
729
- if (test_opt (& ctx -> opt , POSIX_ACL ))
715
+ if (test_opt (& new_sbi -> opt , POSIX_ACL ))
730
716
fc -> sb_flags |= SB_POSIXACL ;
731
717
else
732
718
fc -> sb_flags &= ~SB_POSIXACL ;
733
719
734
- sbi -> opt = ctx -> opt ;
720
+ sbi -> opt = new_sbi -> opt ;
735
721
736
722
fc -> sb_flags |= SB_RDONLY ;
737
723
return 0 ;
@@ -762,12 +748,15 @@ static void erofs_free_dev_context(struct erofs_dev_context *devs)
762
748
763
749
static void erofs_fc_free (struct fs_context * fc )
764
750
{
765
- struct erofs_fs_context * ctx = fc -> fs_private ;
751
+ struct erofs_sb_info * sbi = fc -> s_fs_info ;
752
+
753
+ if (!sbi )
754
+ return ;
766
755
767
- erofs_free_dev_context (ctx -> devs );
768
- kfree (ctx -> fsid );
769
- kfree (ctx -> domain_id );
770
- kfree (ctx );
756
+ erofs_free_dev_context (sbi -> devs );
757
+ kfree (sbi -> fsid );
758
+ kfree (sbi -> domain_id );
759
+ kfree (sbi );
771
760
}
772
761
773
762
static const struct fs_context_operations erofs_context_ops = {
@@ -779,21 +768,22 @@ static const struct fs_context_operations erofs_context_ops = {
779
768
780
769
static int erofs_init_fs_context (struct fs_context * fc )
781
770
{
782
- struct erofs_fs_context * ctx ;
771
+ struct erofs_sb_info * sbi ;
783
772
784
- ctx = kzalloc (sizeof (* ctx ), GFP_KERNEL );
785
- if (!ctx )
773
+ sbi = kzalloc (sizeof (* sbi ), GFP_KERNEL );
774
+ if (!sbi )
786
775
return - ENOMEM ;
787
- ctx -> devs = kzalloc (sizeof (struct erofs_dev_context ), GFP_KERNEL );
788
- if (!ctx -> devs ) {
789
- kfree (ctx );
776
+
777
+ sbi -> devs = kzalloc (sizeof (struct erofs_dev_context ), GFP_KERNEL );
778
+ if (!sbi -> devs ) {
779
+ kfree (sbi );
790
780
return - ENOMEM ;
791
781
}
792
- fc -> fs_private = ctx ;
782
+ fc -> s_fs_info = sbi ;
793
783
794
- idr_init (& ctx -> devs -> tree );
795
- init_rwsem (& ctx -> devs -> rwsem );
796
- erofs_default_options (ctx );
784
+ idr_init (& sbi -> devs -> tree );
785
+ init_rwsem (& sbi -> devs -> rwsem );
786
+ erofs_default_options (sbi );
797
787
fc -> ops = & erofs_context_ops ;
798
788
return 0 ;
799
789
}
0 commit comments