Skip to content

Commit afb6ffa

Browse files
Chi Zhilingnamjaejeon
authored andcommitted
exfat: reduce the number of parameters for exfat_get_cluster()
Remove parameter 'fclus' and 'allow_eof': - The fclus parameter is changed to a local variable as it is not needed to be returned. - The passed allow_eof parameter was always 1, remove it and the associated error handling. Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn> Reviewed-by: Yuezhang Mo <Yuezhang.Mo@sony.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
1 parent 5dc72a5 commit afb6ffa

3 files changed

Lines changed: 11 additions & 24 deletions

File tree

fs/exfat/cache.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,12 @@ static inline void cache_init(struct exfat_cache_id *cid,
234234
}
235235

236236
int exfat_get_cluster(struct inode *inode, unsigned int cluster,
237-
unsigned int *fclus, unsigned int *dclus,
238-
unsigned int *last_dclus, int allow_eof)
237+
unsigned int *dclus, unsigned int *last_dclus)
239238
{
240239
struct super_block *sb = inode->i_sb;
241240
struct exfat_inode_info *ei = EXFAT_I(inode);
242241
struct exfat_cache_id cid;
243-
unsigned int content;
242+
unsigned int content, fclus;
244243

245244
if (ei->start_clu == EXFAT_FREE_CLUSTER) {
246245
exfat_fs_error(sb,
@@ -249,7 +248,7 @@ int exfat_get_cluster(struct inode *inode, unsigned int cluster,
249248
return -EIO;
250249
}
251250

252-
*fclus = 0;
251+
fclus = 0;
253252
*dclus = ei->start_clu;
254253
*last_dclus = *dclus;
255254

@@ -260,32 +259,24 @@ int exfat_get_cluster(struct inode *inode, unsigned int cluster,
260259
return 0;
261260

262261
cache_init(&cid, EXFAT_EOF_CLUSTER, EXFAT_EOF_CLUSTER);
263-
exfat_cache_lookup(inode, cluster, &cid, fclus, dclus);
262+
exfat_cache_lookup(inode, cluster, &cid, &fclus, dclus);
264263

265-
if (*fclus == cluster)
264+
if (fclus == cluster)
266265
return 0;
267266

268-
while (*fclus < cluster) {
267+
while (fclus < cluster) {
269268
if (exfat_ent_get(sb, *dclus, &content, NULL))
270269
return -EIO;
271270

272271
*last_dclus = *dclus;
273272
*dclus = content;
274-
(*fclus)++;
275-
276-
if (content == EXFAT_EOF_CLUSTER) {
277-
if (!allow_eof) {
278-
exfat_fs_error(sb,
279-
"invalid cluster chain (i_pos %u, last_clus 0x%08x is EOF)",
280-
*fclus, (*last_dclus));
281-
return -EIO;
282-
}
273+
fclus++;
283274

275+
if (content == EXFAT_EOF_CLUSTER)
284276
break;
285-
}
286277

287278
if (!cache_contiguous(&cid, *dclus))
288-
cache_init(&cid, *fclus, *dclus);
279+
cache_init(&cid, fclus, *dclus);
289280
}
290281

291282
exfat_cache_add(inode, &cid);

fs/exfat/exfat_fs.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,7 @@ int exfat_cache_init(void);
486486
void exfat_cache_shutdown(void);
487487
void exfat_cache_inval_inode(struct inode *inode);
488488
int exfat_get_cluster(struct inode *inode, unsigned int cluster,
489-
unsigned int *fclus, unsigned int *dclus,
490-
unsigned int *last_dclus, int allow_eof);
489+
unsigned int *dclus, unsigned int *last_dclus);
491490

492491
/* dir.c */
493492
extern const struct inode_operations exfat_dir_inode_operations;

fs/exfat/inode.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,10 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset,
157157
*clu += clu_offset;
158158
}
159159
} else if (ei->type == TYPE_FILE) {
160-
unsigned int fclus = 0;
161160
int err = exfat_get_cluster(inode, clu_offset,
162-
&fclus, clu, &last_clu, 1);
161+
clu, &last_clu);
163162
if (err)
164163
return -EIO;
165-
166-
clu_offset -= fclus;
167164
} else {
168165
/* hint information */
169166
if (clu_offset > 0 && ei->hint_bmap.off != EXFAT_EOF_CLUSTER &&

0 commit comments

Comments
 (0)