Skip to content

Commit 2c7f893

Browse files
Tetsuhiro Kohadanamjaejeon
authored andcommitted
exfat: remove EXFAT_SB_DIRTY flag
This flag is set/reset in exfat_put_super()/exfat_sync_fs() to avoid sync_blockdev(). - exfat_put_super(): Before calling this, the VFS has already called sync_filesystem(), so sync is never performed here. - exfat_sync_fs(): After calling this, the VFS calls sync_blockdev(), so, it is meaningless to check EXFAT_SB_DIRTY or to bypass sync_blockdev() here. Remove the EXFAT_SB_DIRTY check to ensure synchronization. And remove the code related to the flag. Signed-off-by: Tetsuhiro Kohada <[email protected]> Reviewed-by: Sungjong Seo <[email protected]> Signed-off-by: Namjae Jeon <[email protected]>
1 parent bcf8768 commit 2c7f893

File tree

7 files changed

+26
-35
lines changed

7 files changed

+26
-35
lines changed

fs/exfat/balloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ int exfat_set_bitmap(struct inode *inode, unsigned int clu)
158158
b = BITMAP_OFFSET_BIT_IN_SECTOR(sb, ent_idx);
159159

160160
set_bit_le(b, sbi->vol_amap[i]->b_data);
161-
exfat_update_bh(sb, sbi->vol_amap[i], IS_DIRSYNC(inode));
161+
exfat_update_bh(sbi->vol_amap[i], IS_DIRSYNC(inode));
162162
return 0;
163163
}
164164

@@ -180,7 +180,7 @@ void exfat_clear_bitmap(struct inode *inode, unsigned int clu)
180180
b = BITMAP_OFFSET_BIT_IN_SECTOR(sb, ent_idx);
181181

182182
clear_bit_le(b, sbi->vol_amap[i]->b_data);
183-
exfat_update_bh(sb, sbi->vol_amap[i], IS_DIRSYNC(inode));
183+
exfat_update_bh(sbi->vol_amap[i], IS_DIRSYNC(inode));
184184

185185
if (opts->discard) {
186186
int ret_discard;

fs/exfat/dir.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ int exfat_init_dir_entry(struct inode *inode, struct exfat_chain *p_dir,
470470
&ep->dentry.file.access_date,
471471
NULL);
472472

473-
exfat_update_bh(sb, bh, IS_DIRSYNC(inode));
473+
exfat_update_bh(bh, IS_DIRSYNC(inode));
474474
brelse(bh);
475475

476476
ep = exfat_get_dentry(sb, p_dir, entry + 1, &bh, &sector);
@@ -480,7 +480,7 @@ int exfat_init_dir_entry(struct inode *inode, struct exfat_chain *p_dir,
480480
exfat_init_stream_entry(ep,
481481
(type == TYPE_FILE) ? ALLOC_FAT_CHAIN : ALLOC_NO_FAT_CHAIN,
482482
start_clu, size);
483-
exfat_update_bh(sb, bh, IS_DIRSYNC(inode));
483+
exfat_update_bh(bh, IS_DIRSYNC(inode));
484484
brelse(bh);
485485

486486
return 0;
@@ -516,7 +516,7 @@ int exfat_update_dir_chksum(struct inode *inode, struct exfat_chain *p_dir,
516516
}
517517

518518
fep->dentry.file.checksum = cpu_to_le16(chksum);
519-
exfat_update_bh(sb, fbh, IS_DIRSYNC(inode));
519+
exfat_update_bh(fbh, IS_DIRSYNC(inode));
520520
release_fbh:
521521
brelse(fbh);
522522
return ret;
@@ -538,7 +538,7 @@ int exfat_init_ext_entry(struct inode *inode, struct exfat_chain *p_dir,
538538
return -EIO;
539539

540540
ep->dentry.file.num_ext = (unsigned char)(num_entries - 1);
541-
exfat_update_bh(sb, bh, sync);
541+
exfat_update_bh(bh, sync);
542542
brelse(bh);
543543

544544
ep = exfat_get_dentry(sb, p_dir, entry + 1, &bh, &sector);
@@ -547,7 +547,7 @@ int exfat_init_ext_entry(struct inode *inode, struct exfat_chain *p_dir,
547547

548548
ep->dentry.stream.name_len = p_uniname->name_len;
549549
ep->dentry.stream.name_hash = cpu_to_le16(p_uniname->name_hash);
550-
exfat_update_bh(sb, bh, sync);
550+
exfat_update_bh(bh, sync);
551551
brelse(bh);
552552

553553
for (i = EXFAT_FIRST_CLUSTER; i < num_entries; i++) {
@@ -556,7 +556,7 @@ int exfat_init_ext_entry(struct inode *inode, struct exfat_chain *p_dir,
556556
return -EIO;
557557

558558
exfat_init_name_entry(ep, uniname);
559-
exfat_update_bh(sb, bh, sync);
559+
exfat_update_bh(bh, sync);
560560
brelse(bh);
561561
uniname += EXFAT_FILE_NAME_LEN;
562562
}
@@ -580,7 +580,7 @@ int exfat_remove_entries(struct inode *inode, struct exfat_chain *p_dir,
580580
return -EIO;
581581

582582
exfat_set_entry_type(ep, TYPE_DELETED);
583-
exfat_update_bh(sb, bh, IS_DIRSYNC(inode));
583+
exfat_update_bh(bh, IS_DIRSYNC(inode));
584584
brelse(bh);
585585
}
586586

@@ -610,7 +610,7 @@ void exfat_free_dentry_set(struct exfat_entry_set_cache *es, int sync)
610610

611611
for (i = 0; i < es->num_bh; i++) {
612612
if (es->modified)
613-
exfat_update_bh(es->sb, es->bh[i], sync);
613+
exfat_update_bh(es->bh[i], sync);
614614
brelse(es->bh[i]);
615615
}
616616
kfree(es);

fs/exfat/exfat_fs.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#define EXFAT_SUPER_MAGIC 0x2011BAB0UL
1414
#define EXFAT_ROOT_INO 1
1515

16-
#define EXFAT_SB_DIRTY 0
17-
1816
#define EXFAT_CLUSTERS_UNTRACKED (~0u)
1917

2018
/*
@@ -238,7 +236,6 @@ struct exfat_sb_info {
238236
unsigned int clu_srch_ptr; /* cluster search pointer */
239237
unsigned int used_clusters; /* number of used clusters */
240238

241-
unsigned long s_state;
242239
struct mutex s_lock; /* superblock lock */
243240
struct exfat_mount_options options;
244241
struct nls_table *nls_io; /* Charset used for input and display */
@@ -515,7 +512,7 @@ void exfat_set_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
515512
u8 *tz, __le16 *time, __le16 *date, u8 *time_cs);
516513
u16 exfat_calc_chksum16(void *data, int len, u16 chksum, int type);
517514
u32 exfat_calc_chksum32(void *data, int len, u32 chksum, int type);
518-
void exfat_update_bh(struct super_block *sb, struct buffer_head *bh, int sync);
515+
void exfat_update_bh(struct buffer_head *bh, int sync);
519516
void exfat_chain_set(struct exfat_chain *ec, unsigned int dir,
520517
unsigned int size, unsigned char flags);
521518
void exfat_chain_dup(struct exfat_chain *dup, struct exfat_chain *ec);

fs/exfat/fatent.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ int exfat_ent_set(struct super_block *sb, unsigned int loc,
7575

7676
fat_entry = (__le32 *)&(bh->b_data[off]);
7777
*fat_entry = cpu_to_le32(content);
78-
exfat_update_bh(sb, bh, sb->s_flags & SB_SYNCHRONOUS);
78+
exfat_update_bh(bh, sb->s_flags & SB_SYNCHRONOUS);
7979
exfat_mirror_bh(sb, sec, bh);
8080
brelse(bh);
8181
return 0;
@@ -174,7 +174,6 @@ int exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain)
174174
return -EIO;
175175
}
176176

177-
set_bit(EXFAT_SB_DIRTY, &sbi->s_state);
178177
clu = p_chain->dir;
179178

180179
if (p_chain->flags == ALLOC_NO_FAT_CHAIN) {
@@ -274,7 +273,7 @@ int exfat_zeroed_cluster(struct inode *dir, unsigned int clu)
274273
goto release_bhs;
275274
}
276275
memset(bhs[n]->b_data, 0, sb->s_blocksize);
277-
exfat_update_bh(sb, bhs[n], 0);
276+
exfat_update_bh(bhs[n], 0);
278277

279278
n++;
280279
blknr++;
@@ -358,8 +357,6 @@ int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc,
358357
}
359358
}
360359

361-
set_bit(EXFAT_SB_DIRTY, &sbi->s_state);
362-
363360
p_chain->dir = EXFAT_EOF_CLUSTER;
364361

365362
while ((new_clu = exfat_find_free_bitmap(sb, hint_clu)) !=

fs/exfat/misc.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,8 @@ u32 exfat_calc_chksum32(void *data, int len, u32 chksum, int type)
163163
return chksum;
164164
}
165165

166-
void exfat_update_bh(struct super_block *sb, struct buffer_head *bh, int sync)
166+
void exfat_update_bh(struct buffer_head *bh, int sync)
167167
{
168-
set_bit(EXFAT_SB_DIRTY, &EXFAT_SB(sb)->s_state);
169168
set_buffer_uptodate(bh);
170169
mark_buffer_dirty(bh);
171170

fs/exfat/namei.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ static int exfat_find_empty_entry(struct inode *inode,
387387
ep->dentry.stream.valid_size = cpu_to_le64(size);
388388
ep->dentry.stream.size = ep->dentry.stream.valid_size;
389389
ep->dentry.stream.flags = p_dir->flags;
390-
exfat_update_bh(sb, bh, IS_DIRSYNC(inode));
390+
exfat_update_bh(bh, IS_DIRSYNC(inode));
391391
brelse(bh);
392392
if (exfat_update_dir_chksum(inode, &(ei->dir),
393393
ei->entry))
@@ -1071,7 +1071,7 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir,
10711071
epnew->dentry.file.attr |= cpu_to_le16(ATTR_ARCHIVE);
10721072
ei->attr |= ATTR_ARCHIVE;
10731073
}
1074-
exfat_update_bh(sb, new_bh, sync);
1074+
exfat_update_bh(new_bh, sync);
10751075
brelse(old_bh);
10761076
brelse(new_bh);
10771077

@@ -1087,7 +1087,7 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir,
10871087
}
10881088

10891089
memcpy(epnew, epold, DENTRY_SIZE);
1090-
exfat_update_bh(sb, new_bh, sync);
1090+
exfat_update_bh(new_bh, sync);
10911091
brelse(old_bh);
10921092
brelse(new_bh);
10931093

@@ -1104,7 +1104,7 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir,
11041104
epold->dentry.file.attr |= cpu_to_le16(ATTR_ARCHIVE);
11051105
ei->attr |= ATTR_ARCHIVE;
11061106
}
1107-
exfat_update_bh(sb, old_bh, sync);
1107+
exfat_update_bh(old_bh, sync);
11081108
brelse(old_bh);
11091109
ret = exfat_init_ext_entry(inode, p_dir, oldentry,
11101110
num_new_entries, p_uniname);
@@ -1159,7 +1159,7 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir,
11591159
epnew->dentry.file.attr |= cpu_to_le16(ATTR_ARCHIVE);
11601160
ei->attr |= ATTR_ARCHIVE;
11611161
}
1162-
exfat_update_bh(sb, new_bh, IS_DIRSYNC(inode));
1162+
exfat_update_bh(new_bh, IS_DIRSYNC(inode));
11631163
brelse(mov_bh);
11641164
brelse(new_bh);
11651165

@@ -1175,7 +1175,7 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir,
11751175
}
11761176

11771177
memcpy(epnew, epmov, DENTRY_SIZE);
1178-
exfat_update_bh(sb, new_bh, IS_DIRSYNC(inode));
1178+
exfat_update_bh(new_bh, IS_DIRSYNC(inode));
11791179
brelse(mov_bh);
11801180
brelse(new_bh);
11811181

fs/exfat/super.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ static void exfat_put_super(struct super_block *sb)
4545
struct exfat_sb_info *sbi = EXFAT_SB(sb);
4646

4747
mutex_lock(&sbi->s_lock);
48-
if (test_and_clear_bit(EXFAT_SB_DIRTY, &sbi->s_state))
49-
sync_blockdev(sb->s_bdev);
50-
exfat_set_vol_flags(sb, VOL_CLEAN);
5148
exfat_free_bitmap(sbi);
5249
brelse(sbi->boot_bh);
5350
mutex_unlock(&sbi->s_lock);
@@ -60,13 +57,14 @@ static int exfat_sync_fs(struct super_block *sb, int wait)
6057
struct exfat_sb_info *sbi = EXFAT_SB(sb);
6158
int err = 0;
6259

60+
if (!wait)
61+
return 0;
62+
6363
/* If there are some dirty buffers in the bdev inode */
6464
mutex_lock(&sbi->s_lock);
65-
if (test_and_clear_bit(EXFAT_SB_DIRTY, &sbi->s_state)) {
66-
sync_blockdev(sb->s_bdev);
67-
if (exfat_set_vol_flags(sb, VOL_CLEAN))
68-
err = -EIO;
69-
}
65+
sync_blockdev(sb->s_bdev);
66+
if (exfat_set_vol_flags(sb, VOL_CLEAN))
67+
err = -EIO;
7068
mutex_unlock(&sbi->s_lock);
7169
return err;
7270
}

0 commit comments

Comments
 (0)