|
28 | 28 | #include "fs_context.h" |
29 | 29 | #include "cached_dir.h" |
30 | 30 |
|
| 31 | +struct tcon_list { |
| 32 | + struct list_head entry; |
| 33 | + struct cifs_tcon *tcon; |
| 34 | +}; |
| 35 | + |
31 | 36 | /* The xid serves as a useful identifier for each incoming vfs request, |
32 | 37 | in a similar way to the mid which is useful to track each sent smb, |
33 | 38 | and CurrentXid can also provide a running counter (although it |
@@ -554,6 +559,43 @@ cifs_close_all_deferred_files(struct cifs_tcon *tcon) |
554 | 559 | } |
555 | 560 | } |
556 | 561 |
|
| 562 | +void cifs_close_all_deferred_files_sb(struct cifs_sb_info *cifs_sb) |
| 563 | +{ |
| 564 | + struct rb_root *root = &cifs_sb->tlink_tree; |
| 565 | + struct rb_node *node; |
| 566 | + struct cifs_tcon *tcon; |
| 567 | + struct tcon_link *tlink; |
| 568 | + struct tcon_list *tmp_list, *q; |
| 569 | + LIST_HEAD(tcon_head); |
| 570 | + |
| 571 | + spin_lock(&cifs_sb->tlink_tree_lock); |
| 572 | + for (node = rb_first(root); node; node = rb_next(node)) { |
| 573 | + tlink = rb_entry(node, struct tcon_link, tl_rbnode); |
| 574 | + tcon = tlink_tcon(tlink); |
| 575 | + if (IS_ERR(tcon)) |
| 576 | + continue; |
| 577 | + tmp_list = kmalloc_obj(struct tcon_list, GFP_ATOMIC); |
| 578 | + if (tmp_list == NULL) |
| 579 | + break; |
| 580 | + tmp_list->tcon = tcon; |
| 581 | + /* Take a reference on tcon to prevent it from being freed */ |
| 582 | + spin_lock(&tcon->tc_lock); |
| 583 | + ++tcon->tc_count; |
| 584 | + trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count, |
| 585 | + netfs_trace_tcon_ref_get_close_defer_files); |
| 586 | + spin_unlock(&tcon->tc_lock); |
| 587 | + list_add_tail(&tmp_list->entry, &tcon_head); |
| 588 | + } |
| 589 | + spin_unlock(&cifs_sb->tlink_tree_lock); |
| 590 | + |
| 591 | + list_for_each_entry_safe(tmp_list, q, &tcon_head, entry) { |
| 592 | + cifs_close_all_deferred_files(tmp_list->tcon); |
| 593 | + list_del(&tmp_list->entry); |
| 594 | + cifs_put_tcon(tmp_list->tcon, netfs_trace_tcon_ref_put_close_defer_files); |
| 595 | + kfree(tmp_list); |
| 596 | + } |
| 597 | +} |
| 598 | + |
557 | 599 | void cifs_close_deferred_file_under_dentry(struct cifs_tcon *tcon, |
558 | 600 | struct dentry *dentry) |
559 | 601 | { |
|
0 commit comments