Skip to content

Commit 122fa8c

Browse files
committed
Merge tag 'for-5.14-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs updates from David Sterba: "A normal mix of improvements, core changes and features that user have been missing or complaining about. User visible changes: - new sysfs exports: - add sysfs knob to limit scrub IO bandwidth per device - device stats are also available in /sys/fs/btrfs/FSID/devinfo/DEVID/error_stats - support cancellable resize and device delete ioctls - change how the empty value is interpreted when setting a property, so far we have only 'btrfs.compression' and we need to distinguish a reset to defaults and setting "do not compress", in general the empty value will always mean 'reset to defaults' for any other property, for compression it's either 'no' or 'none' to forbid compression Performance improvements: - no need for full sync when truncation does not touch extents, reported run time change is -12% - avoid unnecessary logging of xattrs during fast fsyncs (+17% throughput, -17% runtime on xattr stress workload) Core: - preemptive flushing improvements and fixes - adjust clamping logic on multi-threaded workloads to avoid flushing too soon - take into account global block reserve, may help on almost full filesystems - continue flushing when there are enough pending delalloc and ordered bytes - simplify logic around conditional transaction commit, a workaround used in the past for throttling that's been superseded by ticket reservations that manage the throttling in a better way - subpage blocksize preparation: - submit read time repair only for each corrupted sector - scrub repair now works with sectors and not pages - free space cache (v1) works with sectors and not pages - more fine grained bio tracking for extents - subpage support in page callbacks, extent callbacks, end io callbacks - simplify transaction abort logic and always abort and don't check various potentially unreliable stats tracked by the transaction - exclusive operations can do more checks when started and allow eg. cancellation of the same running operation - ensure relocation never runs while we have send operations running, e.g. when zoned background auto reclaim starts Fixes: - zoned: more sanity checks of write pointer - improve error handling in delayed inodes - send: - fix invalid path for unlink operations after parent orphanization - fix crash when memory allocations trigger reclaim - skip compression of we have only one page (can't make things better) - empty value of a property newly means reset to default Other: - lots of cleanups, comment updates, yearly typo fixing - disable build on platforms having page size 256K" * tag 'for-5.14-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: (101 commits) btrfs: remove unused btrfs_fs_info::total_pinned btrfs: rip out btrfs_space_info::total_bytes_pinned btrfs: rip the first_ticket_bytes logic from fail_all_tickets btrfs: remove FLUSH_DELAYED_REFS from data ENOSPC flushing btrfs: rip out may_commit_transaction btrfs: send: fix crash when memory allocations trigger reclaim btrfs: ensure relocation never runs while we have send operations running btrfs: shorten integrity checker extent data mount option btrfs: switch mount option bits to enums and use wider type btrfs: props: change how empty value is interpreted btrfs: compression: don't try to compress if we don't have enough pages btrfs: fix unbalanced unlock in qgroup_account_snapshot() btrfs: sysfs: export dev stats in devinfo directory btrfs: fix typos in comments btrfs: remove a stale comment for btrfs_decompress_bio() btrfs: send: use list_move_tail instead of list_del/list_add_tail btrfs: disable build on platforms having page size 256K btrfs: send: fix invalid path for unlink operations after parent orphanization btrfs: inline wait_current_trans_commit_start in its caller btrfs: sink wait_for_unblock parameter to async commit ...
2 parents 7aed4d5 + 629e33a commit 122fa8c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2041
-1431
lines changed

fs/btrfs/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ config BTRFS_FS
1818
select RAID6_PQ
1919
select XOR_BLOCKS
2020
select SRCU
21+
depends on !PPC_256K_PAGES # powerpc
22+
depends on !PAGE_SIZE_256KB # hexagon
2123

2224
help
2325
Btrfs is a general purpose copy-on-write filesystem with extents,

fs/btrfs/backref.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2675,7 +2675,7 @@ static int handle_direct_tree_backref(struct btrfs_backref_cache *cache,
26752675
*
26762676
* @ref_key: The same as @ref_key in handle_direct_tree_backref()
26772677
* @tree_key: The first key of this tree block.
2678-
* @path: A clean (released) path, to avoid allocating path everytime
2678+
* @path: A clean (released) path, to avoid allocating path every time
26792679
* the function get called.
26802680
*/
26812681
static int handle_indirect_tree_backref(struct btrfs_backref_cache *cache,

fs/btrfs/block-group.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,6 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
13991399
btrfs_space_info_update_bytes_pinned(fs_info, space_info,
14001400
-block_group->pinned);
14011401
space_info->bytes_readonly += block_group->pinned;
1402-
__btrfs_mod_total_bytes_pinned(space_info, -block_group->pinned);
14031402
block_group->pinned = 0;
14041403

14051404
spin_unlock(&block_group->lock);
@@ -1491,7 +1490,7 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
14911490
container_of(work, struct btrfs_fs_info, reclaim_bgs_work);
14921491
struct btrfs_block_group *bg;
14931492
struct btrfs_space_info *space_info;
1494-
int ret;
1493+
LIST_HEAD(again_list);
14951494

14961495
if (!test_bit(BTRFS_FS_OPEN, &fs_info->flags))
14971496
return;
@@ -1502,6 +1501,8 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
15021501
mutex_lock(&fs_info->reclaim_bgs_lock);
15031502
spin_lock(&fs_info->unused_bgs_lock);
15041503
while (!list_empty(&fs_info->reclaim_bgs)) {
1504+
int ret = 0;
1505+
15051506
bg = list_first_entry(&fs_info->reclaim_bgs,
15061507
struct btrfs_block_group,
15071508
bg_list);
@@ -1547,9 +1548,13 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
15471548
bg->start);
15481549

15491550
next:
1550-
btrfs_put_block_group(bg);
15511551
spin_lock(&fs_info->unused_bgs_lock);
1552+
if (ret == -EAGAIN && list_empty(&bg->bg_list))
1553+
list_add_tail(&bg->bg_list, &again_list);
1554+
else
1555+
btrfs_put_block_group(bg);
15521556
}
1557+
list_splice_tail(&again_list, &fs_info->reclaim_bgs);
15531558
spin_unlock(&fs_info->unused_bgs_lock);
15541559
mutex_unlock(&fs_info->reclaim_bgs_lock);
15551560
btrfs_exclop_finish(fs_info);
@@ -2505,7 +2510,7 @@ static int cache_save_setup(struct btrfs_block_group *block_group,
25052510
struct extent_changeset *data_reserved = NULL;
25062511
u64 alloc_hint = 0;
25072512
int dcs = BTRFS_DC_ERROR;
2508-
u64 num_pages = 0;
2513+
u64 cache_size = 0;
25092514
int retries = 0;
25102515
int ret = 0;
25112516

@@ -2617,20 +2622,20 @@ static int cache_save_setup(struct btrfs_block_group *block_group,
26172622
* taking up quite a bit since it's not folded into the other space
26182623
* cache.
26192624
*/
2620-
num_pages = div_u64(block_group->length, SZ_256M);
2621-
if (!num_pages)
2622-
num_pages = 1;
2625+
cache_size = div_u64(block_group->length, SZ_256M);
2626+
if (!cache_size)
2627+
cache_size = 1;
26232628

2624-
num_pages *= 16;
2625-
num_pages *= PAGE_SIZE;
2629+
cache_size *= 16;
2630+
cache_size *= fs_info->sectorsize;
26262631

26272632
ret = btrfs_check_data_free_space(BTRFS_I(inode), &data_reserved, 0,
2628-
num_pages);
2633+
cache_size);
26292634
if (ret)
26302635
goto out_put;
26312636

2632-
ret = btrfs_prealloc_file_range_trans(inode, trans, 0, 0, num_pages,
2633-
num_pages, num_pages,
2637+
ret = btrfs_prealloc_file_range_trans(inode, trans, 0, 0, cache_size,
2638+
cache_size, cache_size,
26342639
&alloc_hint);
26352640
/*
26362641
* Our cache requires contiguous chunks so that we don't modify a bunch
@@ -3062,8 +3067,6 @@ int btrfs_update_block_group(struct btrfs_trans_handle *trans,
30623067
spin_unlock(&cache->lock);
30633068
spin_unlock(&cache->space_info->lock);
30643069

3065-
__btrfs_mod_total_bytes_pinned(cache->space_info,
3066-
num_bytes);
30673070
set_extent_dirty(&trans->transaction->pinned_extents,
30683071
bytenr, bytenr + num_bytes - 1,
30693072
GFP_NOFS | __GFP_NOFAIL);

fs/btrfs/compression.c

Lines changed: 15 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static int check_compressed_csum(struct btrfs_inode *inode, struct bio *bio,
149149
const u32 csum_size = fs_info->csum_size;
150150
const u32 sectorsize = fs_info->sectorsize;
151151
struct page *page;
152-
unsigned long i;
152+
unsigned int i;
153153
char *kaddr;
154154
u8 csum[BTRFS_CSUM_SIZE];
155155
struct compressed_bio *cb = bio->bi_private;
@@ -208,7 +208,7 @@ static void end_compressed_bio_read(struct bio *bio)
208208
struct compressed_bio *cb = bio->bi_private;
209209
struct inode *inode;
210210
struct page *page;
211-
unsigned long index;
211+
unsigned int index;
212212
unsigned int mirror = btrfs_io_bio(bio)->mirror_num;
213213
int ret = 0;
214214

@@ -334,7 +334,7 @@ static void end_compressed_bio_write(struct bio *bio)
334334
struct compressed_bio *cb = bio->bi_private;
335335
struct inode *inode;
336336
struct page *page;
337-
unsigned long index;
337+
unsigned int index;
338338

339339
if (bio->bi_status)
340340
cb->errors = 1;
@@ -349,12 +349,10 @@ static void end_compressed_bio_write(struct bio *bio)
349349
* call back into the FS and do all the end_io operations
350350
*/
351351
inode = cb->inode;
352-
cb->compressed_pages[0]->mapping = cb->inode->i_mapping;
353352
btrfs_record_physical_zoned(inode, cb->start, bio);
354-
btrfs_writepage_endio_finish_ordered(cb->compressed_pages[0],
353+
btrfs_writepage_endio_finish_ordered(BTRFS_I(inode), NULL,
355354
cb->start, cb->start + cb->len - 1,
356355
bio->bi_status == BLK_STS_OK);
357-
cb->compressed_pages[0]->mapping = NULL;
358356

359357
end_compressed_writeback(inode, cb);
360358
/* note, our inode could be gone now */
@@ -387,10 +385,10 @@ static void end_compressed_bio_write(struct bio *bio)
387385
* the end io hooks.
388386
*/
389387
blk_status_t btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start,
390-
unsigned long len, u64 disk_start,
391-
unsigned long compressed_len,
388+
unsigned int len, u64 disk_start,
389+
unsigned int compressed_len,
392390
struct page **compressed_pages,
393-
unsigned long nr_pages,
391+
unsigned int nr_pages,
394392
unsigned int write_flags,
395393
struct cgroup_subsys_state *blkcg_css)
396394
{
@@ -427,24 +425,16 @@ blk_status_t btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start,
427425
bio->bi_end_io = end_compressed_bio_write;
428426

429427
if (use_append) {
430-
struct extent_map *em;
431-
struct map_lookup *map;
432-
struct block_device *bdev;
428+
struct btrfs_device *device;
433429

434-
em = btrfs_get_chunk_map(fs_info, disk_start, PAGE_SIZE);
435-
if (IS_ERR(em)) {
430+
device = btrfs_zoned_get_device(fs_info, disk_start, PAGE_SIZE);
431+
if (IS_ERR(device)) {
436432
kfree(cb);
437433
bio_put(bio);
438434
return BLK_STS_NOTSUPP;
439435
}
440436

441-
map = em->map_lookup;
442-
/* We only support single profile for now */
443-
ASSERT(map->num_stripes == 1);
444-
bdev = map->stripes[0].dev->bdev;
445-
446-
bio_set_dev(bio, bdev);
447-
free_extent_map(em);
437+
bio_set_dev(bio, device->bdev);
448438
}
449439

450440
if (blkcg_css) {
@@ -515,7 +505,7 @@ blk_status_t btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start,
515505
}
516506
if (bytes_left < PAGE_SIZE) {
517507
btrfs_info(fs_info,
518-
"bytes left %lu compress len %lu nr %lu",
508+
"bytes left %lu compress len %u nr %u",
519509
bytes_left, cb->compressed_len, cb->nr_pages);
520510
}
521511
bytes_left -= PAGE_SIZE;
@@ -677,9 +667,9 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
677667
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
678668
struct extent_map_tree *em_tree;
679669
struct compressed_bio *cb;
680-
unsigned long compressed_len;
681-
unsigned long nr_pages;
682-
unsigned long pg_index;
670+
unsigned int compressed_len;
671+
unsigned int nr_pages;
672+
unsigned int pg_index;
683673
struct page *page;
684674
struct bio *comp_bio;
685675
u64 cur_disk_byte = bio->bi_iter.bi_sector << 9;
@@ -1202,9 +1192,6 @@ static unsigned int btrfs_compress_set_level(int type, unsigned level)
12021192
*
12031193
* @total_out is an in/out parameter, must be set to the input length and will
12041194
* be also used to return the total number of compressed bytes
1205-
*
1206-
* @max_out tells us the max number of bytes that we're allowed to
1207-
* stuff into pages
12081195
*/
12091196
int btrfs_compress_pages(unsigned int type_level, struct address_space *mapping,
12101197
u64 start, struct page **pages,
@@ -1225,20 +1212,6 @@ int btrfs_compress_pages(unsigned int type_level, struct address_space *mapping,
12251212
return ret;
12261213
}
12271214

1228-
/*
1229-
* pages_in is an array of pages with compressed data.
1230-
*
1231-
* disk_start is the starting logical offset of this array in the file
1232-
*
1233-
* orig_bio contains the pages from the file that we want to decompress into
1234-
*
1235-
* srclen is the number of bytes in pages_in
1236-
*
1237-
* The basic idea is that we have a bio that was created by readpages.
1238-
* The pages in the bio are for the uncompressed data, and they may not
1239-
* be contiguous. They all correspond to the range of bytes covered by
1240-
* the compressed extent.
1241-
*/
12421215
static int btrfs_decompress_bio(struct compressed_bio *cb)
12431216
{
12441217
struct list_head *workspace;

fs/btrfs/compression.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ struct compressed_bio {
3131
/* number of bios pending for this compressed extent */
3232
refcount_t pending_bios;
3333

34+
/* Number of compressed pages in the array */
35+
unsigned int nr_pages;
36+
3437
/* the pages with the compressed data on them */
3538
struct page **compressed_pages;
3639

@@ -40,20 +43,17 @@ struct compressed_bio {
4043
/* starting offset in the inode for our pages */
4144
u64 start;
4245

43-
/* number of bytes in the inode we're working on */
44-
unsigned long len;
45-
46-
/* number of bytes on disk */
47-
unsigned long compressed_len;
46+
/* Number of bytes in the inode we're working on */
47+
unsigned int len;
4848

49-
/* the compression algorithm for this bio */
50-
int compress_type;
49+
/* Number of bytes on disk */
50+
unsigned int compressed_len;
5151

52-
/* number of compressed pages in the array */
53-
unsigned long nr_pages;
52+
/* The compression algorithm for this bio */
53+
u8 compress_type;
5454

5555
/* IO errors */
56-
int errors;
56+
u8 errors;
5757
int mirror_num;
5858

5959
/* for reads, this is the bio we are copying the data into */
@@ -91,10 +91,10 @@ int btrfs_decompress_buf2page(const char *buf, unsigned long buf_start,
9191
struct bio *bio);
9292

9393
blk_status_t btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start,
94-
unsigned long len, u64 disk_start,
95-
unsigned long compressed_len,
94+
unsigned int len, u64 disk_start,
95+
unsigned int compressed_len,
9696
struct page **compressed_pages,
97-
unsigned long nr_pages,
97+
unsigned int nr_pages,
9898
unsigned int write_flags,
9999
struct cgroup_subsys_state *blkcg_css);
100100
blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,

fs/btrfs/ctree.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,6 @@ noinline int btrfs_cow_block(struct btrfs_trans_handle *trans,
596596
trans->transid, fs_info->generation);
597597

598598
if (!should_cow_block(trans, root, buf)) {
599-
trans->dirty = true;
600599
*cow_ret = buf;
601600
return 0;
602601
}
@@ -1788,10 +1787,8 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root *root,
17881787
* then we don't want to set the path blocking,
17891788
* so we test it here
17901789
*/
1791-
if (!should_cow_block(trans, root, b)) {
1792-
trans->dirty = true;
1790+
if (!should_cow_block(trans, root, b))
17931791
goto cow_done;
1794-
}
17951792

17961793
/*
17971794
* must have write locks on this node and the

0 commit comments

Comments
 (0)