]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
fat: zero out seek range on _fat_get_block
authorNamjae Jeon <namjae.jeon@samsung.com>
Fri, 3 Jan 2014 03:10:25 +0000 (14:10 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 3 Jan 2014 03:10:25 +0000 (14:10 +1100)
For normal buffered write operations, normally if we try to write to an
offset > than file size, it does a cont_expand_zero till that offset.
Now, in case of fallocated regions, since the blocks are already
allocated.  So, make it zero out that buffers for those blocks till the
seek'ed offset.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/fat/cache.c
fs/fat/inode.c

index a132666920e66ef15a6d553406f9de03d6ec09fa..c56bd7e4af925f2417ef21312ee9aec0bdae5313 100644 (file)
@@ -334,7 +334,8 @@ int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys,
                 */
                last_block = (MSDOS_I(inode)->i_disksize + (blocksize - 1))
                        >> blocksize_bits;
-               if (sector >= last_block)
+               if (sector >= last_block &&
+                   MSDOS_I(inode)->mmu_private == MSDOS_I(inode)->i_disksize)
                        return 0;
        }
 
index fb388001decbc36c22dc78da8fa51fb352bb4e66..7a547ee0d567906d0b57e5cf67417d5a3370ef8d 100644 (file)
@@ -61,15 +61,26 @@ static inline int __fat_get_block(struct inode *inode, sector_t iblock,
        struct super_block *sb = inode->i_sb;
        struct msdos_sb_info *sbi = MSDOS_SB(sb);
        unsigned long mapped_blocks;
-       sector_t phys;
+       sector_t phys, last_block, disk_block;
        int err, offset;
+       const unsigned long blocksize = sb->s_blocksize;
+       const unsigned char blocksize_bits = sb->s_blocksize_bits;
 
        err = fat_bmap(inode, iblock, &phys, &mapped_blocks, create);
        if (err)
                return err;
        if (phys) {
-               map_bh(bh_result, sb, phys);
                *max_blocks = min(mapped_blocks, *max_blocks);
+               last_block = (MSDOS_I(inode)->mmu_private + (blocksize - 1))
+                       >> blocksize_bits;
+               disk_block = (MSDOS_I(inode)->i_disksize + (blocksize - 1))
+                       >> blocksize_bits;
+               if (iblock >= last_block && iblock <= disk_block) {
+                       MSDOS_I(inode)->mmu_private +=
+                               *max_blocks << blocksize_bits;
+                       set_buffer_new(bh_result);
+               }
+               map_bh(bh_result, sb, phys);
                return 0;
        }
        if (!create)