GNU Linux-libre 5.13.14-gnu1
[releases.git] / fs / erofs / super.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (C) 2017-2018 HUAWEI, Inc.
4  *             https://www.huawei.com/
5  * Created by Gao Xiang <gaoxiang25@huawei.com>
6  */
7 #include <linux/module.h>
8 #include <linux/buffer_head.h>
9 #include <linux/statfs.h>
10 #include <linux/parser.h>
11 #include <linux/seq_file.h>
12 #include <linux/crc32c.h>
13 #include <linux/fs_context.h>
14 #include <linux/fs_parser.h>
15 #include "xattr.h"
16
17 #define CREATE_TRACE_POINTS
18 #include <trace/events/erofs.h>
19
20 static struct kmem_cache *erofs_inode_cachep __read_mostly;
21
22 void _erofs_err(struct super_block *sb, const char *function,
23                 const char *fmt, ...)
24 {
25         struct va_format vaf;
26         va_list args;
27
28         va_start(args, fmt);
29
30         vaf.fmt = fmt;
31         vaf.va = &args;
32
33         pr_err("(device %s): %s: %pV", sb->s_id, function, &vaf);
34         va_end(args);
35 }
36
37 void _erofs_info(struct super_block *sb, const char *function,
38                  const char *fmt, ...)
39 {
40         struct va_format vaf;
41         va_list args;
42
43         va_start(args, fmt);
44
45         vaf.fmt = fmt;
46         vaf.va = &args;
47
48         pr_info("(device %s): %pV", sb->s_id, &vaf);
49         va_end(args);
50 }
51
52 static int erofs_superblock_csum_verify(struct super_block *sb, void *sbdata)
53 {
54         struct erofs_super_block *dsb;
55         u32 expected_crc, crc;
56
57         dsb = kmemdup(sbdata + EROFS_SUPER_OFFSET,
58                       EROFS_BLKSIZ - EROFS_SUPER_OFFSET, GFP_KERNEL);
59         if (!dsb)
60                 return -ENOMEM;
61
62         expected_crc = le32_to_cpu(dsb->checksum);
63         dsb->checksum = 0;
64         /* to allow for x86 boot sectors and other oddities. */
65         crc = crc32c(~0, dsb, EROFS_BLKSIZ - EROFS_SUPER_OFFSET);
66         kfree(dsb);
67
68         if (crc != expected_crc) {
69                 erofs_err(sb, "invalid checksum 0x%08x, 0x%08x expected",
70                           crc, expected_crc);
71                 return -EBADMSG;
72         }
73         return 0;
74 }
75
76 static void erofs_inode_init_once(void *ptr)
77 {
78         struct erofs_inode *vi = ptr;
79
80         inode_init_once(&vi->vfs_inode);
81 }
82
83 static struct inode *erofs_alloc_inode(struct super_block *sb)
84 {
85         struct erofs_inode *vi =
86                 kmem_cache_alloc(erofs_inode_cachep, GFP_KERNEL);
87
88         if (!vi)
89                 return NULL;
90
91         /* zero out everything except vfs_inode */
92         memset(vi, 0, offsetof(struct erofs_inode, vfs_inode));
93         return &vi->vfs_inode;
94 }
95
96 static void erofs_free_inode(struct inode *inode)
97 {
98         struct erofs_inode *vi = EROFS_I(inode);
99
100         /* be careful of RCU symlink path */
101         if (inode->i_op == &erofs_fast_symlink_iops)
102                 kfree(inode->i_link);
103         kfree(vi->xattr_shared_xattrs);
104
105         kmem_cache_free(erofs_inode_cachep, vi);
106 }
107
108 static bool check_layout_compatibility(struct super_block *sb,
109                                        struct erofs_super_block *dsb)
110 {
111         const unsigned int feature = le32_to_cpu(dsb->feature_incompat);
112
113         EROFS_SB(sb)->feature_incompat = feature;
114
115         /* check if current kernel meets all mandatory requirements */
116         if (feature & (~EROFS_ALL_FEATURE_INCOMPAT)) {
117                 erofs_err(sb,
118                           "unidentified incompatible feature %x, please upgrade kernel version",
119                            feature & ~EROFS_ALL_FEATURE_INCOMPAT);
120                 return false;
121         }
122         return true;
123 }
124
125 #ifdef CONFIG_EROFS_FS_ZIP
126 /* read variable-sized metadata, offset will be aligned by 4-byte */
127 static void *erofs_read_metadata(struct super_block *sb, struct page **pagep,
128                                  erofs_off_t *offset, int *lengthp)
129 {
130         struct page *page = *pagep;
131         u8 *buffer, *ptr;
132         int len, i, cnt;
133         erofs_blk_t blk;
134
135         *offset = round_up(*offset, 4);
136         blk = erofs_blknr(*offset);
137
138         if (!page || page->index != blk) {
139                 if (page) {
140                         unlock_page(page);
141                         put_page(page);
142                 }
143                 page = erofs_get_meta_page(sb, blk);
144                 if (IS_ERR(page))
145                         goto err_nullpage;
146         }
147
148         ptr = kmap(page);
149         len = le16_to_cpu(*(__le16 *)&ptr[erofs_blkoff(*offset)]);
150         if (!len)
151                 len = U16_MAX + 1;
152         buffer = kmalloc(len, GFP_KERNEL);
153         if (!buffer) {
154                 buffer = ERR_PTR(-ENOMEM);
155                 goto out;
156         }
157         *offset += sizeof(__le16);
158         *lengthp = len;
159
160         for (i = 0; i < len; i += cnt) {
161                 cnt = min(EROFS_BLKSIZ - (int)erofs_blkoff(*offset), len - i);
162                 blk = erofs_blknr(*offset);
163
164                 if (!page || page->index != blk) {
165                         if (page) {
166                                 kunmap(page);
167                                 unlock_page(page);
168                                 put_page(page);
169                         }
170                         page = erofs_get_meta_page(sb, blk);
171                         if (IS_ERR(page)) {
172                                 kfree(buffer);
173                                 goto err_nullpage;
174                         }
175                         ptr = kmap(page);
176                 }
177                 memcpy(buffer + i, ptr + erofs_blkoff(*offset), cnt);
178                 *offset += cnt;
179         }
180 out:
181         kunmap(page);
182         *pagep = page;
183         return buffer;
184 err_nullpage:
185         *pagep = NULL;
186         return page;
187 }
188
189 static int erofs_load_compr_cfgs(struct super_block *sb,
190                                  struct erofs_super_block *dsb)
191 {
192         struct erofs_sb_info *sbi;
193         struct page *page;
194         unsigned int algs, alg;
195         erofs_off_t offset;
196         int size, ret;
197
198         sbi = EROFS_SB(sb);
199         sbi->available_compr_algs = le16_to_cpu(dsb->u1.available_compr_algs);
200
201         if (sbi->available_compr_algs & ~Z_EROFS_ALL_COMPR_ALGS) {
202                 erofs_err(sb, "try to load compressed fs with unsupported algorithms %x",
203                           sbi->available_compr_algs & ~Z_EROFS_ALL_COMPR_ALGS);
204                 return -EINVAL;
205         }
206
207         offset = EROFS_SUPER_OFFSET + sbi->sb_size;
208         page = NULL;
209         alg = 0;
210         ret = 0;
211
212         for (algs = sbi->available_compr_algs; algs; algs >>= 1, ++alg) {
213                 void *data;
214
215                 if (!(algs & 1))
216                         continue;
217
218                 data = erofs_read_metadata(sb, &page, &offset, &size);
219                 if (IS_ERR(data)) {
220                         ret = PTR_ERR(data);
221                         goto err;
222                 }
223
224                 switch (alg) {
225                 case Z_EROFS_COMPRESSION_LZ4:
226                         ret = z_erofs_load_lz4_config(sb, dsb, data, size);
227                         break;
228                 default:
229                         DBG_BUGON(1);
230                         ret = -EFAULT;
231                 }
232                 kfree(data);
233                 if (ret)
234                         goto err;
235         }
236 err:
237         if (page) {
238                 unlock_page(page);
239                 put_page(page);
240         }
241         return ret;
242 }
243 #else
244 static int erofs_load_compr_cfgs(struct super_block *sb,
245                                  struct erofs_super_block *dsb)
246 {
247         if (dsb->u1.available_compr_algs) {
248                 erofs_err(sb, "try to load compressed fs when compression is disabled");
249                 return -EINVAL;
250         }
251         return 0;
252 }
253 #endif
254
255 static int erofs_read_superblock(struct super_block *sb)
256 {
257         struct erofs_sb_info *sbi;
258         struct page *page;
259         struct erofs_super_block *dsb;
260         unsigned int blkszbits;
261         void *data;
262         int ret;
263
264         page = read_mapping_page(sb->s_bdev->bd_inode->i_mapping, 0, NULL);
265         if (IS_ERR(page)) {
266                 erofs_err(sb, "cannot read erofs superblock");
267                 return PTR_ERR(page);
268         }
269
270         sbi = EROFS_SB(sb);
271
272         data = kmap(page);
273         dsb = (struct erofs_super_block *)(data + EROFS_SUPER_OFFSET);
274
275         ret = -EINVAL;
276         if (le32_to_cpu(dsb->magic) != EROFS_SUPER_MAGIC_V1) {
277                 erofs_err(sb, "cannot find valid erofs superblock");
278                 goto out;
279         }
280
281         sbi->feature_compat = le32_to_cpu(dsb->feature_compat);
282         if (erofs_sb_has_sb_chksum(sbi)) {
283                 ret = erofs_superblock_csum_verify(sb, data);
284                 if (ret)
285                         goto out;
286         }
287
288         ret = -EINVAL;
289         blkszbits = dsb->blkszbits;
290         /* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */
291         if (blkszbits != LOG_BLOCK_SIZE) {
292                 erofs_err(sb, "blkszbits %u isn't supported on this platform",
293                           blkszbits);
294                 goto out;
295         }
296
297         if (!check_layout_compatibility(sb, dsb))
298                 goto out;
299
300         sbi->sb_size = 128 + dsb->sb_extslots * EROFS_SB_EXTSLOT_SIZE;
301         if (sbi->sb_size > EROFS_BLKSIZ) {
302                 erofs_err(sb, "invalid sb_extslots %u (more than a fs block)",
303                           sbi->sb_size);
304                 goto out;
305         }
306         sbi->blocks = le32_to_cpu(dsb->blocks);
307         sbi->meta_blkaddr = le32_to_cpu(dsb->meta_blkaddr);
308 #ifdef CONFIG_EROFS_FS_XATTR
309         sbi->xattr_blkaddr = le32_to_cpu(dsb->xattr_blkaddr);
310 #endif
311         sbi->islotbits = ilog2(sizeof(struct erofs_inode_compact));
312         sbi->root_nid = le16_to_cpu(dsb->root_nid);
313         sbi->inos = le64_to_cpu(dsb->inos);
314
315         sbi->build_time = le64_to_cpu(dsb->build_time);
316         sbi->build_time_nsec = le32_to_cpu(dsb->build_time_nsec);
317
318         memcpy(&sb->s_uuid, dsb->uuid, sizeof(dsb->uuid));
319
320         ret = strscpy(sbi->volume_name, dsb->volume_name,
321                       sizeof(dsb->volume_name));
322         if (ret < 0) {  /* -E2BIG */
323                 erofs_err(sb, "bad volume name without NIL terminator");
324                 ret = -EFSCORRUPTED;
325                 goto out;
326         }
327
328         /* parse on-disk compression configurations */
329         if (erofs_sb_has_compr_cfgs(sbi))
330                 ret = erofs_load_compr_cfgs(sb, dsb);
331         else
332                 ret = z_erofs_load_lz4_config(sb, dsb, NULL, 0);
333 out:
334         kunmap(page);
335         put_page(page);
336         return ret;
337 }
338
339 /* set up default EROFS parameters */
340 static void erofs_default_options(struct erofs_fs_context *ctx)
341 {
342 #ifdef CONFIG_EROFS_FS_ZIP
343         ctx->cache_strategy = EROFS_ZIP_CACHE_READAROUND;
344         ctx->max_sync_decompress_pages = 3;
345         ctx->readahead_sync_decompress = false;
346 #endif
347 #ifdef CONFIG_EROFS_FS_XATTR
348         set_opt(ctx, XATTR_USER);
349 #endif
350 #ifdef CONFIG_EROFS_FS_POSIX_ACL
351         set_opt(ctx, POSIX_ACL);
352 #endif
353 }
354
355 enum {
356         Opt_user_xattr,
357         Opt_acl,
358         Opt_cache_strategy,
359         Opt_err
360 };
361
362 static const struct constant_table erofs_param_cache_strategy[] = {
363         {"disabled",    EROFS_ZIP_CACHE_DISABLED},
364         {"readahead",   EROFS_ZIP_CACHE_READAHEAD},
365         {"readaround",  EROFS_ZIP_CACHE_READAROUND},
366         {}
367 };
368
369 static const struct fs_parameter_spec erofs_fs_parameters[] = {
370         fsparam_flag_no("user_xattr",   Opt_user_xattr),
371         fsparam_flag_no("acl",          Opt_acl),
372         fsparam_enum("cache_strategy",  Opt_cache_strategy,
373                      erofs_param_cache_strategy),
374         {}
375 };
376
377 static int erofs_fc_parse_param(struct fs_context *fc,
378                                 struct fs_parameter *param)
379 {
380         struct erofs_fs_context *ctx __maybe_unused = fc->fs_private;
381         struct fs_parse_result result;
382         int opt;
383
384         opt = fs_parse(fc, erofs_fs_parameters, param, &result);
385         if (opt < 0)
386                 return opt;
387
388         switch (opt) {
389         case Opt_user_xattr:
390 #ifdef CONFIG_EROFS_FS_XATTR
391                 if (result.boolean)
392                         set_opt(ctx, XATTR_USER);
393                 else
394                         clear_opt(ctx, XATTR_USER);
395 #else
396                 errorfc(fc, "{,no}user_xattr options not supported");
397 #endif
398                 break;
399         case Opt_acl:
400 #ifdef CONFIG_EROFS_FS_POSIX_ACL
401                 if (result.boolean)
402                         set_opt(ctx, POSIX_ACL);
403                 else
404                         clear_opt(ctx, POSIX_ACL);
405 #else
406                 errorfc(fc, "{,no}acl options not supported");
407 #endif
408                 break;
409         case Opt_cache_strategy:
410 #ifdef CONFIG_EROFS_FS_ZIP
411                 ctx->cache_strategy = result.uint_32;
412 #else
413                 errorfc(fc, "compression not supported, cache_strategy ignored");
414 #endif
415                 break;
416         default:
417                 return -ENOPARAM;
418         }
419         return 0;
420 }
421
422 #ifdef CONFIG_EROFS_FS_ZIP
423 static const struct address_space_operations managed_cache_aops;
424
425 static int erofs_managed_cache_releasepage(struct page *page, gfp_t gfp_mask)
426 {
427         int ret = 1;    /* 0 - busy */
428         struct address_space *const mapping = page->mapping;
429
430         DBG_BUGON(!PageLocked(page));
431         DBG_BUGON(mapping->a_ops != &managed_cache_aops);
432
433         if (PagePrivate(page))
434                 ret = erofs_try_to_free_cached_page(mapping, page);
435
436         return ret;
437 }
438
439 static void erofs_managed_cache_invalidatepage(struct page *page,
440                                                unsigned int offset,
441                                                unsigned int length)
442 {
443         const unsigned int stop = length + offset;
444
445         DBG_BUGON(!PageLocked(page));
446
447         /* Check for potential overflow in debug mode */
448         DBG_BUGON(stop > PAGE_SIZE || stop < length);
449
450         if (offset == 0 && stop == PAGE_SIZE)
451                 while (!erofs_managed_cache_releasepage(page, GFP_NOFS))
452                         cond_resched();
453 }
454
455 static const struct address_space_operations managed_cache_aops = {
456         .releasepage = erofs_managed_cache_releasepage,
457         .invalidatepage = erofs_managed_cache_invalidatepage,
458 };
459
460 static int erofs_init_managed_cache(struct super_block *sb)
461 {
462         struct erofs_sb_info *const sbi = EROFS_SB(sb);
463         struct inode *const inode = new_inode(sb);
464
465         if (!inode)
466                 return -ENOMEM;
467
468         set_nlink(inode, 1);
469         inode->i_size = OFFSET_MAX;
470
471         inode->i_mapping->a_ops = &managed_cache_aops;
472         mapping_set_gfp_mask(inode->i_mapping,
473                              GFP_NOFS | __GFP_HIGHMEM | __GFP_MOVABLE);
474         sbi->managed_cache = inode;
475         return 0;
476 }
477 #else
478 static int erofs_init_managed_cache(struct super_block *sb) { return 0; }
479 #endif
480
481 static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
482 {
483         struct inode *inode;
484         struct erofs_sb_info *sbi;
485         struct erofs_fs_context *ctx = fc->fs_private;
486         int err;
487
488         sb->s_magic = EROFS_SUPER_MAGIC;
489
490         if (!sb_set_blocksize(sb, EROFS_BLKSIZ)) {
491                 erofs_err(sb, "failed to set erofs blksize");
492                 return -EINVAL;
493         }
494
495         sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
496         if (!sbi)
497                 return -ENOMEM;
498
499         sb->s_fs_info = sbi;
500         err = erofs_read_superblock(sb);
501         if (err)
502                 return err;
503
504         sb->s_flags |= SB_RDONLY | SB_NOATIME;
505         sb->s_maxbytes = MAX_LFS_FILESIZE;
506         sb->s_time_gran = 1;
507
508         sb->s_op = &erofs_sops;
509         sb->s_xattr = erofs_xattr_handlers;
510
511         if (test_opt(ctx, POSIX_ACL))
512                 sb->s_flags |= SB_POSIXACL;
513         else
514                 sb->s_flags &= ~SB_POSIXACL;
515
516         sbi->ctx = *ctx;
517
518 #ifdef CONFIG_EROFS_FS_ZIP
519         xa_init(&sbi->managed_pslots);
520 #endif
521
522         /* get the root inode */
523         inode = erofs_iget(sb, ROOT_NID(sbi), true);
524         if (IS_ERR(inode))
525                 return PTR_ERR(inode);
526
527         if (!S_ISDIR(inode->i_mode)) {
528                 erofs_err(sb, "rootino(nid %llu) is not a directory(i_mode %o)",
529                           ROOT_NID(sbi), inode->i_mode);
530                 iput(inode);
531                 return -EINVAL;
532         }
533
534         sb->s_root = d_make_root(inode);
535         if (!sb->s_root)
536                 return -ENOMEM;
537
538         erofs_shrinker_register(sb);
539         /* sb->s_umount is already locked, SB_ACTIVE and SB_BORN are not set */
540         err = erofs_init_managed_cache(sb);
541         if (err)
542                 return err;
543
544         erofs_info(sb, "mounted with root inode @ nid %llu.", ROOT_NID(sbi));
545         return 0;
546 }
547
548 static int erofs_fc_get_tree(struct fs_context *fc)
549 {
550         return get_tree_bdev(fc, erofs_fc_fill_super);
551 }
552
553 static int erofs_fc_reconfigure(struct fs_context *fc)
554 {
555         struct super_block *sb = fc->root->d_sb;
556         struct erofs_sb_info *sbi = EROFS_SB(sb);
557         struct erofs_fs_context *ctx = fc->fs_private;
558
559         DBG_BUGON(!sb_rdonly(sb));
560
561         if (test_opt(ctx, POSIX_ACL))
562                 fc->sb_flags |= SB_POSIXACL;
563         else
564                 fc->sb_flags &= ~SB_POSIXACL;
565
566         sbi->ctx = *ctx;
567
568         fc->sb_flags |= SB_RDONLY;
569         return 0;
570 }
571
572 static void erofs_fc_free(struct fs_context *fc)
573 {
574         kfree(fc->fs_private);
575 }
576
577 static const struct fs_context_operations erofs_context_ops = {
578         .parse_param    = erofs_fc_parse_param,
579         .get_tree       = erofs_fc_get_tree,
580         .reconfigure    = erofs_fc_reconfigure,
581         .free           = erofs_fc_free,
582 };
583
584 static int erofs_init_fs_context(struct fs_context *fc)
585 {
586         fc->fs_private = kzalloc(sizeof(struct erofs_fs_context), GFP_KERNEL);
587         if (!fc->fs_private)
588                 return -ENOMEM;
589
590         /* set default mount options */
591         erofs_default_options(fc->fs_private);
592
593         fc->ops = &erofs_context_ops;
594
595         return 0;
596 }
597
598 /*
599  * could be triggered after deactivate_locked_super()
600  * is called, thus including umount and failed to initialize.
601  */
602 static void erofs_kill_sb(struct super_block *sb)
603 {
604         struct erofs_sb_info *sbi;
605
606         WARN_ON(sb->s_magic != EROFS_SUPER_MAGIC);
607
608         kill_block_super(sb);
609
610         sbi = EROFS_SB(sb);
611         if (!sbi)
612                 return;
613         kfree(sbi);
614         sb->s_fs_info = NULL;
615 }
616
617 /* called when ->s_root is non-NULL */
618 static void erofs_put_super(struct super_block *sb)
619 {
620         struct erofs_sb_info *const sbi = EROFS_SB(sb);
621
622         DBG_BUGON(!sbi);
623
624         erofs_shrinker_unregister(sb);
625 #ifdef CONFIG_EROFS_FS_ZIP
626         iput(sbi->managed_cache);
627         sbi->managed_cache = NULL;
628 #endif
629 }
630
631 static struct file_system_type erofs_fs_type = {
632         .owner          = THIS_MODULE,
633         .name           = "erofs",
634         .init_fs_context = erofs_init_fs_context,
635         .kill_sb        = erofs_kill_sb,
636         .fs_flags       = FS_REQUIRES_DEV,
637 };
638 MODULE_ALIAS_FS("erofs");
639
640 static int __init erofs_module_init(void)
641 {
642         int err;
643
644         erofs_check_ondisk_layout_definitions();
645
646         erofs_inode_cachep = kmem_cache_create("erofs_inode",
647                                                sizeof(struct erofs_inode), 0,
648                                                SLAB_RECLAIM_ACCOUNT,
649                                                erofs_inode_init_once);
650         if (!erofs_inode_cachep) {
651                 err = -ENOMEM;
652                 goto icache_err;
653         }
654
655         err = erofs_init_shrinker();
656         if (err)
657                 goto shrinker_err;
658
659         erofs_pcpubuf_init();
660         err = z_erofs_init_zip_subsystem();
661         if (err)
662                 goto zip_err;
663
664         err = register_filesystem(&erofs_fs_type);
665         if (err)
666                 goto fs_err;
667
668         return 0;
669
670 fs_err:
671         z_erofs_exit_zip_subsystem();
672 zip_err:
673         erofs_exit_shrinker();
674 shrinker_err:
675         kmem_cache_destroy(erofs_inode_cachep);
676 icache_err:
677         return err;
678 }
679
680 static void __exit erofs_module_exit(void)
681 {
682         unregister_filesystem(&erofs_fs_type);
683         z_erofs_exit_zip_subsystem();
684         erofs_exit_shrinker();
685
686         /* Ensure all RCU free inodes are safe before cache is destroyed. */
687         rcu_barrier();
688         kmem_cache_destroy(erofs_inode_cachep);
689         erofs_pcpubuf_exit();
690 }
691
692 /* get filesystem statistics */
693 static int erofs_statfs(struct dentry *dentry, struct kstatfs *buf)
694 {
695         struct super_block *sb = dentry->d_sb;
696         struct erofs_sb_info *sbi = EROFS_SB(sb);
697         u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
698
699         buf->f_type = sb->s_magic;
700         buf->f_bsize = EROFS_BLKSIZ;
701         buf->f_blocks = sbi->blocks;
702         buf->f_bfree = buf->f_bavail = 0;
703
704         buf->f_files = ULLONG_MAX;
705         buf->f_ffree = ULLONG_MAX - sbi->inos;
706
707         buf->f_namelen = EROFS_NAME_LEN;
708
709         buf->f_fsid    = u64_to_fsid(id);
710         return 0;
711 }
712
713 static int erofs_show_options(struct seq_file *seq, struct dentry *root)
714 {
715         struct erofs_sb_info *sbi __maybe_unused = EROFS_SB(root->d_sb);
716         struct erofs_fs_context *ctx __maybe_unused = &sbi->ctx;
717
718 #ifdef CONFIG_EROFS_FS_XATTR
719         if (test_opt(ctx, XATTR_USER))
720                 seq_puts(seq, ",user_xattr");
721         else
722                 seq_puts(seq, ",nouser_xattr");
723 #endif
724 #ifdef CONFIG_EROFS_FS_POSIX_ACL
725         if (test_opt(ctx, POSIX_ACL))
726                 seq_puts(seq, ",acl");
727         else
728                 seq_puts(seq, ",noacl");
729 #endif
730 #ifdef CONFIG_EROFS_FS_ZIP
731         if (ctx->cache_strategy == EROFS_ZIP_CACHE_DISABLED)
732                 seq_puts(seq, ",cache_strategy=disabled");
733         else if (ctx->cache_strategy == EROFS_ZIP_CACHE_READAHEAD)
734                 seq_puts(seq, ",cache_strategy=readahead");
735         else if (ctx->cache_strategy == EROFS_ZIP_CACHE_READAROUND)
736                 seq_puts(seq, ",cache_strategy=readaround");
737 #endif
738         return 0;
739 }
740
741 const struct super_operations erofs_sops = {
742         .put_super = erofs_put_super,
743         .alloc_inode = erofs_alloc_inode,
744         .free_inode = erofs_free_inode,
745         .statfs = erofs_statfs,
746         .show_options = erofs_show_options,
747 };
748
749 module_init(erofs_module_init);
750 module_exit(erofs_module_exit);
751
752 MODULE_DESCRIPTION("Enhanced ROM File System");
753 MODULE_AUTHOR("Gao Xiang, Chao Yu, Miao Xie, CONSUMER BG, HUAWEI Inc.");
754 MODULE_LICENSE("GPL");
755