Skip to content

Commit 4dc7d35

Browse files
Tetsuhiro Kohadanamjaejeon
authored andcommitted
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 <[email protected]> Reviewed-by: Sungjong Seo <[email protected]> Signed-off-by: Namjae Jeon <[email protected]>
1 parent 8b0c471 commit 4dc7d35

File tree

1 file changed

+10
-43
lines changed

1 file changed

+10
-43
lines changed

fs/exfat/fatent.c

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -229,21 +229,6 @@ int exfat_find_last_cluster(struct super_block *sb, struct exfat_chain *p_chain,
229229
return 0;
230230
}
231231

232-
static inline int exfat_sync_bhs(struct buffer_head **bhs, int nr_bhs)
233-
{
234-
int i, err = 0;
235-
236-
for (i = 0; i < nr_bhs; i++)
237-
write_dirty_buffer(bhs[i], 0);
238-
239-
for (i = 0; i < nr_bhs; i++) {
240-
wait_on_buffer(bhs[i]);
241-
if (!err && !buffer_uptodate(bhs[i]))
242-
err = -EIO;
243-
}
244-
return err;
245-
}
246-
247232
int exfat_zeroed_cluster(struct inode *dir, unsigned int clu)
248233
{
249234
struct super_block *sb = dir->i_sb;
@@ -265,41 +250,23 @@ int exfat_zeroed_cluster(struct inode *dir, unsigned int clu)
265250
}
266251

267252
/* Zeroing the unused blocks on this cluster */
268-
n = 0;
269253
while (blknr < last_blknr) {
270-
bhs[n] = sb_getblk(sb, blknr);
271-
if (!bhs[n]) {
272-
err = -ENOMEM;
273-
goto release_bhs;
274-
}
275-
memset(bhs[n]->b_data, 0, sb->s_blocksize);
276-
exfat_update_bh(bhs[n], 0);
277-
278-
n++;
279-
blknr++;
280-
281-
if (n == nr_bhs) {
282-
if (IS_DIRSYNC(dir)) {
283-
err = exfat_sync_bhs(bhs, n);
284-
if (err)
285-
goto release_bhs;
254+
for (n = 0; n < nr_bhs && blknr < last_blknr; n++, blknr++) {
255+
bhs[n] = sb_getblk(sb, blknr);
256+
if (!bhs[n]) {
257+
err = -ENOMEM;
258+
goto release_bhs;
286259
}
287-
288-
for (i = 0; i < n; i++)
289-
brelse(bhs[i]);
290-
n = 0;
260+
memset(bhs[n]->b_data, 0, sb->s_blocksize);
291261
}
292-
}
293262

294-
if (IS_DIRSYNC(dir)) {
295-
err = exfat_sync_bhs(bhs, n);
263+
err = exfat_update_bhs(bhs, n, IS_DIRSYNC(dir));
296264
if (err)
297265
goto release_bhs;
298-
}
299-
300-
for (i = 0; i < n; i++)
301-
brelse(bhs[i]);
302266

267+
for (i = 0; i < n; i++)
268+
brelse(bhs[i]);
269+
}
303270
return 0;
304271

305272
release_bhs:

0 commit comments

Comments
 (0)