|
27 | 27 | #include "fs_context.h" |
28 | 28 | #include "cached_dir.h" |
29 | 29 |
|
| 30 | +struct tcon_list { |
| 31 | + struct list_head entry; |
| 32 | + struct cifs_tcon *tcon; |
| 33 | +}; |
| 34 | + |
30 | 35 | /* The xid serves as a useful identifier for each incoming vfs request, |
31 | 36 | in a similar way to the mid which is useful to track each sent smb, |
32 | 37 | and CurrentXid can also provide a running counter (although it |
@@ -833,6 +838,43 @@ cifs_close_all_deferred_files(struct cifs_tcon *tcon) |
833 | 838 | } |
834 | 839 | } |
835 | 840 |
|
| 841 | +void cifs_close_all_deferred_files_sb(struct cifs_sb_info *cifs_sb) |
| 842 | +{ |
| 843 | + struct rb_root *root = &cifs_sb->tlink_tree; |
| 844 | + struct rb_node *node; |
| 845 | + struct cifs_tcon *tcon; |
| 846 | + struct tcon_link *tlink; |
| 847 | + struct tcon_list *tmp_list, *q; |
| 848 | + LIST_HEAD(tcon_head); |
| 849 | + |
| 850 | + spin_lock(&cifs_sb->tlink_tree_lock); |
| 851 | + for (node = rb_first(root); node; node = rb_next(node)) { |
| 852 | + tlink = rb_entry(node, struct tcon_link, tl_rbnode); |
| 853 | + tcon = tlink_tcon(tlink); |
| 854 | + if (IS_ERR(tcon)) |
| 855 | + continue; |
| 856 | + tmp_list = kmalloc(sizeof(struct tcon_list), GFP_ATOMIC); |
| 857 | + if (tmp_list == NULL) |
| 858 | + break; |
| 859 | + tmp_list->tcon = tcon; |
| 860 | + /* Take a reference on tcon to prevent it from being freed */ |
| 861 | + spin_lock(&tcon->tc_lock); |
| 862 | + ++tcon->tc_count; |
| 863 | + trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count, |
| 864 | + netfs_trace_tcon_ref_get_close_defer_files); |
| 865 | + spin_unlock(&tcon->tc_lock); |
| 866 | + list_add_tail(&tmp_list->entry, &tcon_head); |
| 867 | + } |
| 868 | + spin_unlock(&cifs_sb->tlink_tree_lock); |
| 869 | + |
| 870 | + list_for_each_entry_safe(tmp_list, q, &tcon_head, entry) { |
| 871 | + cifs_close_all_deferred_files(tmp_list->tcon); |
| 872 | + list_del(&tmp_list->entry); |
| 873 | + cifs_put_tcon(tmp_list->tcon, netfs_trace_tcon_ref_put_close_defer_files); |
| 874 | + kfree(tmp_list); |
| 875 | + } |
| 876 | +} |
| 877 | + |
836 | 878 | void cifs_close_deferred_file_under_dentry(struct cifs_tcon *tcon, |
837 | 879 | struct dentry *dentry) |
838 | 880 | { |
|
0 commit comments