fat: add i_disksize to represent uninitialized size
Subsystems (2)
PATCH 1/5 fat: add i_disksize to represent uninitialized size
From: Namjae Jeon <[email protected]>
Add i_disksize to represent uninitialized allocated size. And mmu_private represent initialized allocated size.
--- fs/fat/cache.c | 4 ++-- fs/fat/fat.h | 3 ++- fs/fat/file.c | 4 +++- fs/fat/inode.c | 4 ++++ 4 files changed, 11 insertions(+), 4 deletions(-)
fs/fat/cache.c +2 -2
@@ -329,10 +329,10 @@ int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys,return 0 ;/* -* ->mmu_private can access on only allocation path. +* ->i_disksize can access on only allocation path. * (caller must hold ->i_mutex) */ - last_block = (MSDOS_I (inode)->mmu_private + (blocksize -1 )) + last_block = (MSDOS_I (inode)->i_disksize + (blocksize -1 )) >> blocksize_bits;if (sector >= last_block)return 0 ;
fs/fat/fat.h +2 -1
@@ -117,7 +117,8 @@ struct msdos_inode_info {unsigned int cache_valid_id;/* NOTE: mmu_private is 64bits, so must hold ->i_mutex to access */ -loff_t mmu_private;/* physically allocated size */ +loff_t mmu_private;/* physically allocated size (uninitialized) */ +loff_t i_disksize;/* physically allocated size (initialized) */ int i_start;/* first cluster or 0 */ int i_logstart;/* logical first cluster */
fs/fat/file.c +3 -1
@@ -300,8 +300,10 @@ void fat_truncate_blocks(struct inode *inode, loff_t offset)* This protects against truncating a file bigger than it was then * trying to write into the hole. */ -if (MSDOS_I (inode)->mmu_private > offset) +if (MSDOS_I (inode)->mmu_private > offset) {MSDOS_I (inode)->mmu_private = offset; +MSDOS_I (inode)->i_disksize = offset; + } nr_clusters = (offset + (cluster_size -1 )) >> sbi->cluster_bits;
fs/fat/inode.c +4 -0
@@ -93,6 +93,7 @@ static inline int __fat_get_block(struct inode *inode, sector_t iblock, *max_blocks =min (mapped_blocks, *max_blocks);MSDOS_I (inode)->mmu_private += *max_blocks << sb->s_blocksize_bits; +MSDOS_I (inode)->i_disksize =MSDOS_I (inode)->mmu_private; err =fat_bmap (inode, iblock, &phys, &mapped_blocks, create);if (err)
@@ -406,6 +407,7 @@ int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)if (error <0 )return error;MSDOS_I (inode)->mmu_private = inode->i_size; +MSDOS_I (inode)->i_disksize = inode->i_size;set_nlink (inode,fat_subdirs (inode)); }else {/* not a directory */
@@ -421,6 +423,7 @@ int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de) inode->i_fop = &fat_file_operations; inode->i_mapping->a_ops = &fat_aops;MSDOS_I (inode)->mmu_private = inode->i_size; +MSDOS_I (inode)->i_disksize = inode->i_size; }if (de->attr &ATTR_SYS ) {if (sbi->options.sys_immutable)
@@ -1218,6 +1221,7 @@ static int fat_read_root(struct inode *inode) & ~((loff_t)sbi->cluster_size - 1)) >> 9;MSDOS_I (inode)->i_logstart =0 ;MSDOS_I (inode)->mmu_private = inode->i_size; +MSDOS_I (inode)->i_disksize = inode->i_size;fat_save_attrs (inode,ATTR_DIR ); inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec =0 ;
Signature · 1 line
1.7.9.5
OGAWA Hirofumi
maintainerNamjae Jeon <[email protected]> writes:
Code seems to be much became simpler.
Quoted 7 lines
fs/fat/cache.c +0
-0@@ -329,10 +329,10 @@ int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys,return 0 ;
fs/fat/cache.c int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys, · line 338
Quoted 10 lines
fs/fat/cache.c +2
-2/* -* ->mmu_private can access on only allocation path. +* ->i_disksize can access on only allocation path. * (caller must hold ->i_mutex) */ - last_block = (MSDOS_I (inode)->mmu_private + (blocksize -1 )) + last_block = (MSDOS_I (inode)->i_disksize + (blocksize -1 )) >> blocksize_bits;if (sector >= last_block)return 0 ;
Hm, bmap() ioctl returns between ->mmu_private and i_disksize? I'm not checking other FSes what does...
Signature · 1 line
OGAWA Hirofumi <[email protected]>
2013/10/27, OGAWA Hirofumi <[email protected]>:
Quoted 1 line
Namjae Jeon <[email protected]> writes:
Hi OGAWA.
Quoted 2 lines
Code seems to be much became simpler.
Thanks :)
Quoted 9 lines
Quoted 9 lines
fs/fat/cache.c +0
-0@@ -329,10 +329,10 @@ int fat_bmap(struct inode *inode, sector_t sector,sector_t *phys, return 0;
Quoted 13 lines
Quoted 10 lines
fs/fat/cache.c +2
-2/* -* ->mmu_private can access on only allocation path. +* ->i_disksize can access on only allocation path. * (caller must hold ->i_mutex) */ - last_block = (MSDOS_I (inode)->mmu_private + (blocksize -1 )) + last_block = (MSDOS_I (inode)->i_disksize + (blocksize -1 )) >> blocksize_bits;if (sector >= last_block)return 0;
Hm,
bmap()ioctl returns between ->mmu_private andi_disksize? I'm not checking other FSes what does...
I added this code after checking such behaviour from ext4.
Thanks.
Quoted 3 lines
--
OGAWA Hirofumi <[email protected]>
OGAWA Hirofumi
maintainerQuoted 21 lines · Namjae Jeon
Quoted 8 lines
Quoted 8 lines
fs/fat/cache.c +0
-0@@ -329,10 +329,10 @@ int fat_bmap(struct inode *inode, sector_t sector,sector_t *phys, return 0;Quoted 13 lines
Quoted 10 lines
fs/fat/cache.c +2
-2/* -* ->mmu_private can access on only allocation path. +* ->i_disksize can access on only allocation path. * (caller must hold ->i_mutex) */ - last_block = (MSDOS_I (inode)->mmu_private + (blocksize -1 )) + last_block = (MSDOS_I (inode)->i_disksize + (blocksize -1 )) >> blocksize_bits;if (sector >= last_block)return 0;
Hm,
bmap()ioctl returns between ->mmu_private andi_disksize? I'm not checking other FSes what does...
Quoted 1 line
I added this code after checking such behaviour from ext4.
OK. I will check with it. BTW, comment should say the both (i.e. ->mmu_private and ->i_disksize must under ->i_mutex).
Signature · 1 line
OGAWA Hirofumi <[email protected]>
2013/10/30, OGAWA Hirofumi <[email protected]>:
Quoted 24 lines
Quoted 22 lines · Namjae Jeon
Quoted 22 lines
Quoted 17 lines
fs/fat/cache.c +2
-2@@ -329,10 +329,10 @@ int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys, return 0;/* -* ->mmu_private can access on only allocation path. +* ->i_disksize can access on only allocation path. * (caller must hold ->i_mutex) */ - last_block = (MSDOS_I (inode)->mmu_private + (blocksize -1 )) + last_block = (MSDOS_I (inode)->i_disksize + (blocksize -1 )) >> blocksize_bits;fs/fat/cache.c int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys, · line 338
Quoted 2 lines
fs/fat/cache.c +0
-0if (sector >= last_block)return 0 ;Hm,
bmap()ioctl returns between ->mmu_private andi_disksize? I'm not checking other FSes what does...
Quoted 4 lines
Quoted 1 line
I added this code after checking such behaviour from ext4.
OK. I will check with it. BTW, comment should say the both (i.e. ->mmu_private and ->i_disksize must under ->i_mutex).
Okay, I will update.
Thanks!
Quoted 3 lines
--
OGAWA Hirofumi <[email protected]>