diff options
Diffstat (limited to 'fs/ubifs/super.c')
-rw-r--r-- | fs/ubifs/super.c | 383 |
1 files changed, 243 insertions, 140 deletions
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index d80b2aef42b6..1182b66a5491 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
@@ -34,6 +34,8 @@ | |||
34 | #include <linux/parser.h> | 34 | #include <linux/parser.h> |
35 | #include <linux/seq_file.h> | 35 | #include <linux/seq_file.h> |
36 | #include <linux/mount.h> | 36 | #include <linux/mount.h> |
37 | #include <linux/math64.h> | ||
38 | #include <linux/writeback.h> | ||
37 | #include "ubifs.h" | 39 | #include "ubifs.h" |
38 | 40 | ||
39 | /* | 41 | /* |
@@ -395,6 +397,7 @@ static int ubifs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
395 | buf->f_namelen = UBIFS_MAX_NLEN; | 397 | buf->f_namelen = UBIFS_MAX_NLEN; |
396 | buf->f_fsid.val[0] = le32_to_cpu(uuid[0]) ^ le32_to_cpu(uuid[2]); | 398 | buf->f_fsid.val[0] = le32_to_cpu(uuid[0]) ^ le32_to_cpu(uuid[2]); |
397 | buf->f_fsid.val[1] = le32_to_cpu(uuid[1]) ^ le32_to_cpu(uuid[3]); | 399 | buf->f_fsid.val[1] = le32_to_cpu(uuid[1]) ^ le32_to_cpu(uuid[3]); |
400 | ubifs_assert(buf->f_bfree <= c->block_cnt); | ||
398 | return 0; | 401 | return 0; |
399 | } | 402 | } |
400 | 403 | ||
@@ -417,39 +420,62 @@ static int ubifs_show_options(struct seq_file *s, struct vfsmount *mnt) | |||
417 | else if (c->mount_opts.chk_data_crc == 1) | 420 | else if (c->mount_opts.chk_data_crc == 1) |
418 | seq_printf(s, ",no_chk_data_crc"); | 421 | seq_printf(s, ",no_chk_data_crc"); |
419 | 422 | ||
423 | if (c->mount_opts.override_compr) { | ||
424 | seq_printf(s, ",compr="); | ||
425 | seq_printf(s, ubifs_compr_name(c->mount_opts.compr_type)); | ||
426 | } | ||
427 | |||
420 | return 0; | 428 | return 0; |
421 | } | 429 | } |
422 | 430 | ||
423 | static int ubifs_sync_fs(struct super_block *sb, int wait) | 431 | static int ubifs_sync_fs(struct super_block *sb, int wait) |
424 | { | 432 | { |
433 | int i, err; | ||
425 | struct ubifs_info *c = sb->s_fs_info; | 434 | struct ubifs_info *c = sb->s_fs_info; |
426 | int i, ret = 0, err; | 435 | struct writeback_control wbc = { |
427 | long long bud_bytes; | 436 | .sync_mode = WB_SYNC_ALL, |
437 | .range_start = 0, | ||
438 | .range_end = LLONG_MAX, | ||
439 | .nr_to_write = LONG_MAX, | ||
440 | }; | ||
428 | 441 | ||
429 | if (c->jheads) { | 442 | /* |
430 | for (i = 0; i < c->jhead_cnt; i++) { | 443 | * Zero @wait is just an advisory thing to help the file system shove |
431 | err = ubifs_wbuf_sync(&c->jheads[i].wbuf); | 444 | * lots of data into the queues, and there will be the second |
432 | if (err && !ret) | 445 | * '->sync_fs()' call, with non-zero @wait. |
433 | ret = err; | 446 | */ |
434 | } | 447 | if (!wait) |
448 | return 0; | ||
435 | 449 | ||
436 | /* Commit the journal unless it has too little data */ | 450 | if (sb->s_flags & MS_RDONLY) |
437 | spin_lock(&c->buds_lock); | 451 | return 0; |
438 | bud_bytes = c->bud_bytes; | 452 | |
439 | spin_unlock(&c->buds_lock); | 453 | /* |
440 | if (bud_bytes > c->leb_size) { | 454 | * VFS calls '->sync_fs()' before synchronizing all dirty inodes and |
441 | err = ubifs_run_commit(c); | 455 | * pages, so synchronize them first, then commit the journal. Strictly |
442 | if (err) | 456 | * speaking, it is not necessary to commit the journal here, |
443 | return err; | 457 | * synchronizing write-buffers would be enough. But committing makes |
444 | } | 458 | * UBIFS free space predictions much more accurate, so we want to let |
445 | } | 459 | * the user be able to get more accurate results of 'statfs()' after |
460 | * they synchronize the file system. | ||
461 | */ | ||
462 | generic_sync_sb_inodes(sb, &wbc); | ||
446 | 463 | ||
447 | /* | 464 | /* |
448 | * We ought to call sync for c->ubi but it does not have one. If it had | 465 | * Synchronize write buffers, because 'ubifs_run_commit()' does not |
449 | * it would in turn call mtd->sync, however mtd operations are | 466 | * do this if it waits for an already running commit. |
450 | * synchronous anyway, so we don't lose any sleep here. | ||
451 | */ | 467 | */ |
452 | return ret; | 468 | for (i = 0; i < c->jhead_cnt; i++) { |
469 | err = ubifs_wbuf_sync(&c->jheads[i].wbuf); | ||
470 | if (err) | ||
471 | return err; | ||
472 | } | ||
473 | |||
474 | err = ubifs_run_commit(c); | ||
475 | if (err) | ||
476 | return err; | ||
477 | |||
478 | return ubi_sync(c->vi.ubi_num); | ||
453 | } | 479 | } |
454 | 480 | ||
455 | /** | 481 | /** |
@@ -548,15 +574,8 @@ static int init_constants_early(struct ubifs_info *c) | |||
548 | c->ranges[UBIFS_IDX_NODE].max_len = INT_MAX; | 574 | c->ranges[UBIFS_IDX_NODE].max_len = INT_MAX; |
549 | 575 | ||
550 | /* | 576 | /* |
551 | * Initialize dead and dark LEB space watermarks. | 577 | * Initialize dead and dark LEB space watermarks. See gc.c for comments |
552 | * | 578 | * about these values. |
553 | * Dead space is the space which cannot be used. Its watermark is | ||
554 | * equivalent to min. I/O unit or minimum node size if it is greater | ||
555 | * then min. I/O unit. | ||
556 | * | ||
557 | * Dark space is the space which might be used, or might not, depending | ||
558 | * on which node should be written to the LEB. Its watermark is | ||
559 | * equivalent to maximum UBIFS node size. | ||
560 | */ | 579 | */ |
561 | c->dead_wm = ALIGN(MIN_WRITE_SZ, c->min_io_size); | 580 | c->dead_wm = ALIGN(MIN_WRITE_SZ, c->min_io_size); |
562 | c->dark_wm = ALIGN(UBIFS_MAX_NODE_SZ, c->min_io_size); | 581 | c->dark_wm = ALIGN(UBIFS_MAX_NODE_SZ, c->min_io_size); |
@@ -596,7 +615,7 @@ static int bud_wbuf_callback(struct ubifs_info *c, int lnum, int free, int pad) | |||
596 | } | 615 | } |
597 | 616 | ||
598 | /* | 617 | /* |
599 | * init_constants_late - initialize UBIFS constants. | 618 | * init_constants_sb - initialize UBIFS constants. |
600 | * @c: UBIFS file-system description object | 619 | * @c: UBIFS file-system description object |
601 | * | 620 | * |
602 | * This is a helper function which initializes various UBIFS constants after | 621 | * This is a helper function which initializes various UBIFS constants after |
@@ -604,10 +623,10 @@ static int bud_wbuf_callback(struct ubifs_info *c, int lnum, int free, int pad) | |||
604 | * makes sure they are all right. Returns zero in case of success and a | 623 | * makes sure they are all right. Returns zero in case of success and a |
605 | * negative error code in case of failure. | 624 | * negative error code in case of failure. |
606 | */ | 625 | */ |
607 | static int init_constants_late(struct ubifs_info *c) | 626 | static int init_constants_sb(struct ubifs_info *c) |
608 | { | 627 | { |
609 | int tmp, err; | 628 | int tmp, err; |
610 | uint64_t tmp64; | 629 | long long tmp64; |
611 | 630 | ||
612 | c->main_bytes = (long long)c->main_lebs * c->leb_size; | 631 | c->main_bytes = (long long)c->main_lebs * c->leb_size; |
613 | c->max_znode_sz = sizeof(struct ubifs_znode) + | 632 | c->max_znode_sz = sizeof(struct ubifs_znode) + |
@@ -634,9 +653,8 @@ static int init_constants_late(struct ubifs_info *c) | |||
634 | * Make sure that the log is large enough to fit reference nodes for | 653 | * Make sure that the log is large enough to fit reference nodes for |
635 | * all buds plus one reserved LEB. | 654 | * all buds plus one reserved LEB. |
636 | */ | 655 | */ |
637 | tmp64 = c->max_bud_bytes; | 656 | tmp64 = c->max_bud_bytes + c->leb_size - 1; |
638 | tmp = do_div(tmp64, c->leb_size); | 657 | c->max_bud_cnt = div_u64(tmp64, c->leb_size); |
639 | c->max_bud_cnt = tmp64 + !!tmp; | ||
640 | tmp = (c->ref_node_alsz * c->max_bud_cnt + c->leb_size - 1); | 658 | tmp = (c->ref_node_alsz * c->max_bud_cnt + c->leb_size - 1); |
641 | tmp /= c->leb_size; | 659 | tmp /= c->leb_size; |
642 | tmp += 1; | 660 | tmp += 1; |
@@ -672,7 +690,7 @@ static int init_constants_late(struct ubifs_info *c) | |||
672 | * Consequently, if the journal is too small, UBIFS will treat it as | 690 | * Consequently, if the journal is too small, UBIFS will treat it as |
673 | * always full. | 691 | * always full. |
674 | */ | 692 | */ |
675 | tmp64 = (uint64_t)(c->jhead_cnt + 1) * c->leb_size + 1; | 693 | tmp64 = (long long)(c->jhead_cnt + 1) * c->leb_size + 1; |
676 | if (c->bg_bud_bytes < tmp64) | 694 | if (c->bg_bud_bytes < tmp64) |
677 | c->bg_bud_bytes = tmp64; | 695 | c->bg_bud_bytes = tmp64; |
678 | if (c->max_bud_bytes < tmp64 + c->leb_size) | 696 | if (c->max_bud_bytes < tmp64 + c->leb_size) |
@@ -682,6 +700,21 @@ static int init_constants_late(struct ubifs_info *c) | |||
682 | if (err) | 700 | if (err) |
683 | return err; | 701 | return err; |
684 | 702 | ||
703 | return 0; | ||
704 | } | ||
705 | |||
706 | /* | ||
707 | * init_constants_master - initialize UBIFS constants. | ||
708 | * @c: UBIFS file-system description object | ||
709 | * | ||
710 | * This is a helper function which initializes various UBIFS constants after | ||
711 | * the master node has been read. It also checks various UBIFS parameters and | ||
712 | * makes sure they are all right. | ||
713 | */ | ||
714 | static void init_constants_master(struct ubifs_info *c) | ||
715 | { | ||
716 | long long tmp64; | ||
717 | |||
685 | c->min_idx_lebs = ubifs_calc_min_idx_lebs(c); | 718 | c->min_idx_lebs = ubifs_calc_min_idx_lebs(c); |
686 | 719 | ||
687 | /* | 720 | /* |
@@ -690,26 +723,25 @@ static int init_constants_late(struct ubifs_info *c) | |||
690 | * necessary to report something for the 'statfs()' call. | 723 | * necessary to report something for the 'statfs()' call. |
691 | * | 724 | * |
692 | * Subtract the LEB reserved for GC, the LEB which is reserved for | 725 | * Subtract the LEB reserved for GC, the LEB which is reserved for |
693 | * deletions, and assume only one journal head is available. | 726 | * deletions, minimum LEBs for the index, and assume only one journal |
727 | * head is available. | ||
694 | */ | 728 | */ |
695 | tmp64 = c->main_lebs - 2 - c->jhead_cnt + 1; | 729 | tmp64 = c->main_lebs - 1 - 1 - MIN_INDEX_LEBS - c->jhead_cnt + 1; |
696 | tmp64 *= (uint64_t)c->leb_size - c->leb_overhead; | 730 | tmp64 *= (long long)c->leb_size - c->leb_overhead; |
697 | tmp64 = ubifs_reported_space(c, tmp64); | 731 | tmp64 = ubifs_reported_space(c, tmp64); |
698 | c->block_cnt = tmp64 >> UBIFS_BLOCK_SHIFT; | 732 | c->block_cnt = tmp64 >> UBIFS_BLOCK_SHIFT; |
699 | |||
700 | return 0; | ||
701 | } | 733 | } |
702 | 734 | ||
703 | /** | 735 | /** |
704 | * take_gc_lnum - reserve GC LEB. | 736 | * take_gc_lnum - reserve GC LEB. |
705 | * @c: UBIFS file-system description object | 737 | * @c: UBIFS file-system description object |
706 | * | 738 | * |
707 | * This function ensures that the LEB reserved for garbage collection is | 739 | * This function ensures that the LEB reserved for garbage collection is marked |
708 | * unmapped and is marked as "taken" in lprops. We also have to set free space | 740 | * as "taken" in lprops. We also have to set free space to LEB size and dirty |
709 | * to LEB size and dirty space to zero, because lprops may contain out-of-date | 741 | * space to zero, because lprops may contain out-of-date information if the |
710 | * information if the file-system was un-mounted before it has been committed. | 742 | * file-system was un-mounted before it has been committed. This function |
711 | * This function returns zero in case of success and a negative error code in | 743 | * returns zero in case of success and a negative error code in case of |
712 | * case of failure. | 744 | * failure. |
713 | */ | 745 | */ |
714 | static int take_gc_lnum(struct ubifs_info *c) | 746 | static int take_gc_lnum(struct ubifs_info *c) |
715 | { | 747 | { |
@@ -720,10 +752,6 @@ static int take_gc_lnum(struct ubifs_info *c) | |||
720 | return -EINVAL; | 752 | return -EINVAL; |
721 | } | 753 | } |
722 | 754 | ||
723 | err = ubifs_leb_unmap(c, c->gc_lnum); | ||
724 | if (err) | ||
725 | return err; | ||
726 | |||
727 | /* And we have to tell lprops that this LEB is taken */ | 755 | /* And we have to tell lprops that this LEB is taken */ |
728 | err = ubifs_change_one_lp(c, c->gc_lnum, c->leb_size, 0, | 756 | err = ubifs_change_one_lp(c, c->gc_lnum, c->leb_size, 0, |
729 | LPROPS_TAKEN, 0, 0); | 757 | LPROPS_TAKEN, 0, 0); |
@@ -878,6 +906,7 @@ static int check_volume_empty(struct ubifs_info *c) | |||
878 | * Opt_no_bulk_read: disable bulk-reads | 906 | * Opt_no_bulk_read: disable bulk-reads |
879 | * Opt_chk_data_crc: check CRCs when reading data nodes | 907 | * Opt_chk_data_crc: check CRCs when reading data nodes |
880 | * Opt_no_chk_data_crc: do not check CRCs when reading data nodes | 908 | * Opt_no_chk_data_crc: do not check CRCs when reading data nodes |
909 | * Opt_override_compr: override default compressor | ||
881 | * Opt_err: just end of array marker | 910 | * Opt_err: just end of array marker |
882 | */ | 911 | */ |
883 | enum { | 912 | enum { |
@@ -887,6 +916,7 @@ enum { | |||
887 | Opt_no_bulk_read, | 916 | Opt_no_bulk_read, |
888 | Opt_chk_data_crc, | 917 | Opt_chk_data_crc, |
889 | Opt_no_chk_data_crc, | 918 | Opt_no_chk_data_crc, |
919 | Opt_override_compr, | ||
890 | Opt_err, | 920 | Opt_err, |
891 | }; | 921 | }; |
892 | 922 | ||
@@ -897,6 +927,7 @@ static const match_table_t tokens = { | |||
897 | {Opt_no_bulk_read, "no_bulk_read"}, | 927 | {Opt_no_bulk_read, "no_bulk_read"}, |
898 | {Opt_chk_data_crc, "chk_data_crc"}, | 928 | {Opt_chk_data_crc, "chk_data_crc"}, |
899 | {Opt_no_chk_data_crc, "no_chk_data_crc"}, | 929 | {Opt_no_chk_data_crc, "no_chk_data_crc"}, |
930 | {Opt_override_compr, "compr=%s"}, | ||
900 | {Opt_err, NULL}, | 931 | {Opt_err, NULL}, |
901 | }; | 932 | }; |
902 | 933 | ||
@@ -926,13 +957,16 @@ static int ubifs_parse_options(struct ubifs_info *c, char *options, | |||
926 | 957 | ||
927 | token = match_token(p, tokens, args); | 958 | token = match_token(p, tokens, args); |
928 | switch (token) { | 959 | switch (token) { |
960 | /* | ||
961 | * %Opt_fast_unmount and %Opt_norm_unmount options are ignored. | ||
962 | * We accepte them in order to be backware-compatible. But this | ||
963 | * should be removed at some point. | ||
964 | */ | ||
929 | case Opt_fast_unmount: | 965 | case Opt_fast_unmount: |
930 | c->mount_opts.unmount_mode = 2; | 966 | c->mount_opts.unmount_mode = 2; |
931 | c->fast_unmount = 1; | ||
932 | break; | 967 | break; |
933 | case Opt_norm_unmount: | 968 | case Opt_norm_unmount: |
934 | c->mount_opts.unmount_mode = 1; | 969 | c->mount_opts.unmount_mode = 1; |
935 | c->fast_unmount = 0; | ||
936 | break; | 970 | break; |
937 | case Opt_bulk_read: | 971 | case Opt_bulk_read: |
938 | c->mount_opts.bulk_read = 2; | 972 | c->mount_opts.bulk_read = 2; |
@@ -950,6 +984,28 @@ static int ubifs_parse_options(struct ubifs_info *c, char *options, | |||
950 | c->mount_opts.chk_data_crc = 1; | 984 | c->mount_opts.chk_data_crc = 1; |
951 | c->no_chk_data_crc = 1; | 985 | c->no_chk_data_crc = 1; |
952 | break; | 986 | break; |
987 | case Opt_override_compr: | ||
988 | { | ||
989 | char *name = match_strdup(&args[0]); | ||
990 | |||
991 | if (!name) | ||
992 | return -ENOMEM; | ||
993 | if (!strcmp(name, "none")) | ||
994 | c->mount_opts.compr_type = UBIFS_COMPR_NONE; | ||
995 | else if (!strcmp(name, "lzo")) | ||
996 | c->mount_opts.compr_type = UBIFS_COMPR_LZO; | ||
997 | else if (!strcmp(name, "zlib")) | ||
998 | c->mount_opts.compr_type = UBIFS_COMPR_ZLIB; | ||
999 | else { | ||
1000 | ubifs_err("unknown compressor \"%s\"", name); | ||
1001 | kfree(name); | ||
1002 | return -EINVAL; | ||
1003 | } | ||
1004 | kfree(name); | ||
1005 | c->mount_opts.override_compr = 1; | ||
1006 | c->default_compr = c->mount_opts.compr_type; | ||
1007 | break; | ||
1008 | } | ||
953 | default: | 1009 | default: |
954 | ubifs_err("unrecognized mount option \"%s\" " | 1010 | ubifs_err("unrecognized mount option \"%s\" " |
955 | "or missing value", p); | 1011 | "or missing value", p); |
@@ -1019,6 +1075,25 @@ again: | |||
1019 | } | 1075 | } |
1020 | 1076 | ||
1021 | /** | 1077 | /** |
1078 | * check_free_space - check if there is enough free space to mount. | ||
1079 | * @c: UBIFS file-system description object | ||
1080 | * | ||
1081 | * This function makes sure UBIFS has enough free space to be mounted in | ||
1082 | * read/write mode. UBIFS must always have some free space to allow deletions. | ||
1083 | */ | ||
1084 | static int check_free_space(struct ubifs_info *c) | ||
1085 | { | ||
1086 | ubifs_assert(c->dark_wm > 0); | ||
1087 | if (c->lst.total_free + c->lst.total_dirty < c->dark_wm) { | ||
1088 | ubifs_err("insufficient free space to mount in read/write mode"); | ||
1089 | dbg_dump_budg(c); | ||
1090 | dbg_dump_lprops(c); | ||
1091 | return -ENOSPC; | ||
1092 | } | ||
1093 | return 0; | ||
1094 | } | ||
1095 | |||
1096 | /** | ||
1022 | * mount_ubifs - mount UBIFS file-system. | 1097 | * mount_ubifs - mount UBIFS file-system. |
1023 | * @c: UBIFS file-system description object | 1098 | * @c: UBIFS file-system description object |
1024 | * | 1099 | * |
@@ -1039,11 +1114,9 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1039 | if (err) | 1114 | if (err) |
1040 | return err; | 1115 | return err; |
1041 | 1116 | ||
1042 | #ifdef CONFIG_UBIFS_FS_DEBUG | 1117 | err = ubifs_debugging_init(c); |
1043 | c->dbg_buf = vmalloc(c->leb_size); | 1118 | if (err) |
1044 | if (!c->dbg_buf) | 1119 | return err; |
1045 | return -ENOMEM; | ||
1046 | #endif | ||
1047 | 1120 | ||
1048 | err = check_volume_empty(c); | 1121 | err = check_volume_empty(c); |
1049 | if (err) | 1122 | if (err) |
@@ -1100,27 +1173,25 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1100 | goto out_free; | 1173 | goto out_free; |
1101 | 1174 | ||
1102 | /* | 1175 | /* |
1103 | * Make sure the compressor which is set as the default on in the | 1176 | * Make sure the compressor which is set as default in the superblock |
1104 | * superblock was actually compiled in. | 1177 | * or overridden by mount options is actually compiled in. |
1105 | */ | 1178 | */ |
1106 | if (!ubifs_compr_present(c->default_compr)) { | 1179 | if (!ubifs_compr_present(c->default_compr)) { |
1107 | ubifs_warn("'%s' compressor is set by superblock, but not " | 1180 | ubifs_err("'compressor \"%s\" is not compiled in", |
1108 | "compiled in", ubifs_compr_name(c->default_compr)); | 1181 | ubifs_compr_name(c->default_compr)); |
1109 | c->default_compr = UBIFS_COMPR_NONE; | 1182 | goto out_free; |
1110 | } | 1183 | } |
1111 | 1184 | ||
1112 | dbg_failure_mode_registration(c); | 1185 | err = init_constants_sb(c); |
1113 | |||
1114 | err = init_constants_late(c); | ||
1115 | if (err) | 1186 | if (err) |
1116 | goto out_dereg; | 1187 | goto out_free; |
1117 | 1188 | ||
1118 | sz = ALIGN(c->max_idx_node_sz, c->min_io_size); | 1189 | sz = ALIGN(c->max_idx_node_sz, c->min_io_size); |
1119 | sz = ALIGN(sz + c->max_idx_node_sz, c->min_io_size); | 1190 | sz = ALIGN(sz + c->max_idx_node_sz, c->min_io_size); |
1120 | c->cbuf = kmalloc(sz, GFP_NOFS); | 1191 | c->cbuf = kmalloc(sz, GFP_NOFS); |
1121 | if (!c->cbuf) { | 1192 | if (!c->cbuf) { |
1122 | err = -ENOMEM; | 1193 | err = -ENOMEM; |
1123 | goto out_dereg; | 1194 | goto out_free; |
1124 | } | 1195 | } |
1125 | 1196 | ||
1126 | sprintf(c->bgt_name, BGT_NAME_PATTERN, c->vi.ubi_num, c->vi.vol_id); | 1197 | sprintf(c->bgt_name, BGT_NAME_PATTERN, c->vi.ubi_num, c->vi.vol_id); |
@@ -1145,6 +1216,8 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1145 | if (err) | 1216 | if (err) |
1146 | goto out_master; | 1217 | goto out_master; |
1147 | 1218 | ||
1219 | init_constants_master(c); | ||
1220 | |||
1148 | if ((c->mst_node->flags & cpu_to_le32(UBIFS_MST_DIRTY)) != 0) { | 1221 | if ((c->mst_node->flags & cpu_to_le32(UBIFS_MST_DIRTY)) != 0) { |
1149 | ubifs_msg("recovery needed"); | 1222 | ubifs_msg("recovery needed"); |
1150 | c->need_recovery = 1; | 1223 | c->need_recovery = 1; |
@@ -1183,12 +1256,9 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1183 | if (!mounted_read_only) { | 1256 | if (!mounted_read_only) { |
1184 | int lnum; | 1257 | int lnum; |
1185 | 1258 | ||
1186 | /* Check for enough free space */ | 1259 | err = check_free_space(c); |
1187 | if (ubifs_calc_available(c, c->min_idx_lebs) <= 0) { | 1260 | if (err) |
1188 | ubifs_err("insufficient available space"); | ||
1189 | err = -EINVAL; | ||
1190 | goto out_orphans; | 1261 | goto out_orphans; |
1191 | } | ||
1192 | 1262 | ||
1193 | /* Check for enough log space */ | 1263 | /* Check for enough log space */ |
1194 | lnum = c->lhead_lnum + 1; | 1264 | lnum = c->lhead_lnum + 1; |
@@ -1205,10 +1275,19 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1205 | if (err) | 1275 | if (err) |
1206 | goto out_orphans; | 1276 | goto out_orphans; |
1207 | err = ubifs_rcvry_gc_commit(c); | 1277 | err = ubifs_rcvry_gc_commit(c); |
1208 | } else | 1278 | } else { |
1209 | err = take_gc_lnum(c); | 1279 | err = take_gc_lnum(c); |
1210 | if (err) | 1280 | if (err) |
1211 | goto out_orphans; | 1281 | goto out_orphans; |
1282 | |||
1283 | /* | ||
1284 | * GC LEB may contain garbage if there was an unclean | ||
1285 | * reboot, and it should be un-mapped. | ||
1286 | */ | ||
1287 | err = ubifs_leb_unmap(c, c->gc_lnum); | ||
1288 | if (err) | ||
1289 | return err; | ||
1290 | } | ||
1212 | 1291 | ||
1213 | err = dbg_check_lprops(c); | 1292 | err = dbg_check_lprops(c); |
1214 | if (err) | 1293 | if (err) |
@@ -1217,6 +1296,16 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1217 | err = ubifs_recover_size(c); | 1296 | err = ubifs_recover_size(c); |
1218 | if (err) | 1297 | if (err) |
1219 | goto out_orphans; | 1298 | goto out_orphans; |
1299 | } else { | ||
1300 | /* | ||
1301 | * Even if we mount read-only, we have to set space in GC LEB | ||
1302 | * to proper value because this affects UBIFS free space | ||
1303 | * reporting. We do not want to have a situation when | ||
1304 | * re-mounting from R/O to R/W changes amount of free space. | ||
1305 | */ | ||
1306 | err = take_gc_lnum(c); | ||
1307 | if (err) | ||
1308 | goto out_orphans; | ||
1220 | } | 1309 | } |
1221 | 1310 | ||
1222 | spin_lock(&ubifs_infos_lock); | 1311 | spin_lock(&ubifs_infos_lock); |
@@ -1229,13 +1318,20 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1229 | else { | 1318 | else { |
1230 | c->need_recovery = 0; | 1319 | c->need_recovery = 0; |
1231 | ubifs_msg("recovery completed"); | 1320 | ubifs_msg("recovery completed"); |
1321 | /* GC LEB has to be empty and taken at this point */ | ||
1322 | ubifs_assert(c->lst.taken_empty_lebs == 1); | ||
1232 | } | 1323 | } |
1233 | } | 1324 | } else |
1325 | ubifs_assert(c->lst.taken_empty_lebs == 1); | ||
1234 | 1326 | ||
1235 | err = dbg_check_filesystem(c); | 1327 | err = dbg_check_filesystem(c); |
1236 | if (err) | 1328 | if (err) |
1237 | goto out_infos; | 1329 | goto out_infos; |
1238 | 1330 | ||
1331 | err = dbg_debugfs_init_fs(c); | ||
1332 | if (err) | ||
1333 | goto out_infos; | ||
1334 | |||
1239 | c->always_chk_crc = 0; | 1335 | c->always_chk_crc = 0; |
1240 | 1336 | ||
1241 | ubifs_msg("mounted UBI device %d, volume %d, name \"%s\"", | 1337 | ubifs_msg("mounted UBI device %d, volume %d, name \"%s\"", |
@@ -1266,7 +1362,6 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1266 | c->uuid[4], c->uuid[5], c->uuid[6], c->uuid[7], | 1362 | c->uuid[4], c->uuid[5], c->uuid[6], c->uuid[7], |
1267 | c->uuid[8], c->uuid[9], c->uuid[10], c->uuid[11], | 1363 | c->uuid[8], c->uuid[9], c->uuid[10], c->uuid[11], |
1268 | c->uuid[12], c->uuid[13], c->uuid[14], c->uuid[15]); | 1364 | c->uuid[12], c->uuid[13], c->uuid[14], c->uuid[15]); |
1269 | dbg_msg("fast unmount: %d", c->fast_unmount); | ||
1270 | dbg_msg("big_lpt %d", c->big_lpt); | 1365 | dbg_msg("big_lpt %d", c->big_lpt); |
1271 | dbg_msg("log LEBs: %d (%d - %d)", | 1366 | dbg_msg("log LEBs: %d (%d - %d)", |
1272 | c->log_lebs, UBIFS_LOG_LNUM, c->log_last); | 1367 | c->log_lebs, UBIFS_LOG_LNUM, c->log_last); |
@@ -1283,8 +1378,20 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1283 | dbg_msg("tree fanout: %d", c->fanout); | 1378 | dbg_msg("tree fanout: %d", c->fanout); |
1284 | dbg_msg("reserved GC LEB: %d", c->gc_lnum); | 1379 | dbg_msg("reserved GC LEB: %d", c->gc_lnum); |
1285 | dbg_msg("first main LEB: %d", c->main_first); | 1380 | dbg_msg("first main LEB: %d", c->main_first); |
1381 | dbg_msg("max. znode size %d", c->max_znode_sz); | ||
1382 | dbg_msg("max. index node size %d", c->max_idx_node_sz); | ||
1383 | dbg_msg("node sizes: data %zu, inode %zu, dentry %zu", | ||
1384 | UBIFS_DATA_NODE_SZ, UBIFS_INO_NODE_SZ, UBIFS_DENT_NODE_SZ); | ||
1385 | dbg_msg("node sizes: trun %zu, sb %zu, master %zu", | ||
1386 | UBIFS_TRUN_NODE_SZ, UBIFS_SB_NODE_SZ, UBIFS_MST_NODE_SZ); | ||
1387 | dbg_msg("node sizes: ref %zu, cmt. start %zu, orph %zu", | ||
1388 | UBIFS_REF_NODE_SZ, UBIFS_CS_NODE_SZ, UBIFS_ORPH_NODE_SZ); | ||
1389 | dbg_msg("max. node sizes: data %zu, inode %zu dentry %zu", | ||
1390 | UBIFS_MAX_DATA_NODE_SZ, UBIFS_MAX_INO_NODE_SZ, | ||
1391 | UBIFS_MAX_DENT_NODE_SZ); | ||
1286 | dbg_msg("dead watermark: %d", c->dead_wm); | 1392 | dbg_msg("dead watermark: %d", c->dead_wm); |
1287 | dbg_msg("dark watermark: %d", c->dark_wm); | 1393 | dbg_msg("dark watermark: %d", c->dark_wm); |
1394 | dbg_msg("LEB overhead: %d", c->leb_overhead); | ||
1288 | x = (long long)c->main_lebs * c->dark_wm; | 1395 | x = (long long)c->main_lebs * c->dark_wm; |
1289 | dbg_msg("max. dark space: %lld (%lld KiB, %lld MiB)", | 1396 | dbg_msg("max. dark space: %lld (%lld KiB, %lld MiB)", |
1290 | x, x >> 10, x >> 20); | 1397 | x, x >> 10, x >> 20); |
@@ -1320,14 +1427,12 @@ out_wbufs: | |||
1320 | free_wbufs(c); | 1427 | free_wbufs(c); |
1321 | out_cbuf: | 1428 | out_cbuf: |
1322 | kfree(c->cbuf); | 1429 | kfree(c->cbuf); |
1323 | out_dereg: | ||
1324 | dbg_failure_mode_deregistration(c); | ||
1325 | out_free: | 1430 | out_free: |
1326 | kfree(c->bu.buf); | 1431 | kfree(c->bu.buf); |
1327 | vfree(c->ileb_buf); | 1432 | vfree(c->ileb_buf); |
1328 | vfree(c->sbuf); | 1433 | vfree(c->sbuf); |
1329 | kfree(c->bottom_up_buf); | 1434 | kfree(c->bottom_up_buf); |
1330 | UBIFS_DBG(vfree(c->dbg_buf)); | 1435 | ubifs_debugging_exit(c); |
1331 | return err; | 1436 | return err; |
1332 | } | 1437 | } |
1333 | 1438 | ||
@@ -1345,6 +1450,7 @@ static void ubifs_umount(struct ubifs_info *c) | |||
1345 | dbg_gen("un-mounting UBI device %d, volume %d", c->vi.ubi_num, | 1450 | dbg_gen("un-mounting UBI device %d, volume %d", c->vi.ubi_num, |
1346 | c->vi.vol_id); | 1451 | c->vi.vol_id); |
1347 | 1452 | ||
1453 | dbg_debugfs_exit_fs(c); | ||
1348 | spin_lock(&ubifs_infos_lock); | 1454 | spin_lock(&ubifs_infos_lock); |
1349 | list_del(&c->infos_list); | 1455 | list_del(&c->infos_list); |
1350 | spin_unlock(&ubifs_infos_lock); | 1456 | spin_unlock(&ubifs_infos_lock); |
@@ -1364,8 +1470,7 @@ static void ubifs_umount(struct ubifs_info *c) | |||
1364 | vfree(c->ileb_buf); | 1470 | vfree(c->ileb_buf); |
1365 | vfree(c->sbuf); | 1471 | vfree(c->sbuf); |
1366 | kfree(c->bottom_up_buf); | 1472 | kfree(c->bottom_up_buf); |
1367 | UBIFS_DBG(vfree(c->dbg_buf)); | 1473 | ubifs_debugging_exit(c); |
1368 | dbg_failure_mode_deregistration(c); | ||
1369 | } | 1474 | } |
1370 | 1475 | ||
1371 | /** | 1476 | /** |
@@ -1380,19 +1485,14 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
1380 | { | 1485 | { |
1381 | int err, lnum; | 1486 | int err, lnum; |
1382 | 1487 | ||
1383 | if (c->ro_media) | ||
1384 | return -EINVAL; | ||
1385 | |||
1386 | mutex_lock(&c->umount_mutex); | 1488 | mutex_lock(&c->umount_mutex); |
1489 | dbg_save_space_info(c); | ||
1387 | c->remounting_rw = 1; | 1490 | c->remounting_rw = 1; |
1388 | c->always_chk_crc = 1; | 1491 | c->always_chk_crc = 1; |
1389 | 1492 | ||
1390 | /* Check for enough free space */ | 1493 | err = check_free_space(c); |
1391 | if (ubifs_calc_available(c, c->min_idx_lebs) <= 0) { | 1494 | if (err) |
1392 | ubifs_err("insufficient available space"); | ||
1393 | err = -EINVAL; | ||
1394 | goto out; | 1495 | goto out; |
1395 | } | ||
1396 | 1496 | ||
1397 | if (c->old_leb_cnt != c->leb_cnt) { | 1497 | if (c->old_leb_cnt != c->leb_cnt) { |
1398 | struct ubifs_sb_node *sup; | 1498 | struct ubifs_sb_node *sup; |
@@ -1422,6 +1522,12 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
1422 | err = ubifs_recover_inl_heads(c, c->sbuf); | 1522 | err = ubifs_recover_inl_heads(c, c->sbuf); |
1423 | if (err) | 1523 | if (err) |
1424 | goto out; | 1524 | goto out; |
1525 | } else { | ||
1526 | /* A readonly mount is not allowed to have orphans */ | ||
1527 | ubifs_assert(c->tot_orphans == 0); | ||
1528 | err = ubifs_clear_orphans(c); | ||
1529 | if (err) | ||
1530 | goto out; | ||
1425 | } | 1531 | } |
1426 | 1532 | ||
1427 | if (!(c->mst_node->flags & cpu_to_le32(UBIFS_MST_DIRTY))) { | 1533 | if (!(c->mst_node->flags & cpu_to_le32(UBIFS_MST_DIRTY))) { |
@@ -1477,7 +1583,7 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
1477 | if (c->need_recovery) | 1583 | if (c->need_recovery) |
1478 | err = ubifs_rcvry_gc_commit(c); | 1584 | err = ubifs_rcvry_gc_commit(c); |
1479 | else | 1585 | else |
1480 | err = take_gc_lnum(c); | 1586 | err = ubifs_leb_unmap(c, c->gc_lnum); |
1481 | if (err) | 1587 | if (err) |
1482 | goto out; | 1588 | goto out; |
1483 | 1589 | ||
@@ -1490,8 +1596,9 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
1490 | c->vfs_sb->s_flags &= ~MS_RDONLY; | 1596 | c->vfs_sb->s_flags &= ~MS_RDONLY; |
1491 | c->remounting_rw = 0; | 1597 | c->remounting_rw = 0; |
1492 | c->always_chk_crc = 0; | 1598 | c->always_chk_crc = 0; |
1599 | err = dbg_check_space_info(c); | ||
1493 | mutex_unlock(&c->umount_mutex); | 1600 | mutex_unlock(&c->umount_mutex); |
1494 | return 0; | 1601 | return err; |
1495 | 1602 | ||
1496 | out: | 1603 | out: |
1497 | vfree(c->orph_buf); | 1604 | vfree(c->orph_buf); |
@@ -1511,39 +1618,18 @@ out: | |||
1511 | } | 1618 | } |
1512 | 1619 | ||
1513 | /** | 1620 | /** |
1514 | * commit_on_unmount - commit the journal when un-mounting. | ||
1515 | * @c: UBIFS file-system description object | ||
1516 | * | ||
1517 | * This function is called during un-mounting and re-mounting, and it commits | ||
1518 | * the journal unless the "fast unmount" mode is enabled. It also avoids | ||
1519 | * committing the journal if it contains too few data. | ||
1520 | */ | ||
1521 | static void commit_on_unmount(struct ubifs_info *c) | ||
1522 | { | ||
1523 | if (!c->fast_unmount) { | ||
1524 | long long bud_bytes; | ||
1525 | |||
1526 | spin_lock(&c->buds_lock); | ||
1527 | bud_bytes = c->bud_bytes; | ||
1528 | spin_unlock(&c->buds_lock); | ||
1529 | if (bud_bytes > c->leb_size) | ||
1530 | ubifs_run_commit(c); | ||
1531 | } | ||
1532 | } | ||
1533 | |||
1534 | /** | ||
1535 | * ubifs_remount_ro - re-mount in read-only mode. | 1621 | * ubifs_remount_ro - re-mount in read-only mode. |
1536 | * @c: UBIFS file-system description object | 1622 | * @c: UBIFS file-system description object |
1537 | * | 1623 | * |
1538 | * We rely on VFS to have stopped writing. Possibly the background thread could | 1624 | * We assume VFS has stopped writing. Possibly the background thread could be |
1539 | * be running a commit, however kthread_stop will wait in that case. | 1625 | * running a commit, however kthread_stop will wait in that case. |
1540 | */ | 1626 | */ |
1541 | static void ubifs_remount_ro(struct ubifs_info *c) | 1627 | static void ubifs_remount_ro(struct ubifs_info *c) |
1542 | { | 1628 | { |
1543 | int i, err; | 1629 | int i, err; |
1544 | 1630 | ||
1545 | ubifs_assert(!c->need_recovery); | 1631 | ubifs_assert(!c->need_recovery); |
1546 | commit_on_unmount(c); | 1632 | ubifs_assert(!(c->vfs_sb->s_flags & MS_RDONLY)); |
1547 | 1633 | ||
1548 | mutex_lock(&c->umount_mutex); | 1634 | mutex_lock(&c->umount_mutex); |
1549 | if (c->bgt) { | 1635 | if (c->bgt) { |
@@ -1551,27 +1637,29 @@ static void ubifs_remount_ro(struct ubifs_info *c) | |||
1551 | c->bgt = NULL; | 1637 | c->bgt = NULL; |
1552 | } | 1638 | } |
1553 | 1639 | ||
1640 | dbg_save_space_info(c); | ||
1641 | |||
1554 | for (i = 0; i < c->jhead_cnt; i++) { | 1642 | for (i = 0; i < c->jhead_cnt; i++) { |
1555 | ubifs_wbuf_sync(&c->jheads[i].wbuf); | 1643 | ubifs_wbuf_sync(&c->jheads[i].wbuf); |
1556 | del_timer_sync(&c->jheads[i].wbuf.timer); | 1644 | del_timer_sync(&c->jheads[i].wbuf.timer); |
1557 | } | 1645 | } |
1558 | 1646 | ||
1559 | if (!c->ro_media) { | 1647 | c->mst_node->flags &= ~cpu_to_le32(UBIFS_MST_DIRTY); |
1560 | c->mst_node->flags &= ~cpu_to_le32(UBIFS_MST_DIRTY); | 1648 | c->mst_node->flags |= cpu_to_le32(UBIFS_MST_NO_ORPHS); |
1561 | c->mst_node->flags |= cpu_to_le32(UBIFS_MST_NO_ORPHS); | 1649 | c->mst_node->gc_lnum = cpu_to_le32(c->gc_lnum); |
1562 | c->mst_node->gc_lnum = cpu_to_le32(c->gc_lnum); | 1650 | err = ubifs_write_master(c); |
1563 | err = ubifs_write_master(c); | 1651 | if (err) |
1564 | if (err) | 1652 | ubifs_ro_mode(c, err); |
1565 | ubifs_ro_mode(c, err); | ||
1566 | } | ||
1567 | 1653 | ||
1568 | ubifs_destroy_idx_gc(c); | ||
1569 | free_wbufs(c); | 1654 | free_wbufs(c); |
1570 | vfree(c->orph_buf); | 1655 | vfree(c->orph_buf); |
1571 | c->orph_buf = NULL; | 1656 | c->orph_buf = NULL; |
1572 | vfree(c->ileb_buf); | 1657 | vfree(c->ileb_buf); |
1573 | c->ileb_buf = NULL; | 1658 | c->ileb_buf = NULL; |
1574 | ubifs_lpt_free(c, 1); | 1659 | ubifs_lpt_free(c, 1); |
1660 | err = dbg_check_space_info(c); | ||
1661 | if (err) | ||
1662 | ubifs_ro_mode(c, err); | ||
1575 | mutex_unlock(&c->umount_mutex); | 1663 | mutex_unlock(&c->umount_mutex); |
1576 | } | 1664 | } |
1577 | 1665 | ||
@@ -1664,11 +1752,20 @@ static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data) | |||
1664 | } | 1752 | } |
1665 | 1753 | ||
1666 | if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) { | 1754 | if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) { |
1755 | if (c->ro_media) { | ||
1756 | ubifs_msg("cannot re-mount due to prior errors"); | ||
1757 | return -EROFS; | ||
1758 | } | ||
1667 | err = ubifs_remount_rw(c); | 1759 | err = ubifs_remount_rw(c); |
1668 | if (err) | 1760 | if (err) |
1669 | return err; | 1761 | return err; |
1670 | } else if (!(sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY)) | 1762 | } else if (!(sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY)) { |
1763 | if (c->ro_media) { | ||
1764 | ubifs_msg("cannot re-mount due to prior errors"); | ||
1765 | return -EROFS; | ||
1766 | } | ||
1671 | ubifs_remount_ro(c); | 1767 | ubifs_remount_ro(c); |
1768 | } | ||
1672 | 1769 | ||
1673 | if (c->bulk_read == 1) | 1770 | if (c->bulk_read == 1) |
1674 | bu_init(c); | 1771 | bu_init(c); |
@@ -1678,10 +1775,11 @@ static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data) | |||
1678 | c->bu.buf = NULL; | 1775 | c->bu.buf = NULL; |
1679 | } | 1776 | } |
1680 | 1777 | ||
1778 | ubifs_assert(c->lst.taken_empty_lebs == 1); | ||
1681 | return 0; | 1779 | return 0; |
1682 | } | 1780 | } |
1683 | 1781 | ||
1684 | struct super_operations ubifs_super_operations = { | 1782 | const struct super_operations ubifs_super_operations = { |
1685 | .alloc_inode = ubifs_alloc_inode, | 1783 | .alloc_inode = ubifs_alloc_inode, |
1686 | .destroy_inode = ubifs_destroy_inode, | 1784 | .destroy_inode = ubifs_destroy_inode, |
1687 | .put_super = ubifs_put_super, | 1785 | .put_super = ubifs_put_super, |
@@ -1849,7 +1947,6 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent) | |||
1849 | goto out_iput; | 1947 | goto out_iput; |
1850 | 1948 | ||
1851 | mutex_unlock(&c->umount_mutex); | 1949 | mutex_unlock(&c->umount_mutex); |
1852 | |||
1853 | return 0; | 1950 | return 0; |
1854 | 1951 | ||
1855 | out_iput: | 1952 | out_iput: |
@@ -1949,15 +2046,6 @@ out_close: | |||
1949 | 2046 | ||
1950 | static void ubifs_kill_sb(struct super_block *sb) | 2047 | static void ubifs_kill_sb(struct super_block *sb) |
1951 | { | 2048 | { |
1952 | struct ubifs_info *c = sb->s_fs_info; | ||
1953 | |||
1954 | /* | ||
1955 | * We do 'commit_on_unmount()' here instead of 'ubifs_put_super()' | ||
1956 | * in order to be outside BKL. | ||
1957 | */ | ||
1958 | if (sb->s_root && !(sb->s_flags & MS_RDONLY)) | ||
1959 | commit_on_unmount(c); | ||
1960 | /* The un-mount routine is actually done in put_super() */ | ||
1961 | generic_shutdown_super(sb); | 2049 | generic_shutdown_super(sb); |
1962 | } | 2050 | } |
1963 | 2051 | ||
@@ -2021,6 +2109,14 @@ static int __init ubifs_init(void) | |||
2021 | BUILD_BUG_ON(UBIFS_REF_NODE_SZ != 64); | 2109 | BUILD_BUG_ON(UBIFS_REF_NODE_SZ != 64); |
2022 | 2110 | ||
2023 | /* | 2111 | /* |
2112 | * We use 2 bit wide bit-fields to store compression type, which should | ||
2113 | * be amended if more compressors are added. The bit-fields are: | ||
2114 | * @compr_type in 'struct ubifs_inode', @default_compr in | ||
2115 | * 'struct ubifs_info' and @compr_type in 'struct ubifs_mount_opts'. | ||
2116 | */ | ||
2117 | BUILD_BUG_ON(UBIFS_COMPR_TYPES_CNT > 4); | ||
2118 | |||
2119 | /* | ||
2024 | * We require that PAGE_CACHE_SIZE is greater-than-or-equal-to | 2120 | * We require that PAGE_CACHE_SIZE is greater-than-or-equal-to |
2025 | * UBIFS_BLOCK_SIZE. It is assumed that both are powers of 2. | 2121 | * UBIFS_BLOCK_SIZE. It is assumed that both are powers of 2. |
2026 | */ | 2122 | */ |
@@ -2049,11 +2145,17 @@ static int __init ubifs_init(void) | |||
2049 | 2145 | ||
2050 | err = ubifs_compressors_init(); | 2146 | err = ubifs_compressors_init(); |
2051 | if (err) | 2147 | if (err) |
2148 | goto out_shrinker; | ||
2149 | |||
2150 | err = dbg_debugfs_init(); | ||
2151 | if (err) | ||
2052 | goto out_compr; | 2152 | goto out_compr; |
2053 | 2153 | ||
2054 | return 0; | 2154 | return 0; |
2055 | 2155 | ||
2056 | out_compr: | 2156 | out_compr: |
2157 | ubifs_compressors_exit(); | ||
2158 | out_shrinker: | ||
2057 | unregister_shrinker(&ubifs_shrinker_info); | 2159 | unregister_shrinker(&ubifs_shrinker_info); |
2058 | kmem_cache_destroy(ubifs_inode_slab); | 2160 | kmem_cache_destroy(ubifs_inode_slab); |
2059 | out_reg: | 2161 | out_reg: |
@@ -2068,6 +2170,7 @@ static void __exit ubifs_exit(void) | |||
2068 | ubifs_assert(list_empty(&ubifs_infos)); | 2170 | ubifs_assert(list_empty(&ubifs_infos)); |
2069 | ubifs_assert(atomic_long_read(&ubifs_clean_zn_cnt) == 0); | 2171 | ubifs_assert(atomic_long_read(&ubifs_clean_zn_cnt) == 0); |
2070 | 2172 | ||
2173 | dbg_debugfs_exit(); | ||
2071 | ubifs_compressors_exit(); | 2174 | ubifs_compressors_exit(); |
2072 | unregister_shrinker(&ubifs_shrinker_info); | 2175 | unregister_shrinker(&ubifs_shrinker_info); |
2073 | kmem_cache_destroy(ubifs_inode_slab); | 2176 | kmem_cache_destroy(ubifs_inode_slab); |