~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/btrfs/delayed-inode.h

Version: ~ [ linux-5.5-rc7 ] ~ [ linux-5.4.13 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.97 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.166 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.210 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.210 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.81 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright (C) 2011 Fujitsu.  All rights reserved.
  3  * Written by Miao Xie <miaox@cn.fujitsu.com>
  4  *
  5  * This program is free software; you can redistribute it and/or
  6  * modify it under the terms of the GNU General Public
  7  * License v2 as published by the Free Software Foundation.
  8  *
  9  * This program is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12  * General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU General Public
 15  * License along with this program; if not, write to the
 16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 17  * Boston, MA 021110-1307, USA.
 18  */
 19 
 20 #ifndef __DELAYED_TREE_OPERATION_H
 21 #define __DELAYED_TREE_OPERATION_H
 22 
 23 #include <linux/rbtree.h>
 24 #include <linux/spinlock.h>
 25 #include <linux/mutex.h>
 26 #include <linux/list.h>
 27 #include <linux/wait.h>
 28 #include <linux/atomic.h>
 29 
 30 #include "ctree.h"
 31 
 32 /* types of the delayed item */
 33 #define BTRFS_DELAYED_INSERTION_ITEM    1
 34 #define BTRFS_DELAYED_DELETION_ITEM     2
 35 
 36 struct btrfs_delayed_root {
 37         spinlock_t lock;
 38         struct list_head node_list;
 39         /*
 40          * Used for delayed nodes which is waiting to be dealt with by the
 41          * worker. If the delayed node is inserted into the work queue, we
 42          * drop it from this list.
 43          */
 44         struct list_head prepare_list;
 45         atomic_t items;         /* for delayed items */
 46         int nodes;              /* for delayed nodes */
 47         wait_queue_head_t wait;
 48 };
 49 
 50 struct btrfs_delayed_node {
 51         u64 inode_id;
 52         u64 bytes_reserved;
 53         struct btrfs_root *root;
 54         /* Used to add the node into the delayed root's node list. */
 55         struct list_head n_list;
 56         /*
 57          * Used to add the node into the prepare list, the nodes in this list
 58          * is waiting to be dealt with by the async worker.
 59          */
 60         struct list_head p_list;
 61         struct rb_root ins_root;
 62         struct rb_root del_root;
 63         struct mutex mutex;
 64         struct btrfs_inode_item inode_item;
 65         atomic_t refs;
 66         u64 index_cnt;
 67         bool in_list;
 68         bool inode_dirty;
 69         int count;
 70 };
 71 
 72 struct btrfs_delayed_item {
 73         struct rb_node rb_node;
 74         struct btrfs_key key;
 75         struct list_head tree_list;     /* used for batch insert/delete items */
 76         struct list_head readdir_list;  /* used for readdir items */
 77         u64 bytes_reserved;
 78         struct btrfs_delayed_node *delayed_node;
 79         atomic_t refs;
 80         int ins_or_del;
 81         u32 data_len;
 82         char data[0];
 83 };
 84 
 85 static inline void btrfs_init_delayed_root(
 86                                 struct btrfs_delayed_root *delayed_root)
 87 {
 88         atomic_set(&delayed_root->items, 0);
 89         delayed_root->nodes = 0;
 90         spin_lock_init(&delayed_root->lock);
 91         init_waitqueue_head(&delayed_root->wait);
 92         INIT_LIST_HEAD(&delayed_root->node_list);
 93         INIT_LIST_HEAD(&delayed_root->prepare_list);
 94 }
 95 
 96 int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans,
 97                                    struct btrfs_root *root, const char *name,
 98                                    int name_len, struct inode *dir,
 99                                    struct btrfs_disk_key *disk_key, u8 type,
100                                    u64 index);
101 
102 int btrfs_delete_delayed_dir_index(struct btrfs_trans_handle *trans,
103                                    struct btrfs_root *root, struct inode *dir,
104                                    u64 index);
105 
106 int btrfs_inode_delayed_dir_index_count(struct inode *inode);
107 
108 int btrfs_run_delayed_items(struct btrfs_trans_handle *trans,
109                             struct btrfs_root *root);
110 
111 void btrfs_balance_delayed_items(struct btrfs_root *root);
112 
113 int btrfs_commit_inode_delayed_items(struct btrfs_trans_handle *trans,
114                                      struct inode *inode);
115 /* Used for evicting the inode. */
116 void btrfs_remove_delayed_node(struct inode *inode);
117 void btrfs_kill_delayed_inode_items(struct inode *inode);
118 
119 
120 int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans,
121                                struct btrfs_root *root, struct inode *inode);
122 int btrfs_fill_inode(struct inode *inode, u32 *rdev);
123 
124 /* Used for drop dead root */
125 void btrfs_kill_all_delayed_nodes(struct btrfs_root *root);
126 
127 /* Used for clean the transaction */
128 void btrfs_destroy_delayed_inodes(struct btrfs_root *root);
129 
130 /* Used for readdir() */
131 void btrfs_get_delayed_items(struct inode *inode, struct list_head *ins_list,
132                              struct list_head *del_list);
133 void btrfs_put_delayed_items(struct list_head *ins_list,
134                              struct list_head *del_list);
135 int btrfs_should_delete_dir_index(struct list_head *del_list,
136                                   u64 index);
137 int btrfs_readdir_delayed_dir_index(struct file *filp, void *dirent,
138                                     filldir_t filldir,
139                                     struct list_head *ins_list);
140 
141 /* for init */
142 int __init btrfs_delayed_inode_init(void);
143 void btrfs_delayed_inode_exit(void);
144 
145 /* for debugging */
146 void btrfs_assert_delayed_root_empty(struct btrfs_root *root);
147 
148 #endif
149 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp