Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

exfat: remove 'rwoffset' in exfat_inode_info

Remove 'rwoffset' in exfat_inode_info and replace it with the parameter of
exfat_readdir().
Since rwoffset is referenced only by exfat_readdir(), it is not necessary
a exfat_inode_info's member.
Also, change cpos to point to the next of entry-set, and return the index
of dir-entry via dir_entry->entry.

Signed-off-by: Tetsuhiro Kohada <kohada.t2@gmail.com>
Acked-by: Sungjong Seo <sj1557.seo@samsung.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>

authored by

Tetsuhiro Kohada and committed by
Namjae Jeon
04cee52f a7a24168

+9 -20
+9 -12
fs/exfat/dir.c
··· 59 59 } 60 60 61 61 /* read a directory entry from the opened directory */ 62 - static int exfat_readdir(struct inode *inode, struct exfat_dir_entry *dir_entry) 62 + static int exfat_readdir(struct inode *inode, loff_t *cpos, struct exfat_dir_entry *dir_entry) 63 63 { 64 - int i, dentries_per_clu, dentries_per_clu_bits = 0; 64 + int i, dentries_per_clu, dentries_per_clu_bits = 0, num_ext; 65 65 unsigned int type, clu_offset; 66 66 sector_t sector; 67 67 struct exfat_chain dir, clu; ··· 70 70 struct super_block *sb = inode->i_sb; 71 71 struct exfat_sb_info *sbi = EXFAT_SB(sb); 72 72 struct exfat_inode_info *ei = EXFAT_I(inode); 73 - unsigned int dentry = ei->rwoffset & 0xFFFFFFFF; 73 + unsigned int dentry = EXFAT_B_TO_DEN(*cpos) & 0xFFFFFFFF; 74 74 struct buffer_head *bh; 75 75 76 76 /* check if the given file ID is opened */ ··· 127 127 continue; 128 128 } 129 129 130 + num_ext = ep->dentry.file.num_ext; 130 131 dir_entry->attr = le16_to_cpu(ep->dentry.file.attr); 131 132 exfat_get_entry_time(sbi, &dir_entry->crtime, 132 133 ep->dentry.file.create_tz, ··· 158 157 return -EIO; 159 158 dir_entry->size = 160 159 le64_to_cpu(ep->dentry.stream.valid_size); 160 + dir_entry->entry = dentry; 161 161 brelse(bh); 162 162 163 163 ei->hint_bmap.off = dentry >> dentries_per_clu_bits; 164 164 ei->hint_bmap.clu = clu.dir; 165 165 166 - ei->rwoffset = ++dentry; 166 + *cpos = EXFAT_DEN_TO_B(dentry + 1 + num_ext); 167 167 return 0; 168 168 } 169 169 ··· 180 178 } 181 179 182 180 dir_entry->namebuf.lfn[0] = '\0'; 183 - ei->rwoffset = dentry; 181 + *cpos = EXFAT_DEN_TO_B(dentry); 184 182 return 0; 185 183 } 186 184 ··· 244 242 if (err) 245 243 goto unlock; 246 244 get_new: 247 - ei->rwoffset = EXFAT_B_TO_DEN(cpos); 248 - 249 245 if (cpos >= i_size_read(inode)) 250 246 goto end_of_dir; 251 247 252 - err = exfat_readdir(inode, &de); 248 + err = exfat_readdir(inode, &cpos, &de); 253 249 if (err) { 254 250 /* 255 251 * At least we tried to read a sector. Move cpos to next sector ··· 262 262 goto end_of_dir; 263 263 } 264 264 265 - cpos = EXFAT_DEN_TO_B(ei->rwoffset); 266 - 267 265 if (!nb->lfn[0]) 268 266 goto end_of_dir; 269 267 270 - i_pos = ((loff_t)ei->start_clu << 32) | 271 - ((ei->rwoffset - 1) & 0xffffffff); 268 + i_pos = ((loff_t)ei->start_clu << 32) | (de.entry & 0xffffffff); 272 269 tmp = exfat_iget(sb, i_pos); 273 270 if (tmp) { 274 271 inum = tmp->i_ino;
-2
fs/exfat/exfat_fs.h
··· 265 265 * the validation of hint_stat. 266 266 */ 267 267 unsigned int version; 268 - /* file offset or dentry index for readdir */ 269 - loff_t rwoffset; 270 268 271 269 /* hint for cluster last accessed */ 272 270 struct exfat_hint hint_bmap;
-2
fs/exfat/file.c
··· 208 208 /* hint information */ 209 209 ei->hint_bmap.off = EXFAT_EOF_CLUSTER; 210 210 ei->hint_bmap.clu = EXFAT_EOF_CLUSTER; 211 - if (ei->rwoffset > new_size) 212 - ei->rwoffset = new_size; 213 211 214 212 /* hint_stat will be used if this is directory. */ 215 213 ei->hint_stat.eidx = 0;
-3
fs/exfat/inode.c
··· 114 114 unsigned int local_clu_offset = clu_offset; 115 115 unsigned int num_to_be_allocated = 0, num_clusters = 0; 116 116 117 - ei->rwoffset = EXFAT_CLU_TO_B(clu_offset, sbi); 118 - 119 117 if (EXFAT_I(inode)->i_size_ondisk > 0) 120 118 num_clusters = 121 119 EXFAT_B_TO_CLU_ROUND_UP(EXFAT_I(inode)->i_size_ondisk, ··· 565 567 ei->hint_stat.eidx = 0; 566 568 ei->hint_stat.clu = info->start_clu; 567 569 ei->hint_femp.eidx = EXFAT_HINT_NONE; 568 - ei->rwoffset = 0; 569 570 ei->hint_bmap.off = EXFAT_EOF_CLUSTER; 570 571 ei->i_pos = 0; 571 572
-1
fs/exfat/super.c
··· 342 342 ei->flags = ALLOC_FAT_CHAIN; 343 343 ei->type = TYPE_DIR; 344 344 ei->version = 0; 345 - ei->rwoffset = 0; 346 345 ei->hint_bmap.off = EXFAT_EOF_CLUSTER; 347 346 ei->hint_stat.eidx = 0; 348 347 ei->hint_stat.clu = sbi->root_dir;