summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2018-08-08 21:11:43 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:09 -0400
commit5f461e01b830a6730765d4a19ab0865749733289 (patch)
tree8a8b35f34b5634c331ee4859adb66084583f3a8d /fs
parent54e2264e17941c3b21b1240d719cd2a3b330bec1 (diff)
bcachefs: convert fpunch to bch2_extent_update()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r--fs/bcachefs/fs-io.c32
1 files changed, 3 insertions, 29 deletions
diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c
index 2389b1f69aa5..7954455bea93 100644
--- a/fs/bcachefs/fs-io.c
+++ b/fs/bcachefs/fs-io.c
@@ -2380,7 +2380,6 @@ err:
static long bch2_fpunch(struct bch_inode_info *inode, loff_t offset, loff_t len)
{
struct bch_fs *c = inode->v.i_sb->s_fs_info;
- u64 ino = inode->v.i_ino;
u64 discard_start = round_up(offset, PAGE_SIZE) >> 9;
u64 discard_end = round_down(offset + len, PAGE_SIZE) >> 9;
int ret = 0;
@@ -2406,34 +2405,9 @@ static long bch2_fpunch(struct bch_inode_info *inode, loff_t offset, loff_t len)
truncate_pagecache_range(&inode->v, offset, offset + len - 1);
- if (discard_start < discard_end) {
- /*
- * We need to pass in a disk reservation here because we might
- * be splitting a compressed extent into two. This isn't a
- * problem with truncate because truncate will never split an
- * extent, only truncate it...
- */
- struct disk_reservation disk_res =
- bch2_disk_reservation_init(c, 0);
- struct i_sectors_hook i_sectors_hook =
- i_sectors_hook_init(inode, 0);
- int ret;
-
- ret = i_sectors_dirty_start(c, &i_sectors_hook);
- if (unlikely(ret))
- goto err;
-
- ret = bch2_btree_delete_range(c,
- BTREE_ID_EXTENTS,
- POS(ino, discard_start),
- POS(ino, discard_end),
- ZERO_VERSION,
- &disk_res,
- &i_sectors_hook.hook,
- &inode->ei_journal_seq);
-
- ret = i_sectors_dirty_finish(c, &i_sectors_hook) ?: ret;
- }
+ if (discard_start < discard_end)
+ ret = __bch2_fpunch(c, inode, discard_start, discard_end,
+ &inode->ei_journal_seq);
err:
bch2_pagecache_block_put(&inode->ei_pagecache_lock);
inode_unlock(&inode->v);