Skip to contentSkip to conversation

exfat: improve performance of exfat_free_cluster when using dirsync mount option

PATCH Applied Hyeongseok Kim 3 participants 3 messages Jan 6, 2021 – Jan 8, 2021

Subsystems (2)

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 exfat: improve performance of exfat_free_cluster when using dirsync mount option

There are stressful update of cluster allocation bitmap when using dirsync mount option which is doing sync buffer on every cluster bit clearing. This could result in performance degradation when deleting big size file.
Fix to update only when the bitmap buffer index is changed would make less disk access, improving performance especially for truncate operation.

Testing with Samsung 256GB sdcard, mounted with dirsync option (mount -t exfat /dev/block/mmcblk0p1 /temp/mount -o dirsync)

Remove 4GB file, blktrace result.
[Before] : 39 secs.
Total (blktrace):

 Reads Queued:      0,        0KiB	 Writes Queued:      32775,    16387KiB
 Read Dispatches:   0,        0KiB	 Write Dispatches:   32775,    16387KiB
 Reads Requeued:    0		         Writes Requeued:        0
 Reads Completed:   0,        0KiB	 Writes Completed:   32775,    16387KiB
 Read Merges:       0,        0KiB	 Write Merges:           0,        0KiB
 IO unplugs:        2        	     Timer unplugs:          0

[After] : 1 sec.
Total (blktrace):

 Reads Queued:      0,        0KiB	 Writes Queued:         13,        6KiB
 Read Dispatches:   0,        0KiB	 Write Dispatches:      13,        6KiB
 Reads Requeued:    0		         Writes Requeued:        0
 Reads Completed:   0,        0KiB	 Writes Completed:      13,        6KiB
 Read Merges:       0,        0KiB	 Write Merges:           0,        0KiB
 IO unplugs:        1        	     Timer unplugs:          0
---
 fs/exfat/balloc.c   |  4 ++--
 fs/exfat/exfat_fs.h |  2 +-
 fs/exfat/fatent.c   | 42 ++++++++++++++++++++++++++++++++++++------
 3 files changed, 39 insertions(+), 9 deletions(-)
fs/exfat/balloc.c +2 -2
index a987919686c0..761c79c3a4ba 100644
@@ -166,7 +166,7 @@ int exfat_set_bitmap(struct inode *inode, unsigned int clu)
  * If the value of "clu" is 0, it means cluster 2 which is the first cluster of
  * the cluster heap.
  */
-void exfat_clear_bitmap(struct inode *inode, unsigned int clu)
+void exfat_clear_bitmap(struct inode *inode, unsigned int clu, bool sync)
 {
 	int i, b;
 	unsigned int ent_idx;
@@ -180,7 +180,7 @@ void exfat_clear_bitmap(struct inode *inode, unsigned int clu)
 	b = BITMAP_OFFSET_BIT_IN_SECTOR(sb, ent_idx);
 
 	clear_bit_le(b, sbi->vol_amap[i]->b_data);
-	exfat_update_bh(sbi->vol_amap[i], IS_DIRSYNC(inode));
+	exfat_update_bh(sbi->vol_amap[i], sync);
 
 	if (opts->discard) {
 		int ret_discard;
fs/exfat/exfat_fs.h +1 -1
index b8f0e829ecbd..764bc645241e 100644
@@ -408,7 +408,7 @@ int exfat_count_num_clusters(struct super_block *sb,
 int exfat_load_bitmap(struct super_block *sb);
 void exfat_free_bitmap(struct exfat_sb_info *sbi);
 int exfat_set_bitmap(struct inode *inode, unsigned int clu);
-void exfat_clear_bitmap(struct inode *inode, unsigned int clu);
+void exfat_clear_bitmap(struct inode *inode, unsigned int clu, bool sync);
 unsigned int exfat_find_free_bitmap(struct super_block *sb, unsigned int clu);
 int exfat_count_used_clusters(struct super_block *sb, unsigned int *ret_count);
 
fs/exfat/fatent.c +36 -6

63 lines not on this page · raw message

Signature · 1 line
2.27.0.83.g0313f36
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines

There are stressful update of cluster allocation bitmap when using dirsync mount option which is doing sync buffer on every cluster bit clearing. This could result in performance degradation when deleting big size file. Fix to update only when the bitmap buffer index is changed would make less disk access, improving performance especially for truncate operation.

Quoted 7 lines

Testing with Samsung 256GB sdcard, mounted with dirsync option (mount -t exfat /dev/block/mmcblk0p1 /temp/mount -o dirsync)

Remove 4GB file, blktrace result.
[Before] : 39 secs.
Total (blktrace):
Reads Queued: 0, 0KiB Writes Queued: 32775,

16387KiB

Quoted 1 line

Read Dispatches: 0, 0KiB Write Dispatches: 32775,

16387KiB

Quoted 2 lines
 Reads Requeued:    0		         Writes Requeued:        0
 Reads Completed:   0,        0KiB	 Writes Completed:   32775,

16387KiB

Quoted 1 line

Read Merges: 0, 0KiB Write Merges: 0,

0KiB

Quoted 5 lines

IO unplugs: 2 Timer unplugs: 0

[After] : 1 sec.
Total (blktrace):
Reads Queued: 0, 0KiB Writes Queued: 13,

6KiB

Quoted 1 line

Read Dispatches: 0, 0KiB Write Dispatches: 13,

6KiB

Quoted 2 lines

Reads Requeued: 0 Writes Requeued: 0
Reads Completed: 0, 0KiB Writes Completed: 13,

6KiB

Quoted 1 line

Read Merges: 0, 0KiB Write Merges: 0,

0KiB

Quoted 3 lines

IO unplugs: 1 Timer unplugs: 0

Looks good.
Thanks for your work!

Applied
#2 lore raw
Quoted 34 lines
Quoted 6 lines

There are stressful update of cluster allocation bitmap when using dirsync mount option which is doing sync buffer on every cluster bit clearing. This could result in performance degradation when deleting big size file. Fix to update only when the bitmap buffer index is changed would make less disk access, improving performance especially for truncate operation.

Quoted 7 lines

Testing with Samsung 256GB sdcard, mounted with dirsync option (mount -t exfat /dev/block/mmcblk0p1 /temp/mount -o dirsync)

Remove 4GB file, blktrace result.
[Before] : 39 secs.
Total (blktrace):
Reads Queued: 0, 0KiB Writes Queued: 32775,

16387KiB

Quoted 1 line

Read Dispatches: 0, 0KiB Write Dispatches: 32775,

16387KiB

Quoted 2 lines
 Reads Requeued:    0		         Writes Requeued:        0
 Reads Completed:   0,        0KiB	 Writes Completed:   32775,

16387KiB

Quoted 1 line

Read Merges: 0, 0KiB Write Merges: 0,

0KiB

Quoted 5 lines

IO unplugs: 2 Timer unplugs: 0

[After] : 1 sec.
Total (blktrace):
Reads Queued: 0, 0KiB Writes Queued: 13,

6KiB

Quoted 1 line

Read Dispatches: 0, 0KiB Write Dispatches: 13,

6KiB

Quoted 2 lines

Reads Requeued: 0 Writes Requeued: 0
Reads Completed: 0, 0KiB Writes Completed: 13,

6KiB

Quoted 1 line

Read Merges: 0, 0KiB Write Merges: 0,

0KiB

Quoted 8 lines
Quoted 3 lines

IO unplugs: 1 Timer unplugs: 0

Looks good.
Thanks for your work!

Applied. Thanks!