]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
fat: add i_disksize to represent uninitialized size
authorNamjae Jeon <namjae.jeon@samsung.com>
Tue, 5 Nov 2013 05:57:30 +0000 (16:57 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 5 Nov 2013 05:57:30 +0000 (16:57 +1100)
Add i_disksize to represent uninitialized allocated size.  And mmu_private
represent initialized allocated size.

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>
fs/fat/cache.c
fs/fat/fat.h
fs/fat/file.c
fs/fat/inode.c

index 91ad9e1c94417a813c1661af830bc2ecbc962033..37572c29c741a22c9cddacb03c217c57d8540881 100644 (file)
@@ -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;
index 4241e6f39e86450b4fc5a7df4d0b224b5fee7862..1716199b4f4e4c23567cdd15be42ef39e6d0626d 100644 (file)
@@ -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 */
index 9b104f543056238016c683ef822046a784169f50..9166c656aa9792bde32295a977e0b14d6149f081 100644 (file)
@@ -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;
 
index 0062da21dd8b7995aa1764bfd943cde9d2e22364..2c059f8b911b21d36e42e0c32d1e896e21fcbb1b 100644 (file)
@@ -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)
@@ -408,6 +409,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 */
@@ -423,6 +425,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)
@@ -1220,6 +1223,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;