Lines Matching refs:sbi
24 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat12_ent_blocknr() local
26 WARN_ON(entry < FAT_START_ENT || sbi->max_cluster <= entry); in fat12_ent_blocknr()
28 *blocknr = sbi->fat_start + (bytes >> sb->s_blocksize_bits); in fat12_ent_blocknr()
34 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_ent_blocknr() local
35 int bytes = (entry << sbi->fatent_shift); in fat_ent_blocknr()
36 WARN_ON(entry < FAT_START_ENT || sbi->max_cluster <= entry); in fat_ent_blocknr()
38 *blocknr = sbi->fat_start + (bytes >> sb->s_blocksize_bits); in fat_ent_blocknr()
276 static inline void lock_fat(struct msdos_sb_info *sbi) in lock_fat() argument
278 mutex_lock(&sbi->fat_lock); in lock_fat()
281 static inline void unlock_fat(struct msdos_sb_info *sbi) in unlock_fat() argument
283 mutex_unlock(&sbi->fat_lock); in unlock_fat()
288 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_ent_access_init() local
290 mutex_init(&sbi->fat_lock); in fat_ent_access_init()
292 switch (sbi->fat_bits) { in fat_ent_access_init()
294 sbi->fatent_shift = 2; in fat_ent_access_init()
295 sbi->fatent_ops = &fat32_ops; in fat_ent_access_init()
298 sbi->fatent_shift = 1; in fat_ent_access_init()
299 sbi->fatent_ops = &fat16_ops; in fat_ent_access_init()
302 sbi->fatent_shift = -1; in fat_ent_access_init()
303 sbi->fatent_ops = &fat12_ops; in fat_ent_access_init()
310 struct msdos_sb_info *sbi = MSDOS_SB(sb); in mark_fsinfo_dirty() local
312 if (sb->s_flags & MS_RDONLY || sbi->fat_bits != 32) in mark_fsinfo_dirty()
315 __mark_inode_dirty(sbi->fsinfo_inode, I_DIRTY_SYNC); in mark_fsinfo_dirty()
322 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_ent_update_ptr() local
323 struct fatent_operations *ops = sbi->fatent_ops; in fat_ent_update_ptr()
329 if (sbi->fat_bits == 12) { in fat_ent_update_ptr()
351 struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb); in fat_ent_read() local
352 struct fatent_operations *ops = sbi->fatent_ops; in fat_ent_read()
356 if (entry < FAT_START_ENT || sbi->max_cluster <= entry) { in fat_ent_read()
378 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_mirror_bhs() local
383 for (copy = 1; copy < sbi->fats; copy++) { in fat_mirror_bhs()
384 sector_t backup_fat = sbi->fat_length * copy; in fat_mirror_bhs()
394 mark_buffer_dirty_inode(c_bh, sbi->fat_inode); in fat_mirror_bhs()
422 static inline int fat_ent_next(struct msdos_sb_info *sbi, in fat_ent_next() argument
425 if (sbi->fatent_ops->ent_next(fatent)) { in fat_ent_next()
426 if (fatent->entry < sbi->max_cluster) in fat_ent_next()
465 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_alloc_clusters() local
466 struct fatent_operations *ops = sbi->fatent_ops; in fat_alloc_clusters()
473 lock_fat(sbi); in fat_alloc_clusters()
474 if (sbi->free_clusters != -1 && sbi->free_clus_valid && in fat_alloc_clusters()
475 sbi->free_clusters < nr_cluster) { in fat_alloc_clusters()
476 unlock_fat(sbi); in fat_alloc_clusters()
484 fatent_set_entry(&fatent, sbi->prev_free + 1); in fat_alloc_clusters()
485 while (count < sbi->max_cluster) { in fat_alloc_clusters()
486 if (fatent.entry >= sbi->max_cluster) in fat_alloc_clusters()
505 sbi->prev_free = entry; in fat_alloc_clusters()
506 if (sbi->free_clusters != -1) in fat_alloc_clusters()
507 sbi->free_clusters--; in fat_alloc_clusters()
521 if (count == sbi->max_cluster) in fat_alloc_clusters()
523 } while (fat_ent_next(sbi, &fatent)); in fat_alloc_clusters()
527 sbi->free_clusters = 0; in fat_alloc_clusters()
528 sbi->free_clus_valid = 1; in fat_alloc_clusters()
532 unlock_fat(sbi); in fat_alloc_clusters()
553 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_free_clusters() local
554 struct fatent_operations *ops = sbi->fatent_ops; in fat_free_clusters()
562 lock_fat(sbi); in fat_free_clusters()
575 if (sbi->options.discard) { in fat_free_clusters()
585 fat_clus_to_blknr(sbi, first_cl), in fat_free_clusters()
586 nr_clus * sbi->sec_per_clus, in fat_free_clusters()
594 if (sbi->free_clusters != -1) { in fat_free_clusters()
595 sbi->free_clusters++; in fat_free_clusters()
625 unlock_fat(sbi); in fat_free_clusters()
651 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_count_free_clusters() local
652 struct fatent_operations *ops = sbi->fatent_ops; in fat_count_free_clusters()
657 lock_fat(sbi); in fat_count_free_clusters()
658 if (sbi->free_clusters != -1 && sbi->free_clus_valid) in fat_count_free_clusters()
668 while (fatent.entry < sbi->max_cluster) { in fat_count_free_clusters()
671 unsigned long rest = sbi->fat_length - cur_block; in fat_count_free_clusters()
683 } while (fat_ent_next(sbi, &fatent)); in fat_count_free_clusters()
685 sbi->free_clusters = free; in fat_count_free_clusters()
686 sbi->free_clus_valid = 1; in fat_count_free_clusters()
690 unlock_fat(sbi); in fat_count_free_clusters()