Skip to content

Commit 7309e48

Browse files
committed
Fix last blocknr calculation in nova_truncate_file_blocks
A truncate following fallocate (file size 0) does not really truncate the file blocks allocated, and a write after that will write to old blocks. Fix last blocknr calculation so the blocks will be truncated.
1 parent 9b8cfca commit 7309e48

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

fs/nova/inode.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,9 @@ static void nova_truncate_file_blocks(struct inode *inode, loff_t start,
410410
first_blocknr = (start + (1UL << data_bits) - 1) >> data_bits;
411411

412412
if (end == 0)
413-
return;
414-
last_blocknr = (end - 1) >> data_bits;
413+
last_blocknr = 0;
414+
else
415+
last_blocknr = (end - 1) >> data_bits;
415416

416417
if (first_blocknr > last_blocknr)
417418
return;

0 commit comments

Comments
 (0)