diff options
Diffstat (limited to 'fs/fat/inode.c')
-rw-r--r-- | fs/fat/inode.c | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 31b7174176ba..ab96ae823753 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -50,14 +50,14 @@ static int fat_add_cluster(struct inode *inode) | |||
50 | return err; | 50 | return err; |
51 | } | 51 | } |
52 | 52 | ||
53 | static int __fat_get_blocks(struct inode *inode, sector_t iblock, | 53 | static inline int __fat_get_block(struct inode *inode, sector_t iblock, |
54 | unsigned long *max_blocks, | 54 | unsigned long *max_blocks, |
55 | struct buffer_head *bh_result, int create) | 55 | struct buffer_head *bh_result, int create) |
56 | { | 56 | { |
57 | struct super_block *sb = inode->i_sb; | 57 | struct super_block *sb = inode->i_sb; |
58 | struct msdos_sb_info *sbi = MSDOS_SB(sb); | 58 | struct msdos_sb_info *sbi = MSDOS_SB(sb); |
59 | sector_t phys; | ||
60 | unsigned long mapped_blocks; | 59 | unsigned long mapped_blocks; |
60 | sector_t phys; | ||
61 | int err, offset; | 61 | int err, offset; |
62 | 62 | ||
63 | err = fat_bmap(inode, iblock, &phys, &mapped_blocks); | 63 | err = fat_bmap(inode, iblock, &phys, &mapped_blocks); |
@@ -73,7 +73,7 @@ static int __fat_get_blocks(struct inode *inode, sector_t iblock, | |||
73 | 73 | ||
74 | if (iblock != MSDOS_I(inode)->mmu_private >> sb->s_blocksize_bits) { | 74 | if (iblock != MSDOS_I(inode)->mmu_private >> sb->s_blocksize_bits) { |
75 | fat_fs_panic(sb, "corrupted file size (i_pos %lld, %lld)", | 75 | fat_fs_panic(sb, "corrupted file size (i_pos %lld, %lld)", |
76 | MSDOS_I(inode)->i_pos, MSDOS_I(inode)->mmu_private); | 76 | MSDOS_I(inode)->i_pos, MSDOS_I(inode)->mmu_private); |
77 | return -EIO; | 77 | return -EIO; |
78 | } | 78 | } |
79 | 79 | ||
@@ -93,34 +93,29 @@ static int __fat_get_blocks(struct inode *inode, sector_t iblock, | |||
93 | err = fat_bmap(inode, iblock, &phys, &mapped_blocks); | 93 | err = fat_bmap(inode, iblock, &phys, &mapped_blocks); |
94 | if (err) | 94 | if (err) |
95 | return err; | 95 | return err; |
96 | |||
96 | BUG_ON(!phys); | 97 | BUG_ON(!phys); |
97 | BUG_ON(*max_blocks != mapped_blocks); | 98 | BUG_ON(*max_blocks != mapped_blocks); |
98 | set_buffer_new(bh_result); | 99 | set_buffer_new(bh_result); |
99 | map_bh(bh_result, sb, phys); | 100 | map_bh(bh_result, sb, phys); |
101 | |||
100 | return 0; | 102 | return 0; |
101 | } | 103 | } |
102 | 104 | ||
103 | static int fat_get_blocks(struct inode *inode, sector_t iblock, | 105 | static int fat_get_block(struct inode *inode, sector_t iblock, |
104 | struct buffer_head *bh_result, int create) | 106 | struct buffer_head *bh_result, int create) |
105 | { | 107 | { |
106 | struct super_block *sb = inode->i_sb; | 108 | struct super_block *sb = inode->i_sb; |
107 | int err; | ||
108 | unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits; | 109 | unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits; |
110 | int err; | ||
109 | 111 | ||
110 | err = __fat_get_blocks(inode, iblock, &max_blocks, bh_result, create); | 112 | err = __fat_get_block(inode, iblock, &max_blocks, bh_result, create); |
111 | if (err) | 113 | if (err) |
112 | return err; | 114 | return err; |
113 | bh_result->b_size = max_blocks << sb->s_blocksize_bits; | 115 | bh_result->b_size = max_blocks << sb->s_blocksize_bits; |
114 | return 0; | 116 | return 0; |
115 | } | 117 | } |
116 | 118 | ||
117 | static int fat_get_block(struct inode *inode, sector_t iblock, | ||
118 | struct buffer_head *bh_result, int create) | ||
119 | { | ||
120 | unsigned long max_blocks = 1; | ||
121 | return __fat_get_blocks(inode, iblock, &max_blocks, bh_result, create); | ||
122 | } | ||
123 | |||
124 | static int fat_writepage(struct page *page, struct writeback_control *wbc) | 119 | static int fat_writepage(struct page *page, struct writeback_control *wbc) |
125 | { | 120 | { |
126 | return block_write_full_page(page, fat_get_block, wbc); | 121 | return block_write_full_page(page, fat_get_block, wbc); |
@@ -188,7 +183,7 @@ static ssize_t fat_direct_IO(int rw, struct kiocb *iocb, | |||
188 | * condition of fat_get_block() and ->truncate(). | 183 | * condition of fat_get_block() and ->truncate(). |
189 | */ | 184 | */ |
190 | return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov, | 185 | return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov, |
191 | offset, nr_segs, fat_get_blocks, NULL); | 186 | offset, nr_segs, fat_get_block, NULL); |
192 | } | 187 | } |
193 | 188 | ||
194 | static sector_t _fat_bmap(struct address_space *mapping, sector_t block) | 189 | static sector_t _fat_bmap(struct address_space *mapping, sector_t block) |
@@ -375,8 +370,6 @@ static int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de) | |||
375 | inode->i_flags |= S_IMMUTABLE; | 370 | inode->i_flags |= S_IMMUTABLE; |
376 | } | 371 | } |
377 | MSDOS_I(inode)->i_attrs = de->attr & ATTR_UNUSED; | 372 | MSDOS_I(inode)->i_attrs = de->attr & ATTR_UNUSED; |
378 | /* this is as close to the truth as we can get ... */ | ||
379 | inode->i_blksize = sbi->cluster_size; | ||
380 | inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1)) | 373 | inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1)) |
381 | & ~((loff_t)sbi->cluster_size - 1)) >> 9; | 374 | & ~((loff_t)sbi->cluster_size - 1)) >> 9; |
382 | inode->i_mtime.tv_sec = | 375 | inode->i_mtime.tv_sec = |
@@ -528,8 +521,7 @@ static int __init fat_init_inodecache(void) | |||
528 | 521 | ||
529 | static void __exit fat_destroy_inodecache(void) | 522 | static void __exit fat_destroy_inodecache(void) |
530 | { | 523 | { |
531 | if (kmem_cache_destroy(fat_inode_cachep)) | 524 | kmem_cache_destroy(fat_inode_cachep); |
532 | printk(KERN_INFO "fat_inode_cache: not all structures were freed\n"); | ||
533 | } | 525 | } |
534 | 526 | ||
535 | static int fat_remount(struct super_block *sb, int *flags, char *data) | 527 | static int fat_remount(struct super_block *sb, int *flags, char *data) |
@@ -1137,7 +1129,6 @@ static int fat_read_root(struct inode *inode) | |||
1137 | MSDOS_I(inode)->i_start = 0; | 1129 | MSDOS_I(inode)->i_start = 0; |
1138 | inode->i_size = sbi->dir_entries * sizeof(struct msdos_dir_entry); | 1130 | inode->i_size = sbi->dir_entries * sizeof(struct msdos_dir_entry); |
1139 | } | 1131 | } |
1140 | inode->i_blksize = sbi->cluster_size; | ||
1141 | inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1)) | 1132 | inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1)) |
1142 | & ~((loff_t)sbi->cluster_size - 1)) >> 9; | 1133 | & ~((loff_t)sbi->cluster_size - 1)) >> 9; |
1143 | MSDOS_I(inode)->i_logstart = 0; | 1134 | MSDOS_I(inode)->i_logstart = 0; |
@@ -1168,11 +1159,10 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, | |||
1168 | long error; | 1159 | long error; |
1169 | char buf[50]; | 1160 | char buf[50]; |
1170 | 1161 | ||
1171 | sbi = kmalloc(sizeof(struct msdos_sb_info), GFP_KERNEL); | 1162 | sbi = kzalloc(sizeof(struct msdos_sb_info), GFP_KERNEL); |
1172 | if (!sbi) | 1163 | if (!sbi) |
1173 | return -ENOMEM; | 1164 | return -ENOMEM; |
1174 | sb->s_fs_info = sbi; | 1165 | sb->s_fs_info = sbi; |
1175 | memset(sbi, 0, sizeof(struct msdos_sb_info)); | ||
1176 | 1166 | ||
1177 | sb->s_flags |= MS_NODIRATIME; | 1167 | sb->s_flags |= MS_NODIRATIME; |
1178 | sb->s_magic = MSDOS_SUPER_MAGIC; | 1168 | sb->s_magic = MSDOS_SUPER_MAGIC; |