Skip to content

Commit c9cfc12

Browse files
committed
Merge tag 'for-6.18-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
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
2 parents 8bb886c + 3b1a4a5 commit c9cfc12

File tree

5 files changed

+24
-2
lines changed

5 files changed

+24
-2
lines changed

fs/btrfs/extent_io.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,6 +2228,14 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,
22282228
wbc_account_cgroup_owner(wbc, folio, range_len);
22292229
folio_unlock(folio);
22302230
}
2231+
/*
2232+
* If the fs is already in error status, do not submit any writeback
2233+
* but immediately finish it.
2234+
*/
2235+
if (unlikely(BTRFS_FS_ERROR(fs_info))) {
2236+
btrfs_bio_end_io(bbio, errno_to_blk_status(BTRFS_FS_ERROR(fs_info)));
2237+
return;
2238+
}
22312239
btrfs_submit_bbio(bbio, 0);
22322240
}
22332241

fs/btrfs/file.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2854,12 +2854,22 @@ static int btrfs_fallocate_update_isize(struct inode *inode,
28542854
{
28552855
struct btrfs_trans_handle *trans;
28562856
struct btrfs_root *root = BTRFS_I(inode)->root;
2857+
u64 range_start;
2858+
u64 range_end;
28572859
int ret;
28582860
int ret2;
28592861

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

2865+
range_start = round_down(i_size_read(inode), root->fs_info->sectorsize);
2866+
range_end = round_up(end, root->fs_info->sectorsize);
2867+
2868+
ret = btrfs_inode_set_file_extent_range(BTRFS_I(inode), range_start,
2869+
range_end - range_start);
2870+
if (ret)
2871+
return ret;
2872+
28632873
trans = btrfs_start_transaction(root, 1);
28642874
if (IS_ERR(trans))
28652875
return PTR_ERR(trans);

fs/btrfs/inode.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6873,7 +6873,6 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
68736873
BTRFS_I(inode)->dir_index = 0ULL;
68746874
inode_inc_iversion(inode);
68756875
inode_set_ctime_current(inode);
6876-
set_bit(BTRFS_INODE_COPY_EVERYTHING, &BTRFS_I(inode)->runtime_flags);
68776876

68786877
ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode),
68796878
&fname.disk_name, 1, index);

fs/btrfs/qgroup.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1539,8 +1539,10 @@ int btrfs_add_qgroup_relation(struct btrfs_trans_handle *trans, u64 src, u64 dst
15391539
ASSERT(prealloc);
15401540

15411541
/* Check the level of src and dst first */
1542-
if (btrfs_qgroup_level(src) >= btrfs_qgroup_level(dst))
1542+
if (btrfs_qgroup_level(src) >= btrfs_qgroup_level(dst)) {
1543+
kfree(prealloc);
15431544
return -EINVAL;
1545+
}
15441546

15451547
mutex_lock(&fs_info->qgroup_ioctl_lock);
15461548
if (!fs_info->quota_root) {

fs/btrfs/tree-log.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7910,6 +7910,9 @@ void btrfs_log_new_name(struct btrfs_trans_handle *trans,
79107910
bool log_pinned = false;
79117911
int ret;
79127912

7913+
/* The inode has a new name (ref/extref), so make sure we log it. */
7914+
set_bit(BTRFS_INODE_COPY_EVERYTHING, &inode->runtime_flags);
7915+
79137916
btrfs_init_log_ctx(&ctx, inode);
79147917
ctx.logging_new_name = true;
79157918

0 commit comments

Comments
 (0)