mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 06:31:49 +00:00
exfat: optimize exfat_zeroed_cluster()
Replace part of exfat_zeroed_cluster() with exfat_update_bhs(). And remove exfat_sync_bhs(). Signed-off-by: Tetsuhiro Kohada <kohada.t2@gmail.com> Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
This commit is contained in:
parent
8b0c471773
commit
4dc7d35e09
@ -229,21 +229,6 @@ int exfat_find_last_cluster(struct super_block *sb, struct exfat_chain *p_chain,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int exfat_sync_bhs(struct buffer_head **bhs, int nr_bhs)
|
|
||||||
{
|
|
||||||
int i, err = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < nr_bhs; i++)
|
|
||||||
write_dirty_buffer(bhs[i], 0);
|
|
||||||
|
|
||||||
for (i = 0; i < nr_bhs; i++) {
|
|
||||||
wait_on_buffer(bhs[i]);
|
|
||||||
if (!err && !buffer_uptodate(bhs[i]))
|
|
||||||
err = -EIO;
|
|
||||||
}
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
int exfat_zeroed_cluster(struct inode *dir, unsigned int clu)
|
int exfat_zeroed_cluster(struct inode *dir, unsigned int clu)
|
||||||
{
|
{
|
||||||
struct super_block *sb = dir->i_sb;
|
struct super_block *sb = dir->i_sb;
|
||||||
@ -265,41 +250,23 @@ int exfat_zeroed_cluster(struct inode *dir, unsigned int clu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Zeroing the unused blocks on this cluster */
|
/* Zeroing the unused blocks on this cluster */
|
||||||
n = 0;
|
|
||||||
while (blknr < last_blknr) {
|
while (blknr < last_blknr) {
|
||||||
bhs[n] = sb_getblk(sb, blknr);
|
for (n = 0; n < nr_bhs && blknr < last_blknr; n++, blknr++) {
|
||||||
if (!bhs[n]) {
|
bhs[n] = sb_getblk(sb, blknr);
|
||||||
err = -ENOMEM;
|
if (!bhs[n]) {
|
||||||
goto release_bhs;
|
err = -ENOMEM;
|
||||||
}
|
goto release_bhs;
|
||||||
memset(bhs[n]->b_data, 0, sb->s_blocksize);
|
|
||||||
exfat_update_bh(bhs[n], 0);
|
|
||||||
|
|
||||||
n++;
|
|
||||||
blknr++;
|
|
||||||
|
|
||||||
if (n == nr_bhs) {
|
|
||||||
if (IS_DIRSYNC(dir)) {
|
|
||||||
err = exfat_sync_bhs(bhs, n);
|
|
||||||
if (err)
|
|
||||||
goto release_bhs;
|
|
||||||
}
|
}
|
||||||
|
memset(bhs[n]->b_data, 0, sb->s_blocksize);
|
||||||
for (i = 0; i < n; i++)
|
|
||||||
brelse(bhs[i]);
|
|
||||||
n = 0;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (IS_DIRSYNC(dir)) {
|
err = exfat_update_bhs(bhs, n, IS_DIRSYNC(dir));
|
||||||
err = exfat_sync_bhs(bhs, n);
|
|
||||||
if (err)
|
if (err)
|
||||||
goto release_bhs;
|
goto release_bhs;
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
brelse(bhs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
|
||||||
brelse(bhs[i]);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
release_bhs:
|
release_bhs:
|
||||||
|
Loading…
Reference in New Issue
Block a user