Skip to content

Commit 97d0bf9

Browse files
committed
Merge tag 'for-5.5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs updates from David Sterba: "User visible changes: - new block group profiles: RAID1 with 3- and 4- copies - RAID1 in btrfs has always 2 copies, now add support for 3 and 4 - this is an incompat feature (named RAID1C34) - recommended use of RAID1C3 is replacement of RAID6 profile on metadata, this brings a more reliable resiliency against 2 device loss/damage - support for new checksums - per-filesystem, set at mkfs time - fast hash (crc32c successor): xxhash, 64bit digest - strong hashes (both 256bit): sha256 (slower, FIPS), blake2b (faster) - the blake2b module goes via the crypto tree, btrfs.ko has a soft dependency - speed up lseek, don't take inode locks unnecessarily, this can speed up parallel SEEK_CUR/SEEK_SET/SEEK_END by 80% - send: - allow clone operations within the same file - limit maximum number of sent clone references to avoid slow backref walking - error message improvements: device scan prints process name and PID Core changes: - cleanups - remove unique workqueue helpers, used to provide a way to avoid deadlocks in the workqueue code, now done in a simpler way - remove lots of indirect function calls in compression code - extent IO tree code moved out of extent_io.c - cleanup backup superblock handling at mount time - transaction life cycle documentation and cleanups - locking code cleanups, annotations and documentation - add more cold, const, pure function attributes - removal of unused or redundant struct members or variables - new tree-checker sanity tests - try to detect missing INODE_ITEM, cross-reference checks of DIR_ITEM, DIR_INDEX, INODE_REF, and XATTR_* items - remove own bio scheduling code (used to avoid checksum submissions being stuck behind other IO), replaced by cgroup controller-based code to allow better control and avoid priority inversions in cases where the custom and cgroup scheduling disagreed Fixes: - avoid getting stuck during cyclic writebacks - fix trimming of ranges crossing block group boundaries - fix rename exchange on subvolumes, all involved subvolumes need to be recorded in the transaction" * tag 'for-5.5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: (137 commits) btrfs: drop bdev argument from submit_extent_page btrfs: remove extent_map::bdev btrfs: drop bio_set_dev where not needed btrfs: get bdev directly from fs_devices in submit_extent_page btrfs: record all roots for rename exchange on a subvol Btrfs: fix block group remaining RO forever after error during device replace btrfs: scrub: Don't check free space before marking a block group RO btrfs: change btrfs_fs_devices::rotating to bool btrfs: change btrfs_fs_devices::seeding to bool btrfs: rename btrfs_block_group_cache btrfs: block-group: Reuse the item key from caller of read_one_block_group() btrfs: block-group: Refactor btrfs_read_block_groups() btrfs: document extent buffer locking btrfs: access eb::blocking_writers according to ACCESS_ONCE policies btrfs: set blocking_writers directly, no increment or decrement btrfs: merge blocking_writers branches in btrfs_tree_read_lock btrfs: drop incompat bit for raid1c34 after last block group is gone btrfs: add incompat for raid1 with 3, 4 copies btrfs: add support for 4-copy replication (raid1c4) btrfs: add support for 3-copy replication (raid1c3) ...
2 parents 1b88176 + fa17ed0 commit 97d0bf9

66 files changed

Lines changed: 2780 additions & 2619 deletions

Some content is hidden

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

‎fs/btrfs/Kconfig‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ config BTRFS_FS
55
select CRYPTO
66
select CRYPTO_CRC32C
77
select LIBCRC32C
8+
select CRYPTO_XXHASH
9+
select CRYPTO_SHA256
810
select ZLIB_INFLATE
911
select ZLIB_DEFLATE
1012
select LZO_COMPRESS

‎fs/btrfs/async-thread.c‎

Lines changed: 53 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,12 @@ struct btrfs_workqueue {
5353
struct __btrfs_workqueue *high;
5454
};
5555

56-
static void normal_work_helper(struct btrfs_work *work);
57-
58-
#define BTRFS_WORK_HELPER(name) \
59-
noinline_for_stack void btrfs_##name(struct work_struct *arg) \
60-
{ \
61-
struct btrfs_work *work = container_of(arg, struct btrfs_work, \
62-
normal_work); \
63-
normal_work_helper(work); \
64-
}
65-
66-
struct btrfs_fs_info *
67-
btrfs_workqueue_owner(const struct __btrfs_workqueue *wq)
56+
struct btrfs_fs_info * __pure btrfs_workqueue_owner(const struct __btrfs_workqueue *wq)
6857
{
6958
return wq->fs_info;
7059
}
7160

72-
struct btrfs_fs_info *
73-
btrfs_work_owner(const struct btrfs_work *work)
61+
struct btrfs_fs_info * __pure btrfs_work_owner(const struct btrfs_work *work)
7462
{
7563
return work->wq->fs_info;
7664
}
@@ -89,29 +77,6 @@ bool btrfs_workqueue_normal_congested(const struct btrfs_workqueue *wq)
8977
return atomic_read(&wq->normal->pending) > wq->normal->thresh * 2;
9078
}
9179

92-
BTRFS_WORK_HELPER(worker_helper);
93-
BTRFS_WORK_HELPER(delalloc_helper);
94-
BTRFS_WORK_HELPER(flush_delalloc_helper);
95-
BTRFS_WORK_HELPER(cache_helper);
96-
BTRFS_WORK_HELPER(submit_helper);
97-
BTRFS_WORK_HELPER(fixup_helper);
98-
BTRFS_WORK_HELPER(endio_helper);
99-
BTRFS_WORK_HELPER(endio_meta_helper);
100-
BTRFS_WORK_HELPER(endio_meta_write_helper);
101-
BTRFS_WORK_HELPER(endio_raid56_helper);
102-
BTRFS_WORK_HELPER(endio_repair_helper);
103-
BTRFS_WORK_HELPER(rmw_helper);
104-
BTRFS_WORK_HELPER(endio_write_helper);
105-
BTRFS_WORK_HELPER(freespace_write_helper);
106-
BTRFS_WORK_HELPER(delayed_meta_helper);
107-
BTRFS_WORK_HELPER(readahead_helper);
108-
BTRFS_WORK_HELPER(qgroup_rescan_helper);
109-
BTRFS_WORK_HELPER(extent_refs_helper);
110-
BTRFS_WORK_HELPER(scrub_helper);
111-
BTRFS_WORK_HELPER(scrubwrc_helper);
112-
BTRFS_WORK_HELPER(scrubnc_helper);
113-
BTRFS_WORK_HELPER(scrubparity_helper);
114-
11580
static struct __btrfs_workqueue *
11681
__btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info, const char *name,
11782
unsigned int flags, int limit_active, int thresh)
@@ -252,16 +217,16 @@ static inline void thresh_exec_hook(struct __btrfs_workqueue *wq)
252217
}
253218
}
254219

255-
static void run_ordered_work(struct __btrfs_workqueue *wq)
220+
static void run_ordered_work(struct __btrfs_workqueue *wq,
221+
struct btrfs_work *self)
256222
{
257223
struct list_head *list = &wq->ordered_list;
258224
struct btrfs_work *work;
259225
spinlock_t *lock = &wq->list_lock;
260226
unsigned long flags;
227+
bool free_self = false;
261228

262229
while (1) {
263-
void *wtag;
264-
265230
spin_lock_irqsave(lock, flags);
266231
if (list_empty(list))
267232
break;
@@ -287,22 +252,53 @@ static void run_ordered_work(struct __btrfs_workqueue *wq)
287252
list_del(&work->ordered_list);
288253
spin_unlock_irqrestore(lock, flags);
289254

290-
/*
291-
* We don't want to call the ordered free functions with the
292-
* lock held though. Save the work as tag for the trace event,
293-
* because the callback could free the structure.
294-
*/
295-
wtag = work;
296-
work->ordered_free(work);
297-
trace_btrfs_all_work_done(wq->fs_info, wtag);
255+
if (work == self) {
256+
/*
257+
* This is the work item that the worker is currently
258+
* executing.
259+
*
260+
* The kernel workqueue code guarantees non-reentrancy
261+
* of work items. I.e., if a work item with the same
262+
* address and work function is queued twice, the second
263+
* execution is blocked until the first one finishes. A
264+
* work item may be freed and recycled with the same
265+
* work function; the workqueue code assumes that the
266+
* original work item cannot depend on the recycled work
267+
* item in that case (see find_worker_executing_work()).
268+
*
269+
* Note that different types of Btrfs work can depend on
270+
* each other, and one type of work on one Btrfs
271+
* filesystem may even depend on the same type of work
272+
* on another Btrfs filesystem via, e.g., a loop device.
273+
* Therefore, we must not allow the current work item to
274+
* be recycled until we are really done, otherwise we
275+
* break the above assumption and can deadlock.
276+
*/
277+
free_self = true;
278+
} else {
279+
/*
280+
* We don't want to call the ordered free functions with
281+
* the lock held.
282+
*/
283+
work->ordered_free(work);
284+
/* NB: work must not be dereferenced past this point. */
285+
trace_btrfs_all_work_done(wq->fs_info, work);
286+
}
298287
}
299288
spin_unlock_irqrestore(lock, flags);
289+
290+
if (free_self) {
291+
self->ordered_free(self);
292+
/* NB: self must not be dereferenced past this point. */
293+
trace_btrfs_all_work_done(wq->fs_info, self);
294+
}
300295
}
301296

302-
static void normal_work_helper(struct btrfs_work *work)
297+
static void btrfs_work_helper(struct work_struct *normal_work)
303298
{
299+
struct btrfs_work *work = container_of(normal_work, struct btrfs_work,
300+
normal_work);
304301
struct __btrfs_workqueue *wq;
305-
void *wtag;
306302
int need_order = 0;
307303

308304
/*
@@ -316,29 +312,26 @@ static void normal_work_helper(struct btrfs_work *work)
316312
if (work->ordered_func)
317313
need_order = 1;
318314
wq = work->wq;
319-
/* Safe for tracepoints in case work gets freed by the callback */
320-
wtag = work;
321315

322316
trace_btrfs_work_sched(work);
323317
thresh_exec_hook(wq);
324318
work->func(work);
325319
if (need_order) {
326320
set_bit(WORK_DONE_BIT, &work->flags);
327-
run_ordered_work(wq);
321+
run_ordered_work(wq, work);
322+
} else {
323+
/* NB: work must not be dereferenced past this point. */
324+
trace_btrfs_all_work_done(wq->fs_info, work);
328325
}
329-
if (!need_order)
330-
trace_btrfs_all_work_done(wq->fs_info, wtag);
331326
}
332327

333-
void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t uniq_func,
334-
btrfs_func_t func,
335-
btrfs_func_t ordered_func,
336-
btrfs_func_t ordered_free)
328+
void btrfs_init_work(struct btrfs_work *work, btrfs_func_t func,
329+
btrfs_func_t ordered_func, btrfs_func_t ordered_free)
337330
{
338331
work->func = func;
339332
work->ordered_func = ordered_func;
340333
work->ordered_free = ordered_free;
341-
INIT_WORK(&work->normal_work, uniq_func);
334+
INIT_WORK(&work->normal_work, btrfs_work_helper);
342335
INIT_LIST_HEAD(&work->ordered_list);
343336
work->flags = 0;
344337
}

‎fs/btrfs/async-thread.h‎

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,49 +29,20 @@ struct btrfs_work {
2929
unsigned long flags;
3030
};
3131

32-
#define BTRFS_WORK_HELPER_PROTO(name) \
33-
void btrfs_##name(struct work_struct *arg)
34-
35-
BTRFS_WORK_HELPER_PROTO(worker_helper);
36-
BTRFS_WORK_HELPER_PROTO(delalloc_helper);
37-
BTRFS_WORK_HELPER_PROTO(flush_delalloc_helper);
38-
BTRFS_WORK_HELPER_PROTO(cache_helper);
39-
BTRFS_WORK_HELPER_PROTO(submit_helper);
40-
BTRFS_WORK_HELPER_PROTO(fixup_helper);
41-
BTRFS_WORK_HELPER_PROTO(endio_helper);
42-
BTRFS_WORK_HELPER_PROTO(endio_meta_helper);
43-
BTRFS_WORK_HELPER_PROTO(endio_meta_write_helper);
44-
BTRFS_WORK_HELPER_PROTO(endio_raid56_helper);
45-
BTRFS_WORK_HELPER_PROTO(endio_repair_helper);
46-
BTRFS_WORK_HELPER_PROTO(rmw_helper);
47-
BTRFS_WORK_HELPER_PROTO(endio_write_helper);
48-
BTRFS_WORK_HELPER_PROTO(freespace_write_helper);
49-
BTRFS_WORK_HELPER_PROTO(delayed_meta_helper);
50-
BTRFS_WORK_HELPER_PROTO(readahead_helper);
51-
BTRFS_WORK_HELPER_PROTO(qgroup_rescan_helper);
52-
BTRFS_WORK_HELPER_PROTO(extent_refs_helper);
53-
BTRFS_WORK_HELPER_PROTO(scrub_helper);
54-
BTRFS_WORK_HELPER_PROTO(scrubwrc_helper);
55-
BTRFS_WORK_HELPER_PROTO(scrubnc_helper);
56-
BTRFS_WORK_HELPER_PROTO(scrubparity_helper);
57-
58-
5932
struct btrfs_workqueue *btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info,
6033
const char *name,
6134
unsigned int flags,
6235
int limit_active,
6336
int thresh);
64-
void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t helper,
65-
btrfs_func_t func,
66-
btrfs_func_t ordered_func,
67-
btrfs_func_t ordered_free);
37+
void btrfs_init_work(struct btrfs_work *work, btrfs_func_t func,
38+
btrfs_func_t ordered_func, btrfs_func_t ordered_free);
6839
void btrfs_queue_work(struct btrfs_workqueue *wq,
6940
struct btrfs_work *work);
7041
void btrfs_destroy_workqueue(struct btrfs_workqueue *wq);
7142
void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max);
7243
void btrfs_set_work_high_priority(struct btrfs_work *work);
73-
struct btrfs_fs_info *btrfs_work_owner(const struct btrfs_work *work);
74-
struct btrfs_fs_info *btrfs_workqueue_owner(const struct __btrfs_workqueue *wq);
44+
struct btrfs_fs_info * __pure btrfs_work_owner(const struct btrfs_work *work);
45+
struct btrfs_fs_info * __pure btrfs_workqueue_owner(const struct __btrfs_workqueue *wq);
7546
bool btrfs_workqueue_normal_congested(const struct btrfs_workqueue *wq);
7647

7748
#endif

0 commit comments

Comments
 (0)