Skip to content

Commit 3db3c3f

Browse files
Tetsuhiro Kohadanamjaejeon
authored andcommitted
exfat: write multiple sectors at once
Write multiple sectors at once when updating dir-entries. Add exfat_update_bhs() for that. It wait for write completion once instead of sector by sector. It's only effective if sync enabled. Signed-off-by: Tetsuhiro Kohada <[email protected]> Signed-off-by: Namjae Jeon <[email protected]>
1 parent 2c7f893 commit 3db3c3f

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

fs/exfat/dir.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -606,13 +606,16 @@ void exfat_update_dir_chksum_with_entry_set(struct exfat_entry_set_cache *es)
606606

607607
void exfat_free_dentry_set(struct exfat_entry_set_cache *es, int sync)
608608
{
609-
int i;
609+
int i, err = 0;
610610

611-
for (i = 0; i < es->num_bh; i++) {
612-
if (es->modified)
613-
exfat_update_bh(es->bh[i], sync);
614-
brelse(es->bh[i]);
615-
}
611+
if (es->modified)
612+
err = exfat_update_bhs(es->bh, es->num_bh, sync);
613+
614+
for (i = 0; i < es->num_bh; i++)
615+
if (err)
616+
bforget(es->bh[i]);
617+
else
618+
brelse(es->bh[i]);
616619
kfree(es);
617620
}
618621

fs/exfat/exfat_fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ void exfat_set_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
513513
u16 exfat_calc_chksum16(void *data, int len, u16 chksum, int type);
514514
u32 exfat_calc_chksum32(void *data, int len, u32 chksum, int type);
515515
void exfat_update_bh(struct buffer_head *bh, int sync);
516+
int exfat_update_bhs(struct buffer_head **bhs, int nr_bhs, int sync);
516517
void exfat_chain_set(struct exfat_chain *ec, unsigned int dir,
517518
unsigned int size, unsigned char flags);
518519
void exfat_chain_dup(struct exfat_chain *dup, struct exfat_chain *ec);

fs/exfat/misc.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,25 @@ void exfat_update_bh(struct buffer_head *bh, int sync)
172172
sync_dirty_buffer(bh);
173173
}
174174

175+
int exfat_update_bhs(struct buffer_head **bhs, int nr_bhs, int sync)
176+
{
177+
int i, err = 0;
178+
179+
for (i = 0; i < nr_bhs; i++) {
180+
set_buffer_uptodate(bhs[i]);
181+
mark_buffer_dirty(bhs[i]);
182+
if (sync)
183+
write_dirty_buffer(bhs[i], 0);
184+
}
185+
186+
for (i = 0; i < nr_bhs && sync; i++) {
187+
wait_on_buffer(bhs[i]);
188+
if (!err && !buffer_uptodate(bhs[i]))
189+
err = -EIO;
190+
}
191+
return err;
192+
}
193+
175194
void exfat_chain_set(struct exfat_chain *ec, unsigned int dir,
176195
unsigned int size, unsigned char flags)
177196
{

0 commit comments

Comments
 (0)