Lines Matching full:c
5 * Copyright (C) 2006-2008 Nokia Corporation.
119 /* from fs/inode.c */
196 * @c: UBIFS file-system description object
204 static int validate_inode(struct ubifs_info *c, const struct inode *inode) in validate_inode() argument
209 if (inode->i_size > c->max_inode_sz) { in validate_inode()
210 ubifs_err(c, "inode is too large (%lld)", in validate_inode()
216 ubifs_err(c, "unknown compression type %d", ui->compr_type); in validate_inode()
230 ubifs_warn(c, "inode %lu uses '%s' compression, but it was not compiled in", in validate_inode()
234 err = dbg_check_dir(c, inode); in validate_inode()
243 struct ubifs_info *c = sb->s_fs_info; in ubifs_iget() local
288 ino_key_init(c, &key, inode->i_ino); in ubifs_iget()
290 err = ubifs_tnc_lookup(c, &key, ino); in ubifs_iget()
318 err = validate_inode(c, inode); in ubifs_iget()
427 ubifs_err(c, "inode %lu validation failed, error %d", inode->i_ino, err); in ubifs_iget()
428 ubifs_dump_node(c, ino); in ubifs_iget()
429 ubifs_dump_inode(c, inode); in ubifs_iget()
434 ubifs_err(c, "failed to read inode %lu, error %d", inode->i_ino, err); in ubifs_iget()
476 struct ubifs_info *c = inode->i_sb->s_fs_info; in ubifs_write_inode() local
503 err = ubifs_jnl_write_inode(c, inode); in ubifs_write_inode()
505 ubifs_err(c, "can't write inode %lu, error %d", in ubifs_write_inode()
508 err = dbg_check_inode_size(c, inode, ui->ui_size); in ubifs_write_inode()
513 ubifs_release_dirty_inode_budget(c, ui); in ubifs_write_inode()
520 struct ubifs_info *c = inode->i_sb->s_fs_info; in ubifs_evict_inode() local
543 err = ubifs_jnl_delete_inode(c, inode); in ubifs_evict_inode()
549 ubifs_err(c, "can't delete inode %lu, error %d", in ubifs_evict_inode()
554 ubifs_release_dirty_inode_budget(c, ui); in ubifs_evict_inode()
557 c->bi.nospace = c->bi.nospace_rp = 0; in ubifs_evict_inode()
579 struct ubifs_info *c = dentry->d_sb->s_fs_info; in ubifs_statfs() local
581 __le32 *uuid = (__le32 *)c->uuid; in ubifs_statfs()
583 free = ubifs_get_free_space(c); in ubifs_statfs()
589 buf->f_blocks = c->block_cnt; in ubifs_statfs()
591 if (free > c->report_rp_size) in ubifs_statfs()
592 buf->f_bavail = (free - c->report_rp_size) >> UBIFS_BLOCK_SHIFT; in ubifs_statfs()
600 ubifs_assert(buf->f_bfree <= c->block_cnt); in ubifs_statfs()
606 struct ubifs_info *c = root->d_sb->s_fs_info; in ubifs_show_options() local
608 if (c->mount_opts.unmount_mode == 2) in ubifs_show_options()
610 else if (c->mount_opts.unmount_mode == 1) in ubifs_show_options()
613 if (c->mount_opts.bulk_read == 2) in ubifs_show_options()
615 else if (c->mount_opts.bulk_read == 1) in ubifs_show_options()
618 if (c->mount_opts.chk_data_crc == 2) in ubifs_show_options()
620 else if (c->mount_opts.chk_data_crc == 1) in ubifs_show_options()
623 if (c->mount_opts.override_compr) { in ubifs_show_options()
625 ubifs_compr_name(c->mount_opts.compr_type)); in ubifs_show_options()
634 struct ubifs_info *c = sb->s_fs_info; in ubifs_sync_fs() local
648 for (i = 0; i < c->jhead_cnt; i++) { in ubifs_sync_fs()
649 err = ubifs_wbuf_sync(&c->jheads[i].wbuf); in ubifs_sync_fs()
661 err = ubifs_run_commit(c); in ubifs_sync_fs()
665 return ubi_sync(c->vi.ubi_num); in ubifs_sync_fs()
671 * @c: UBIFS file-system description object
678 static int init_constants_early(struct ubifs_info *c) in init_constants_early() argument
680 if (c->vi.corrupted) { in init_constants_early()
681 ubifs_warn(c, "UBI volume is corrupted - read-only mode"); in init_constants_early()
682 c->ro_media = 1; in init_constants_early()
685 if (c->di.ro_mode) { in init_constants_early()
686 ubifs_msg(c, "read-only UBI device"); in init_constants_early()
687 c->ro_media = 1; in init_constants_early()
690 if (c->vi.vol_type == UBI_STATIC_VOLUME) { in init_constants_early()
691 ubifs_msg(c, "static UBI volume - read-only mode"); in init_constants_early()
692 c->ro_media = 1; in init_constants_early()
695 c->leb_cnt = c->vi.size; in init_constants_early()
696 c->leb_size = c->vi.usable_leb_size; in init_constants_early()
697 c->leb_start = c->di.leb_start; in init_constants_early()
698 c->half_leb_size = c->leb_size / 2; in init_constants_early()
699 c->min_io_size = c->di.min_io_size; in init_constants_early()
700 c->min_io_shift = fls(c->min_io_size) - 1; in init_constants_early()
701 c->max_write_size = c->di.max_write_size; in init_constants_early()
702 c->max_write_shift = fls(c->max_write_size) - 1; in init_constants_early()
704 if (c->leb_size < UBIFS_MIN_LEB_SZ) { in init_constants_early()
705 ubifs_err(c, "too small LEBs (%d bytes), min. is %d bytes", in init_constants_early()
706 c->leb_size, UBIFS_MIN_LEB_SZ); in init_constants_early()
710 if (c->leb_cnt < UBIFS_MIN_LEB_CNT) { in init_constants_early()
711 ubifs_err(c, "too few LEBs (%d), min. is %d", in init_constants_early()
712 c->leb_cnt, UBIFS_MIN_LEB_CNT); in init_constants_early()
716 if (!is_power_of_2(c->min_io_size)) { in init_constants_early()
717 ubifs_err(c, "bad min. I/O size %d", c->min_io_size); in init_constants_early()
725 if (c->max_write_size < c->min_io_size || in init_constants_early()
726 c->max_write_size % c->min_io_size || in init_constants_early()
727 !is_power_of_2(c->max_write_size)) { in init_constants_early()
728 ubifs_err(c, "bad write buffer size %d for %d min. I/O unit", in init_constants_early()
729 c->max_write_size, c->min_io_size); in init_constants_early()
735 * io.c simpler, assume minimum I/O unit size to be 8 bytes if it is in init_constants_early()
738 if (c->min_io_size < 8) { in init_constants_early()
739 c->min_io_size = 8; in init_constants_early()
740 c->min_io_shift = 3; in init_constants_early()
741 if (c->max_write_size < c->min_io_size) { in init_constants_early()
742 c->max_write_size = c->min_io_size; in init_constants_early()
743 c->max_write_shift = c->min_io_shift; in init_constants_early()
747 c->ref_node_alsz = ALIGN(UBIFS_REF_NODE_SZ, c->min_io_size); in init_constants_early()
748 c->mst_node_alsz = ALIGN(UBIFS_MST_NODE_SZ, c->min_io_size); in init_constants_early()
754 c->ranges[UBIFS_PAD_NODE].len = UBIFS_PAD_NODE_SZ; in init_constants_early()
755 c->ranges[UBIFS_SB_NODE].len = UBIFS_SB_NODE_SZ; in init_constants_early()
756 c->ranges[UBIFS_MST_NODE].len = UBIFS_MST_NODE_SZ; in init_constants_early()
757 c->ranges[UBIFS_REF_NODE].len = UBIFS_REF_NODE_SZ; in init_constants_early()
758 c->ranges[UBIFS_TRUN_NODE].len = UBIFS_TRUN_NODE_SZ; in init_constants_early()
759 c->ranges[UBIFS_CS_NODE].len = UBIFS_CS_NODE_SZ; in init_constants_early()
761 c->ranges[UBIFS_INO_NODE].min_len = UBIFS_INO_NODE_SZ; in init_constants_early()
762 c->ranges[UBIFS_INO_NODE].max_len = UBIFS_MAX_INO_NODE_SZ; in init_constants_early()
763 c->ranges[UBIFS_ORPH_NODE].min_len = in init_constants_early()
765 c->ranges[UBIFS_ORPH_NODE].max_len = c->leb_size; in init_constants_early()
766 c->ranges[UBIFS_DENT_NODE].min_len = UBIFS_DENT_NODE_SZ; in init_constants_early()
767 c->ranges[UBIFS_DENT_NODE].max_len = UBIFS_MAX_DENT_NODE_SZ; in init_constants_early()
768 c->ranges[UBIFS_XENT_NODE].min_len = UBIFS_XENT_NODE_SZ; in init_constants_early()
769 c->ranges[UBIFS_XENT_NODE].max_len = UBIFS_MAX_XENT_NODE_SZ; in init_constants_early()
770 c->ranges[UBIFS_DATA_NODE].min_len = UBIFS_DATA_NODE_SZ; in init_constants_early()
771 c->ranges[UBIFS_DATA_NODE].max_len = UBIFS_MAX_DATA_NODE_SZ; in init_constants_early()
776 c->ranges[UBIFS_IDX_NODE].min_len = UBIFS_IDX_NODE_SZ + UBIFS_BRANCH_SZ; in init_constants_early()
781 c->ranges[UBIFS_IDX_NODE].max_len = INT_MAX; in init_constants_early()
784 * Initialize dead and dark LEB space watermarks. See gc.c for comments in init_constants_early()
787 c->dead_wm = ALIGN(MIN_WRITE_SZ, c->min_io_size); in init_constants_early()
788 c->dark_wm = ALIGN(UBIFS_MAX_NODE_SZ, c->min_io_size); in init_constants_early()
795 c->leb_overhead = c->leb_size % UBIFS_MAX_DATA_NODE_SZ; in init_constants_early()
798 c->max_bu_buf_len = UBIFS_MAX_BULK_READ * UBIFS_MAX_DATA_NODE_SZ; in init_constants_early()
799 if (c->max_bu_buf_len > c->leb_size) in init_constants_early()
800 c->max_bu_buf_len = c->leb_size; in init_constants_early()
806 * @c: UBIFS file-system description object
819 static int bud_wbuf_callback(struct ubifs_info *c, int lnum, int free, int pad) in bud_wbuf_callback() argument
821 return ubifs_update_one_lp(c, lnum, free, pad, 0, 0); in bud_wbuf_callback()
826 * @c: UBIFS file-system description object
833 static int init_constants_sb(struct ubifs_info *c) in init_constants_sb() argument
838 c->main_bytes = (long long)c->main_lebs * c->leb_size; in init_constants_sb()
839 c->max_znode_sz = sizeof(struct ubifs_znode) + in init_constants_sb()
840 c->fanout * sizeof(struct ubifs_zbranch); in init_constants_sb()
842 tmp = ubifs_idx_node_sz(c, 1); in init_constants_sb()
843 c->ranges[UBIFS_IDX_NODE].min_len = tmp; in init_constants_sb()
844 c->min_idx_node_sz = ALIGN(tmp, 8); in init_constants_sb()
846 tmp = ubifs_idx_node_sz(c, c->fanout); in init_constants_sb()
847 c->ranges[UBIFS_IDX_NODE].max_len = tmp; in init_constants_sb()
848 c->max_idx_node_sz = ALIGN(tmp, 8); in init_constants_sb()
851 tmp = UBIFS_CS_NODE_SZ + UBIFS_REF_NODE_SZ * c->jhead_cnt; in init_constants_sb()
852 tmp = ALIGN(tmp, c->min_io_size); in init_constants_sb()
853 if (tmp > c->leb_size) { in init_constants_sb()
854 ubifs_err(c, "too small LEB size %d, at least %d needed", in init_constants_sb()
855 c->leb_size, tmp); in init_constants_sb()
863 tmp64 = c->max_bud_bytes + c->leb_size - 1; in init_constants_sb()
864 c->max_bud_cnt = div_u64(tmp64, c->leb_size); in init_constants_sb()
865 tmp = (c->ref_node_alsz * c->max_bud_cnt + c->leb_size - 1); in init_constants_sb()
866 tmp /= c->leb_size; in init_constants_sb()
868 if (c->log_lebs < tmp) { in init_constants_sb()
869 ubifs_err(c, "too small log %d LEBs, required min. %d LEBs", in init_constants_sb()
870 c->log_lebs, tmp); in init_constants_sb()
879 * it is not included into 'c->bi.inode_budget'. in init_constants_sb()
881 c->bi.page_budget = UBIFS_MAX_DATA_NODE_SZ * UBIFS_BLOCKS_PER_PAGE; in init_constants_sb()
882 c->bi.inode_budget = UBIFS_INO_NODE_SZ; in init_constants_sb()
883 c->bi.dent_budget = UBIFS_MAX_DENT_NODE_SZ; in init_constants_sb()
887 * 'c->max_bud_bytes', UBIFS just blocks all writers and starts commit. in init_constants_sb()
892 c->bg_bud_bytes = (c->max_bud_bytes * 13) >> 4; in init_constants_sb()
900 tmp64 = (long long)(c->jhead_cnt + 1) * c->leb_size + 1; in init_constants_sb()
901 if (c->bg_bud_bytes < tmp64) in init_constants_sb()
902 c->bg_bud_bytes = tmp64; in init_constants_sb()
903 if (c->max_bud_bytes < tmp64 + c->leb_size) in init_constants_sb()
904 c->max_bud_bytes = tmp64 + c->leb_size; in init_constants_sb()
906 err = ubifs_calc_lpt_geom(c); in init_constants_sb()
911 c->idx_leb_size = c->leb_size - c->max_idx_node_sz; in init_constants_sb()
917 * @c: UBIFS file-system description object
923 static void init_constants_master(struct ubifs_info *c) in init_constants_master() argument
927 c->bi.min_idx_lebs = ubifs_calc_min_idx_lebs(c); in init_constants_master()
928 c->report_rp_size = ubifs_reported_space(c, c->rp_size); in init_constants_master()
939 tmp64 = c->main_lebs - 1 - 1 - MIN_INDEX_LEBS - c->jhead_cnt + 1; in init_constants_master()
940 tmp64 *= (long long)c->leb_size - c->leb_overhead; in init_constants_master()
941 tmp64 = ubifs_reported_space(c, tmp64); in init_constants_master()
942 c->block_cnt = tmp64 >> UBIFS_BLOCK_SHIFT; in init_constants_master()
947 * @c: UBIFS file-system description object
956 static int take_gc_lnum(struct ubifs_info *c) in take_gc_lnum() argument
960 if (c->gc_lnum == -1) { in take_gc_lnum()
961 ubifs_err(c, "no LEB for GC"); in take_gc_lnum()
966 err = ubifs_change_one_lp(c, c->gc_lnum, c->leb_size, 0, in take_gc_lnum()
973 * @c: UBIFS file-system description object
978 static int alloc_wbufs(struct ubifs_info *c) in alloc_wbufs() argument
982 c->jheads = kcalloc(c->jhead_cnt, sizeof(struct ubifs_jhead), in alloc_wbufs()
984 if (!c->jheads) in alloc_wbufs()
988 for (i = 0; i < c->jhead_cnt; i++) { in alloc_wbufs()
989 INIT_LIST_HEAD(&c->jheads[i].buds_list); in alloc_wbufs()
990 err = ubifs_wbuf_init(c, &c->jheads[i].wbuf); in alloc_wbufs()
994 c->jheads[i].wbuf.sync_callback = &bud_wbuf_callback; in alloc_wbufs()
995 c->jheads[i].wbuf.jhead = i; in alloc_wbufs()
996 c->jheads[i].grouped = 1; in alloc_wbufs()
1003 c->jheads[GCHD].wbuf.no_timer = 1; in alloc_wbufs()
1004 c->jheads[GCHD].grouped = 0; in alloc_wbufs()
1011 * @c: UBIFS file-system description object
1013 static void free_wbufs(struct ubifs_info *c) in free_wbufs() argument
1017 if (c->jheads) { in free_wbufs()
1018 for (i = 0; i < c->jhead_cnt; i++) { in free_wbufs()
1019 kfree(c->jheads[i].wbuf.buf); in free_wbufs()
1020 kfree(c->jheads[i].wbuf.inodes); in free_wbufs()
1022 kfree(c->jheads); in free_wbufs()
1023 c->jheads = NULL; in free_wbufs()
1029 * @c: UBIFS file-system description object
1031 static void free_orphans(struct ubifs_info *c) in free_orphans() argument
1035 while (c->orph_dnext) { in free_orphans()
1036 orph = c->orph_dnext; in free_orphans()
1037 c->orph_dnext = orph->dnext; in free_orphans()
1042 while (!list_empty(&c->orph_list)) { in free_orphans()
1043 orph = list_entry(c->orph_list.next, struct ubifs_orphan, list); in free_orphans()
1046 ubifs_err(c, "orphan list not empty at unmount"); in free_orphans()
1049 vfree(c->orph_buf); in free_orphans()
1050 c->orph_buf = NULL; in free_orphans()
1055 * @c: UBIFS file-system description object
1057 static void free_buds(struct ubifs_info *c) in free_buds() argument
1061 rbtree_postorder_for_each_entry_safe(bud, n, &c->buds, rb) in free_buds()
1067 * @c: UBIFS file-system description object
1070 * mapped or not. The result of checking is stored in the @c->empty variable.
1074 static int check_volume_empty(struct ubifs_info *c) in check_volume_empty() argument
1078 c->empty = 1; in check_volume_empty()
1079 for (lnum = 0; lnum < c->leb_cnt; lnum++) { in check_volume_empty()
1080 err = ubifs_is_mapped(c, lnum); in check_volume_empty()
1084 c->empty = 0; in check_volume_empty()
1153 * @c: UBIFS file-system description object
1160 static int ubifs_parse_options(struct ubifs_info *c, char *options, in ubifs_parse_options() argument
1183 c->mount_opts.unmount_mode = 2; in ubifs_parse_options()
1186 c->mount_opts.unmount_mode = 1; in ubifs_parse_options()
1189 c->mount_opts.bulk_read = 2; in ubifs_parse_options()
1190 c->bulk_read = 1; in ubifs_parse_options()
1193 c->mount_opts.bulk_read = 1; in ubifs_parse_options()
1194 c->bulk_read = 0; in ubifs_parse_options()
1197 c->mount_opts.chk_data_crc = 2; in ubifs_parse_options()
1198 c->no_chk_data_crc = 0; in ubifs_parse_options()
1201 c->mount_opts.chk_data_crc = 1; in ubifs_parse_options()
1202 c->no_chk_data_crc = 1; in ubifs_parse_options()
1211 c->mount_opts.compr_type = UBIFS_COMPR_NONE; in ubifs_parse_options()
1213 c->mount_opts.compr_type = UBIFS_COMPR_LZO; in ubifs_parse_options()
1215 c->mount_opts.compr_type = UBIFS_COMPR_ZLIB; in ubifs_parse_options()
1217 ubifs_err(c, "unknown compressor \"%s\"", name); //FIXME: is c ready? in ubifs_parse_options()
1222 c->mount_opts.override_compr = 1; in ubifs_parse_options()
1223 c->default_compr = c->mount_opts.compr_type; in ubifs_parse_options()
1229 struct super_block *sb = c->vfs_sb; in ubifs_parse_options()
1233 ubifs_err(c, "unrecognized mount option \"%s\" or missing value", in ubifs_parse_options()
1249 * @c: UBIFS file-system description object
1254 static void destroy_journal(struct ubifs_info *c) in destroy_journal() argument
1256 while (!list_empty(&c->unclean_leb_list)) { in destroy_journal()
1259 ucleb = list_entry(c->unclean_leb_list.next, in destroy_journal()
1264 while (!list_empty(&c->old_buds)) { in destroy_journal()
1267 bud = list_entry(c->old_buds.next, struct ubifs_bud, list); in destroy_journal()
1271 ubifs_destroy_idx_gc(c); in destroy_journal()
1272 ubifs_destroy_size_tree(c); in destroy_journal()
1273 ubifs_tnc_close(c); in destroy_journal()
1274 free_buds(c); in destroy_journal()
1279 * @c: UBIFS file-system description object
1281 static void bu_init(struct ubifs_info *c) in bu_init() argument
1283 ubifs_assert(c->bulk_read == 1); in bu_init()
1285 if (c->bu.buf) in bu_init()
1289 c->bu.buf = kmalloc(c->max_bu_buf_len, GFP_KERNEL | __GFP_NOWARN); in bu_init()
1290 if (!c->bu.buf) { in bu_init()
1291 if (c->max_bu_buf_len > UBIFS_KMALLOC_OK) { in bu_init()
1292 c->max_bu_buf_len = UBIFS_KMALLOC_OK; in bu_init()
1297 ubifs_warn(c, "cannot allocate %d bytes of memory for bulk-read, disabling it", in bu_init()
1298 c->max_bu_buf_len); in bu_init()
1299 c->mount_opts.bulk_read = 1; in bu_init()
1300 c->bulk_read = 0; in bu_init()
1308 * @c: UBIFS file-system description object
1313 static int check_free_space(struct ubifs_info *c) in check_free_space() argument
1315 ubifs_assert(c->dark_wm > 0); in check_free_space()
1316 if (c->lst.total_free + c->lst.total_dirty < c->dark_wm) { in check_free_space()
1317 ubifs_err(c, "insufficient free space to mount in R/W mode"); in check_free_space()
1318 ubifs_dump_budg(c, &c->bi); in check_free_space()
1319 ubifs_dump_lprops(c); in check_free_space()
1328 * @c: UBIFS file-system description object
1333 static int mount_ubifs(struct ubifs_info *c) in mount_ubifs() argument
1342 c->ro_mount = !!(c->vfs_sb->s_flags & MS_RDONLY); in mount_ubifs()
1344 c->probing = !!(c->vfs_sb->s_flags & MS_SILENT); in mount_ubifs()
1346 if (!c->ro_mount) { in mount_ubifs()
1352 err = init_constants_early(c); in mount_ubifs()
1356 err = ubifs_debugging_init(c); in mount_ubifs()
1360 err = check_volume_empty(c); in mount_ubifs()
1364 if (c->empty && (c->ro_mount || c->ro_media)) { in mount_ubifs()
1369 ubifs_err(c, "can't format empty UBI volume: read-only %s", in mount_ubifs()
1370 c->ro_media ? "UBI volume" : "mount"); in mount_ubifs()
1375 if (c->ro_media && !c->ro_mount) { in mount_ubifs()
1376 ubifs_err(c, "cannot mount read-write - read-only media"); in mount_ubifs()
1387 c->bottom_up_buf = kmalloc(BOTTOM_UP_HEIGHT * sizeof(int), GFP_KERNEL); in mount_ubifs()
1388 if (!c->bottom_up_buf) in mount_ubifs()
1391 c->sbuf = vmalloc(c->leb_size); in mount_ubifs()
1392 if (!c->sbuf) in mount_ubifs()
1396 if (!c->ro_mount) { in mount_ubifs()
1397 c->ileb_buf = vmalloc(c->leb_size); in mount_ubifs()
1398 if (!c->ileb_buf) in mount_ubifs()
1403 if (c->bulk_read == 1) in mount_ubifs()
1404 bu_init(c); in mount_ubifs()
1407 if (!c->ro_mount) { in mount_ubifs()
1408 c->write_reserve_buf = kmalloc(COMPRESSED_DATA_NODE_BUF_SZ, in mount_ubifs()
1410 if (!c->write_reserve_buf) in mount_ubifs()
1415 c->mounting = 1; in mount_ubifs()
1417 err = ubifs_read_superblock(c); in mount_ubifs()
1421 c->probing = 0; in mount_ubifs()
1427 if (!ubifs_compr_present(c->default_compr)) { in mount_ubifs()
1428 ubifs_err(c, "'compressor \"%s\" is not compiled in", in mount_ubifs()
1429 ubifs_compr_name(c->default_compr)); in mount_ubifs()
1434 err = init_constants_sb(c); in mount_ubifs()
1438 sz = ALIGN(c->max_idx_node_sz, c->min_io_size); in mount_ubifs()
1439 sz = ALIGN(sz + c->max_idx_node_sz, c->min_io_size); in mount_ubifs()
1440 c->cbuf = kmalloc(sz, GFP_NOFS); in mount_ubifs()
1441 if (!c->cbuf) { in mount_ubifs()
1446 err = alloc_wbufs(c); in mount_ubifs()
1450 sprintf(c->bgt_name, BGT_NAME_PATTERN, c->vi.ubi_num, c->vi.vol_id); in mount_ubifs()
1452 if (!c->ro_mount) { in mount_ubifs()
1454 c->bgt = kthread_create(ubifs_bg_thread, c, "%s", c->bgt_name); in mount_ubifs()
1455 if (IS_ERR(c->bgt)) { in mount_ubifs()
1456 err = PTR_ERR(c->bgt); in mount_ubifs()
1457 c->bgt = NULL; in mount_ubifs()
1458 ubifs_err(c, "cannot spawn \"%s\", error %d", in mount_ubifs()
1459 c->bgt_name, err); in mount_ubifs()
1462 wake_up_process(c->bgt); in mount_ubifs()
1466 err = ubifs_read_master(c); in mount_ubifs()
1470 init_constants_master(c); in mount_ubifs()
1472 if ((c->mst_node->flags & cpu_to_le32(UBIFS_MST_DIRTY)) != 0) { in mount_ubifs()
1473 ubifs_msg(c, "recovery needed"); in mount_ubifs()
1474 c->need_recovery = 1; in mount_ubifs()
1478 if (c->need_recovery && !c->ro_mount) { in mount_ubifs()
1479 err = ubifs_recover_inl_heads(c, c->sbuf); in mount_ubifs()
1485 err = ubifs_lpt_init(c, 1, !c->ro_mount); in mount_ubifs()
1490 if (!c->ro_mount && c->space_fixup) { in mount_ubifs()
1491 err = ubifs_fixup_free_space(c); in mount_ubifs()
1496 if (!c->ro_mount && !c->need_recovery) { in mount_ubifs()
1501 c->mst_node->flags |= cpu_to_le32(UBIFS_MST_DIRTY); in mount_ubifs()
1502 err = ubifs_write_master(c); in mount_ubifs()
1508 err = dbg_check_idx_size(c, c->bi.old_idx_sz); in mount_ubifs()
1512 err = ubifs_replay_journal(c); in mount_ubifs()
1517 c->bi.min_idx_lebs = ubifs_calc_min_idx_lebs(c); in mount_ubifs()
1519 err = ubifs_mount_orphans(c, c->need_recovery, c->ro_mount); in mount_ubifs()
1523 if (!c->ro_mount) { in mount_ubifs()
1527 err = check_free_space(c); in mount_ubifs()
1532 lnum = c->lhead_lnum + 1; in mount_ubifs()
1533 if (lnum >= UBIFS_LOG_LNUM + c->log_lebs) in mount_ubifs()
1535 if (lnum == c->ltail_lnum) { in mount_ubifs()
1536 err = ubifs_consolidate_log(c); in mount_ubifs()
1541 if (c->need_recovery) { in mount_ubifs()
1542 err = ubifs_recover_size(c); in mount_ubifs()
1545 err = ubifs_rcvry_gc_commit(c); in mount_ubifs()
1549 err = take_gc_lnum(c); in mount_ubifs()
1557 err = ubifs_leb_unmap(c, c->gc_lnum); in mount_ubifs()
1562 err = dbg_check_lprops(c); in mount_ubifs()
1566 } else if (c->need_recovery) { in mount_ubifs()
1567 err = ubifs_recover_size(c); in mount_ubifs()
1577 err = take_gc_lnum(c); in mount_ubifs()
1584 list_add_tail(&c->infos_list, &ubifs_infos); in mount_ubifs()
1588 if (c->need_recovery) { in mount_ubifs()
1589 if (c->ro_mount) in mount_ubifs()
1590 ubifs_msg(c, "recovery deferred"); in mount_ubifs()
1592 c->need_recovery = 0; in mount_ubifs()
1593 ubifs_msg(c, "recovery completed"); in mount_ubifs()
1599 ubifs_assert(c->lst.taken_empty_lebs > 0); in mount_ubifs()
1602 ubifs_assert(c->lst.taken_empty_lebs > 0); in mount_ubifs()
1604 err = dbg_check_filesystem(c); in mount_ubifs()
1608 err = dbg_debugfs_init_fs(c); in mount_ubifs()
1612 c->mounting = 0; in mount_ubifs()
1614 ubifs_msg(c, "UBIFS: mounted UBI device %d, volume %d, name \"%s\"%s", in mount_ubifs()
1615 c->vi.ubi_num, c->vi.vol_id, c->vi.name, in mount_ubifs()
1616 c->ro_mount ? ", R/O mode" : ""); in mount_ubifs()
1617 x = (long long)c->main_lebs * c->leb_size; in mount_ubifs()
1619 y = (long long)c->log_lebs * c->leb_size + c->max_bud_bytes; in mount_ubifs()
1621 ubifs_msg(c, "LEB size: %d bytes (%d KiB), min./max. I/O unit sizes: %d bytes/%d bytes", in mount_ubifs()
1622 c->leb_size, c->leb_size >> 10, c->min_io_size, in mount_ubifs()
1623 c->max_write_size); in mount_ubifs()
1624 …ubifs_msg(c, "FS size: %lld bytes (%lld MiB, %d LEBs), journal size %lld bytes (%lld MiB, %d LEBs)… in mount_ubifs()
1625 x, x >> 20, c->main_lebs, in mount_ubifs()
1626 y, y >> 20, c->log_lebs + c->max_bud_cnt); in mount_ubifs()
1627 ubifs_msg(c, "reserved for root: %llu bytes (%llu KiB)", in mount_ubifs()
1628 c->report_rp_size, c->report_rp_size >> 10); in mount_ubifs()
1629 ubifs_msg(c, "media format: w%d/r%d (latest is w%d/r%d), UUID %pUB%s", in mount_ubifs()
1630 c->fmt_version, c->ro_compat_version, in mount_ubifs()
1631 UBIFS_FORMAT_VERSION, UBIFS_RO_COMPAT_VERSION, c->uuid, in mount_ubifs()
1632 c->big_lpt ? ", big LPT model" : ", small LPT model"); in mount_ubifs()
1634 dbg_gen("default compressor: %s", ubifs_compr_name(c->default_compr)); in mount_ubifs()
1636 c->jhead_cnt - NONDATA_JHEADS_CNT); in mount_ubifs()
1638 c->log_lebs, UBIFS_LOG_LNUM, c->log_last); in mount_ubifs()
1640 c->lpt_lebs, c->lpt_first, c->lpt_last); in mount_ubifs()
1642 c->orph_lebs, c->orph_first, c->orph_last); in mount_ubifs()
1644 c->main_lebs, c->main_first, c->leb_cnt - 1); in mount_ubifs()
1645 dbg_gen("index LEBs: %d", c->lst.idx_lebs); in mount_ubifs()
1647 c->bi.old_idx_sz, c->bi.old_idx_sz >> 10, in mount_ubifs()
1648 c->bi.old_idx_sz >> 20); in mount_ubifs()
1649 dbg_gen("key hash type: %d", c->key_hash_type); in mount_ubifs()
1650 dbg_gen("tree fanout: %d", c->fanout); in mount_ubifs()
1651 dbg_gen("reserved GC LEB: %d", c->gc_lnum); in mount_ubifs()
1652 dbg_gen("max. znode size %d", c->max_znode_sz); in mount_ubifs()
1653 dbg_gen("max. index node size %d", c->max_idx_node_sz); in mount_ubifs()
1662 UBIFS_MAX_DENT_NODE_SZ, ubifs_idx_node_sz(c, c->fanout)); in mount_ubifs()
1663 dbg_gen("dead watermark: %d", c->dead_wm); in mount_ubifs()
1664 dbg_gen("dark watermark: %d", c->dark_wm); in mount_ubifs()
1665 dbg_gen("LEB overhead: %d", c->leb_overhead); in mount_ubifs()
1666 x = (long long)c->main_lebs * c->dark_wm; in mount_ubifs()
1670 c->max_bud_bytes, c->max_bud_bytes >> 10, in mount_ubifs()
1671 c->max_bud_bytes >> 20); in mount_ubifs()
1673 c->bg_bud_bytes, c->bg_bud_bytes >> 10, in mount_ubifs()
1674 c->bg_bud_bytes >> 20); in mount_ubifs()
1676 c->bud_bytes, c->bud_bytes >> 10, c->bud_bytes >> 20); in mount_ubifs()
1677 dbg_gen("max. seq. number: %llu", c->max_sqnum); in mount_ubifs()
1678 dbg_gen("commit number: %llu", c->cmt_no); in mount_ubifs()
1684 list_del(&c->infos_list); in mount_ubifs()
1687 free_orphans(c); in mount_ubifs()
1689 destroy_journal(c); in mount_ubifs()
1691 ubifs_lpt_free(c, 0); in mount_ubifs()
1693 kfree(c->mst_node); in mount_ubifs()
1694 kfree(c->rcvrd_mst_node); in mount_ubifs()
1695 if (c->bgt) in mount_ubifs()
1696 kthread_stop(c->bgt); in mount_ubifs()
1700 free_wbufs(c); in mount_ubifs()
1702 kfree(c->cbuf); in mount_ubifs()
1704 kfree(c->write_reserve_buf); in mount_ubifs()
1705 kfree(c->bu.buf); in mount_ubifs()
1706 vfree(c->ileb_buf); in mount_ubifs()
1707 vfree(c->sbuf); in mount_ubifs()
1708 kfree(c->bottom_up_buf); in mount_ubifs()
1709 ubifs_debugging_exit(c); in mount_ubifs()
1715 * @c: UBIFS file-system description object
1723 static void ubifs_umount(struct ubifs_info *c) in ubifs_umount() argument
1725 void ubifs_umount(struct ubifs_info *c) in ubifs_umount()
1728 dbg_gen("un-mounting UBI device %d, volume %d", c->vi.ubi_num, in ubifs_umount()
1729 c->vi.vol_id); in ubifs_umount()
1731 dbg_debugfs_exit_fs(c); in ubifs_umount()
1733 list_del(&c->infos_list); in ubifs_umount()
1737 if (c->bgt) in ubifs_umount()
1738 kthread_stop(c->bgt); in ubifs_umount()
1740 destroy_journal(c); in ubifs_umount()
1742 free_wbufs(c); in ubifs_umount()
1743 free_orphans(c); in ubifs_umount()
1744 ubifs_lpt_free(c, 0); in ubifs_umount()
1746 kfree(c->cbuf); in ubifs_umount()
1747 kfree(c->rcvrd_mst_node); in ubifs_umount()
1748 kfree(c->mst_node); in ubifs_umount()
1749 kfree(c->write_reserve_buf); in ubifs_umount()
1750 kfree(c->bu.buf); in ubifs_umount()
1751 vfree(c->ileb_buf); in ubifs_umount()
1752 vfree(c->sbuf); in ubifs_umount()
1753 kfree(c->bottom_up_buf); in ubifs_umount()
1754 ubifs_debugging_exit(c); in ubifs_umount()
1767 * @c: UBIFS file-system description object
1773 static int ubifs_remount_rw(struct ubifs_info *c) in ubifs_remount_rw() argument
1777 if (c->rw_incompat) { in ubifs_remount_rw()
1778 ubifs_err(c, "the file-system is not R/W-compatible"); in ubifs_remount_rw()
1779 …ubifs_msg(c, "on-flash format version is w%d/r%d, but software only supports up to version w%d/r%d… in ubifs_remount_rw()
1780 c->fmt_version, c->ro_compat_version, in ubifs_remount_rw()
1785 mutex_lock(&c->umount_mutex); in ubifs_remount_rw()
1786 dbg_save_space_info(c); in ubifs_remount_rw()
1787 c->remounting_rw = 1; in ubifs_remount_rw()
1788 c->ro_mount = 0; in ubifs_remount_rw()
1790 if (c->space_fixup) { in ubifs_remount_rw()
1791 err = ubifs_fixup_free_space(c); in ubifs_remount_rw()
1796 err = check_free_space(c); in ubifs_remount_rw()
1800 if (c->old_leb_cnt != c->leb_cnt) { in ubifs_remount_rw()
1803 sup = ubifs_read_sb_node(c); in ubifs_remount_rw()
1808 sup->leb_cnt = cpu_to_le32(c->leb_cnt); in ubifs_remount_rw()
1809 err = ubifs_write_sb_node(c, sup); in ubifs_remount_rw()
1815 if (c->need_recovery) { in ubifs_remount_rw()
1816 ubifs_msg(c, "completing deferred recovery"); in ubifs_remount_rw()
1817 err = ubifs_write_rcvrd_mst_node(c); in ubifs_remount_rw()
1820 err = ubifs_recover_size(c); in ubifs_remount_rw()
1823 err = ubifs_clean_lebs(c, c->sbuf); in ubifs_remount_rw()
1826 err = ubifs_recover_inl_heads(c, c->sbuf); in ubifs_remount_rw()
1831 ubifs_assert(c->tot_orphans == 0); in ubifs_remount_rw()
1832 err = ubifs_clear_orphans(c); in ubifs_remount_rw()
1837 if (!(c->mst_node->flags & cpu_to_le32(UBIFS_MST_DIRTY))) { in ubifs_remount_rw()
1838 c->mst_node->flags |= cpu_to_le32(UBIFS_MST_DIRTY); in ubifs_remount_rw()
1839 err = ubifs_write_master(c); in ubifs_remount_rw()
1844 c->ileb_buf = vmalloc(c->leb_size); in ubifs_remount_rw()
1845 if (!c->ileb_buf) { in ubifs_remount_rw()
1850 c->write_reserve_buf = kmalloc(COMPRESSED_DATA_NODE_BUF_SZ, GFP_KERNEL); in ubifs_remount_rw()
1851 if (!c->write_reserve_buf) { in ubifs_remount_rw()
1856 err = ubifs_lpt_init(c, 0, 1); in ubifs_remount_rw()
1861 c->bgt = kthread_create(ubifs_bg_thread, c, "%s", c->bgt_name); in ubifs_remount_rw()
1862 if (IS_ERR(c->bgt)) { in ubifs_remount_rw()
1863 err = PTR_ERR(c->bgt); in ubifs_remount_rw()
1864 c->bgt = NULL; in ubifs_remount_rw()
1865 ubifs_err(c, "cannot spawn \"%s\", error %d", in ubifs_remount_rw()
1866 c->bgt_name, err); in ubifs_remount_rw()
1869 wake_up_process(c->bgt); in ubifs_remount_rw()
1871 c->orph_buf = vmalloc(c->leb_size); in ubifs_remount_rw()
1872 if (!c->orph_buf) { in ubifs_remount_rw()
1878 lnum = c->lhead_lnum + 1; in ubifs_remount_rw()
1879 if (lnum >= UBIFS_LOG_LNUM + c->log_lebs) in ubifs_remount_rw()
1881 if (lnum == c->ltail_lnum) { in ubifs_remount_rw()
1882 err = ubifs_consolidate_log(c); in ubifs_remount_rw()
1887 if (c->need_recovery) in ubifs_remount_rw()
1888 err = ubifs_rcvry_gc_commit(c); in ubifs_remount_rw()
1890 err = ubifs_leb_unmap(c, c->gc_lnum); in ubifs_remount_rw()
1895 c->remounting_rw = 0; in ubifs_remount_rw()
1897 if (c->need_recovery) { in ubifs_remount_rw()
1898 c->need_recovery = 0; in ubifs_remount_rw()
1899 ubifs_msg(c, "deferred recovery completed"); in ubifs_remount_rw()
1911 err = dbg_check_space_info(c); in ubifs_remount_rw()
1914 mutex_unlock(&c->umount_mutex); in ubifs_remount_rw()
1918 c->ro_mount = 1; in ubifs_remount_rw()
1919 vfree(c->orph_buf); in ubifs_remount_rw()
1920 c->orph_buf = NULL; in ubifs_remount_rw()
1921 if (c->bgt) { in ubifs_remount_rw()
1922 kthread_stop(c->bgt); in ubifs_remount_rw()
1923 c->bgt = NULL; in ubifs_remount_rw()
1925 free_wbufs(c); in ubifs_remount_rw()
1926 kfree(c->write_reserve_buf); in ubifs_remount_rw()
1927 c->write_reserve_buf = NULL; in ubifs_remount_rw()
1928 vfree(c->ileb_buf); in ubifs_remount_rw()
1929 c->ileb_buf = NULL; in ubifs_remount_rw()
1930 ubifs_lpt_free(c, 1); in ubifs_remount_rw()
1931 c->remounting_rw = 0; in ubifs_remount_rw()
1932 mutex_unlock(&c->umount_mutex); in ubifs_remount_rw()
1938 * @c: UBIFS file-system description object
1943 static void ubifs_remount_ro(struct ubifs_info *c) in ubifs_remount_ro() argument
1947 ubifs_assert(!c->need_recovery); in ubifs_remount_ro()
1948 ubifs_assert(!c->ro_mount); in ubifs_remount_ro()
1950 mutex_lock(&c->umount_mutex); in ubifs_remount_ro()
1951 if (c->bgt) { in ubifs_remount_ro()
1952 kthread_stop(c->bgt); in ubifs_remount_ro()
1953 c->bgt = NULL; in ubifs_remount_ro()
1956 dbg_save_space_info(c); in ubifs_remount_ro()
1958 for (i = 0; i < c->jhead_cnt; i++) in ubifs_remount_ro()
1959 ubifs_wbuf_sync(&c->jheads[i].wbuf); in ubifs_remount_ro()
1961 c->mst_node->flags &= ~cpu_to_le32(UBIFS_MST_DIRTY); in ubifs_remount_ro()
1962 c->mst_node->flags |= cpu_to_le32(UBIFS_MST_NO_ORPHS); in ubifs_remount_ro()
1963 c->mst_node->gc_lnum = cpu_to_le32(c->gc_lnum); in ubifs_remount_ro()
1964 err = ubifs_write_master(c); in ubifs_remount_ro()
1966 ubifs_ro_mode(c, err); in ubifs_remount_ro()
1968 vfree(c->orph_buf); in ubifs_remount_ro()
1969 c->orph_buf = NULL; in ubifs_remount_ro()
1970 kfree(c->write_reserve_buf); in ubifs_remount_ro()
1971 c->write_reserve_buf = NULL; in ubifs_remount_ro()
1972 vfree(c->ileb_buf); in ubifs_remount_ro()
1973 c->ileb_buf = NULL; in ubifs_remount_ro()
1974 ubifs_lpt_free(c, 1); in ubifs_remount_ro()
1975 c->ro_mount = 1; in ubifs_remount_ro()
1976 err = dbg_check_space_info(c); in ubifs_remount_ro()
1978 ubifs_ro_mode(c, err); in ubifs_remount_ro()
1979 mutex_unlock(&c->umount_mutex); in ubifs_remount_ro()
1985 struct ubifs_info *c = sb->s_fs_info; in ubifs_put_super() local
1987 ubifs_msg(c, "un-mount UBI device %d", c->vi.ubi_num); in ubifs_put_super()
1994 if (!c->ro_error) { in ubifs_put_super()
1995 ubifs_assert(c->bi.idx_growth == 0); in ubifs_put_super()
1996 ubifs_assert(c->bi.dd_growth == 0); in ubifs_put_super()
1997 ubifs_assert(c->bi.data_growth == 0); in ubifs_put_super()
2001 * The 'c->umount_lock' prevents races between UBIFS memory shrinker in ubifs_put_super()
2006 mutex_lock(&c->umount_mutex); in ubifs_put_super()
2007 if (!c->ro_mount) { in ubifs_put_super()
2012 if (c->bgt) { in ubifs_put_super()
2013 kthread_stop(c->bgt); in ubifs_put_super()
2014 c->bgt = NULL; in ubifs_put_super()
2018 * On fatal errors c->ro_error is set to 1, in which case we do in ubifs_put_super()
2021 if (!c->ro_error) { in ubifs_put_super()
2025 for (i = 0; i < c->jhead_cnt; i++) in ubifs_put_super()
2026 ubifs_wbuf_sync(&c->jheads[i].wbuf); in ubifs_put_super()
2033 c->mst_node->flags &= ~cpu_to_le32(UBIFS_MST_DIRTY); in ubifs_put_super()
2034 c->mst_node->flags |= cpu_to_le32(UBIFS_MST_NO_ORPHS); in ubifs_put_super()
2035 c->mst_node->gc_lnum = cpu_to_le32(c->gc_lnum); in ubifs_put_super()
2036 err = ubifs_write_master(c); in ubifs_put_super()
2043 ubifs_err(c, "failed to write master node, error %d", in ubifs_put_super()
2047 for (i = 0; i < c->jhead_cnt; i++) in ubifs_put_super()
2049 hrtimer_cancel(&c->jheads[i].wbuf.timer); in ubifs_put_super()
2054 ubifs_umount(c); in ubifs_put_super()
2056 bdi_destroy(&c->bdi); in ubifs_put_super()
2058 ubi_close_volume(c->ubi); in ubifs_put_super()
2059 mutex_unlock(&c->umount_mutex); in ubifs_put_super()
2067 struct ubifs_info *c = sb->s_fs_info; in ubifs_remount_fs() local
2072 err = ubifs_parse_options(c, data, 1); in ubifs_remount_fs()
2074 ubifs_err(c, "invalid or unknown remount parameter"); in ubifs_remount_fs()
2078 if (c->ro_mount && !(*flags & MS_RDONLY)) { in ubifs_remount_fs()
2079 if (c->ro_error) { in ubifs_remount_fs()
2080 ubifs_msg(c, "cannot re-mount R/W due to prior errors"); in ubifs_remount_fs()
2083 if (c->ro_media) { in ubifs_remount_fs()
2084 ubifs_msg(c, "cannot re-mount R/W - UBI volume is R/O"); in ubifs_remount_fs()
2087 err = ubifs_remount_rw(c); in ubifs_remount_fs()
2090 } else if (!c->ro_mount && (*flags & MS_RDONLY)) { in ubifs_remount_fs()
2091 if (c->ro_error) { in ubifs_remount_fs()
2092 ubifs_msg(c, "cannot re-mount R/O due to prior errors"); in ubifs_remount_fs()
2095 ubifs_remount_ro(c); in ubifs_remount_fs()
2098 if (c->bulk_read == 1) in ubifs_remount_fs()
2099 bu_init(c); in ubifs_remount_fs()
2102 kfree(c->bu.buf); in ubifs_remount_fs()
2103 c->bu.buf = NULL; in ubifs_remount_fs()
2106 ubifs_assert(c->lst.taken_empty_lebs > 0); in ubifs_remount_fs()
2196 struct ubifs_info *c; in alloc_ubifs_info() local
2198 c = kzalloc(sizeof(struct ubifs_info), GFP_KERNEL); in alloc_ubifs_info()
2199 if (c) { in alloc_ubifs_info()
2200 spin_lock_init(&c->cnt_lock); in alloc_ubifs_info()
2201 spin_lock_init(&c->cs_lock); in alloc_ubifs_info()
2202 spin_lock_init(&c->buds_lock); in alloc_ubifs_info()
2203 spin_lock_init(&c->space_lock); in alloc_ubifs_info()
2204 spin_lock_init(&c->orphan_lock); in alloc_ubifs_info()
2205 init_rwsem(&c->commit_sem); in alloc_ubifs_info()
2206 mutex_init(&c->lp_mutex); in alloc_ubifs_info()
2207 mutex_init(&c->tnc_mutex); in alloc_ubifs_info()
2208 mutex_init(&c->log_mutex); in alloc_ubifs_info()
2209 mutex_init(&c->umount_mutex); in alloc_ubifs_info()
2210 mutex_init(&c->bu_mutex); in alloc_ubifs_info()
2211 mutex_init(&c->write_reserve_mutex); in alloc_ubifs_info()
2212 init_waitqueue_head(&c->cmt_wq); in alloc_ubifs_info()
2213 c->buds = RB_ROOT; in alloc_ubifs_info()
2214 c->old_idx = RB_ROOT; in alloc_ubifs_info()
2215 c->size_tree = RB_ROOT; in alloc_ubifs_info()
2216 c->orph_tree = RB_ROOT; in alloc_ubifs_info()
2217 INIT_LIST_HEAD(&c->infos_list); in alloc_ubifs_info()
2218 INIT_LIST_HEAD(&c->idx_gc); in alloc_ubifs_info()
2219 INIT_LIST_HEAD(&c->replay_list); in alloc_ubifs_info()
2220 INIT_LIST_HEAD(&c->replay_buds); in alloc_ubifs_info()
2221 INIT_LIST_HEAD(&c->uncat_list); in alloc_ubifs_info()
2222 INIT_LIST_HEAD(&c->empty_list); in alloc_ubifs_info()
2223 INIT_LIST_HEAD(&c->freeable_list); in alloc_ubifs_info()
2224 INIT_LIST_HEAD(&c->frdi_idx_list); in alloc_ubifs_info()
2225 INIT_LIST_HEAD(&c->unclean_leb_list); in alloc_ubifs_info()
2226 INIT_LIST_HEAD(&c->old_buds); in alloc_ubifs_info()
2227 INIT_LIST_HEAD(&c->orph_list); in alloc_ubifs_info()
2228 INIT_LIST_HEAD(&c->orph_new); in alloc_ubifs_info()
2229 c->no_chk_data_crc = 1; in alloc_ubifs_info()
2231 c->highest_inum = UBIFS_FIRST_INO; in alloc_ubifs_info()
2232 c->lhead_lnum = c->ltail_lnum = UBIFS_LOG_LNUM; in alloc_ubifs_info()
2234 ubi_get_volume_info(ubi, &c->vi); in alloc_ubifs_info()
2235 ubi_get_device_info(c->vi.ubi_num, &c->di); in alloc_ubifs_info()
2237 return c; in alloc_ubifs_info()
2242 struct ubifs_info *c = sb->s_fs_info; in ubifs_fill_super() local
2246 c->vfs_sb = sb; in ubifs_fill_super()
2249 c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READWRITE); in ubifs_fill_super()
2252 c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY); in ubifs_fill_super()
2255 if (IS_ERR(c->ubi)) { in ubifs_fill_super()
2256 err = PTR_ERR(c->ubi); in ubifs_fill_super()
2267 * Read-ahead will be disabled because @c->bdi.ra_pages is 0. in ubifs_fill_super()
2269 c->bdi.name = "ubifs", in ubifs_fill_super()
2270 c->bdi.capabilities = 0; in ubifs_fill_super()
2271 err = bdi_init(&c->bdi); in ubifs_fill_super()
2274 err = bdi_register(&c->bdi, NULL, "ubifs_%d_%d", in ubifs_fill_super()
2275 c->vi.ubi_num, c->vi.vol_id); in ubifs_fill_super()
2279 err = ubifs_parse_options(c, data, 0); in ubifs_fill_super()
2283 sb->s_bdi = &c->bdi; in ubifs_fill_super()
2285 sb->s_fs_info = c; in ubifs_fill_super()
2289 sb->s_maxbytes = c->max_inode_sz = key_max_inode_size(c); in ubifs_fill_super()
2290 if (c->max_inode_sz > MAX_LFS_FILESIZE) in ubifs_fill_super()
2291 sb->s_maxbytes = c->max_inode_sz = MAX_LFS_FILESIZE; in ubifs_fill_super()
2297 mutex_lock(&c->umount_mutex); in ubifs_fill_super()
2298 err = mount_ubifs(c); in ubifs_fill_super()
2321 mutex_unlock(&c->umount_mutex); in ubifs_fill_super()
2325 ubifs_umount(c); in ubifs_fill_super()
2327 mutex_unlock(&c->umount_mutex); in ubifs_fill_super()
2330 bdi_destroy(&c->bdi); in ubifs_fill_super()
2333 ubi_close_volume(c->ubi); in ubifs_fill_super()
2341 struct ubifs_info *c = sb->s_fs_info; in sb_test() local
2343 return c->vi.cdev == c1->vi.cdev; in sb_test()
2451 struct ubifs_info *c; in ubifs_mount() local
2469 c = alloc_ubifs_info(ubi); in ubifs_mount()
2470 if (!c) { in ubifs_mount()
2475 dbg_gen("opened ubi%d_%d", c->vi.ubi_num, c->vi.vol_id); in ubifs_mount()
2477 sb = sget(fs_type, sb_test, sb_set, flags, c); in ubifs_mount()
2480 kfree(c); in ubifs_mount()
2486 kfree(c); in ubifs_mount()
2522 struct ubifs_info *c = s->s_fs_info; in kill_ubifs_super() local
2526 kfree(c); in kill_ubifs_super()