Commit c9cfc122 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull btrfs fixes from David Sterba:

 - fix memory leak in qgroup relation ioctl when qgroup levels are
   invalid

 - don't write back dirty metadata on filesystem with errors

 - properly log renamed links

 - properly mark prealloc extent range beyond inode size as dirty (when
   no-noles is not enabled)

* tag 'for-6.18-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  btrfs: mark dirty extent range for out of bound prealloc extents
  btrfs: set inode flag BTRFS_INODE_COPY_EVERYTHING when logging new name
  btrfs: fix memory leak of qgroup_list in btrfs_add_qgroup_relation
  btrfs: ensure no dirty metadata is written back for an fs with errors
parents 8bb886cb 3b1a4a59
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -2228,6 +2228,14 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,
		wbc_account_cgroup_owner(wbc, folio, range_len);
		folio_unlock(folio);
	}
	/*
	 * If the fs is already in error status, do not submit any writeback
	 * but immediately finish it.
	 */
	if (unlikely(BTRFS_FS_ERROR(fs_info))) {
		btrfs_bio_end_io(bbio, errno_to_blk_status(BTRFS_FS_ERROR(fs_info)));
		return;
	}
	btrfs_submit_bbio(bbio, 0);
}

+10 −0
Original line number Diff line number Diff line
@@ -2854,12 +2854,22 @@ static int btrfs_fallocate_update_isize(struct inode *inode,
{
	struct btrfs_trans_handle *trans;
	struct btrfs_root *root = BTRFS_I(inode)->root;
	u64 range_start;
	u64 range_end;
	int ret;
	int ret2;

	if (mode & FALLOC_FL_KEEP_SIZE || end <= i_size_read(inode))
		return 0;

	range_start = round_down(i_size_read(inode), root->fs_info->sectorsize);
	range_end = round_up(end, root->fs_info->sectorsize);

	ret = btrfs_inode_set_file_extent_range(BTRFS_I(inode), range_start,
						range_end - range_start);
	if (ret)
		return ret;

	trans = btrfs_start_transaction(root, 1);
	if (IS_ERR(trans))
		return PTR_ERR(trans);
+0 −1
Original line number Diff line number Diff line
@@ -6873,7 +6873,6 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
	BTRFS_I(inode)->dir_index = 0ULL;
	inode_inc_iversion(inode);
	inode_set_ctime_current(inode);
	set_bit(BTRFS_INODE_COPY_EVERYTHING, &BTRFS_I(inode)->runtime_flags);

	ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode),
			     &fname.disk_name, 1, index);
+3 −1
Original line number Diff line number Diff line
@@ -1539,8 +1539,10 @@ int btrfs_add_qgroup_relation(struct btrfs_trans_handle *trans, u64 src, u64 dst
	ASSERT(prealloc);

	/* Check the level of src and dst first */
	if (btrfs_qgroup_level(src) >= btrfs_qgroup_level(dst))
	if (btrfs_qgroup_level(src) >= btrfs_qgroup_level(dst)) {
		kfree(prealloc);
		return -EINVAL;
	}

	mutex_lock(&fs_info->qgroup_ioctl_lock);
	if (!fs_info->quota_root) {
+3 −0
Original line number Diff line number Diff line
@@ -7910,6 +7910,9 @@ void btrfs_log_new_name(struct btrfs_trans_handle *trans,
	bool log_pinned = false;
	int ret;

	/* The inode has a new name (ref/extref), so make sure we log it. */
	set_bit(BTRFS_INODE_COPY_EVERYTHING, &inode->runtime_flags);

	btrfs_init_log_ctx(&ctx, inode);
	ctx.logging_new_name = true;