Skip to contentSkip to conversation

fat: skip cluster allocation on fallocated region

PATCH Superseded Namjae Jeon 2 participants 2 messages Oct 17, 2014 – Oct 23, 2014

Subsystems (2)

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v6 2/4 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.

---
 fs/fat/inode.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/fat/inode.c +6 -1
index acb45ce..20e9fe5 100644
@@ -144,7 +144,12 @@ static inline int __fat_get_block(struct inode *inode, sector_t iblock,
 	}
 
 	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 < (sector_t)inode->i_blocks)) {
 		/* TODO: multiple cluster allocation would be desirable. */
 		err = fat_add_cluster(inode);
 		if (err)
Signature · 1 line
1.7.11-rc0
maintainer
#1 lore raw
Quoted 17 lines · Namjae Jeon

Skip new cluster allocation after checking i_blocks limit in _fat_get_block, because the blocks are already allocated in fallocated region.

---
 fs/fat/inode.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/fat/inode.c +0 -0
index acb45ce..20e9fe5 100644
@@ -144,7 +144,12 @@ static inline int __fat_get_block(struct inode *inode, sector_t iblock,
 	}
 
 	offset = (unsigned long)iblock & (sbi->sec_per_clus - 1);

fs/fat/inode.c static inline int __fat_get_block(struct inode *inode, sector_t iblock, · line 155

Quoted 10 lines
fs/fat/inode.c +6 -1
-	if (!offset) {
+	/*
+	 * allocate a cluster according to the following.
+	 * 1) no more available blocks
+	 * 2) not part of fallocate region
+	 */
+	if (!offset && !(iblock < (sector_t)inode->i_blocks)) {
 		/* TODO: multiple cluster allocation would be desirable. */
 		err = fat_add_cluster(inode);
 		if (err)

iblock and i_blocks have different unit. iblock == s_blocksize, i_blocks == 9 alwasy.

Signature · 1 line
OGAWA Hirofumi <[email protected]>