inode.c (7e0f236b5b9cc23aa004eb58ee2201f294d0422a) inode.c (16fab2015099a937e1a771f2785c5dd3445fe483)
1/*
2 * linux/fs/fat/inode.c
3 *
4 * Written 1992,1993 by Werner Almesberger
5 * VFAT extensions by Gordon Chaffee, merged with msdos fs by Henrik Storner
6 * Rewritten for the constant inumbers support by Al Viro
7 *
8 * Fixes:

--- 104 unchanged lines hidden (view full) ---

113 struct buffer_head *bh_result, int create)
114{
115 struct super_block *sb = inode->i_sb;
116 struct msdos_sb_info *sbi = MSDOS_SB(sb);
117 unsigned long mapped_blocks;
118 sector_t phys, last_block;
119 int err, offset;
120
1/*
2 * linux/fs/fat/inode.c
3 *
4 * Written 1992,1993 by Werner Almesberger
5 * VFAT extensions by Gordon Chaffee, merged with msdos fs by Henrik Storner
6 * Rewritten for the constant inumbers support by Al Viro
7 *
8 * Fixes:

--- 104 unchanged lines hidden (view full) ---

113 struct buffer_head *bh_result, int create)
114{
115 struct super_block *sb = inode->i_sb;
116 struct msdos_sb_info *sbi = MSDOS_SB(sb);
117 unsigned long mapped_blocks;
118 sector_t phys, last_block;
119 int err, offset;
120
121 err = fat_bmap(inode, iblock, &phys, &mapped_blocks, create);
121 err = fat_bmap(inode, iblock, &phys, &mapped_blocks, create, false);
122 if (err)
123 return err;
124 if (phys) {
125 map_bh(bh_result, sb, phys);
126 *max_blocks = min(mapped_blocks, *max_blocks);
127 return 0;
128 }
129 if (!create)

--- 19 unchanged lines hidden (view full) ---

149 return err;
150 }
151 /* available blocks on this cluster */
152 mapped_blocks = sbi->sec_per_clus - offset;
153
154 *max_blocks = min(mapped_blocks, *max_blocks);
155 MSDOS_I(inode)->mmu_private += *max_blocks << sb->s_blocksize_bits;
156
122 if (err)
123 return err;
124 if (phys) {
125 map_bh(bh_result, sb, phys);
126 *max_blocks = min(mapped_blocks, *max_blocks);
127 return 0;
128 }
129 if (!create)

--- 19 unchanged lines hidden (view full) ---

149 return err;
150 }
151 /* available blocks on this cluster */
152 mapped_blocks = sbi->sec_per_clus - offset;
153
154 *max_blocks = min(mapped_blocks, *max_blocks);
155 MSDOS_I(inode)->mmu_private += *max_blocks << sb->s_blocksize_bits;
156
157 err = fat_bmap(inode, iblock, &phys, &mapped_blocks, create);
157 err = fat_bmap(inode, iblock, &phys, &mapped_blocks, create, false);
158 if (err)
159 return err;
160
161 BUG_ON(!phys);
162 BUG_ON(*max_blocks != mapped_blocks);
163 set_buffer_new(bh_result);
164 map_bh(bh_result, sb, phys);
165

--- 108 unchanged lines hidden (view full) ---

274 */
275 ret = blockdev_direct_IO(iocb, inode, iter, offset, fat_get_block);
276 if (ret < 0 && iov_iter_rw(iter) == WRITE)
277 fat_write_failed(mapping, offset + count);
278
279 return ret;
280}
281
158 if (err)
159 return err;
160
161 BUG_ON(!phys);
162 BUG_ON(*max_blocks != mapped_blocks);
163 set_buffer_new(bh_result);
164 map_bh(bh_result, sb, phys);
165

--- 108 unchanged lines hidden (view full) ---

274 */
275 ret = blockdev_direct_IO(iocb, inode, iter, offset, fat_get_block);
276 if (ret < 0 && iov_iter_rw(iter) == WRITE)
277 fat_write_failed(mapping, offset + count);
278
279 return ret;
280}
281
282static int fat_get_block_bmap(struct inode *inode, sector_t iblock,
283 struct buffer_head *bh_result, int create)
284{
285 struct super_block *sb = inode->i_sb;
286 unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits;
287 int err;
288 sector_t bmap;
289 unsigned long mapped_blocks;
290
291 BUG_ON(create != 0);
292
293 err = fat_bmap(inode, iblock, &bmap, &mapped_blocks, create, true);
294 if (err)
295 return err;
296
297 if (bmap) {
298 map_bh(bh_result, sb, bmap);
299 max_blocks = min(mapped_blocks, max_blocks);
300 }
301
302 bh_result->b_size = max_blocks << sb->s_blocksize_bits;
303
304 return 0;
305}
306
282static sector_t _fat_bmap(struct address_space *mapping, sector_t block)
283{
284 sector_t blocknr;
285
286 /* fat_get_cluster() assumes the requested blocknr isn't truncated. */
287 down_read(&MSDOS_I(mapping->host)->truncate_lock);
307static sector_t _fat_bmap(struct address_space *mapping, sector_t block)
308{
309 sector_t blocknr;
310
311 /* fat_get_cluster() assumes the requested blocknr isn't truncated. */
312 down_read(&MSDOS_I(mapping->host)->truncate_lock);
288 blocknr = generic_block_bmap(mapping, block, fat_get_block);
313 blocknr = generic_block_bmap(mapping, block, fat_get_block_bmap);
289 up_read(&MSDOS_I(mapping->host)->truncate_lock);
290
291 return blocknr;
292}
293
294/*
295 * fat_block_truncate_page() zeroes out a mapping from file offset `from'
296 * up to the end of the block which corresponds to `from'.

--- 1618 unchanged lines hidden ---
314 up_read(&MSDOS_I(mapping->host)->truncate_lock);
315
316 return blocknr;
317}
318
319/*
320 * fat_block_truncate_page() zeroes out a mapping from file offset `from'
321 * up to the end of the block which corresponds to `from'.

--- 1618 unchanged lines hidden ---