aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/fat/inode.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index d30151190434..e1035a590664 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
53static int __fat_get_blocks(struct inode *inode, sector_t iblock, 53static 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
103static int fat_get_blocks(struct inode *inode, sector_t iblock, 105static 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
117static 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
124static int fat_writepage(struct page *page, struct writeback_control *wbc) 119static 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
194static sector_t _fat_bmap(struct address_space *mapping, sector_t block) 189static sector_t _fat_bmap(struct address_space *mapping, sector_t block)