Lines Matching refs:sb
21 static void fat12_ent_blocknr(struct super_block *sb, int entry, in fat12_ent_blocknr() argument
24 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat12_ent_blocknr()
27 *offset = bytes & (sb->s_blocksize - 1); in fat12_ent_blocknr()
28 *blocknr = sbi->fat_start + (bytes >> sb->s_blocksize_bits); in fat12_ent_blocknr()
31 static void fat_ent_blocknr(struct super_block *sb, int entry, in fat_ent_blocknr() argument
34 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_ent_blocknr()
37 *offset = bytes & (sb->s_blocksize - 1); in fat_ent_blocknr()
38 *blocknr = sbi->fat_start + (bytes >> sb->s_blocksize_bits); in fat_ent_blocknr()
67 static int fat12_ent_bread(struct super_block *sb, struct fat_entry *fatent, in fat12_ent_bread() argument
72 WARN_ON(blocknr < MSDOS_SB(sb)->fat_start); in fat12_ent_bread()
73 fatent->fat_inode = MSDOS_SB(sb)->fat_inode; in fat12_ent_bread()
75 bhs[0] = sb_bread(sb, blocknr); in fat12_ent_bread()
79 if ((offset + 1) < sb->s_blocksize) in fat12_ent_bread()
84 bhs[1] = sb_bread(sb, blocknr); in fat12_ent_bread()
95 fat_msg(sb, KERN_ERR, "FAT read failed (blocknr %llu)", (llu)blocknr); in fat12_ent_bread()
99 static int fat_ent_bread(struct super_block *sb, struct fat_entry *fatent, in fat_ent_bread() argument
102 struct fatent_operations *ops = MSDOS_SB(sb)->fatent_ops; in fat_ent_bread()
104 WARN_ON(blocknr < MSDOS_SB(sb)->fat_start); in fat_ent_bread()
105 fatent->fat_inode = MSDOS_SB(sb)->fat_inode; in fat_ent_bread()
106 fatent->bhs[0] = sb_bread(sb, blocknr); in fat_ent_bread()
108 fat_msg(sb, KERN_ERR, "FAT read failed (blocknr %llu)", in fat_ent_bread()
286 void fat_ent_access_init(struct super_block *sb) in fat_ent_access_init() argument
288 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_ent_access_init()
308 static void mark_fsinfo_dirty(struct super_block *sb) in mark_fsinfo_dirty() argument
310 struct msdos_sb_info *sbi = MSDOS_SB(sb); in mark_fsinfo_dirty()
312 if (sb->s_flags & MS_RDONLY || sbi->fat_bits != 32) in mark_fsinfo_dirty()
318 static inline int fat_ent_update_ptr(struct super_block *sb, in fat_ent_update_ptr() argument
322 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_ent_update_ptr()
330 if ((offset + 1) < sb->s_blocksize) { in fat_ent_update_ptr()
350 struct super_block *sb = inode->i_sb; in fat_ent_read() local
358 fat_fs_error(sb, "invalid access to FAT (entry 0x%08x)", entry); in fat_ent_read()
363 ops->ent_blocknr(sb, entry, &offset, &blocknr); in fat_ent_read()
365 if (!fat_ent_update_ptr(sb, fatent, offset, blocknr)) { in fat_ent_read()
367 err = ops->ent_bread(sb, fatent, offset, blocknr); in fat_ent_read()
375 static int fat_mirror_bhs(struct super_block *sb, struct buffer_head **bhs, in fat_mirror_bhs() argument
378 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_mirror_bhs()
387 c_bh = sb_getblk(sb, backup_fat + bhs[n]->b_blocknr); in fat_mirror_bhs()
392 memcpy(c_bh->b_data, bhs[n]->b_data, sb->s_blocksize); in fat_mirror_bhs()
395 if (sb->s_flags & MS_SYNCHRONOUS) in fat_mirror_bhs()
409 struct super_block *sb = inode->i_sb; in fat_ent_write() local
410 struct fatent_operations *ops = MSDOS_SB(sb)->fatent_ops; in fat_ent_write()
419 return fat_mirror_bhs(sb, fatent->bhs, fatent->nr_bhs); in fat_ent_write()
432 static inline int fat_ent_read_block(struct super_block *sb, in fat_ent_read_block() argument
435 struct fatent_operations *ops = MSDOS_SB(sb)->fatent_ops; in fat_ent_read_block()
440 ops->ent_blocknr(sb, fatent->entry, &offset, &blocknr); in fat_ent_read_block()
441 return ops->ent_bread(sb, fatent, offset, blocknr); in fat_ent_read_block()
464 struct super_block *sb = inode->i_sb; in fat_alloc_clusters() local
465 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_alloc_clusters()
489 err = fat_ent_read_block(sb, &fatent); in fat_alloc_clusters()
533 mark_fsinfo_dirty(sb); in fat_alloc_clusters()
539 err = fat_mirror_bhs(sb, bhs, nr_bhs); in fat_alloc_clusters()
552 struct super_block *sb = inode->i_sb; in fat_free_clusters() local
553 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_free_clusters()
569 fat_fs_error(sb, "%s: deleting FAT entry beyond EOF", in fat_free_clusters()
584 sb_issue_discard(sb, in fat_free_clusters()
600 if (sb->s_flags & MS_SYNCHRONOUS) { in fat_free_clusters()
605 err = fat_mirror_bhs(sb, bhs, nr_bhs); in fat_free_clusters()
615 if (sb->s_flags & MS_SYNCHRONOUS) { in fat_free_clusters()
620 err = fat_mirror_bhs(sb, bhs, nr_bhs); in fat_free_clusters()
627 mark_fsinfo_dirty(sb); in fat_free_clusters()
636 static void fat_ent_reada(struct super_block *sb, struct fat_entry *fatent, in fat_ent_reada() argument
639 struct fatent_operations *ops = MSDOS_SB(sb)->fatent_ops; in fat_ent_reada()
643 ops->ent_blocknr(sb, fatent->entry, &offset, &blocknr); in fat_ent_reada()
646 sb_breadahead(sb, blocknr + i); in fat_ent_reada()
649 int fat_count_free_clusters(struct super_block *sb) in fat_count_free_clusters() argument
651 struct msdos_sb_info *sbi = MSDOS_SB(sb); in fat_count_free_clusters()
661 reada_blocks = FAT_READA_SIZE >> sb->s_blocksize_bits; in fat_count_free_clusters()
672 fat_ent_reada(sb, &fatent, min(reada_blocks, rest)); in fat_count_free_clusters()
676 err = fat_ent_read_block(sb, &fatent); in fat_count_free_clusters()
687 mark_fsinfo_dirty(sb); in fat_count_free_clusters()