Skip to content

Commit e96f8f1

Browse files
committed
Merge branch 'for-linus-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs
Pull btrfs fixes from Chris Mason: "These are all over the place. The tracepoint part of the pull fixes a crash and adds a little more information to two tracepoints, while the rest are good old fashioned fixes" * 'for-linus-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs: btrfs: make tracepoint format strings more compact Btrfs: add truncated_len for ordered extent tracepoints Btrfs: add 'inode' for extent map tracepoint btrfs: fix crash when tracepoint arguments are freed by wq callbacks Btrfs: adjust outstanding_extents counter properly when dio write is split Btrfs: fix lockdep warning about log_mutex Btrfs: use down_read_nested to make lockdep silent btrfs: fix locking when we put back a delayed ref that's too new btrfs: fix error handling when run_delayed_extent_op fails btrfs: return the actual error value from from btrfs_uuid_tree_iterate
2 parents 04e3962 + 0bf70ae commit e96f8f1

File tree

6 files changed

+117
-82
lines changed

6 files changed

+117
-82
lines changed

fs/btrfs/async-thread.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ static void run_ordered_work(struct __btrfs_workqueue *wq)
273273
unsigned long flags;
274274

275275
while (1) {
276+
void *wtag;
277+
276278
spin_lock_irqsave(lock, flags);
277279
if (list_empty(list))
278280
break;
@@ -299,18 +301,21 @@ static void run_ordered_work(struct __btrfs_workqueue *wq)
299301
spin_unlock_irqrestore(lock, flags);
300302

301303
/*
302-
* we don't want to call the ordered free functions
303-
* with the lock held though
304+
* We don't want to call the ordered free functions with the
305+
* lock held though. Save the work as tag for the trace event,
306+
* because the callback could free the structure.
304307
*/
308+
wtag = work;
305309
work->ordered_free(work);
306-
trace_btrfs_all_work_done(work);
310+
trace_btrfs_all_work_done(wq->fs_info, wtag);
307311
}
308312
spin_unlock_irqrestore(lock, flags);
309313
}
310314

311315
static void normal_work_helper(struct btrfs_work *work)
312316
{
313317
struct __btrfs_workqueue *wq;
318+
void *wtag;
314319
int need_order = 0;
315320

316321
/*
@@ -324,6 +329,8 @@ static void normal_work_helper(struct btrfs_work *work)
324329
if (work->ordered_func)
325330
need_order = 1;
326331
wq = work->wq;
332+
/* Safe for tracepoints in case work gets freed by the callback */
333+
wtag = work;
327334

328335
trace_btrfs_work_sched(work);
329336
thresh_exec_hook(wq);
@@ -333,7 +340,7 @@ static void normal_work_helper(struct btrfs_work *work)
333340
run_ordered_work(wq);
334341
}
335342
if (!need_order)
336-
trace_btrfs_all_work_done(work);
343+
trace_btrfs_all_work_done(wq->fs_info, wtag);
337344
}
338345

339346
void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t uniq_func,

fs/btrfs/extent-tree.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2522,11 +2522,11 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
25222522
if (ref && ref->seq &&
25232523
btrfs_check_delayed_seq(fs_info, delayed_refs, ref->seq)) {
25242524
spin_unlock(&locked_ref->lock);
2525-
btrfs_delayed_ref_unlock(locked_ref);
25262525
spin_lock(&delayed_refs->lock);
25272526
locked_ref->processing = 0;
25282527
delayed_refs->num_heads_ready++;
25292528
spin_unlock(&delayed_refs->lock);
2529+
btrfs_delayed_ref_unlock(locked_ref);
25302530
locked_ref = NULL;
25312531
cond_resched();
25322532
count++;
@@ -2572,7 +2572,10 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
25722572
*/
25732573
if (must_insert_reserved)
25742574
locked_ref->must_insert_reserved = 1;
2575+
spin_lock(&delayed_refs->lock);
25752576
locked_ref->processing = 0;
2577+
delayed_refs->num_heads_ready++;
2578+
spin_unlock(&delayed_refs->lock);
25762579
btrfs_debug(fs_info,
25772580
"run_delayed_extent_op returned %d",
25782581
ret);
@@ -7384,7 +7387,8 @@ btrfs_lock_cluster(struct btrfs_block_group_cache *block_group,
73847387

73857388
spin_unlock(&cluster->refill_lock);
73867389

7387-
down_read(&used_bg->data_rwsem);
7390+
/* We should only have one-level nested. */
7391+
down_read_nested(&used_bg->data_rwsem, SINGLE_DEPTH_NESTING);
73887392

73897393
spin_lock(&cluster->refill_lock);
73907394
if (used_bg == cluster->block_group)

fs/btrfs/inode.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7059,7 +7059,7 @@ struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page,
70597059
write_unlock(&em_tree->lock);
70607060
out:
70617061

7062-
trace_btrfs_get_extent(root, em);
7062+
trace_btrfs_get_extent(root, inode, em);
70637063

70647064
btrfs_free_path(path);
70657065
if (trans) {
@@ -7623,11 +7623,18 @@ static void adjust_dio_outstanding_extents(struct inode *inode,
76237623
* within our reservation, otherwise we need to adjust our inode
76247624
* counter appropriately.
76257625
*/
7626-
if (dio_data->outstanding_extents) {
7626+
if (dio_data->outstanding_extents >= num_extents) {
76277627
dio_data->outstanding_extents -= num_extents;
76287628
} else {
7629+
/*
7630+
* If dio write length has been split due to no large enough
7631+
* contiguous space, we need to compensate our inode counter
7632+
* appropriately.
7633+
*/
7634+
u64 num_needed = num_extents - dio_data->outstanding_extents;
7635+
76297636
spin_lock(&BTRFS_I(inode)->lock);
7630-
BTRFS_I(inode)->outstanding_extents += num_extents;
7637+
BTRFS_I(inode)->outstanding_extents += num_needed;
76317638
spin_unlock(&BTRFS_I(inode)->lock);
76327639
}
76337640
}

fs/btrfs/tree-log.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
*/
3838
#define LOG_INODE_ALL 0
3939
#define LOG_INODE_EXISTS 1
40+
#define LOG_OTHER_INODE 2
4041

4142
/*
4243
* directory trouble cases
@@ -4641,7 +4642,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
46414642
if (S_ISDIR(inode->i_mode) ||
46424643
(!test_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
46434644
&BTRFS_I(inode)->runtime_flags) &&
4644-
inode_only == LOG_INODE_EXISTS))
4645+
inode_only >= LOG_INODE_EXISTS))
46454646
max_key.type = BTRFS_XATTR_ITEM_KEY;
46464647
else
46474648
max_key.type = (u8)-1;
@@ -4665,7 +4666,13 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
46654666
return ret;
46664667
}
46674668

4668-
mutex_lock(&BTRFS_I(inode)->log_mutex);
4669+
if (inode_only == LOG_OTHER_INODE) {
4670+
inode_only = LOG_INODE_EXISTS;
4671+
mutex_lock_nested(&BTRFS_I(inode)->log_mutex,
4672+
SINGLE_DEPTH_NESTING);
4673+
} else {
4674+
mutex_lock(&BTRFS_I(inode)->log_mutex);
4675+
}
46694676

46704677
/*
46714678
* a brute force approach to making sure we get the most uptodate
@@ -4817,7 +4824,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
48174824
* unpin it.
48184825
*/
48194826
err = btrfs_log_inode(trans, root, other_inode,
4820-
LOG_INODE_EXISTS,
4827+
LOG_OTHER_INODE,
48214828
0, LLONG_MAX, ctx);
48224829
iput(other_inode);
48234830
if (err)

fs/btrfs/uuid-tree.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,5 @@ int btrfs_uuid_tree_iterate(struct btrfs_fs_info *fs_info,
352352

353353
out:
354354
btrfs_free_path(path);
355-
if (ret)
356-
btrfs_warn(fs_info, "btrfs_uuid_tree_iterate failed %d", ret);
357-
return 0;
355+
return ret;
358356
}

0 commit comments

Comments
 (0)