Skip to content

Commit 23befe4

Browse files
hyeongseok-kim901namjaejeon
authored andcommitted
exfat: improve write performance when dirsync enabled
Degradation of write speed caused by frequent disk access for cluster bitmap update on every cluster allocation could be improved by selective syncing bitmap buffer. Change to flush bitmap buffer only for the directory related operations. Signed-off-by: Hyeongseok Kim <[email protected]> Acked-by: Sungjong Seo <[email protected]> Signed-off-by: Namjae Jeon <[email protected]>
1 parent 654762d commit 23befe4

File tree

6 files changed

+10
-9
lines changed

6 files changed

+10
-9
lines changed

fs/exfat/balloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void exfat_free_bitmap(struct exfat_sb_info *sbi)
141141
kfree(sbi->vol_amap);
142142
}
143143

144-
int exfat_set_bitmap(struct inode *inode, unsigned int clu)
144+
int exfat_set_bitmap(struct inode *inode, unsigned int clu, bool sync)
145145
{
146146
int i, b;
147147
unsigned int ent_idx;
@@ -154,7 +154,7 @@ int exfat_set_bitmap(struct inode *inode, unsigned int clu)
154154
b = BITMAP_OFFSET_BIT_IN_SECTOR(sb, ent_idx);
155155

156156
set_bit_le(b, sbi->vol_amap[i]->b_data);
157-
exfat_update_bh(sbi->vol_amap[i], IS_DIRSYNC(inode));
157+
exfat_update_bh(sbi->vol_amap[i], sync);
158158
return 0;
159159
}
160160

fs/exfat/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ int exfat_alloc_new_dir(struct inode *inode, struct exfat_chain *clu)
320320

321321
exfat_chain_set(clu, EXFAT_EOF_CLUSTER, 0, ALLOC_NO_FAT_CHAIN);
322322

323-
ret = exfat_alloc_cluster(inode, 1, clu);
323+
ret = exfat_alloc_cluster(inode, 1, clu, IS_DIRSYNC(inode));
324324
if (ret)
325325
return ret;
326326

fs/exfat/exfat_fs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ int exfat_clear_volume_dirty(struct super_block *sb);
389389
#define exfat_get_next_cluster(sb, pclu) exfat_ent_get(sb, *(pclu), pclu)
390390

391391
int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc,
392-
struct exfat_chain *p_chain);
392+
struct exfat_chain *p_chain, bool sync_bmap);
393393
int exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain);
394394
int exfat_ent_get(struct super_block *sb, unsigned int loc,
395395
unsigned int *content);
@@ -408,7 +408,7 @@ int exfat_count_num_clusters(struct super_block *sb,
408408
/* balloc.c */
409409
int exfat_load_bitmap(struct super_block *sb);
410410
void exfat_free_bitmap(struct exfat_sb_info *sbi);
411-
int exfat_set_bitmap(struct inode *inode, unsigned int clu);
411+
int exfat_set_bitmap(struct inode *inode, unsigned int clu, bool sync);
412412
void exfat_clear_bitmap(struct inode *inode, unsigned int clu, bool sync);
413413
unsigned int exfat_find_free_bitmap(struct super_block *sb, unsigned int clu);
414414
int exfat_count_used_clusters(struct super_block *sb, unsigned int *ret_count);

fs/exfat/fatent.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ int exfat_zeroed_cluster(struct inode *dir, unsigned int clu)
320320
}
321321

322322
int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc,
323-
struct exfat_chain *p_chain)
323+
struct exfat_chain *p_chain, bool sync_bmap)
324324
{
325325
int ret = -ENOSPC;
326326
unsigned int num_clusters = 0, total_cnt;
@@ -388,7 +388,7 @@ int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc,
388388
}
389389

390390
/* update allocation bitmap */
391-
if (exfat_set_bitmap(inode, new_clu)) {
391+
if (exfat_set_bitmap(inode, new_clu, sync_bmap)) {
392392
ret = -EIO;
393393
goto free_cluster;
394394
}

fs/exfat/inode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset,
179179
return -EIO;
180180
}
181181

182-
ret = exfat_alloc_cluster(inode, num_to_be_allocated, &new_clu);
182+
ret = exfat_alloc_cluster(inode, num_to_be_allocated, &new_clu,
183+
inode_needs_sync(inode));
183184
if (ret)
184185
return ret;
185186

fs/exfat/namei.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ static int exfat_find_empty_entry(struct inode *inode,
340340
exfat_chain_set(&clu, last_clu + 1, 0, p_dir->flags);
341341

342342
/* allocate a cluster */
343-
ret = exfat_alloc_cluster(inode, 1, &clu);
343+
ret = exfat_alloc_cluster(inode, 1, &clu, IS_DIRSYNC(inode));
344344
if (ret)
345345
return ret;
346346

0 commit comments

Comments
 (0)