* [PATCH] exfat: remove 'rwoffset' in exfat_inode_info @ 2020-09-09 7:56 ` Tetsuhiro Kohada 2020-09-12 5:01 ` Sungjong Seo 0 siblings, 1 reply; 4+ messages in thread From: Tetsuhiro Kohada @ 2020-09-09 7:56 UTC (permalink / raw) To: kohada.t2 Cc: kohada.tetsuhiro, mori.takahiro, motai.hirotaka, Namjae Jeon, Sungjong Seo, linux-fsdevel, linux-kernel Remove 'rwoffset' in exfat_inode_info and replace it with the parameter(cpos) of exfat_readdir. Since rwoffset of is referenced only by exfat_readdir, it is not necessary a exfat_inode_info's member. Signed-off-by: Tetsuhiro Kohada <kohada.t2@gmail.com> --- fs/exfat/dir.c | 16 ++++++---------- fs/exfat/exfat_fs.h | 2 -- fs/exfat/file.c | 2 -- fs/exfat/inode.c | 3 --- fs/exfat/super.c | 1 - 5 files changed, 6 insertions(+), 18 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index a9b13ae3f325..fa5bb72aa295 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -59,7 +59,7 @@ static void exfat_get_uniname_from_ext_entry(struct super_block *sb, } /* 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; unsigned int type, clu_offset; @@ -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 exfat_sb_info *sbi = EXFAT_SB(sb); 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; /* check if the given file ID is opened */ @@ -162,7 +162,7 @@ static int exfat_readdir(struct inode *inode, struct exfat_dir_entry *dir_entry) ei->hint_bmap.off = dentry >> dentries_per_clu_bits; ei->hint_bmap.clu = clu.dir; - ei->rwoffset = ++dentry; + *cpos = EXFAT_DEN_TO_B(++dentry); return 0; } @@ -178,7 +178,7 @@ static int exfat_readdir(struct inode *inode, struct exfat_dir_entry *dir_entry) } dir_entry->namebuf.lfn[0] = '\0'; - ei->rwoffset = dentry; + *cpos = EXFAT_DEN_TO_B(dentry); return 0; } @@ -242,12 +242,10 @@ static int exfat_iterate(struct file *filp, struct dir_context *ctx) if (err) goto unlock; get_new: - ei->rwoffset = EXFAT_B_TO_DEN(cpos); - if (cpos >= i_size_read(inode)) goto end_of_dir; - err = exfat_readdir(inode, &de); + err = exfat_readdir(inode, &cpos, &de); if (err) { /* * At least we tried to read a sector. Move cpos to next sector @@ -262,13 +260,11 @@ static int exfat_iterate(struct file *filp, struct dir_context *ctx) goto end_of_dir; } - cpos = EXFAT_DEN_TO_B(ei->rwoffset); - if (!nb->lfn[0]) goto end_of_dir; i_pos = ((loff_t)ei->start_clu << 32) | - ((ei->rwoffset - 1) & 0xffffffff); + (EXFAT_B_TO_DEN(cpos-1) & 0xffffffff); tmp = exfat_iget(sb, i_pos); if (tmp) { inum = tmp->i_ino; diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index 44dc04520175..e586daf5a2e7 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -263,8 +263,6 @@ struct exfat_inode_info { * the validation of hint_stat. */ unsigned int version; - /* file offset or dentry index for readdir */ - loff_t rwoffset; /* hint for cluster last accessed */ struct exfat_hint hint_bmap; diff --git a/fs/exfat/file.c b/fs/exfat/file.c index 4831a39632a1..a92478eabfa4 100644 --- a/fs/exfat/file.c +++ b/fs/exfat/file.c @@ -208,8 +208,6 @@ int __exfat_truncate(struct inode *inode, loff_t new_size) /* hint information */ ei->hint_bmap.off = 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. */ ei->hint_stat.eidx = 0; diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c index 7f90204adef5..70a33d4807c3 100644 --- a/fs/exfat/inode.c +++ b/fs/exfat/inode.c @@ -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 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) num_clusters = 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) ei->hint_stat.eidx = 0; ei->hint_stat.clu = info->start_clu; ei->hint_femp.eidx = EXFAT_HINT_NONE; - ei->rwoffset = 0; ei->hint_bmap.off = EXFAT_EOF_CLUSTER; ei->i_pos = 0; diff --git a/fs/exfat/super.c b/fs/exfat/super.c index 3b6a1659892f..b29935a91b9b 100644 --- a/fs/exfat/super.c +++ b/fs/exfat/super.c @@ -342,7 +342,6 @@ static int exfat_read_root(struct inode *inode) ei->flags = ALLOC_FAT_CHAIN; ei->type = TYPE_DIR; ei->version = 0; - ei->rwoffset = 0; ei->hint_bmap.off = EXFAT_EOF_CLUSTER; ei->hint_stat.eidx = 0; ei->hint_stat.clu = sbi->root_dir; -- 2.25.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH] exfat: remove 'rwoffset' in exfat_inode_info 2020-09-09 7:56 ` [PATCH] exfat: remove 'rwoffset' in exfat_inode_info Tetsuhiro Kohada @ 2020-09-12 5:01 ` Sungjong Seo 2020-09-16 5:35 ` Tetsuhiro Kohada 0 siblings, 1 reply; 4+ messages in thread From: Sungjong Seo @ 2020-09-12 5:01 UTC (permalink / raw) To: 'Tetsuhiro Kohada' Cc: kohada.tetsuhiro, mori.takahiro, motai.hirotaka, 'Namjae Jeon', linux-fsdevel, linux-kernel > Remove 'rwoffset' in exfat_inode_info and replace it with the > parameter(cpos) of exfat_readdir. > Since rwoffset of is referenced only by exfat_readdir, it is not > necessary a exfat_inode_info's member. > > Signed-off-by: Tetsuhiro Kohada <kohada.t2@gmail.com> > --- > fs/exfat/dir.c | 16 ++++++---------- > fs/exfat/exfat_fs.h | 2 -- > fs/exfat/file.c | 2 -- > fs/exfat/inode.c | 3 --- > fs/exfat/super.c | 1 - > 5 files changed, 6 insertions(+), 18 deletions(-) > > diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index > a9b13ae3f325..fa5bb72aa295 100644 > --- a/fs/exfat/dir.c > +++ b/fs/exfat/dir.c [snip] > sector @@ -262,13 +260,11 @@ static int exfat_iterate(struct file *filp, > struct dir_context *ctx) > goto end_of_dir; > } > > - cpos = EXFAT_DEN_TO_B(ei->rwoffset); > - > if (!nb->lfn[0]) > goto end_of_dir; > > i_pos = ((loff_t)ei->start_clu << 32) | > - ((ei->rwoffset - 1) & 0xffffffff); > + (EXFAT_B_TO_DEN(cpos-1) & 0xffffffff); Need to fix the above line to be: (EXFAT_B_TO_DEN(cpos)-1)) & 0xffffffff); ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] exfat: remove 'rwoffset' in exfat_inode_info 2020-09-12 5:01 ` Sungjong Seo @ 2020-09-16 5:35 ` Tetsuhiro Kohada 2020-09-25 0:56 ` Sungjong Seo 0 siblings, 1 reply; 4+ messages in thread From: Tetsuhiro Kohada @ 2020-09-16 5:35 UTC (permalink / raw) To: Sungjong Seo Cc: kohada.tetsuhiro, mori.takahiro, motai.hirotaka, 'Namjae Jeon', linux-fsdevel, linux-kernel On 2020/09/12 14:01, Sungjong Seo wrote: >> Remove 'rwoffset' in exfat_inode_info and replace it with the >> parameter(cpos) of exfat_readdir. >> Since rwoffset of is referenced only by exfat_readdir, it is not >> necessary a exfat_inode_info's member. >> >> Signed-off-by: Tetsuhiro Kohada <kohada.t2@gmail.com> >> --- >> fs/exfat/dir.c | 16 ++++++---------- >> fs/exfat/exfat_fs.h | 2 -- >> fs/exfat/file.c | 2 -- >> fs/exfat/inode.c | 3 --- >> fs/exfat/super.c | 1 - >> 5 files changed, 6 insertions(+), 18 deletions(-) >> >> diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index >> a9b13ae3f325..fa5bb72aa295 100644 >> --- a/fs/exfat/dir.c >> +++ b/fs/exfat/dir.c > [snip] >> sector @@ -262,13 +260,11 @@ static int exfat_iterate(struct file *filp, >> struct dir_context *ctx) >> goto end_of_dir; >> } >> >> - cpos = EXFAT_DEN_TO_B(ei->rwoffset); >> - >> if (!nb->lfn[0]) >> goto end_of_dir; >> >> i_pos = ((loff_t)ei->start_clu << 32) | >> - ((ei->rwoffset - 1) & 0xffffffff); >> + (EXFAT_B_TO_DEN(cpos-1) & 0xffffffff); > > Need to fix the above line to be: > (EXFAT_B_TO_DEN(cpos)-1)) & 0xffffffff); Here, we simply converted so that the calculation results would be the same. But after reading it carefully again, I noticed. - Why use the previous entry? - Why does cpos point to stream dir-entry in entry-set? For the former, there is no need to "++dentry" in exfat_readdir(). For the latter, I think cpos should point to the next to current entry-set. I'll make V2 considering these. How do you think? BR --- Tetsuhiro Kohada <kohada.t2@gmail.com> ^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] exfat: remove 'rwoffset' in exfat_inode_info 2020-09-16 5:35 ` Tetsuhiro Kohada @ 2020-09-25 0:56 ` Sungjong Seo 0 siblings, 0 replies; 4+ messages in thread From: Sungjong Seo @ 2020-09-25 0:56 UTC (permalink / raw) To: 'Tetsuhiro Kohada' Cc: kohada.tetsuhiro, mori.takahiro, motai.hirotaka, 'Namjae Jeon', linux-fsdevel, linux-kernel > On 2020/09/12 14:01, Sungjong Seo wrote: > >> Remove 'rwoffset' in exfat_inode_info and replace it with the > >> parameter(cpos) of exfat_readdir. > >> Since rwoffset of is referenced only by exfat_readdir, it is not > >> necessary a exfat_inode_info's member. > >> > >> Signed-off-by: Tetsuhiro Kohada <kohada.t2@gmail.com> > >> --- > >> fs/exfat/dir.c | 16 ++++++---------- > >> fs/exfat/exfat_fs.h | 2 -- > >> fs/exfat/file.c | 2 -- > >> fs/exfat/inode.c | 3 --- > >> fs/exfat/super.c | 1 - > >> 5 files changed, 6 insertions(+), 18 deletions(-) > >> > >> diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index > >> a9b13ae3f325..fa5bb72aa295 100644 > >> --- a/fs/exfat/dir.c > >> +++ b/fs/exfat/dir.c > > [snip] > >> sector @@ -262,13 +260,11 @@ static int exfat_iterate(struct file > >> *filp, struct dir_context *ctx) > >> goto end_of_dir; > >> } > >> > >> - cpos = EXFAT_DEN_TO_B(ei->rwoffset); > >> - > >> if (!nb->lfn[0]) > >> goto end_of_dir; > >> > >> i_pos = ((loff_t)ei->start_clu << 32) | > >> - ((ei->rwoffset - 1) & 0xffffffff); > >> + (EXFAT_B_TO_DEN(cpos-1) & 0xffffffff); > > > > Need to fix the above line to be: > > (EXFAT_B_TO_DEN(cpos)-1)) & 0xffffffff); > > > Here, we simply converted so that the calculation results would be the > same. > But after reading it carefully again, I noticed. > - Why use the previous entry? > - Why does cpos point to stream dir-entry in entry-set? > > For the former, there is no need to "++dentry" in exfat_readdir(). > For the latter, I think cpos should point to the next to current entry-set. > > I'll make V2 considering these. > How do you think? The latter looks better. > > BR > --- > Tetsuhiro Kohada <kohada.t2@gmail.com> ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-09-25 1:06 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <CGME20200909075713epcas1p44c2503251f78baa2fde0ce4351bf936d@epcas1p4.samsung.com> 2020-09-09 7:56 ` [PATCH] exfat: remove 'rwoffset' in exfat_inode_info Tetsuhiro Kohada 2020-09-12 5:01 ` Sungjong Seo 2020-09-16 5:35 ` Tetsuhiro Kohada 2020-09-25 0:56 ` Sungjong Seo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).