summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNamjae Jeon <namjae.jeon@samsung.com>2015-05-14 10:55:15 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2015-05-14 10:55:15 +1000
commit7ca7ece9dc05cc4ca248d81c51b7393ebd425113 (patch)
tree16e1e9b44b7cf5c1ca2db852cb01c9774bc371d1
parent0b777326ab85edf11a1da1a4371d2dfe15f9d03e (diff)
downloadlinux-7ca7ece9dc05cc4ca248d81c51b7393ebd425113.tar.gz
linux-7ca7ece9dc05cc4ca248d81c51b7393ebd425113.tar.xz
fat: skip cluster allocation on fallocated region
Skip new cluster allocation after checking i_blocks limit in _fat_get_block, because the blocks are already allocated in fallocated region. 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>
-rw-r--r--fs/fat/inode.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 3daf3dc88698..3244f064311b 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -114,7 +114,7 @@ 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;
int err, offset;
err = fat_bmap(inode, iblock, &phys, &mapped_blocks, create);
@@ -134,8 +134,14 @@ static inline int __fat_get_block(struct inode *inode, sector_t iblock,
return -EIO;
}
+ last_block = inode->i_blocks >> (sb->s_blocksize_bits - 9);
offset = (unsigned long)iblock & (sbi->sec_per_clus - 1);
- if (!offset) {
+ /*
+ * allocate a cluster according to the following.
+ * 1) no more available blocks
+ * 2) not part of fallocate region
+ */
+ if (!offset && !(iblock < last_block)) {
/* TODO: multiple cluster allocation would be desirable. */
err = fat_add_cluster(inode);
if (err)