All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v2] exfat: remove 'rwoffset' in exfat_inode_info
@ 2020-09-17 20:14 kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2020-09-17 20:14 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 12305 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20200917013916.4523-1-kohada.t2@gmail.com>
References: <20200917013916.4523-1-kohada.t2@gmail.com>
TO: Tetsuhiro Kohada <kohada.t2@gmail.com>
TO: kohada.t2(a)gmail.com
CC: kohada.tetsuhiro(a)dc.mitsubishielectric.co.jp
CC: mori.takahiro(a)ab.mitsubishielectric.co.jp
CC: Namjae Jeon <namjae.jeon@samsung.com>
CC: Sungjong Seo <sj1557.seo@samsung.com>
CC: linux-fsdevel(a)vger.kernel.org
CC: linux-kernel(a)vger.kernel.org

Hi Tetsuhiro,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.9-rc5 next-20200917]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Tetsuhiro-Kohada/exfat-remove-rwoffset-in-exfat_inode_info/20200917-094833
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 5925fa68fe8244651b3f78a88c4af99190a88f0d
:::::: branch date: 18 hours ago
:::::: commit date: 18 hours ago
config: mips-randconfig-m031-20200917 (attached as .config)
compiler: mips-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
fs/exfat/dir.c:167 exfat_readdir() warn: should '(dentry + 1 + num_ext) << 5' be a 64 bit type?

Old smatch warnings:
fs/exfat/dir.c:162 exfat_readdir() warn: passing freed memory 'bh'
fs/exfat/dir.c:183 exfat_readdir() warn: should 'dentry << 5' be a 64 bit type?
fs/exfat/dir.c:257 exfat_iterate() warn: should '1 << (sb->s_blocksize_bits)' be a 64 bit type?
fs/exfat/dir.c:480 exfat_init_dir_entry() warn: passing freed memory 'bh'
fs/exfat/dir.c:547 exfat_init_ext_entry() warn: passing freed memory 'bh'
fs/exfat/dir.c:556 exfat_init_ext_entry() warn: passing freed memory 'bh'

# https://github.com/0day-ci/linux/commit/b689fc5440703f952bb232584622ae6335b3c7fd
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Tetsuhiro-Kohada/exfat-remove-rwoffset-in-exfat_inode_info/20200917-094833
git checkout b689fc5440703f952bb232584622ae6335b3c7fd
vim +167 fs/exfat/dir.c

ca06197382bde0a Namjae Jeon      2020-03-02   60  
ca06197382bde0a Namjae Jeon      2020-03-02   61  /* read a directory entry from the opened directory */
b689fc5440703f9 Tetsuhiro Kohada 2020-09-17   62  static int exfat_readdir(struct inode *inode, loff_t *cpos, struct exfat_dir_entry *dir_entry)
ca06197382bde0a Namjae Jeon      2020-03-02   63  {
b689fc5440703f9 Tetsuhiro Kohada 2020-09-17   64  	int i, dentries_per_clu, dentries_per_clu_bits = 0, num_ext;
ca06197382bde0a Namjae Jeon      2020-03-02   65  	unsigned int type, clu_offset;
ca06197382bde0a Namjae Jeon      2020-03-02   66  	sector_t sector;
ca06197382bde0a Namjae Jeon      2020-03-02   67  	struct exfat_chain dir, clu;
ca06197382bde0a Namjae Jeon      2020-03-02   68  	struct exfat_uni_name uni_name;
ca06197382bde0a Namjae Jeon      2020-03-02   69  	struct exfat_dentry *ep;
ca06197382bde0a Namjae Jeon      2020-03-02   70  	struct super_block *sb = inode->i_sb;
ca06197382bde0a Namjae Jeon      2020-03-02   71  	struct exfat_sb_info *sbi = EXFAT_SB(sb);
ca06197382bde0a Namjae Jeon      2020-03-02   72  	struct exfat_inode_info *ei = EXFAT_I(inode);
b689fc5440703f9 Tetsuhiro Kohada 2020-09-17   73  	unsigned int dentry = EXFAT_B_TO_DEN(*cpos) & 0xFFFFFFFF;
ca06197382bde0a Namjae Jeon      2020-03-02   74  	struct buffer_head *bh;
ca06197382bde0a Namjae Jeon      2020-03-02   75  
ca06197382bde0a Namjae Jeon      2020-03-02   76  	/* check if the given file ID is opened */
ca06197382bde0a Namjae Jeon      2020-03-02   77  	if (ei->type != TYPE_DIR)
ca06197382bde0a Namjae Jeon      2020-03-02   78  		return -EPERM;
ca06197382bde0a Namjae Jeon      2020-03-02   79  
ca06197382bde0a Namjae Jeon      2020-03-02   80  	if (ei->entry == -1)
ca06197382bde0a Namjae Jeon      2020-03-02   81  		exfat_chain_set(&dir, sbi->root_dir, 0, ALLOC_FAT_CHAIN);
ca06197382bde0a Namjae Jeon      2020-03-02   82  	else
ca06197382bde0a Namjae Jeon      2020-03-02   83  		exfat_chain_set(&dir, ei->start_clu,
ca06197382bde0a Namjae Jeon      2020-03-02   84  			EXFAT_B_TO_CLU(i_size_read(inode), sbi), ei->flags);
ca06197382bde0a Namjae Jeon      2020-03-02   85  
ca06197382bde0a Namjae Jeon      2020-03-02   86  	dentries_per_clu = sbi->dentries_per_clu;
ca06197382bde0a Namjae Jeon      2020-03-02   87  	dentries_per_clu_bits = ilog2(dentries_per_clu);
ca06197382bde0a Namjae Jeon      2020-03-02   88  
ca06197382bde0a Namjae Jeon      2020-03-02   89  	clu_offset = dentry >> dentries_per_clu_bits;
ca06197382bde0a Namjae Jeon      2020-03-02   90  	exfat_chain_dup(&clu, &dir);
ca06197382bde0a Namjae Jeon      2020-03-02   91  
ca06197382bde0a Namjae Jeon      2020-03-02   92  	if (clu.flags == ALLOC_NO_FAT_CHAIN) {
ca06197382bde0a Namjae Jeon      2020-03-02   93  		clu.dir += clu_offset;
ca06197382bde0a Namjae Jeon      2020-03-02   94  		clu.size -= clu_offset;
ca06197382bde0a Namjae Jeon      2020-03-02   95  	} else {
ca06197382bde0a Namjae Jeon      2020-03-02   96  		/* hint_information */
ca06197382bde0a Namjae Jeon      2020-03-02   97  		if (clu_offset > 0 && ei->hint_bmap.off != EXFAT_EOF_CLUSTER &&
ca06197382bde0a Namjae Jeon      2020-03-02   98  		    ei->hint_bmap.off > 0 && clu_offset >= ei->hint_bmap.off) {
ca06197382bde0a Namjae Jeon      2020-03-02   99  			clu_offset -= ei->hint_bmap.off;
ca06197382bde0a Namjae Jeon      2020-03-02  100  			clu.dir = ei->hint_bmap.clu;
ca06197382bde0a Namjae Jeon      2020-03-02  101  		}
ca06197382bde0a Namjae Jeon      2020-03-02  102  
ca06197382bde0a Namjae Jeon      2020-03-02  103  		while (clu_offset > 0) {
ca06197382bde0a Namjae Jeon      2020-03-02  104  			if (exfat_get_next_cluster(sb, &(clu.dir)))
ca06197382bde0a Namjae Jeon      2020-03-02  105  				return -EIO;
ca06197382bde0a Namjae Jeon      2020-03-02  106  
ca06197382bde0a Namjae Jeon      2020-03-02  107  			clu_offset--;
ca06197382bde0a Namjae Jeon      2020-03-02  108  		}
ca06197382bde0a Namjae Jeon      2020-03-02  109  	}
ca06197382bde0a Namjae Jeon      2020-03-02  110  
ca06197382bde0a Namjae Jeon      2020-03-02  111  	while (clu.dir != EXFAT_EOF_CLUSTER) {
ca06197382bde0a Namjae Jeon      2020-03-02  112  		i = dentry & (dentries_per_clu - 1);
ca06197382bde0a Namjae Jeon      2020-03-02  113  
ca06197382bde0a Namjae Jeon      2020-03-02  114  		for ( ; i < dentries_per_clu; i++, dentry++) {
ca06197382bde0a Namjae Jeon      2020-03-02  115  			ep = exfat_get_dentry(sb, &clu, i, &bh, &sector);
ca06197382bde0a Namjae Jeon      2020-03-02  116  			if (!ep)
ca06197382bde0a Namjae Jeon      2020-03-02  117  				return -EIO;
ca06197382bde0a Namjae Jeon      2020-03-02  118  
ca06197382bde0a Namjae Jeon      2020-03-02  119  			type = exfat_get_entry_type(ep);
ca06197382bde0a Namjae Jeon      2020-03-02  120  			if (type == TYPE_UNUSED) {
ca06197382bde0a Namjae Jeon      2020-03-02  121  				brelse(bh);
ca06197382bde0a Namjae Jeon      2020-03-02  122  				break;
ca06197382bde0a Namjae Jeon      2020-03-02  123  			}
ca06197382bde0a Namjae Jeon      2020-03-02  124  
ca06197382bde0a Namjae Jeon      2020-03-02  125  			if (type != TYPE_FILE && type != TYPE_DIR) {
ca06197382bde0a Namjae Jeon      2020-03-02  126  				brelse(bh);
ca06197382bde0a Namjae Jeon      2020-03-02  127  				continue;
ca06197382bde0a Namjae Jeon      2020-03-02  128  			}
ca06197382bde0a Namjae Jeon      2020-03-02  129  
b689fc5440703f9 Tetsuhiro Kohada 2020-09-17  130  			num_ext = ep->dentry.file.num_ext;
ca06197382bde0a Namjae Jeon      2020-03-02  131  			dir_entry->attr = le16_to_cpu(ep->dentry.file.attr);
ca06197382bde0a Namjae Jeon      2020-03-02  132  			exfat_get_entry_time(sbi, &dir_entry->crtime,
ca06197382bde0a Namjae Jeon      2020-03-02  133  					ep->dentry.file.create_tz,
ca06197382bde0a Namjae Jeon      2020-03-02  134  					ep->dentry.file.create_time,
ca06197382bde0a Namjae Jeon      2020-03-02  135  					ep->dentry.file.create_date,
ed0f84d30ba65f4 Tetsuhiro Kohada 2020-04-22  136  					ep->dentry.file.create_time_cs);
ca06197382bde0a Namjae Jeon      2020-03-02  137  			exfat_get_entry_time(sbi, &dir_entry->mtime,
ca06197382bde0a Namjae Jeon      2020-03-02  138  					ep->dentry.file.modify_tz,
ca06197382bde0a Namjae Jeon      2020-03-02  139  					ep->dentry.file.modify_time,
ca06197382bde0a Namjae Jeon      2020-03-02  140  					ep->dentry.file.modify_date,
ed0f84d30ba65f4 Tetsuhiro Kohada 2020-04-22  141  					ep->dentry.file.modify_time_cs);
ca06197382bde0a Namjae Jeon      2020-03-02  142  			exfat_get_entry_time(sbi, &dir_entry->atime,
ca06197382bde0a Namjae Jeon      2020-03-02  143  					ep->dentry.file.access_tz,
ca06197382bde0a Namjae Jeon      2020-03-02  144  					ep->dentry.file.access_time,
ca06197382bde0a Namjae Jeon      2020-03-02  145  					ep->dentry.file.access_date,
ca06197382bde0a Namjae Jeon      2020-03-02  146  					0);
ca06197382bde0a Namjae Jeon      2020-03-02  147  
ca06197382bde0a Namjae Jeon      2020-03-02  148  			*uni_name.name = 0x0;
ca06197382bde0a Namjae Jeon      2020-03-02  149  			exfat_get_uniname_from_ext_entry(sb, &dir, dentry,
ca06197382bde0a Namjae Jeon      2020-03-02  150  				uni_name.name);
ca06197382bde0a Namjae Jeon      2020-03-02  151  			exfat_utf16_to_nls(sb, &uni_name,
ca06197382bde0a Namjae Jeon      2020-03-02  152  				dir_entry->namebuf.lfn,
ca06197382bde0a Namjae Jeon      2020-03-02  153  				dir_entry->namebuf.lfnbuf_len);
ca06197382bde0a Namjae Jeon      2020-03-02  154  			brelse(bh);
ca06197382bde0a Namjae Jeon      2020-03-02  155  
ca06197382bde0a Namjae Jeon      2020-03-02  156  			ep = exfat_get_dentry(sb, &clu, i + 1, &bh, NULL);
ca06197382bde0a Namjae Jeon      2020-03-02  157  			if (!ep)
ca06197382bde0a Namjae Jeon      2020-03-02  158  				return -EIO;
ca06197382bde0a Namjae Jeon      2020-03-02  159  			dir_entry->size =
ca06197382bde0a Namjae Jeon      2020-03-02  160  				le64_to_cpu(ep->dentry.stream.valid_size);
b689fc5440703f9 Tetsuhiro Kohada 2020-09-17  161  			dir_entry->entry = dentry;
ca06197382bde0a Namjae Jeon      2020-03-02  162  			brelse(bh);
ca06197382bde0a Namjae Jeon      2020-03-02  163  
ca06197382bde0a Namjae Jeon      2020-03-02  164  			ei->hint_bmap.off = dentry >> dentries_per_clu_bits;
ca06197382bde0a Namjae Jeon      2020-03-02  165  			ei->hint_bmap.clu = clu.dir;
ca06197382bde0a Namjae Jeon      2020-03-02  166  
b689fc5440703f9 Tetsuhiro Kohada 2020-09-17 @167  			*cpos = EXFAT_DEN_TO_B(dentry + 1 + num_ext);
ca06197382bde0a Namjae Jeon      2020-03-02  168  			return 0;
ca06197382bde0a Namjae Jeon      2020-03-02  169  		}
ca06197382bde0a Namjae Jeon      2020-03-02  170  
ca06197382bde0a Namjae Jeon      2020-03-02  171  		if (clu.flags == ALLOC_NO_FAT_CHAIN) {
ca06197382bde0a Namjae Jeon      2020-03-02  172  			if (--clu.size > 0)
ca06197382bde0a Namjae Jeon      2020-03-02  173  				clu.dir++;
ca06197382bde0a Namjae Jeon      2020-03-02  174  			else
ca06197382bde0a Namjae Jeon      2020-03-02  175  				clu.dir = EXFAT_EOF_CLUSTER;
ca06197382bde0a Namjae Jeon      2020-03-02  176  		} else {
ca06197382bde0a Namjae Jeon      2020-03-02  177  			if (exfat_get_next_cluster(sb, &(clu.dir)))
ca06197382bde0a Namjae Jeon      2020-03-02  178  				return -EIO;
ca06197382bde0a Namjae Jeon      2020-03-02  179  		}
ca06197382bde0a Namjae Jeon      2020-03-02  180  	}
ca06197382bde0a Namjae Jeon      2020-03-02  181  
ca06197382bde0a Namjae Jeon      2020-03-02  182  	dir_entry->namebuf.lfn[0] = '\0';
b689fc5440703f9 Tetsuhiro Kohada 2020-09-17  183  	*cpos = EXFAT_DEN_TO_B(dentry);
ca06197382bde0a Namjae Jeon      2020-03-02  184  	return 0;
ca06197382bde0a Namjae Jeon      2020-03-02  185  }
ca06197382bde0a Namjae Jeon      2020-03-02  186  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 27437 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH v2] exfat: remove 'rwoffset' in exfat_inode_info
  2020-09-25  0:58   ` Sungjong Seo
@ 2020-09-25  7:17     ` Namjae Jeon
  0 siblings, 0 replies; 4+ messages in thread
From: Namjae Jeon @ 2020-09-25  7:17 UTC (permalink / raw)
  To: 'Sungjong Seo', 'Tetsuhiro Kohada'
  Cc: kohada.tetsuhiro, mori.takahiro, linux-fsdevel, linux-kernel

> > 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>
Applied, Thanks for your patch!


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH v2] exfat: remove 'rwoffset' in exfat_inode_info
  2020-09-17  1:39 ` Tetsuhiro Kohada
@ 2020-09-25  0:58   ` Sungjong Seo
  2020-09-25  7:17     ` Namjae Jeon
  0 siblings, 1 reply; 4+ messages in thread
From: Sungjong Seo @ 2020-09-25  0:58 UTC (permalink / raw)
  To: 'Tetsuhiro Kohada'
  Cc: kohada.tetsuhiro, mori.takahiro, 'Namjae Jeon',
	linux-fsdevel, linux-kernel

> 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>
> ---
> Changes in v2
>  - 'cpos' point to the next of entry-set
>  - return the index of dir-entry via dir_entry->entry
>  - fix commit-message
> 
>  fs/exfat/dir.c      | 21 +++++++++------------
>  fs/exfat/exfat_fs.h |  2 --
>  fs/exfat/file.c     |  2 --
>  fs/exfat/inode.c    |  3 ---
>  fs/exfat/super.c    |  1 -
>  5 files changed, 9 insertions(+), 20 deletions(-)
> 
> diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index
> a9b13ae3f325..82bee625549d 100644
> --- a/fs/exfat/dir.c
> +++ b/fs/exfat/dir.c
> @@ -59,9 +59,9 @@ 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;
> +	int i, dentries_per_clu, dentries_per_clu_bits = 0, num_ext;
>  	unsigned int type, clu_offset;
>  	sector_t sector;
>  	struct exfat_chain dir, clu;
> @@ -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 */ @@ -127,6 +127,7 @@
> static int exfat_readdir(struct inode *inode, struct exfat_dir_entry
> *dir_entry)
>  				continue;
>  			}
> 
> +			num_ext = ep->dentry.file.num_ext;
>  			dir_entry->attr = le16_to_cpu(ep->dentry.file.attr);
>  			exfat_get_entry_time(sbi, &dir_entry->crtime,
>  					ep->dentry.file.create_tz,
> @@ -157,12 +158,13 @@ static int exfat_readdir(struct inode *inode, struct
> exfat_dir_entry *dir_entry)
>  				return -EIO;
>  			dir_entry->size =
>  				le64_to_cpu(ep->dentry.stream.valid_size);
> +			dir_entry->entry = dentry;
>  			brelse(bh);
> 
>  			ei->hint_bmap.off = dentry >> dentries_per_clu_bits;
>  			ei->hint_bmap.clu = clu.dir;
> 
> -			ei->rwoffset = ++dentry;
> +			*cpos = EXFAT_DEN_TO_B(dentry + 1 + num_ext);
>  			return 0;
>  		}
> 
> @@ -178,7 +180,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 +244,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 +262,10 @@ 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);
> +	i_pos = ((loff_t)ei->start_clu << 32) |	(de.entry & 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	[flat|nested] 4+ messages in thread

* [PATCH v2] exfat: remove 'rwoffset' in exfat_inode_info
@ 2020-09-17  1:39 ` Tetsuhiro Kohada
  2020-09-25  0:58   ` Sungjong Seo
  0 siblings, 1 reply; 4+ messages in thread
From: Tetsuhiro Kohada @ 2020-09-17  1:39 UTC (permalink / raw)
  To: kohada.t2
  Cc: kohada.tetsuhiro, mori.takahiro, Namjae Jeon, Sungjong Seo,
	linux-fsdevel, linux-kernel

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>
---
Changes in v2
 - 'cpos' point to the next of entry-set
 - return the index of dir-entry via dir_entry->entry
 - fix commit-message

 fs/exfat/dir.c      | 21 +++++++++------------
 fs/exfat/exfat_fs.h |  2 --
 fs/exfat/file.c     |  2 --
 fs/exfat/inode.c    |  3 ---
 fs/exfat/super.c    |  1 -
 5 files changed, 9 insertions(+), 20 deletions(-)

diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c
index a9b13ae3f325..82bee625549d 100644
--- a/fs/exfat/dir.c
+++ b/fs/exfat/dir.c
@@ -59,9 +59,9 @@ 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;
+	int i, dentries_per_clu, dentries_per_clu_bits = 0, num_ext;
 	unsigned int type, clu_offset;
 	sector_t sector;
 	struct exfat_chain dir, clu;
@@ -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 */
@@ -127,6 +127,7 @@ static int exfat_readdir(struct inode *inode, struct exfat_dir_entry *dir_entry)
 				continue;
 			}
 
+			num_ext = ep->dentry.file.num_ext;
 			dir_entry->attr = le16_to_cpu(ep->dentry.file.attr);
 			exfat_get_entry_time(sbi, &dir_entry->crtime,
 					ep->dentry.file.create_tz,
@@ -157,12 +158,13 @@ static int exfat_readdir(struct inode *inode, struct exfat_dir_entry *dir_entry)
 				return -EIO;
 			dir_entry->size =
 				le64_to_cpu(ep->dentry.stream.valid_size);
+			dir_entry->entry = dentry;
 			brelse(bh);
 
 			ei->hint_bmap.off = dentry >> dentries_per_clu_bits;
 			ei->hint_bmap.clu = clu.dir;
 
-			ei->rwoffset = ++dentry;
+			*cpos = EXFAT_DEN_TO_B(dentry + 1 + num_ext);
 			return 0;
 		}
 
@@ -178,7 +180,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 +244,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 +262,10 @@ 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);
+	i_pos = ((loff_t)ei->start_clu << 32) |	(de.entry & 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

end of thread, other threads:[~2020-09-25  7:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 20:14 [PATCH v2] exfat: remove 'rwoffset' in exfat_inode_info kernel test robot
     [not found] <CGME20200917014010epcas1p335c9ba540cd41ff9bf6b0ce2e39d7519@epcas1p3.samsung.com>
2020-09-17  1:39 ` Tetsuhiro Kohada
2020-09-25  0:58   ` Sungjong Seo
2020-09-25  7:17     ` Namjae Jeon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.