aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/ubifs/super.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 1c1bbe4135c6..2c91d6fa4e05 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1074,6 +1074,30 @@ again:
1074} 1074}
1075 1075
1076/** 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/**
1077 * mount_ubifs - mount UBIFS file-system. 1101 * mount_ubifs - mount UBIFS file-system.
1078 * @c: UBIFS file-system description object 1102 * @c: UBIFS file-system description object
1079 * 1103 *
@@ -1154,7 +1178,7 @@ static int mount_ubifs(struct ubifs_info *c)
1154 1178
1155 /* 1179 /*
1156 * Make sure the compressor which is set as default in the superblock 1180 * Make sure the compressor which is set as default in the superblock
1157 * or overriden by mount options is actually compiled in. 1181 * or overridden by mount options is actually compiled in.
1158 */ 1182 */
1159 if (!ubifs_compr_present(c->default_compr)) { 1183 if (!ubifs_compr_present(c->default_compr)) {
1160 ubifs_err("'compressor \"%s\" is not compiled in", 1184 ubifs_err("'compressor \"%s\" is not compiled in",
@@ -1236,12 +1260,9 @@ static int mount_ubifs(struct ubifs_info *c)
1236 if (!mounted_read_only) { 1260 if (!mounted_read_only) {
1237 int lnum; 1261 int lnum;
1238 1262
1239 /* Check for enough free space */ 1263 err = check_free_space(c);
1240 if (ubifs_calc_available(c, c->min_idx_lebs) <= 0) { 1264 if (err)
1241 ubifs_err("insufficient available space");
1242 err = -EINVAL;
1243 goto out_orphans; 1265 goto out_orphans;
1244 }
1245 1266
1246 /* Check for enough log space */ 1267 /* Check for enough log space */
1247 lnum = c->lhead_lnum + 1; 1268 lnum = c->lhead_lnum + 1;
@@ -1442,12 +1463,9 @@ static int ubifs_remount_rw(struct ubifs_info *c)
1442 c->remounting_rw = 1; 1463 c->remounting_rw = 1;
1443 c->always_chk_crc = 1; 1464 c->always_chk_crc = 1;
1444 1465
1445 /* Check for enough free space */ 1466 err = check_free_space(c);
1446 if (ubifs_calc_available(c, c->min_idx_lebs) <= 0) { 1467 if (err)
1447 ubifs_err("insufficient available space");
1448 err = -EINVAL;
1449 goto out; 1468 goto out;
1450 }
1451 1469
1452 if (c->old_leb_cnt != c->leb_cnt) { 1470 if (c->old_leb_cnt != c->leb_cnt) {
1453 struct ubifs_sb_node *sup; 1471 struct ubifs_sb_node *sup;