Commit 04cee52f authored by Tetsuhiro Kohada's avatar Tetsuhiro Kohada Committed by Namjae Jeon

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: default avatarTetsuhiro Kohada <kohada.t2@gmail.com>
Acked-by: default avatarSungjong Seo <sj1557.seo@samsung.com>
Signed-off-by: default avatarNamjae Jeon <namjae.jeon@samsung.com>
parent a7a24168
...@@ -59,9 +59,9 @@ static void exfat_get_uniname_from_ext_entry(struct super_block *sb, ...@@ -59,9 +59,9 @@ static void exfat_get_uniname_from_ext_entry(struct super_block *sb,
} }
/* read a directory entry from the opened directory */ /* read a directory entry from the opened directory */
static int exfat_readdir(struct inode *inode, struct exfat_dir_entry *dir_entry) static int exfat_readdir(struct inode *inode, loff_t *cpos, struct exfat_dir_entry *dir_entry)
{ {
int i, dentries_per_clu, dentries_per_clu_bits = 0; int i, dentries_per_clu, dentries_per_clu_bits = 0, num_ext;
unsigned int type, clu_offset; unsigned int type, clu_offset;
sector_t sector; sector_t sector;
struct exfat_chain dir, clu; struct exfat_chain dir, clu;
...@@ -70,7 +70,7 @@ static int exfat_readdir(struct inode *inode, struct exfat_dir_entry *dir_entry) ...@@ -70,7 +70,7 @@ static int exfat_readdir(struct inode *inode, struct exfat_dir_entry *dir_entry)
struct super_block *sb = inode->i_sb; struct super_block *sb = inode->i_sb;
struct exfat_sb_info *sbi = EXFAT_SB(sb); struct exfat_sb_info *sbi = EXFAT_SB(sb);
struct exfat_inode_info *ei = EXFAT_I(inode); struct exfat_inode_info *ei = EXFAT_I(inode);
unsigned int dentry = ei->rwoffset & 0xFFFFFFFF; unsigned int dentry = EXFAT_B_TO_DEN(*cpos) & 0xFFFFFFFF;
struct buffer_head *bh; struct buffer_head *bh;
/* check if the given file ID is opened */ /* check if the given file ID is opened */
...@@ -127,6 +127,7 @@ static int exfat_readdir(struct inode *inode, struct exfat_dir_entry *dir_entry) ...@@ -127,6 +127,7 @@ static int exfat_readdir(struct inode *inode, struct exfat_dir_entry *dir_entry)
continue; continue;
} }
num_ext = ep->dentry.file.num_ext;
dir_entry->attr = le16_to_cpu(ep->dentry.file.attr); dir_entry->attr = le16_to_cpu(ep->dentry.file.attr);
exfat_get_entry_time(sbi, &dir_entry->crtime, exfat_get_entry_time(sbi, &dir_entry->crtime,
ep->dentry.file.create_tz, ep->dentry.file.create_tz,
...@@ -157,12 +158,13 @@ static int exfat_readdir(struct inode *inode, struct exfat_dir_entry *dir_entry) ...@@ -157,12 +158,13 @@ static int exfat_readdir(struct inode *inode, struct exfat_dir_entry *dir_entry)
return -EIO; return -EIO;
dir_entry->size = dir_entry->size =
le64_to_cpu(ep->dentry.stream.valid_size); le64_to_cpu(ep->dentry.stream.valid_size);
dir_entry->entry = dentry;
brelse(bh); brelse(bh);
ei->hint_bmap.off = dentry >> dentries_per_clu_bits; ei->hint_bmap.off = dentry >> dentries_per_clu_bits;
ei->hint_bmap.clu = clu.dir; ei->hint_bmap.clu = clu.dir;
ei->rwoffset = ++dentry; *cpos = EXFAT_DEN_TO_B(dentry + 1 + num_ext);
return 0; return 0;
} }
...@@ -178,7 +180,7 @@ static int exfat_readdir(struct inode *inode, struct exfat_dir_entry *dir_entry) ...@@ -178,7 +180,7 @@ static int exfat_readdir(struct inode *inode, struct exfat_dir_entry *dir_entry)
} }
dir_entry->namebuf.lfn[0] = '\0'; dir_entry->namebuf.lfn[0] = '\0';
ei->rwoffset = dentry; *cpos = EXFAT_DEN_TO_B(dentry);
return 0; return 0;
} }
...@@ -242,12 +244,10 @@ static int exfat_iterate(struct file *filp, struct dir_context *ctx) ...@@ -242,12 +244,10 @@ static int exfat_iterate(struct file *filp, struct dir_context *ctx)
if (err) if (err)
goto unlock; goto unlock;
get_new: get_new:
ei->rwoffset = EXFAT_B_TO_DEN(cpos);
if (cpos >= i_size_read(inode)) if (cpos >= i_size_read(inode))
goto end_of_dir; goto end_of_dir;
err = exfat_readdir(inode, &de); err = exfat_readdir(inode, &cpos, &de);
if (err) { if (err) {
/* /*
* At least we tried to read a sector. Move cpos to next sector * At least we tried to read a sector. Move cpos to next sector
...@@ -262,13 +262,10 @@ static int exfat_iterate(struct file *filp, struct dir_context *ctx) ...@@ -262,13 +262,10 @@ static int exfat_iterate(struct file *filp, struct dir_context *ctx)
goto end_of_dir; goto end_of_dir;
} }
cpos = EXFAT_DEN_TO_B(ei->rwoffset);
if (!nb->lfn[0]) if (!nb->lfn[0])
goto end_of_dir; goto end_of_dir;
i_pos = ((loff_t)ei->start_clu << 32) | i_pos = ((loff_t)ei->start_clu << 32) | (de.entry & 0xffffffff);
((ei->rwoffset - 1) & 0xffffffff);
tmp = exfat_iget(sb, i_pos); tmp = exfat_iget(sb, i_pos);
if (tmp) { if (tmp) {
inum = tmp->i_ino; inum = tmp->i_ino;
......
...@@ -265,8 +265,6 @@ struct exfat_inode_info { ...@@ -265,8 +265,6 @@ struct exfat_inode_info {
* the validation of hint_stat. * the validation of hint_stat.
*/ */
unsigned int version; unsigned int version;
/* file offset or dentry index for readdir */
loff_t rwoffset;
/* hint for cluster last accessed */ /* hint for cluster last accessed */
struct exfat_hint hint_bmap; struct exfat_hint hint_bmap;
......
...@@ -208,8 +208,6 @@ int __exfat_truncate(struct inode *inode, loff_t new_size) ...@@ -208,8 +208,6 @@ int __exfat_truncate(struct inode *inode, loff_t new_size)
/* hint information */ /* hint information */
ei->hint_bmap.off = EXFAT_EOF_CLUSTER; ei->hint_bmap.off = EXFAT_EOF_CLUSTER;
ei->hint_bmap.clu = EXFAT_EOF_CLUSTER; ei->hint_bmap.clu = EXFAT_EOF_CLUSTER;
if (ei->rwoffset > new_size)
ei->rwoffset = new_size;
/* hint_stat will be used if this is directory. */ /* hint_stat will be used if this is directory. */
ei->hint_stat.eidx = 0; ei->hint_stat.eidx = 0;
......
...@@ -114,8 +114,6 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset, ...@@ -114,8 +114,6 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset,
unsigned int local_clu_offset = clu_offset; 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 = 0;
ei->rwoffset = EXFAT_CLU_TO_B(clu_offset, sbi);
if (EXFAT_I(inode)->i_size_ondisk > 0) if (EXFAT_I(inode)->i_size_ondisk > 0)
num_clusters = num_clusters =
EXFAT_B_TO_CLU_ROUND_UP(EXFAT_I(inode)->i_size_ondisk, EXFAT_B_TO_CLU_ROUND_UP(EXFAT_I(inode)->i_size_ondisk,
...@@ -567,7 +565,6 @@ static int exfat_fill_inode(struct inode *inode, struct exfat_dir_entry *info) ...@@ -567,7 +565,6 @@ static int exfat_fill_inode(struct inode *inode, struct exfat_dir_entry *info)
ei->hint_stat.eidx = 0; ei->hint_stat.eidx = 0;
ei->hint_stat.clu = info->start_clu; ei->hint_stat.clu = info->start_clu;
ei->hint_femp.eidx = EXFAT_HINT_NONE; ei->hint_femp.eidx = EXFAT_HINT_NONE;
ei->rwoffset = 0;
ei->hint_bmap.off = EXFAT_EOF_CLUSTER; ei->hint_bmap.off = EXFAT_EOF_CLUSTER;
ei->i_pos = 0; ei->i_pos = 0;
......
...@@ -342,7 +342,6 @@ static int exfat_read_root(struct inode *inode) ...@@ -342,7 +342,6 @@ static int exfat_read_root(struct inode *inode)
ei->flags = ALLOC_FAT_CHAIN; ei->flags = ALLOC_FAT_CHAIN;
ei->type = TYPE_DIR; ei->type = TYPE_DIR;
ei->version = 0; ei->version = 0;
ei->rwoffset = 0;
ei->hint_bmap.off = EXFAT_EOF_CLUSTER; ei->hint_bmap.off = EXFAT_EOF_CLUSTER;
ei->hint_stat.eidx = 0; ei->hint_stat.eidx = 0;
ei->hint_stat.clu = sbi->root_dir; ei->hint_stat.clu = sbi->root_dir;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment