diff options
author | Yuezhang Mo <Yuezhang.Mo@sony.com> | 2024-01-12 10:32:58 +0800 |
---|---|---|
committer | Namjae Jeon <linkinjeon@kernel.org> | 2024-09-17 14:46:51 +0900 |
commit | fba27cf005038a5fedf001b49636594819dbb1d5 (patch) | |
tree | 4303070c2015d841d6de1aafbfa750c6f8d23141 | |
parent | a430d95c5efa2b545d26a094eb5f624e36732af0 (diff) |
exfat: drop ->i_size_ondisk
->i_size_ondisk is no longer used by exfat_write_begin() after
commit(11a347fb6cef exfat: change to get file size from DataLength),
drop it.
Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
-rw-r--r-- | fs/exfat/exfat_fs.h | 10 | ||||
-rw-r--r-- | fs/exfat/file.c | 8 | ||||
-rw-r--r-- | fs/exfat/inode.c | 17 | ||||
-rw-r--r-- | fs/exfat/namei.c | 1 | ||||
-rw-r--r-- | fs/exfat/super.c | 1 |
5 files changed, 12 insertions, 25 deletions
diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index ecc5db952deb..77cc62b026d3 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -309,11 +309,6 @@ struct exfat_inode_info { /* for avoiding the race between alloc and free */ unsigned int cache_valid_id; - /* - * NOTE: i_size_ondisk is 64bits, so must hold ->inode_lock to access. - * physically allocated size. - */ - loff_t i_size_ondisk; /* block-aligned i_size (used in cont_write_begin) */ loff_t i_size_aligned; /* on-disk position of directory entry or 0 */ @@ -417,6 +412,11 @@ static inline bool is_valid_cluster(struct exfat_sb_info *sbi, return clus >= EXFAT_FIRST_CLUSTER && clus < sbi->num_clusters; } +static inline loff_t exfat_ondisk_size(const struct inode *inode) +{ + return ((loff_t)inode->i_blocks) << 9; +} + /* super.c */ int exfat_set_volume_dirty(struct super_block *sb); int exfat_clear_volume_dirty(struct super_block *sb); diff --git a/fs/exfat/file.c b/fs/exfat/file.c index e19469e88000..fd4a8a170c1f 100644 --- a/fs/exfat/file.c +++ b/fs/exfat/file.c @@ -29,7 +29,7 @@ static int exfat_cont_expand(struct inode *inode, loff_t size) if (ret) return ret; - num_clusters = EXFAT_B_TO_CLU_ROUND_UP(ei->i_size_ondisk, sbi); + num_clusters = EXFAT_B_TO_CLU(exfat_ondisk_size(inode), sbi); new_num_clusters = EXFAT_B_TO_CLU_ROUND_UP(size, sbi); if (new_num_clusters == num_clusters) @@ -75,7 +75,6 @@ out: i_size_write(inode, size); ei->i_size_aligned = round_up(size, sb->s_blocksize); - ei->i_size_ondisk = ei->i_size_aligned; inode->i_blocks = round_up(size, sbi->cluster_size) >> 9; mark_inode_dirty(inode); @@ -159,7 +158,7 @@ int __exfat_truncate(struct inode *inode) exfat_set_volume_dirty(sb); num_clusters_new = EXFAT_B_TO_CLU_ROUND_UP(i_size_read(inode), sbi); - num_clusters_phys = EXFAT_B_TO_CLU_ROUND_UP(ei->i_size_ondisk, sbi); + num_clusters_phys = EXFAT_B_TO_CLU(exfat_ondisk_size(inode), sbi); exfat_chain_set(&clu, ei->start_clu, num_clusters_phys, ei->flags); @@ -270,9 +269,6 @@ write_size: aligned_size++; } - if (ei->i_size_ondisk > i_size_read(inode)) - ei->i_size_ondisk = aligned_size; - if (ei->i_size_aligned > i_size_read(inode)) ei->i_size_aligned = aligned_size; mutex_unlock(&sbi->s_lock); diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c index 05f0e07b01d0..ed737ef288d2 100644 --- a/fs/exfat/inode.c +++ b/fs/exfat/inode.c @@ -130,11 +130,9 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset, struct exfat_sb_info *sbi = EXFAT_SB(sb); struct exfat_inode_info *ei = EXFAT_I(inode); unsigned int local_clu_offset = clu_offset; - unsigned int num_to_be_allocated = 0, num_clusters = 0; + unsigned int num_to_be_allocated = 0, num_clusters; - if (ei->i_size_ondisk > 0) - num_clusters = - EXFAT_B_TO_CLU_ROUND_UP(ei->i_size_ondisk, sbi); + num_clusters = EXFAT_B_TO_CLU(exfat_ondisk_size(inode), sbi); if (clu_offset >= num_clusters) num_to_be_allocated = clu_offset - num_clusters + 1; @@ -268,10 +266,10 @@ static int exfat_map_new_buffer(struct exfat_inode_info *ei, set_buffer_new(bh); /* - * Adjust i_size_aligned if i_size_ondisk is bigger than it. + * Adjust i_size_aligned if ondisk_size is bigger than it. */ - if (ei->i_size_ondisk > ei->i_size_aligned) - ei->i_size_aligned = ei->i_size_ondisk; + if (exfat_ondisk_size(&ei->vfs_inode) > ei->i_size_aligned) + ei->i_size_aligned = exfat_ondisk_size(&ei->vfs_inode); return 0; } @@ -317,10 +315,6 @@ static int exfat_get_block(struct inode *inode, sector_t iblock, max_blocks = min(mapped_blocks, max_blocks); pos = EXFAT_BLK_TO_B((iblock + 1), sb); - if ((create && iblock >= last_block) || buffer_delay(bh_result)) { - if (ei->i_size_ondisk < pos) - ei->i_size_ondisk = pos; - } map_bh(bh_result, sb, phys); if (buffer_delay(bh_result)) @@ -674,7 +668,6 @@ static int exfat_fill_inode(struct inode *inode, struct exfat_dir_entry *info) } ei->i_size_aligned = size; - ei->i_size_ondisk = size; exfat_save_attr(inode, info->attr); diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 631ad9e8e32a..6313dee5c9bb 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -372,7 +372,6 @@ static int exfat_find_empty_entry(struct inode *inode, /* directory inode should be updated in here */ i_size_write(inode, size); - ei->i_size_ondisk += sbi->cluster_size; ei->i_size_aligned += sbi->cluster_size; ei->valid_size += sbi->cluster_size; ei->flags = p_dir->flags; diff --git a/fs/exfat/super.c b/fs/exfat/super.c index 323ecebe6f0e..6516edff38fc 100644 --- a/fs/exfat/super.c +++ b/fs/exfat/super.c @@ -371,7 +371,6 @@ static int exfat_read_root(struct inode *inode) inode->i_blocks = round_up(i_size_read(inode), sbi->cluster_size) >> 9; ei->i_pos = ((loff_t)sbi->root_dir << 32) | 0xffffffff; ei->i_size_aligned = i_size_read(inode); - ei->i_size_ondisk = i_size_read(inode); exfat_save_attr(inode, EXFAT_ATTR_SUBDIR); ei->i_crtime = simple_inode_init_ts(inode); |