Skip to content

Commit 2a594d4

Browse files
committed
exfat: directly call filemap_write_and_wait_range() on < 5.19 kernel
sync_blockdev_range will be added to linux 5.19 kernel. So, do directly call filemap_write_and_wait_range() instead of sync_blockdev_range() on lower kernel version than 5.19 kernel. Signed-off-by: Namjae Jeon <[email protected]>
1 parent 08b714e commit 2a594d4

File tree

1 file changed

+5
-47
lines changed

1 file changed

+5
-47
lines changed

fatent.c

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ int exfat_find_last_cluster(struct super_block *sb, struct exfat_chain *p_chain,
273273
return 0;
274274
}
275275

276-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
277276
int exfat_zeroed_cluster(struct inode *dir, unsigned int clu)
278277
{
279278
struct super_block *sb = dir->i_sb;
@@ -306,60 +305,19 @@ int exfat_zeroed_cluster(struct inode *dir, unsigned int clu)
306305
}
307306

308307
if (IS_DIRSYNC(dir))
308+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
309309
return sync_blockdev_range(sb->s_bdev,
310310
EXFAT_BLK_TO_B(blknr, sb),
311311
EXFAT_BLK_TO_B(last_blknr, sb) - 1);
312-
313-
return 0;
314-
}
315312
#else
316-
int exfat_zeroed_cluster(struct inode *dir, unsigned int clu)
317-
{
318-
struct super_block *sb = dir->i_sb;
319-
struct exfat_sb_info *sbi = EXFAT_SB(sb);
320-
struct buffer_head *bhs[MAX_BUF_PER_PAGE];
321-
int nr_bhs = MAX_BUF_PER_PAGE;
322-
sector_t blknr, last_blknr;
323-
int err, i, n;
324-
325-
blknr = exfat_cluster_to_sector(sbi, clu);
326-
last_blknr = blknr + sbi->sect_per_clus;
327-
328-
if (last_blknr > sbi->num_sectors && sbi->num_sectors > 0) {
329-
exfat_fs_error_ratelimit(sb,
330-
"%s: out of range(sect:%llu len:%u)",
331-
__func__, (unsigned long long)blknr,
332-
sbi->sect_per_clus);
333-
return -EIO;
334-
}
335-
336-
/* Zeroing the unused blocks on this cluster */
337-
while (blknr < last_blknr) {
338-
for (n = 0; n < nr_bhs && blknr < last_blknr; n++, blknr++) {
339-
bhs[n] = sb_getblk(sb, blknr);
340-
if (!bhs[n]) {
341-
err = -ENOMEM;
342-
goto release_bhs;
343-
}
344-
memset(bhs[n]->b_data, 0, sb->s_blocksize);
345-
}
313+
return filemap_write_and_wait_range(sb->s_bdev->bd_inode->i_mapping,
314+
EXFAT_BLK_TO_B(blknr, sb),
315+
EXFAT_BLK_TO_B(last_blknr, sb) - 1);
316+
#endif
346317

347-
err = exfat_update_bhs(bhs, n, IS_DIRSYNC(dir));
348-
if (err)
349-
goto release_bhs;
350318

351-
for (i = 0; i < n; i++)
352-
brelse(bhs[i]);
353-
}
354319
return 0;
355-
356-
release_bhs:
357-
exfat_err(sb, "failed zeroed sect %llu\n", (unsigned long long)blknr);
358-
for (i = 0; i < n; i++)
359-
bforget(bhs[i]);
360-
return err;
361320
}
362-
#endif
363321

364322
int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc,
365323
struct exfat_chain *p_chain, bool sync_bmap)

0 commit comments

Comments
 (0)