Lines Matching refs:sbi

99 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);  in hfsplus_system_write_inode()  local
100 struct hfsplus_vh *vhdr = sbi->s_vhdr; in hfsplus_system_write_inode()
107 tree = sbi->ext_tree; in hfsplus_system_write_inode()
111 tree = sbi->cat_tree; in hfsplus_system_write_inode()
121 tree = sbi->attr_tree; in hfsplus_system_write_inode()
128 set_bit(HFSPLUS_SB_WRITEBACKUP, &sbi->flags); in hfsplus_system_write_inode()
175 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); in hfsplus_sync_fs() local
176 struct hfsplus_vh *vhdr = sbi->s_vhdr; in hfsplus_sync_fs()
193 error = filemap_write_and_wait(sbi->cat_tree->inode->i_mapping); in hfsplus_sync_fs()
194 error2 = filemap_write_and_wait(sbi->ext_tree->inode->i_mapping); in hfsplus_sync_fs()
197 if (sbi->attr_tree) { in hfsplus_sync_fs()
199 filemap_write_and_wait(sbi->attr_tree->inode->i_mapping); in hfsplus_sync_fs()
203 error2 = filemap_write_and_wait(sbi->alloc_file->i_mapping); in hfsplus_sync_fs()
207 mutex_lock(&sbi->vh_mutex); in hfsplus_sync_fs()
208 mutex_lock(&sbi->alloc_mutex); in hfsplus_sync_fs()
209 vhdr->free_blocks = cpu_to_be32(sbi->free_blocks); in hfsplus_sync_fs()
210 vhdr->next_cnid = cpu_to_be32(sbi->next_cnid); in hfsplus_sync_fs()
211 vhdr->folder_count = cpu_to_be32(sbi->folder_count); in hfsplus_sync_fs()
212 vhdr->file_count = cpu_to_be32(sbi->file_count); in hfsplus_sync_fs()
214 if (test_and_clear_bit(HFSPLUS_SB_WRITEBACKUP, &sbi->flags)) { in hfsplus_sync_fs()
215 memcpy(sbi->s_backup_vhdr, sbi->s_vhdr, sizeof(*sbi->s_vhdr)); in hfsplus_sync_fs()
220 sbi->part_start + HFSPLUS_VOLHEAD_SECTOR, in hfsplus_sync_fs()
221 sbi->s_vhdr_buf, NULL, WRITE_SYNC); in hfsplus_sync_fs()
228 sbi->part_start + sbi->sect_count - 2, in hfsplus_sync_fs()
229 sbi->s_backup_vhdr_buf, NULL, WRITE_SYNC); in hfsplus_sync_fs()
233 mutex_unlock(&sbi->alloc_mutex); in hfsplus_sync_fs()
234 mutex_unlock(&sbi->vh_mutex); in hfsplus_sync_fs()
236 if (!test_bit(HFSPLUS_SB_NOBARRIER, &sbi->flags)) in hfsplus_sync_fs()
245 struct hfsplus_sb_info *sbi; in delayed_sync_fs() local
247 sbi = container_of(work, struct hfsplus_sb_info, sync_work.work); in delayed_sync_fs()
249 spin_lock(&sbi->work_lock); in delayed_sync_fs()
250 sbi->work_queued = 0; in delayed_sync_fs()
251 spin_unlock(&sbi->work_lock); in delayed_sync_fs()
253 err = hfsplus_sync_fs(sbi->alloc_file->i_sb, 1); in delayed_sync_fs()
260 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); in hfsplus_mark_mdb_dirty() local
266 spin_lock(&sbi->work_lock); in hfsplus_mark_mdb_dirty()
267 if (!sbi->work_queued) { in hfsplus_mark_mdb_dirty()
269 queue_delayed_work(system_long_wq, &sbi->sync_work, delay); in hfsplus_mark_mdb_dirty()
270 sbi->work_queued = 1; in hfsplus_mark_mdb_dirty()
272 spin_unlock(&sbi->work_lock); in hfsplus_mark_mdb_dirty()
277 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); in hfsplus_put_super() local
281 cancel_delayed_work_sync(&sbi->sync_work); in hfsplus_put_super()
283 if (!(sb->s_flags & MS_RDONLY) && sbi->s_vhdr) { in hfsplus_put_super()
284 struct hfsplus_vh *vhdr = sbi->s_vhdr; in hfsplus_put_super()
293 hfs_btree_close(sbi->attr_tree); in hfsplus_put_super()
294 hfs_btree_close(sbi->cat_tree); in hfsplus_put_super()
295 hfs_btree_close(sbi->ext_tree); in hfsplus_put_super()
296 iput(sbi->alloc_file); in hfsplus_put_super()
297 iput(sbi->hidden_dir); in hfsplus_put_super()
298 kfree(sbi->s_vhdr_buf); in hfsplus_put_super()
299 kfree(sbi->s_backup_vhdr_buf); in hfsplus_put_super()
300 unload_nls(sbi->nls); in hfsplus_put_super()
308 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); in hfsplus_statfs() local
313 buf->f_blocks = sbi->total_blocks << sbi->fs_shift; in hfsplus_statfs()
314 buf->f_bfree = sbi->free_blocks << sbi->fs_shift; in hfsplus_statfs()
317 buf->f_ffree = 0xFFFFFFFF - sbi->next_cnid; in hfsplus_statfs()
373 struct hfsplus_sb_info *sbi; in hfsplus_fill_super() local
383 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); in hfsplus_fill_super()
384 if (!sbi) in hfsplus_fill_super()
387 sb->s_fs_info = sbi; in hfsplus_fill_super()
388 mutex_init(&sbi->alloc_mutex); in hfsplus_fill_super()
389 mutex_init(&sbi->vh_mutex); in hfsplus_fill_super()
390 spin_lock_init(&sbi->work_lock); in hfsplus_fill_super()
391 INIT_DELAYED_WORK(&sbi->sync_work, delayed_sync_fs); in hfsplus_fill_super()
392 hfsplus_fill_defaults(sbi); in hfsplus_fill_super()
395 if (!hfsplus_parse_options(data, sbi)) { in hfsplus_fill_super()
401 nls = sbi->nls; in hfsplus_fill_super()
402 sbi->nls = load_nls("utf8"); in hfsplus_fill_super()
403 if (!sbi->nls) { in hfsplus_fill_super()
414 vhdr = sbi->s_vhdr; in hfsplus_fill_super()
423 sbi->total_blocks = be32_to_cpu(vhdr->total_blocks); in hfsplus_fill_super()
424 sbi->free_blocks = be32_to_cpu(vhdr->free_blocks); in hfsplus_fill_super()
425 sbi->next_cnid = be32_to_cpu(vhdr->next_cnid); in hfsplus_fill_super()
426 sbi->file_count = be32_to_cpu(vhdr->file_count); in hfsplus_fill_super()
427 sbi->folder_count = be32_to_cpu(vhdr->folder_count); in hfsplus_fill_super()
428 sbi->data_clump_blocks = in hfsplus_fill_super()
429 be32_to_cpu(vhdr->data_clump_sz) >> sbi->alloc_blksz_shift; in hfsplus_fill_super()
430 if (!sbi->data_clump_blocks) in hfsplus_fill_super()
431 sbi->data_clump_blocks = 1; in hfsplus_fill_super()
432 sbi->rsrc_clump_blocks = in hfsplus_fill_super()
433 be32_to_cpu(vhdr->rsrc_clump_sz) >> sbi->alloc_blksz_shift; in hfsplus_fill_super()
434 if (!sbi->rsrc_clump_blocks) in hfsplus_fill_super()
435 sbi->rsrc_clump_blocks = 1; in hfsplus_fill_super()
438 last_fs_block = sbi->total_blocks - 1; in hfsplus_fill_super()
439 last_fs_page = (last_fs_block << sbi->alloc_blksz_shift) >> in hfsplus_fill_super()
442 if ((last_fs_block > (sector_t)(~0ULL) >> (sbi->alloc_blksz_shift - 9)) || in hfsplus_fill_super()
455 } else if (test_and_clear_bit(HFSPLUS_SB_FORCE, &sbi->flags)) { in hfsplus_fill_super()
469 sbi->ext_tree = hfs_btree_open(sb, HFSPLUS_EXT_CNID); in hfsplus_fill_super()
470 if (!sbi->ext_tree) { in hfsplus_fill_super()
474 sbi->cat_tree = hfs_btree_open(sb, HFSPLUS_CAT_CNID); in hfsplus_fill_super()
475 if (!sbi->cat_tree) { in hfsplus_fill_super()
479 atomic_set(&sbi->attr_tree_state, HFSPLUS_EMPTY_ATTR_TREE); in hfsplus_fill_super()
481 sbi->attr_tree = hfs_btree_open(sb, HFSPLUS_ATTR_CNID); in hfsplus_fill_super()
482 if (!sbi->attr_tree) { in hfsplus_fill_super()
486 atomic_set(&sbi->attr_tree_state, HFSPLUS_VALID_ATTR_TREE); in hfsplus_fill_super()
496 sbi->alloc_file = inode; in hfsplus_fill_super()
515 err = hfs_find_init(sbi->cat_tree, &fd); in hfsplus_fill_super()
530 sbi->hidden_dir = inode; in hfsplus_fill_super()
546 if (!sbi->hidden_dir) { in hfsplus_fill_super()
547 mutex_lock(&sbi->vh_mutex); in hfsplus_fill_super()
548 sbi->hidden_dir = hfsplus_new_inode(sb, S_IFDIR); in hfsplus_fill_super()
549 if (!sbi->hidden_dir) { in hfsplus_fill_super()
550 mutex_unlock(&sbi->vh_mutex); in hfsplus_fill_super()
554 err = hfsplus_create_cat(sbi->hidden_dir->i_ino, root, in hfsplus_fill_super()
555 &str, sbi->hidden_dir); in hfsplus_fill_super()
557 mutex_unlock(&sbi->vh_mutex); in hfsplus_fill_super()
561 err = hfsplus_init_inode_security(sbi->hidden_dir, in hfsplus_fill_super()
570 hfsplus_delete_cat(sbi->hidden_dir->i_ino, in hfsplus_fill_super()
572 mutex_unlock(&sbi->vh_mutex); in hfsplus_fill_super()
576 mutex_unlock(&sbi->vh_mutex); in hfsplus_fill_super()
577 hfsplus_mark_inode_dirty(sbi->hidden_dir, in hfsplus_fill_super()
582 unload_nls(sbi->nls); in hfsplus_fill_super()
583 sbi->nls = nls; in hfsplus_fill_super()
587 iput(sbi->hidden_dir); in hfsplus_fill_super()
592 iput(sbi->alloc_file); in hfsplus_fill_super()
594 hfs_btree_close(sbi->attr_tree); in hfsplus_fill_super()
596 hfs_btree_close(sbi->cat_tree); in hfsplus_fill_super()
598 hfs_btree_close(sbi->ext_tree); in hfsplus_fill_super()
600 kfree(sbi->s_vhdr_buf); in hfsplus_fill_super()
601 kfree(sbi->s_backup_vhdr_buf); in hfsplus_fill_super()
603 unload_nls(sbi->nls); in hfsplus_fill_super()
605 kfree(sbi); in hfsplus_fill_super()