Skip to content

Commit

Permalink
fat: skip cluster allocation on fallocated region
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Amit Sahrawat <[email protected]>
Cc: OGAWA Hirofumi <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
namjaejeon authored and torvalds committed Jan 21, 2016
1 parent b13bb33 commit 7e0f236
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions fs/fat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,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);
Expand All @@ -135,8 +135,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)
Expand Down

0 comments on commit 7e0f236

Please sign in to comment.