Skip to content

Commit a4a3d8c

Browse files
YuezhangMonamjaejeon
authored andcommitted
exfat: do not clear VolumeDirty in writeback
Before this commit, VolumeDirty will be cleared first in writeback if 'dirsync' or 'sync' is not enabled. If the power is suddenly cut off after cleaning VolumeDirty but other updates are not written, the exFAT filesystem will not be able to detect the power failure in the next mount. And VolumeDirty will be set again but not cleared when updating the parent directory. It means that BootSector will be written at least once in each write-back, which will shorten the life of the device. Reviewed-by: Andy Wu <Andy.Wu@sony.com> Reviewed-by: Aoyama Wataru <wataru.aoyama@sony.com> Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
1 parent 9ec784b commit a4a3d8c

3 files changed

Lines changed: 2 additions & 15 deletions

File tree

fs/exfat/file.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,6 @@ int __exfat_truncate(struct inode *inode, loff_t new_size)
218218
if (exfat_free_cluster(inode, &clu))
219219
return -EIO;
220220

221-
exfat_clear_volume_dirty(sb);
222-
223221
return 0;
224222
}
225223

fs/exfat/namei.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,6 @@ static int exfat_create(struct user_namespace *mnt_userns, struct inode *dir,
576576
exfat_set_volume_dirty(sb);
577577
err = exfat_add_entry(dir, dentry->d_name.name, &cdir, TYPE_FILE,
578578
&info);
579-
exfat_clear_volume_dirty(sb);
580579
if (err)
581580
goto unlock;
582581

@@ -834,7 +833,6 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry)
834833

835834
/* This doesn't modify ei */
836835
ei->dir.dir = DIR_DELETED;
837-
exfat_clear_volume_dirty(sb);
838836

839837
inode_inc_iversion(dir);
840838
dir->i_mtime = dir->i_atime = current_time(dir);
@@ -868,7 +866,6 @@ static int exfat_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
868866
exfat_set_volume_dirty(sb);
869867
err = exfat_add_entry(dir, dentry->d_name.name, &cdir, TYPE_DIR,
870868
&info);
871-
exfat_clear_volume_dirty(sb);
872869
if (err)
873870
goto unlock;
874871

@@ -998,7 +995,6 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry)
998995
goto unlock;
999996
}
1000997
ei->dir.dir = DIR_DELETED;
1001-
exfat_clear_volume_dirty(sb);
1002998

1003999
inode_inc_iversion(dir);
10041000
dir->i_mtime = dir->i_atime = current_time(dir);
@@ -1333,7 +1329,6 @@ static int __exfat_rename(struct inode *old_parent_inode,
13331329
*/
13341330
new_ei->dir.dir = DIR_DELETED;
13351331
}
1336-
exfat_clear_volume_dirty(sb);
13371332
out:
13381333
return ret;
13391334
}

fs/exfat/super.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ static int exfat_set_vol_flags(struct super_block *sb, unsigned short new_flags)
100100
{
101101
struct exfat_sb_info *sbi = EXFAT_SB(sb);
102102
struct boot_sector *p_boot = (struct boot_sector *)sbi->boot_bh->b_data;
103-
bool sync;
104103

105104
/* retain persistent-flags */
106105
new_flags |= sbi->vol_flags_persistent;
@@ -119,16 +118,11 @@ static int exfat_set_vol_flags(struct super_block *sb, unsigned short new_flags)
119118

120119
p_boot->vol_flags = cpu_to_le16(new_flags);
121120

122-
if ((new_flags & VOLUME_DIRTY) && !buffer_dirty(sbi->boot_bh))
123-
sync = true;
124-
else
125-
sync = false;
126-
127121
set_buffer_uptodate(sbi->boot_bh);
128122
mark_buffer_dirty(sbi->boot_bh);
129123

130-
if (sync)
131-
sync_dirty_buffer(sbi->boot_bh);
124+
__sync_dirty_buffer(sbi->boot_bh, REQ_SYNC | REQ_FUA | REQ_PREFLUSH);
125+
132126
return 0;
133127
}
134128

0 commit comments

Comments
 (0)