Skip to content

Commit 6a0e382

Browse files
committed
Merge tag 'for-6.11-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs fixes from David Sterba: - fix double inode unlock for direct IO sync writes (reported by syzbot) - fix root tree id/name map definitions, don't use fixed size buffers for name (reported by -Werror=unterminated-string-initialization) - fix qgroup reserve leaks in bufferd write path - update scrub status structure more often so it can be reported in user space more accurately and let 'resume' not repeat work - in preparation to remove space cache v1 in the future print a warning if it's detected * tag 'for-6.11-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: btrfs: avoid using fixed char array size for tree names btrfs: fix double inode unlock for direct IO sync writes btrfs: emit a warning about space cache v1 being deprecated btrfs: fix qgroup reserve leaks in cow_file_range btrfs: implement launder_folio for clearing dirty page reserve btrfs: scrub: update last_physical after scrubbing one stripe btrfs: factor out stripe length calculation into a helper
2 parents 94a8ee1 + 12653ec commit 6a0e382

File tree

5 files changed

+38
-9
lines changed

5 files changed

+38
-9
lines changed

fs/btrfs/file.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1868,7 +1868,10 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
18681868

18691869
out_release_extents:
18701870
btrfs_release_log_ctx_extents(&ctx);
1871-
btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP);
1871+
if (skip_ilock)
1872+
up_write(&inode->i_mmap_lock);
1873+
else
1874+
btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP);
18721875
goto out;
18731876
}
18741877

fs/btrfs/inode.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,6 +1585,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
15851585
locked_page, &cached,
15861586
clear_bits,
15871587
page_ops);
1588+
btrfs_qgroup_free_data(inode, NULL, start, cur_alloc_size, NULL);
15881589
start += cur_alloc_size;
15891590
}
15901591

@@ -1598,6 +1599,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
15981599
clear_bits |= EXTENT_CLEAR_DATA_RESV;
15991600
extent_clear_unlock_delalloc(inode, start, end, locked_page,
16001601
&cached, clear_bits, page_ops);
1602+
btrfs_qgroup_free_data(inode, NULL, start, cur_alloc_size, NULL);
16011603
}
16021604
return ret;
16031605
}
@@ -2259,6 +2261,7 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
22592261
EXTENT_DO_ACCOUNTING, PAGE_UNLOCK |
22602262
PAGE_START_WRITEBACK |
22612263
PAGE_END_WRITEBACK);
2264+
btrfs_qgroup_free_data(inode, NULL, cur_offset, end - cur_offset + 1, NULL);
22622265
}
22632266
btrfs_free_path(path);
22642267
return ret;
@@ -7202,6 +7205,12 @@ static void wait_subpage_spinlock(struct page *page)
72027205
spin_unlock_irq(&subpage->lock);
72037206
}
72047207

7208+
static int btrfs_launder_folio(struct folio *folio)
7209+
{
7210+
return btrfs_qgroup_free_data(folio_to_inode(folio), NULL, folio_pos(folio),
7211+
PAGE_SIZE, NULL);
7212+
}
7213+
72057214
static bool __btrfs_release_folio(struct folio *folio, gfp_t gfp_flags)
72067215
{
72077216
if (try_release_extent_mapping(&folio->page, gfp_flags)) {
@@ -10137,6 +10146,7 @@ static const struct address_space_operations btrfs_aops = {
1013710146
.writepages = btrfs_writepages,
1013810147
.readahead = btrfs_readahead,
1013910148
.invalidate_folio = btrfs_invalidate_folio,
10149+
.launder_folio = btrfs_launder_folio,
1014010150
.release_folio = btrfs_release_folio,
1014110151
.migrate_folio = btrfs_migrate_folio,
1014210152
.dirty_folio = filemap_dirty_folio,

fs/btrfs/print-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
struct root_name_map {
1616
u64 id;
17-
char name[16];
17+
const char *name;
1818
};
1919

2020
static const struct root_name_map root_map[] = {

fs/btrfs/scrub.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,14 +1648,20 @@ static void scrub_reset_stripe(struct scrub_stripe *stripe)
16481648
}
16491649
}
16501650

1651+
static u32 stripe_length(const struct scrub_stripe *stripe)
1652+
{
1653+
ASSERT(stripe->bg);
1654+
1655+
return min(BTRFS_STRIPE_LEN,
1656+
stripe->bg->start + stripe->bg->length - stripe->logical);
1657+
}
1658+
16511659
static void scrub_submit_extent_sector_read(struct scrub_ctx *sctx,
16521660
struct scrub_stripe *stripe)
16531661
{
16541662
struct btrfs_fs_info *fs_info = stripe->bg->fs_info;
16551663
struct btrfs_bio *bbio = NULL;
1656-
unsigned int nr_sectors = min(BTRFS_STRIPE_LEN, stripe->bg->start +
1657-
stripe->bg->length - stripe->logical) >>
1658-
fs_info->sectorsize_bits;
1664+
unsigned int nr_sectors = stripe_length(stripe) >> fs_info->sectorsize_bits;
16591665
u64 stripe_len = BTRFS_STRIPE_LEN;
16601666
int mirror = stripe->mirror_num;
16611667
int i;
@@ -1729,9 +1735,7 @@ static void scrub_submit_initial_read(struct scrub_ctx *sctx,
17291735
{
17301736
struct btrfs_fs_info *fs_info = sctx->fs_info;
17311737
struct btrfs_bio *bbio;
1732-
unsigned int nr_sectors = min(BTRFS_STRIPE_LEN, stripe->bg->start +
1733-
stripe->bg->length - stripe->logical) >>
1734-
fs_info->sectorsize_bits;
1738+
unsigned int nr_sectors = stripe_length(stripe) >> fs_info->sectorsize_bits;
17351739
int mirror = stripe->mirror_num;
17361740

17371741
ASSERT(stripe->bg);
@@ -1871,6 +1875,9 @@ static int flush_scrub_stripes(struct scrub_ctx *sctx)
18711875
stripe = &sctx->stripes[i];
18721876

18731877
wait_scrub_stripe_io(stripe);
1878+
spin_lock(&sctx->stat_lock);
1879+
sctx->stat.last_physical = stripe->physical + stripe_length(stripe);
1880+
spin_unlock(&sctx->stat_lock);
18741881
scrub_reset_stripe(stripe);
18751882
}
18761883
out:
@@ -2139,7 +2146,9 @@ static int scrub_simple_mirror(struct scrub_ctx *sctx,
21392146
cur_physical, &found_logical);
21402147
if (ret > 0) {
21412148
/* No more extent, just update the accounting */
2149+
spin_lock(&sctx->stat_lock);
21422150
sctx->stat.last_physical = physical + logical_length;
2151+
spin_unlock(&sctx->stat_lock);
21432152
ret = 0;
21442153
break;
21452154
}
@@ -2336,6 +2345,10 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
23362345
stripe_logical += chunk_logical;
23372346
ret = scrub_raid56_parity_stripe(sctx, scrub_dev, bg,
23382347
map, stripe_logical);
2348+
spin_lock(&sctx->stat_lock);
2349+
sctx->stat.last_physical = min(physical + BTRFS_STRIPE_LEN,
2350+
physical_end);
2351+
spin_unlock(&sctx->stat_lock);
23392352
if (ret)
23402353
goto out;
23412354
goto next;

fs/btrfs/super.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,8 +683,11 @@ bool btrfs_check_options(const struct btrfs_fs_info *info,
683683
ret = false;
684684

685685
if (!test_bit(BTRFS_FS_STATE_REMOUNTING, &info->fs_state)) {
686-
if (btrfs_raw_test_opt(*mount_opt, SPACE_CACHE))
686+
if (btrfs_raw_test_opt(*mount_opt, SPACE_CACHE)) {
687687
btrfs_info(info, "disk space caching is enabled");
688+
btrfs_warn(info,
689+
"space cache v1 is being deprecated and will be removed in a future release, please use -o space_cache=v2");
690+
}
688691
if (btrfs_raw_test_opt(*mount_opt, FREE_SPACE_TREE))
689692
btrfs_info(info, "using free-space-tree");
690693
}

0 commit comments

Comments
 (0)