Skip to content

Commit f5e5177

Browse files
Chi Zhilingnamjaejeon
authored andcommitted
exfat: introduce exfat_cluster_walk helper
Introduce exfat_cluster_walk() to walk the FAT chain by a given step, handling both ALLOC_NO_FAT_CHAIN and ALLOC_FAT_CHAIN modes. Also redefine exfat_get_next_cluster as a thin wrapper around it for backward compatibility. Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn> Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com> Reviewed-by: Yuezhang Mo <Yuezhang.Mo@sony.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
1 parent ff37797 commit f5e5177

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

fs/exfat/exfat_fs.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,8 @@ int exfat_set_volume_dirty(struct super_block *sb);
437437
int exfat_clear_volume_dirty(struct super_block *sb);
438438

439439
/* fatent.c */
440-
#define exfat_get_next_cluster(sb, pclu) exfat_ent_get(sb, *(pclu), pclu, NULL)
440+
#define exfat_get_next_cluster(sb, pclu) \
441+
exfat_cluster_walk(sb, (pclu), 1, ALLOC_FAT_CHAIN)
441442

442443
int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc,
443444
struct exfat_chain *p_chain, bool sync_bmap);
@@ -456,6 +457,26 @@ int exfat_count_num_clusters(struct super_block *sb,
456457
int exfat_blk_readahead(struct super_block *sb, sector_t sec,
457458
sector_t *ra, blkcnt_t *ra_cnt, sector_t end);
458459

460+
static inline int
461+
exfat_cluster_walk(struct super_block *sb, unsigned int *clu,
462+
unsigned int step, int flags)
463+
{
464+
struct buffer_head *bh = NULL;
465+
466+
if (flags == ALLOC_NO_FAT_CHAIN) {
467+
(*clu) += step;
468+
return 0;
469+
}
470+
471+
while (step--) {
472+
if (exfat_ent_get(sb, *clu, clu, &bh))
473+
return -EIO;
474+
}
475+
brelse(bh);
476+
477+
return 0;
478+
}
479+
459480
/* balloc.c */
460481
int exfat_load_bitmap(struct super_block *sb);
461482
void exfat_free_bitmap(struct exfat_sb_info *sbi);

0 commit comments

Comments
 (0)