Lines Matching refs:sbi

26 	struct msdos_sb_info *sbi = MSDOS_SB(sb);  in fat12_ent_blocknr()  local
28 WARN_ON(!fat_valid_entry(sbi, entry)); in fat12_ent_blocknr()
30 *blocknr = sbi->fat_start + (bytes >> sb->s_blocksize_bits); in fat12_ent_blocknr()
36 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_ent_blocknr() local
37 int bytes = (entry << sbi->fatent_shift); in fat_ent_blocknr()
38 WARN_ON(!fat_valid_entry(sbi, entry)); in fat_ent_blocknr()
40 *blocknr = sbi->fat_start + (bytes >> sb->s_blocksize_bits); in fat_ent_blocknr()
279 static inline void lock_fat(struct msdos_sb_info *sbi) in lock_fat() argument
281 mutex_lock(&sbi->fat_lock); in lock_fat()
284 static inline void unlock_fat(struct msdos_sb_info *sbi) in unlock_fat() argument
286 mutex_unlock(&sbi->fat_lock); in unlock_fat()
291 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_ent_access_init() local
293 mutex_init(&sbi->fat_lock); in fat_ent_access_init()
295 if (is_fat32(sbi)) { in fat_ent_access_init()
296 sbi->fatent_shift = 2; in fat_ent_access_init()
297 sbi->fatent_ops = &fat32_ops; in fat_ent_access_init()
298 } else if (is_fat16(sbi)) { in fat_ent_access_init()
299 sbi->fatent_shift = 1; in fat_ent_access_init()
300 sbi->fatent_ops = &fat16_ops; in fat_ent_access_init()
301 } else if (is_fat12(sbi)) { 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()
305 fat_fs_error(sb, "invalid FAT variant, %u bits", sbi->fat_bits); in fat_ent_access_init()
311 struct msdos_sb_info *sbi = MSDOS_SB(sb); in mark_fsinfo_dirty() local
313 if (sb_rdonly(sb) || !is_fat32(sbi)) in mark_fsinfo_dirty()
316 __mark_inode_dirty(sbi->fsinfo_inode, I_DIRTY_SYNC); in mark_fsinfo_dirty()
323 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_ent_update_ptr() local
324 const struct fatent_operations *ops = sbi->fatent_ops; in fat_ent_update_ptr()
330 if (is_fat12(sbi)) { in fat_ent_update_ptr()
352 struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb); in fat_ent_read() local
353 const struct fatent_operations *ops = sbi->fatent_ops; in fat_ent_read()
357 if (!fat_valid_entry(sbi, entry)) { in fat_ent_read()
379 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_mirror_bhs() local
384 for (copy = 1; copy < sbi->fats; copy++) { in fat_mirror_bhs()
385 sector_t backup_fat = sbi->fat_length * copy; in fat_mirror_bhs()
398 mark_buffer_dirty_inode(c_bh, sbi->fat_inode); in fat_mirror_bhs()
426 static inline int fat_ent_next(struct msdos_sb_info *sbi, in fat_ent_next() argument
429 if (sbi->fatent_ops->ent_next(fatent)) { in fat_ent_next()
430 if (fatent->entry < sbi->max_cluster) in fat_ent_next()
469 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_alloc_clusters() local
470 const struct fatent_operations *ops = sbi->fatent_ops; in fat_alloc_clusters()
477 lock_fat(sbi); in fat_alloc_clusters()
478 if (sbi->free_clusters != -1 && sbi->free_clus_valid && in fat_alloc_clusters()
479 sbi->free_clusters < nr_cluster) { in fat_alloc_clusters()
480 unlock_fat(sbi); in fat_alloc_clusters()
488 fatent_set_entry(&fatent, sbi->prev_free + 1); in fat_alloc_clusters()
489 while (count < sbi->max_cluster) { in fat_alloc_clusters()
490 if (fatent.entry >= sbi->max_cluster) in fat_alloc_clusters()
509 sbi->prev_free = entry; in fat_alloc_clusters()
510 if (sbi->free_clusters != -1) in fat_alloc_clusters()
511 sbi->free_clusters--; in fat_alloc_clusters()
525 if (count == sbi->max_cluster) in fat_alloc_clusters()
527 } while (fat_ent_next(sbi, &fatent)); in fat_alloc_clusters()
531 sbi->free_clusters = 0; in fat_alloc_clusters()
532 sbi->free_clus_valid = 1; in fat_alloc_clusters()
536 unlock_fat(sbi); in fat_alloc_clusters()
557 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_free_clusters() local
558 const struct fatent_operations *ops = sbi->fatent_ops; in fat_free_clusters()
566 lock_fat(sbi); in fat_free_clusters()
579 if (sbi->options.discard) { in fat_free_clusters()
589 fat_clus_to_blknr(sbi, first_cl), in fat_free_clusters()
590 nr_clus * sbi->sec_per_clus, in fat_free_clusters()
598 if (sbi->free_clusters != -1) { in fat_free_clusters()
599 sbi->free_clusters++; in fat_free_clusters()
629 unlock_fat(sbi); in fat_free_clusters()
650 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_ra_init() local
651 const struct fatent_operations *ops = sbi->fatent_ops; in fat_ra_init()
690 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_ent_reada() local
691 const struct fatent_operations *ops = sbi->fatent_ops; in fat_ent_reada()
718 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_count_free_clusters() local
719 const struct fatent_operations *ops = sbi->fatent_ops; in fat_count_free_clusters()
724 lock_fat(sbi); in fat_count_free_clusters()
725 if (sbi->free_clusters != -1 && sbi->free_clus_valid) in fat_count_free_clusters()
731 fat_ra_init(sb, &fatent_ra, &fatent, sbi->max_cluster); in fat_count_free_clusters()
732 while (fatent.entry < sbi->max_cluster) { in fat_count_free_clusters()
743 } while (fat_ent_next(sbi, &fatent)); in fat_count_free_clusters()
746 sbi->free_clusters = free; in fat_count_free_clusters()
747 sbi->free_clus_valid = 1; in fat_count_free_clusters()
751 unlock_fat(sbi); in fat_count_free_clusters()
757 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_trim_clusters() local
758 return sb_issue_discard(sb, fat_clus_to_blknr(sbi, clus), in fat_trim_clusters()
759 nr_clus * sbi->sec_per_clus, GFP_NOFS, 0); in fat_trim_clusters()
765 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_trim_fs() local
766 const struct fatent_operations *ops = sbi->fatent_ops; in fat_trim_fs()
779 ent_start = max_t(u64, range->start>>sbi->cluster_bits, FAT_START_ENT); in fat_trim_fs()
780 ent_end = ent_start + (range->len >> sbi->cluster_bits) - 1; in fat_trim_fs()
781 minlen = range->minlen >> sbi->cluster_bits; in fat_trim_fs()
783 if (ent_start >= sbi->max_cluster || range->len < sbi->cluster_size) in fat_trim_fs()
785 if (ent_end >= sbi->max_cluster) in fat_trim_fs()
786 ent_end = sbi->max_cluster - 1; in fat_trim_fs()
789 lock_fat(sbi); in fat_trim_fs()
815 } while (fat_ent_next(sbi, &fatent) && fatent.entry <= ent_end); in fat_trim_fs()
824 unlock_fat(sbi); in fat_trim_fs()
826 lock_fat(sbi); in fat_trim_fs()
843 unlock_fat(sbi); in fat_trim_fs()
845 range->len = trimmed << sbi->cluster_bits; in fat_trim_fs()