super.c (553dea4dd531562688ba01c641c7f8fc7abaaf8c) super.c (17c2f9f85c896b48a5d74a9155d99ec5b241a0e6)
1/*
2 * This file is part of UBIFS.
3 *
4 * Copyright (C) 2006-2008 Nokia Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by
8 * the Free Software Foundation.

--- 1055 unchanged lines hidden (view full) ---

1064 int err, mounted_read_only = (sb->s_flags & MS_RDONLY);
1065 long long x;
1066 size_t sz;
1067
1068 err = init_constants_early(c);
1069 if (err)
1070 return err;
1071
1/*
2 * This file is part of UBIFS.
3 *
4 * Copyright (C) 2006-2008 Nokia Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by
8 * the Free Software Foundation.

--- 1055 unchanged lines hidden (view full) ---

1064 int err, mounted_read_only = (sb->s_flags & MS_RDONLY);
1065 long long x;
1066 size_t sz;
1067
1068 err = init_constants_early(c);
1069 if (err)
1070 return err;
1071
1072#ifdef CONFIG_UBIFS_FS_DEBUG
1073 c->dbg_buf = vmalloc(c->leb_size);
1074 if (!c->dbg_buf)
1075 return -ENOMEM;
1076#endif
1072 err = ubifs_debugging_init(c);
1073 if (err)
1074 return err;
1077
1078 err = check_volume_empty(c);
1079 if (err)
1080 goto out_free;
1081
1082 if (c->empty && (mounted_read_only || c->ro_media)) {
1083 /*
1084 * This UBI volume is empty, and read-only, or the file system

--- 49 unchanged lines hidden (view full) ---

1134 * or overriden by mount options is actually compiled in.
1135 */
1136 if (!ubifs_compr_present(c->default_compr)) {
1137 ubifs_err("'compressor \"%s\" is not compiled in",
1138 ubifs_compr_name(c->default_compr));
1139 goto out_free;
1140 }
1141
1075
1076 err = check_volume_empty(c);
1077 if (err)
1078 goto out_free;
1079
1080 if (c->empty && (mounted_read_only || c->ro_media)) {
1081 /*
1082 * This UBI volume is empty, and read-only, or the file system

--- 49 unchanged lines hidden (view full) ---

1132 * or overriden by mount options is actually compiled in.
1133 */
1134 if (!ubifs_compr_present(c->default_compr)) {
1135 ubifs_err("'compressor \"%s\" is not compiled in",
1136 ubifs_compr_name(c->default_compr));
1137 goto out_free;
1138 }
1139
1142 dbg_failure_mode_registration(c);
1143
1144 err = init_constants_late(c);
1145 if (err)
1140 err = init_constants_late(c);
1141 if (err)
1146 goto out_dereg;
1142 goto out_free;
1147
1148 sz = ALIGN(c->max_idx_node_sz, c->min_io_size);
1149 sz = ALIGN(sz + c->max_idx_node_sz, c->min_io_size);
1150 c->cbuf = kmalloc(sz, GFP_NOFS);
1151 if (!c->cbuf) {
1152 err = -ENOMEM;
1143
1144 sz = ALIGN(c->max_idx_node_sz, c->min_io_size);
1145 sz = ALIGN(sz + c->max_idx_node_sz, c->min_io_size);
1146 c->cbuf = kmalloc(sz, GFP_NOFS);
1147 if (!c->cbuf) {
1148 err = -ENOMEM;
1153 goto out_dereg;
1149 goto out_free;
1154 }
1155
1156 sprintf(c->bgt_name, BGT_NAME_PATTERN, c->vi.ubi_num, c->vi.vol_id);
1157 if (!mounted_read_only) {
1158 err = alloc_wbufs(c);
1159 if (err)
1160 goto out_cbuf;
1161

--- 183 unchanged lines hidden (view full) ---

1345 kfree(c->mst_node);
1346 kfree(c->rcvrd_mst_node);
1347 if (c->bgt)
1348 kthread_stop(c->bgt);
1349out_wbufs:
1350 free_wbufs(c);
1351out_cbuf:
1352 kfree(c->cbuf);
1150 }
1151
1152 sprintf(c->bgt_name, BGT_NAME_PATTERN, c->vi.ubi_num, c->vi.vol_id);
1153 if (!mounted_read_only) {
1154 err = alloc_wbufs(c);
1155 if (err)
1156 goto out_cbuf;
1157

--- 183 unchanged lines hidden (view full) ---

1341 kfree(c->mst_node);
1342 kfree(c->rcvrd_mst_node);
1343 if (c->bgt)
1344 kthread_stop(c->bgt);
1345out_wbufs:
1346 free_wbufs(c);
1347out_cbuf:
1348 kfree(c->cbuf);
1353out_dereg:
1354 dbg_failure_mode_deregistration(c);
1355out_free:
1356 kfree(c->bu.buf);
1357 vfree(c->ileb_buf);
1358 vfree(c->sbuf);
1359 kfree(c->bottom_up_buf);
1349out_free:
1350 kfree(c->bu.buf);
1351 vfree(c->ileb_buf);
1352 vfree(c->sbuf);
1353 kfree(c->bottom_up_buf);
1360 UBIFS_DBG(vfree(c->dbg_buf));
1354 ubifs_debugging_exit(c);
1361 return err;
1362}
1363
1364/**
1365 * ubifs_umount - un-mount UBIFS file-system.
1366 * @c: UBIFS file-system description object
1367 *
1368 * Note, this function is called to free allocated resourced when un-mounting,

--- 20 unchanged lines hidden (view full) ---

1389
1390 kfree(c->cbuf);
1391 kfree(c->rcvrd_mst_node);
1392 kfree(c->mst_node);
1393 kfree(c->bu.buf);
1394 vfree(c->ileb_buf);
1395 vfree(c->sbuf);
1396 kfree(c->bottom_up_buf);
1355 return err;
1356}
1357
1358/**
1359 * ubifs_umount - un-mount UBIFS file-system.
1360 * @c: UBIFS file-system description object
1361 *
1362 * Note, this function is called to free allocated resourced when un-mounting,

--- 20 unchanged lines hidden (view full) ---

1383
1384 kfree(c->cbuf);
1385 kfree(c->rcvrd_mst_node);
1386 kfree(c->mst_node);
1387 kfree(c->bu.buf);
1388 vfree(c->ileb_buf);
1389 vfree(c->sbuf);
1390 kfree(c->bottom_up_buf);
1397 UBIFS_DBG(vfree(c->dbg_buf));
1398 dbg_failure_mode_deregistration(c);
1391 ubifs_debugging_exit(c);
1399}
1400
1401/**
1402 * ubifs_remount_rw - re-mount in read-write mode.
1403 * @c: UBIFS file-system description object
1404 *
1405 * UBIFS avoids allocating many unnecessary resources when mounted in read-only
1406 * mode. This function allocates the needed resources and re-mounts UBIFS in

--- 467 unchanged lines hidden (view full) ---

1874 goto out_umount;
1875 }
1876
1877 sb->s_root = d_alloc_root(root);
1878 if (!sb->s_root)
1879 goto out_iput;
1880
1881 mutex_unlock(&c->umount_mutex);
1392}
1393
1394/**
1395 * ubifs_remount_rw - re-mount in read-write mode.
1396 * @c: UBIFS file-system description object
1397 *
1398 * UBIFS avoids allocating many unnecessary resources when mounted in read-only
1399 * mode. This function allocates the needed resources and re-mounts UBIFS in

--- 467 unchanged lines hidden (view full) ---

1867 goto out_umount;
1868 }
1869
1870 sb->s_root = d_alloc_root(root);
1871 if (!sb->s_root)
1872 goto out_iput;
1873
1874 mutex_unlock(&c->umount_mutex);
1882
1883 return 0;
1884
1885out_iput:
1886 iput(root);
1887out_umount:
1888 ubifs_umount(c);
1889out_unlock:
1890 mutex_unlock(&c->umount_mutex);

--- 229 unchanged lines hidden ---
1875 return 0;
1876
1877out_iput:
1878 iput(root);
1879out_umount:
1880 ubifs_umount(c);
1881out_unlock:
1882 mutex_unlock(&c->umount_mutex);

--- 229 unchanged lines hidden ---