xref: /openbmc/linux/fs/btrfs/btrfs_inode.h (revision 49eb7e46d47ea72a9bd2a5f8cedb04f5159cc277)
16cbd5570SChris Mason /*
26cbd5570SChris Mason  * Copyright (C) 2007 Oracle.  All rights reserved.
36cbd5570SChris Mason  *
46cbd5570SChris Mason  * This program is free software; you can redistribute it and/or
56cbd5570SChris Mason  * modify it under the terms of the GNU General Public
66cbd5570SChris Mason  * License v2 as published by the Free Software Foundation.
76cbd5570SChris Mason  *
86cbd5570SChris Mason  * This program is distributed in the hope that it will be useful,
96cbd5570SChris Mason  * but WITHOUT ANY WARRANTY; without even the implied warranty of
106cbd5570SChris Mason  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
116cbd5570SChris Mason  * General Public License for more details.
126cbd5570SChris Mason  *
136cbd5570SChris Mason  * You should have received a copy of the GNU General Public
146cbd5570SChris Mason  * License along with this program; if not, write to the
156cbd5570SChris Mason  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
166cbd5570SChris Mason  * Boston, MA 021110-1307, USA.
176cbd5570SChris Mason  */
186cbd5570SChris Mason 
192c90e5d6SChris Mason #ifndef __BTRFS_I__
202c90e5d6SChris Mason #define __BTRFS_I__
212c90e5d6SChris Mason 
22a52d9a80SChris Mason #include "extent_map.h"
23d1310b2eSChris Mason #include "extent_io.h"
24e6dcd2dcSChris Mason #include "ordered-data.h"
25a52d9a80SChris Mason 
26f1ace244SAneesh /* in memory btrfs inode */
272c90e5d6SChris Mason struct btrfs_inode {
28d6e4a428SChris Mason 	struct btrfs_root *root;
2931f3c99bSChris Mason 	struct btrfs_block_group_cache *block_group;
30d6e4a428SChris Mason 	struct btrfs_key location;
31a52d9a80SChris Mason 	struct extent_map_tree extent_tree;
32d1310b2eSChris Mason 	struct extent_io_tree io_tree;
337e38326fSChris Mason 	struct extent_io_tree io_failure_tree;
341b1e2135SChris Mason 	struct mutex csum_mutex;
35ee6e6504SChris Mason 	struct mutex extent_mutex;
36e02119d5SChris Mason 	struct mutex log_mutex;
372c90e5d6SChris Mason 	struct inode vfs_inode;
38e6dcd2dcSChris Mason 	struct btrfs_ordered_inode_tree ordered_tree;
3915ee9bc7SJosef Bacik 
4033268eafSJosef Bacik 	struct posix_acl *i_acl;
4133268eafSJosef Bacik 	struct posix_acl *i_default_acl;
4233268eafSJosef Bacik 
437b128766SJosef Bacik 	/* for keeping track of orphaned inodes */
447b128766SJosef Bacik 	struct list_head i_orphan;
457b128766SJosef Bacik 
46ea8c2819SChris Mason 	struct list_head delalloc_inodes;
47ea8c2819SChris Mason 
48e02119d5SChris Mason 	/* full 64 bit generation number */
49e02119d5SChris Mason 	u64 generation;
50e02119d5SChris Mason 
5115ee9bc7SJosef Bacik 	/*
5215ee9bc7SJosef Bacik 	 * transid of the trans_handle that last modified this inode
5315ee9bc7SJosef Bacik 	 */
5415ee9bc7SJosef Bacik 	u64 last_trans;
55e02119d5SChris Mason 	/*
56e02119d5SChris Mason 	 * transid that last logged this inode
57e02119d5SChris Mason 	 */
58e02119d5SChris Mason 	u64 logged_trans;
59*49eb7e46SChris Mason 
60*49eb7e46SChris Mason 	/* trans that last made a change that should be fully fsync'd */
61*49eb7e46SChris Mason 	u64 log_dirty_trans;
629069218dSChris Mason 	u64 delalloc_bytes;
63dbe674a9SChris Mason 	u64 disk_i_size;
64b98b6767SYan 	u32 flags;
65aec7477bSJosef Bacik 
66aec7477bSJosef Bacik 	/*
67aec7477bSJosef Bacik 	 * if this is a directory then index_cnt is the counter for the index
68aec7477bSJosef Bacik 	 * number for new files that are created
69aec7477bSJosef Bacik 	 */
70aec7477bSJosef Bacik 	u64 index_cnt;
712c90e5d6SChris Mason };
72dbe674a9SChris Mason 
732c90e5d6SChris Mason static inline struct btrfs_inode *BTRFS_I(struct inode *inode)
742c90e5d6SChris Mason {
752c90e5d6SChris Mason 	return container_of(inode, struct btrfs_inode, vfs_inode);
762c90e5d6SChris Mason }
772c90e5d6SChris Mason 
78dbe674a9SChris Mason static inline void btrfs_i_size_write(struct inode *inode, u64 size)
79dbe674a9SChris Mason {
80dbe674a9SChris Mason 	inode->i_size = size;
81dbe674a9SChris Mason 	BTRFS_I(inode)->disk_i_size = size;
82dbe674a9SChris Mason }
83dbe674a9SChris Mason 
84dbe674a9SChris Mason 
852c90e5d6SChris Mason #endif
86