aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ubifs/super.c')
-rw-r--r--fs/ubifs/super.c255
1 files changed, 179 insertions, 76 deletions
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index d80b2aef42b6..0d7564b95f8e 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/*
@@ -417,39 +419,54 @@ static int ubifs_show_options(struct seq_file *s, struct vfsmount *mnt)
417 else if (c->mount_opts.chk_data_crc == 1) 419 else if (c->mount_opts.chk_data_crc == 1)
418 seq_printf(s, ",no_chk_data_crc"); 420 seq_printf(s, ",no_chk_data_crc");
419 421
422 if (c->mount_opts.override_compr) {
423 seq_printf(s, ",compr=");
424 seq_printf(s, ubifs_compr_name(c->mount_opts.compr_type));
425 }
426
420 return 0; 427 return 0;
421} 428}
422 429
423static int ubifs_sync_fs(struct super_block *sb, int wait) 430static int ubifs_sync_fs(struct super_block *sb, int wait)
424{ 431{
432 int i, err;
425 struct ubifs_info *c = sb->s_fs_info; 433 struct ubifs_info *c = sb->s_fs_info;
426 int i, ret = 0, err; 434 struct writeback_control wbc = {
427 long long bud_bytes; 435 .sync_mode = wait ? WB_SYNC_ALL : WB_SYNC_HOLD,
428 436 .range_start = 0,
429 if (c->jheads) { 437 .range_end = LLONG_MAX,
430 for (i = 0; i < c->jhead_cnt; i++) { 438 .nr_to_write = LONG_MAX,
431 err = ubifs_wbuf_sync(&c->jheads[i].wbuf); 439 };
432 if (err && !ret) 440
433 ret = err; 441 if (sb->s_flags & MS_RDONLY)
434 } 442 return 0;
435 443
436 /* Commit the journal unless it has too little data */ 444 /*
437 spin_lock(&c->buds_lock); 445 * Synchronize write buffers, because 'ubifs_run_commit()' does not
438 bud_bytes = c->bud_bytes; 446 * do this if it waits for an already running commit.
439 spin_unlock(&c->buds_lock); 447 */
440 if (bud_bytes > c->leb_size) { 448 for (i = 0; i < c->jhead_cnt; i++) {
441 err = ubifs_run_commit(c); 449 err = ubifs_wbuf_sync(&c->jheads[i].wbuf);
442 if (err) 450 if (err)
443 return err; 451 return err;
444 }
445 } 452 }
446 453
447 /* 454 /*
448 * We ought to call sync for c->ubi but it does not have one. If it had 455 * VFS calls '->sync_fs()' before synchronizing all dirty inodes and
449 * it would in turn call mtd->sync, however mtd operations are 456 * pages, so synchronize them first, then commit the journal. Strictly
450 * synchronous anyway, so we don't lose any sleep here. 457 * speaking, it is not necessary to commit the journal here,
458 * synchronizing write-buffers would be enough. But committing makes
459 * UBIFS free space predictions much more accurate, so we want to let
460 * the user be able to get more accurate results of 'statfs()' after
461 * they synchronize the file system.
451 */ 462 */
452 return ret; 463 generic_sync_sb_inodes(sb, &wbc);
464
465 err = ubifs_run_commit(c);
466 if (err)
467 return err;
468
469 return ubi_sync(c->vi.ubi_num);
453} 470}
454 471
455/** 472/**
@@ -596,7 +613,7 @@ static int bud_wbuf_callback(struct ubifs_info *c, int lnum, int free, int pad)
596} 613}
597 614
598/* 615/*
599 * init_constants_late - initialize UBIFS constants. 616 * init_constants_sb - initialize UBIFS constants.
600 * @c: UBIFS file-system description object 617 * @c: UBIFS file-system description object
601 * 618 *
602 * This is a helper function which initializes various UBIFS constants after 619 * This is a helper function which initializes various UBIFS constants after
@@ -604,10 +621,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 621 * makes sure they are all right. Returns zero in case of success and a
605 * negative error code in case of failure. 622 * negative error code in case of failure.
606 */ 623 */
607static int init_constants_late(struct ubifs_info *c) 624static int init_constants_sb(struct ubifs_info *c)
608{ 625{
609 int tmp, err; 626 int tmp, err;
610 uint64_t tmp64; 627 long long tmp64;
611 628
612 c->main_bytes = (long long)c->main_lebs * c->leb_size; 629 c->main_bytes = (long long)c->main_lebs * c->leb_size;
613 c->max_znode_sz = sizeof(struct ubifs_znode) + 630 c->max_znode_sz = sizeof(struct ubifs_znode) +
@@ -634,9 +651,8 @@ static int init_constants_late(struct ubifs_info *c)
634 * Make sure that the log is large enough to fit reference nodes for 651 * Make sure that the log is large enough to fit reference nodes for
635 * all buds plus one reserved LEB. 652 * all buds plus one reserved LEB.
636 */ 653 */
637 tmp64 = c->max_bud_bytes; 654 tmp64 = c->max_bud_bytes + c->leb_size - 1;
638 tmp = do_div(tmp64, c->leb_size); 655 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); 656 tmp = (c->ref_node_alsz * c->max_bud_cnt + c->leb_size - 1);
641 tmp /= c->leb_size; 657 tmp /= c->leb_size;
642 tmp += 1; 658 tmp += 1;
@@ -672,7 +688,7 @@ static int init_constants_late(struct ubifs_info *c)
672 * Consequently, if the journal is too small, UBIFS will treat it as 688 * Consequently, if the journal is too small, UBIFS will treat it as
673 * always full. 689 * always full.
674 */ 690 */
675 tmp64 = (uint64_t)(c->jhead_cnt + 1) * c->leb_size + 1; 691 tmp64 = (long long)(c->jhead_cnt + 1) * c->leb_size + 1;
676 if (c->bg_bud_bytes < tmp64) 692 if (c->bg_bud_bytes < tmp64)
677 c->bg_bud_bytes = tmp64; 693 c->bg_bud_bytes = tmp64;
678 if (c->max_bud_bytes < tmp64 + c->leb_size) 694 if (c->max_bud_bytes < tmp64 + c->leb_size)
@@ -682,6 +698,21 @@ static int init_constants_late(struct ubifs_info *c)
682 if (err) 698 if (err)
683 return err; 699 return err;
684 700
701 return 0;
702}
703
704/*
705 * init_constants_master - initialize UBIFS constants.
706 * @c: UBIFS file-system description object
707 *
708 * This is a helper function which initializes various UBIFS constants after
709 * the master node has been read. It also checks various UBIFS parameters and
710 * makes sure they are all right.
711 */
712static void init_constants_master(struct ubifs_info *c)
713{
714 long long tmp64;
715
685 c->min_idx_lebs = ubifs_calc_min_idx_lebs(c); 716 c->min_idx_lebs = ubifs_calc_min_idx_lebs(c);
686 717
687 /* 718 /*
@@ -690,14 +721,13 @@ static int init_constants_late(struct ubifs_info *c)
690 * necessary to report something for the 'statfs()' call. 721 * necessary to report something for the 'statfs()' call.
691 * 722 *
692 * Subtract the LEB reserved for GC, the LEB which is reserved for 723 * Subtract the LEB reserved for GC, the LEB which is reserved for
693 * deletions, and assume only one journal head is available. 724 * deletions, minimum LEBs for the index, and assume only one journal
725 * head is available.
694 */ 726 */
695 tmp64 = c->main_lebs - 2 - c->jhead_cnt + 1; 727 tmp64 = c->main_lebs - 1 - 1 - MIN_INDEX_LEBS - c->jhead_cnt + 1;
696 tmp64 *= (uint64_t)c->leb_size - c->leb_overhead; 728 tmp64 *= (long long)c->leb_size - c->leb_overhead;
697 tmp64 = ubifs_reported_space(c, tmp64); 729 tmp64 = ubifs_reported_space(c, tmp64);
698 c->block_cnt = tmp64 >> UBIFS_BLOCK_SHIFT; 730 c->block_cnt = tmp64 >> UBIFS_BLOCK_SHIFT;
699
700 return 0;
701} 731}
702 732
703/** 733/**
@@ -878,6 +908,7 @@ static int check_volume_empty(struct ubifs_info *c)
878 * Opt_no_bulk_read: disable bulk-reads 908 * Opt_no_bulk_read: disable bulk-reads
879 * Opt_chk_data_crc: check CRCs when reading data nodes 909 * Opt_chk_data_crc: check CRCs when reading data nodes
880 * Opt_no_chk_data_crc: do not check CRCs when reading data nodes 910 * Opt_no_chk_data_crc: do not check CRCs when reading data nodes
911 * Opt_override_compr: override default compressor
881 * Opt_err: just end of array marker 912 * Opt_err: just end of array marker
882 */ 913 */
883enum { 914enum {
@@ -887,6 +918,7 @@ enum {
887 Opt_no_bulk_read, 918 Opt_no_bulk_read,
888 Opt_chk_data_crc, 919 Opt_chk_data_crc,
889 Opt_no_chk_data_crc, 920 Opt_no_chk_data_crc,
921 Opt_override_compr,
890 Opt_err, 922 Opt_err,
891}; 923};
892 924
@@ -897,6 +929,7 @@ static const match_table_t tokens = {
897 {Opt_no_bulk_read, "no_bulk_read"}, 929 {Opt_no_bulk_read, "no_bulk_read"},
898 {Opt_chk_data_crc, "chk_data_crc"}, 930 {Opt_chk_data_crc, "chk_data_crc"},
899 {Opt_no_chk_data_crc, "no_chk_data_crc"}, 931 {Opt_no_chk_data_crc, "no_chk_data_crc"},
932 {Opt_override_compr, "compr=%s"},
900 {Opt_err, NULL}, 933 {Opt_err, NULL},
901}; 934};
902 935
@@ -950,6 +983,28 @@ static int ubifs_parse_options(struct ubifs_info *c, char *options,
950 c->mount_opts.chk_data_crc = 1; 983 c->mount_opts.chk_data_crc = 1;
951 c->no_chk_data_crc = 1; 984 c->no_chk_data_crc = 1;
952 break; 985 break;
986 case Opt_override_compr:
987 {
988 char *name = match_strdup(&args[0]);
989
990 if (!name)
991 return -ENOMEM;
992 if (!strcmp(name, "none"))
993 c->mount_opts.compr_type = UBIFS_COMPR_NONE;
994 else if (!strcmp(name, "lzo"))
995 c->mount_opts.compr_type = UBIFS_COMPR_LZO;
996 else if (!strcmp(name, "zlib"))
997 c->mount_opts.compr_type = UBIFS_COMPR_ZLIB;
998 else {
999 ubifs_err("unknown compressor \"%s\"", name);
1000 kfree(name);
1001 return -EINVAL;
1002 }
1003 kfree(name);
1004 c->mount_opts.override_compr = 1;
1005 c->default_compr = c->mount_opts.compr_type;
1006 break;
1007 }
953 default: 1008 default:
954 ubifs_err("unrecognized mount option \"%s\" " 1009 ubifs_err("unrecognized mount option \"%s\" "
955 "or missing value", p); 1010 "or missing value", p);
@@ -1019,6 +1074,30 @@ again:
1019} 1074}
1020 1075
1021/** 1076/**
1077 * check_free_space - check if there is enough free space to mount.
1078 * @c: UBIFS file-system description object
1079 *
1080 * This function makes sure UBIFS has enough free space to be mounted in
1081 * read/write mode. UBIFS must always have some free space to allow deletions.
1082 */
1083static int check_free_space(struct ubifs_info *c)
1084{
1085 ubifs_assert(c->dark_wm > 0);
1086 if (c->lst.total_free + c->lst.total_dirty < c->dark_wm) {
1087 ubifs_err("insufficient free space to mount in read/write mode");
1088 dbg_dump_budg(c);
1089 dbg_dump_lprops(c);
1090 /*
1091 * We return %-EINVAL instead of %-ENOSPC because it seems to
1092 * be the closest error code mentioned in the mount function
1093 * documentation.
1094 */
1095 return -EINVAL;
1096 }
1097 return 0;
1098}
1099
1100/**
1022 * mount_ubifs - mount UBIFS file-system. 1101 * mount_ubifs - mount UBIFS file-system.
1023 * @c: UBIFS file-system description object 1102 * @c: UBIFS file-system description object
1024 * 1103 *
@@ -1039,11 +1118,9 @@ static int mount_ubifs(struct ubifs_info *c)
1039 if (err) 1118 if (err)
1040 return err; 1119 return err;
1041 1120
1042#ifdef CONFIG_UBIFS_FS_DEBUG 1121 err = ubifs_debugging_init(c);
1043 c->dbg_buf = vmalloc(c->leb_size); 1122 if (err)
1044 if (!c->dbg_buf) 1123 return err;
1045 return -ENOMEM;
1046#endif
1047 1124
1048 err = check_volume_empty(c); 1125 err = check_volume_empty(c);
1049 if (err) 1126 if (err)
@@ -1100,27 +1177,25 @@ static int mount_ubifs(struct ubifs_info *c)
1100 goto out_free; 1177 goto out_free;
1101 1178
1102 /* 1179 /*
1103 * Make sure the compressor which is set as the default on in the 1180 * Make sure the compressor which is set as default in the superblock
1104 * superblock was actually compiled in. 1181 * or overridden by mount options is actually compiled in.
1105 */ 1182 */
1106 if (!ubifs_compr_present(c->default_compr)) { 1183 if (!ubifs_compr_present(c->default_compr)) {
1107 ubifs_warn("'%s' compressor is set by superblock, but not " 1184 ubifs_err("'compressor \"%s\" is not compiled in",
1108 "compiled in", ubifs_compr_name(c->default_compr)); 1185 ubifs_compr_name(c->default_compr));
1109 c->default_compr = UBIFS_COMPR_NONE; 1186 goto out_free;
1110 } 1187 }
1111 1188
1112 dbg_failure_mode_registration(c); 1189 err = init_constants_sb(c);
1113
1114 err = init_constants_late(c);
1115 if (err) 1190 if (err)
1116 goto out_dereg; 1191 goto out_free;
1117 1192
1118 sz = ALIGN(c->max_idx_node_sz, c->min_io_size); 1193 sz = ALIGN(c->max_idx_node_sz, c->min_io_size);
1119 sz = ALIGN(sz + c->max_idx_node_sz, c->min_io_size); 1194 sz = ALIGN(sz + c->max_idx_node_sz, c->min_io_size);
1120 c->cbuf = kmalloc(sz, GFP_NOFS); 1195 c->cbuf = kmalloc(sz, GFP_NOFS);
1121 if (!c->cbuf) { 1196 if (!c->cbuf) {
1122 err = -ENOMEM; 1197 err = -ENOMEM;
1123 goto out_dereg; 1198 goto out_free;
1124 } 1199 }
1125 1200
1126 sprintf(c->bgt_name, BGT_NAME_PATTERN, c->vi.ubi_num, c->vi.vol_id); 1201 sprintf(c->bgt_name, BGT_NAME_PATTERN, c->vi.ubi_num, c->vi.vol_id);
@@ -1145,6 +1220,8 @@ static int mount_ubifs(struct ubifs_info *c)
1145 if (err) 1220 if (err)
1146 goto out_master; 1221 goto out_master;
1147 1222
1223 init_constants_master(c);
1224
1148 if ((c->mst_node->flags & cpu_to_le32(UBIFS_MST_DIRTY)) != 0) { 1225 if ((c->mst_node->flags & cpu_to_le32(UBIFS_MST_DIRTY)) != 0) {
1149 ubifs_msg("recovery needed"); 1226 ubifs_msg("recovery needed");
1150 c->need_recovery = 1; 1227 c->need_recovery = 1;
@@ -1183,12 +1260,9 @@ static int mount_ubifs(struct ubifs_info *c)
1183 if (!mounted_read_only) { 1260 if (!mounted_read_only) {
1184 int lnum; 1261 int lnum;
1185 1262
1186 /* Check for enough free space */ 1263 err = check_free_space(c);
1187 if (ubifs_calc_available(c, c->min_idx_lebs) <= 0) { 1264 if (err)
1188 ubifs_err("insufficient available space");
1189 err = -EINVAL;
1190 goto out_orphans; 1265 goto out_orphans;
1191 }
1192 1266
1193 /* Check for enough log space */ 1267 /* Check for enough log space */
1194 lnum = c->lhead_lnum + 1; 1268 lnum = c->lhead_lnum + 1;
@@ -1232,6 +1306,10 @@ static int mount_ubifs(struct ubifs_info *c)
1232 } 1306 }
1233 } 1307 }
1234 1308
1309 err = dbg_debugfs_init_fs(c);
1310 if (err)
1311 goto out_infos;
1312
1235 err = dbg_check_filesystem(c); 1313 err = dbg_check_filesystem(c);
1236 if (err) 1314 if (err)
1237 goto out_infos; 1315 goto out_infos;
@@ -1283,8 +1361,20 @@ static int mount_ubifs(struct ubifs_info *c)
1283 dbg_msg("tree fanout: %d", c->fanout); 1361 dbg_msg("tree fanout: %d", c->fanout);
1284 dbg_msg("reserved GC LEB: %d", c->gc_lnum); 1362 dbg_msg("reserved GC LEB: %d", c->gc_lnum);
1285 dbg_msg("first main LEB: %d", c->main_first); 1363 dbg_msg("first main LEB: %d", c->main_first);
1364 dbg_msg("max. znode size %d", c->max_znode_sz);
1365 dbg_msg("max. index node size %d", c->max_idx_node_sz);
1366 dbg_msg("node sizes: data %zu, inode %zu, dentry %zu",
1367 UBIFS_DATA_NODE_SZ, UBIFS_INO_NODE_SZ, UBIFS_DENT_NODE_SZ);
1368 dbg_msg("node sizes: trun %zu, sb %zu, master %zu",
1369 UBIFS_TRUN_NODE_SZ, UBIFS_SB_NODE_SZ, UBIFS_MST_NODE_SZ);
1370 dbg_msg("node sizes: ref %zu, cmt. start %zu, orph %zu",
1371 UBIFS_REF_NODE_SZ, UBIFS_CS_NODE_SZ, UBIFS_ORPH_NODE_SZ);
1372 dbg_msg("max. node sizes: data %zu, inode %zu dentry %zu",
1373 UBIFS_MAX_DATA_NODE_SZ, UBIFS_MAX_INO_NODE_SZ,
1374 UBIFS_MAX_DENT_NODE_SZ);
1286 dbg_msg("dead watermark: %d", c->dead_wm); 1375 dbg_msg("dead watermark: %d", c->dead_wm);
1287 dbg_msg("dark watermark: %d", c->dark_wm); 1376 dbg_msg("dark watermark: %d", c->dark_wm);
1377 dbg_msg("LEB overhead: %d", c->leb_overhead);
1288 x = (long long)c->main_lebs * c->dark_wm; 1378 x = (long long)c->main_lebs * c->dark_wm;
1289 dbg_msg("max. dark space: %lld (%lld KiB, %lld MiB)", 1379 dbg_msg("max. dark space: %lld (%lld KiB, %lld MiB)",
1290 x, x >> 10, x >> 20); 1380 x, x >> 10, x >> 20);
@@ -1320,14 +1410,12 @@ out_wbufs:
1320 free_wbufs(c); 1410 free_wbufs(c);
1321out_cbuf: 1411out_cbuf:
1322 kfree(c->cbuf); 1412 kfree(c->cbuf);
1323out_dereg:
1324 dbg_failure_mode_deregistration(c);
1325out_free: 1413out_free:
1326 kfree(c->bu.buf); 1414 kfree(c->bu.buf);
1327 vfree(c->ileb_buf); 1415 vfree(c->ileb_buf);
1328 vfree(c->sbuf); 1416 vfree(c->sbuf);
1329 kfree(c->bottom_up_buf); 1417 kfree(c->bottom_up_buf);
1330 UBIFS_DBG(vfree(c->dbg_buf)); 1418 ubifs_debugging_exit(c);
1331 return err; 1419 return err;
1332} 1420}
1333 1421
@@ -1345,6 +1433,7 @@ static void ubifs_umount(struct ubifs_info *c)
1345 dbg_gen("un-mounting UBI device %d, volume %d", c->vi.ubi_num, 1433 dbg_gen("un-mounting UBI device %d, volume %d", c->vi.ubi_num,
1346 c->vi.vol_id); 1434 c->vi.vol_id);
1347 1435
1436 dbg_debugfs_exit_fs(c);
1348 spin_lock(&ubifs_infos_lock); 1437 spin_lock(&ubifs_infos_lock);
1349 list_del(&c->infos_list); 1438 list_del(&c->infos_list);
1350 spin_unlock(&ubifs_infos_lock); 1439 spin_unlock(&ubifs_infos_lock);
@@ -1364,8 +1453,7 @@ static void ubifs_umount(struct ubifs_info *c)
1364 vfree(c->ileb_buf); 1453 vfree(c->ileb_buf);
1365 vfree(c->sbuf); 1454 vfree(c->sbuf);
1366 kfree(c->bottom_up_buf); 1455 kfree(c->bottom_up_buf);
1367 UBIFS_DBG(vfree(c->dbg_buf)); 1456 ubifs_debugging_exit(c);
1368 dbg_failure_mode_deregistration(c);
1369} 1457}
1370 1458
1371/** 1459/**
@@ -1387,12 +1475,9 @@ static int ubifs_remount_rw(struct ubifs_info *c)
1387 c->remounting_rw = 1; 1475 c->remounting_rw = 1;
1388 c->always_chk_crc = 1; 1476 c->always_chk_crc = 1;
1389 1477
1390 /* Check for enough free space */ 1478 err = check_free_space(c);
1391 if (ubifs_calc_available(c, c->min_idx_lebs) <= 0) { 1479 if (err)
1392 ubifs_err("insufficient available space");
1393 err = -EINVAL;
1394 goto out; 1480 goto out;
1395 }
1396 1481
1397 if (c->old_leb_cnt != c->leb_cnt) { 1482 if (c->old_leb_cnt != c->leb_cnt) {
1398 struct ubifs_sb_node *sup; 1483 struct ubifs_sb_node *sup;
@@ -1515,20 +1600,24 @@ out:
1515 * @c: UBIFS file-system description object 1600 * @c: UBIFS file-system description object
1516 * 1601 *
1517 * This function is called during un-mounting and re-mounting, and it commits 1602 * 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 1603 * the journal unless the "fast unmount" mode is enabled.
1519 * committing the journal if it contains too few data.
1520 */ 1604 */
1521static void commit_on_unmount(struct ubifs_info *c) 1605static void commit_on_unmount(struct ubifs_info *c)
1522{ 1606{
1523 if (!c->fast_unmount) { 1607 struct super_block *sb = c->vfs_sb;
1524 long long bud_bytes; 1608 long long bud_bytes;
1525 1609
1526 spin_lock(&c->buds_lock); 1610 /*
1527 bud_bytes = c->bud_bytes; 1611 * This function is called before the background thread is stopped, so
1528 spin_unlock(&c->buds_lock); 1612 * we may race with ongoing commit, which means we have to take
1529 if (bud_bytes > c->leb_size) 1613 * @c->bud_lock to access @c->bud_bytes.
1530 ubifs_run_commit(c); 1614 */
1531 } 1615 spin_lock(&c->buds_lock);
1616 bud_bytes = c->bud_bytes;
1617 spin_unlock(&c->buds_lock);
1618
1619 if (!c->fast_unmount && !(sb->s_flags & MS_RDONLY) && bud_bytes)
1620 ubifs_run_commit(c);
1532} 1621}
1533 1622
1534/** 1623/**
@@ -1849,7 +1938,6 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
1849 goto out_iput; 1938 goto out_iput;
1850 1939
1851 mutex_unlock(&c->umount_mutex); 1940 mutex_unlock(&c->umount_mutex);
1852
1853 return 0; 1941 return 0;
1854 1942
1855out_iput: 1943out_iput:
@@ -1955,7 +2043,7 @@ static void ubifs_kill_sb(struct super_block *sb)
1955 * We do 'commit_on_unmount()' here instead of 'ubifs_put_super()' 2043 * We do 'commit_on_unmount()' here instead of 'ubifs_put_super()'
1956 * in order to be outside BKL. 2044 * in order to be outside BKL.
1957 */ 2045 */
1958 if (sb->s_root && !(sb->s_flags & MS_RDONLY)) 2046 if (sb->s_root)
1959 commit_on_unmount(c); 2047 commit_on_unmount(c);
1960 /* The un-mount routine is actually done in put_super() */ 2048 /* The un-mount routine is actually done in put_super() */
1961 generic_shutdown_super(sb); 2049 generic_shutdown_super(sb);
@@ -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
2056out_compr: 2156out_compr:
2157 ubifs_compressors_exit();
2158out_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);
2059out_reg: 2161out_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);