Skip to content

Commit b947cc5

Browse files
committed
Merge tag 'erofs-for-6.9-rc7-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs
Pull erofs fixes from Gao Xiang: "Three fixes related to EROFS fscache mode. The most important two patches fix calling kill_block_super() in bdev-based mode instead of kill_anon_super(). The remaining patch is an informative one. Summary: - Better error message when prepare_ondemand_read failed - Fix unmount of bdev-based mode if CONFIG_EROFS_FS_ONDEMAND is on" * tag 'erofs-for-6.9-rc7-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs: erofs: reliably distinguish block based and fscache mode erofs: get rid of erofs_fs_context erofs: modify the error message when prepare_ondemand_read failed
2 parents 5af385f + 7af2ae1 commit b947cc5

File tree

3 files changed

+56
-77
lines changed

3 files changed

+56
-77
lines changed

fs/erofs/fscache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static int erofs_fscache_read_io_async(struct fscache_cookie *cookie,
151151
if (WARN_ON(len == 0))
152152
source = NETFS_INVALID_READ;
153153
if (source != NETFS_READ_FROM_CACHE) {
154-
erofs_err(NULL, "prepare_read failed (source %d)", source);
154+
erofs_err(NULL, "prepare_ondemand_read failed (source %d)", source);
155155
return -EIO;
156156
}
157157

fs/erofs/internal.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,6 @@ struct erofs_dev_context {
8484
bool flatdev;
8585
};
8686

87-
struct erofs_fs_context {
88-
struct erofs_mount_opts opt;
89-
struct erofs_dev_context *devs;
90-
char *fsid;
91-
char *domain_id;
92-
};
93-
9487
/* all filesystem-wide lz4 configurations */
9588
struct erofs_sb_lz4_info {
9689
/* # of pages needed for EROFS lz4 rolling decompression */

fs/erofs/super.c

Lines changed: 55 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -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[] = {
426426
static 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)
450450
static 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 = {
581581
static 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

707693
static 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

762748
static 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;
765751

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);
770759
}
771760

772761
static const struct fs_context_operations erofs_context_ops = {
@@ -778,38 +767,35 @@ static const struct fs_context_operations erofs_context_ops = {
778767

779768
static 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
}
799789

800790
static void erofs_kill_sb(struct super_block *sb)
801791
{
802-
struct erofs_sb_info *sbi;
792+
struct erofs_sb_info *sbi = EROFS_SB(sb);
803793

804-
if (erofs_is_fscache_mode(sb))
794+
if (IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND) && sbi->fsid)
805795
kill_anon_super(sb);
806796
else
807797
kill_block_super(sb);
808798

809-
sbi = EROFS_SB(sb);
810-
if (!sbi)
811-
return;
812-
813799
erofs_free_dev_context(sbi->devs);
814800
fs_put_dax(sbi->dax_dev, NULL);
815801
erofs_fscache_unregister_fs(sb);

0 commit comments

Comments
 (0)