From mboxrd@z Thu Jan 1 00:00:00 1970 From: Namjae Jeon Subject: [PATCH v5 3/5] fat: skip cluster allocation on fallocated region Date: Thu, 25 Sep 2014 14:31:12 +0900 Message-ID: <000301cfd881$eb345550$c19cfff0$@samsung.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org To: 'OGAWA Hirofumi' , Andrew Morton Return-path: Received: from mailout2.samsung.com ([203.254.224.25]:26522 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751318AbaIYFbP (ORCPT ); Thu, 25 Sep 2014 01:31:15 -0400 Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NCF00M7VZC12X10@mailout2.samsung.com> for linux-fsdevel@vger.kernel.org; Thu, 25 Sep 2014 14:31:13 +0900 (KST) Content-language: ko Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Skip new cluster allocation after checking i_disksize in _fat_get_block. because the blocks are already allocated in fallocated region. Signed-off-by: Namjae Jeon Signed-off-by: Amit Sahrawat --- fs/fat/inode.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/fat/inode.c b/fs/fat/inode.c index b6a2da2..ecd455c 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c @@ -120,6 +120,14 @@ static int fat_add_cluster(struct inode *inode) return err; } +static inline int check_fallocated_region(struct inode *inode, sector_t iblock) +{ + struct super_block *sb = inode->i_sb; + sector_t last_disk_block = MSDOS_I(inode)->i_disksize >> + sb->s_blocksize_bits; + return iblock < last_disk_block; +} + static inline int __fat_get_block(struct inode *inode, sector_t iblock, unsigned long *max_blocks, struct buffer_head *bh_result, int create) @@ -148,7 +156,7 @@ static inline int __fat_get_block(struct inode *inode, sector_t iblock, } offset = (unsigned long)iblock & (sbi->sec_per_clus - 1); - if (!offset) { + if (!offset && !check_fallocated_region(inode, iblock)) { /* TODO: multiple cluster allocation would be desirable. */ err = fat_add_cluster(inode); if (err) -- 1.7.11-rc0