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 { 28*d352ac68SChris Mason /* which subvolume this inode belongs to */ 29d6e4a428SChris Mason struct btrfs_root *root; 30*d352ac68SChris Mason 31*d352ac68SChris Mason /* the block group preferred for allocations. This pointer is buggy 32*d352ac68SChris Mason * and needs to be replaced with a bytenr instead 33*d352ac68SChris Mason */ 3431f3c99bSChris Mason struct btrfs_block_group_cache *block_group; 35*d352ac68SChris Mason 36*d352ac68SChris Mason /* key used to find this inode on disk. This is used by the code 37*d352ac68SChris Mason * to read in roots of subvolumes 38*d352ac68SChris Mason */ 39d6e4a428SChris Mason struct btrfs_key location; 40*d352ac68SChris Mason 41*d352ac68SChris Mason /* the extent_tree has caches of all the extent mappings to disk */ 42a52d9a80SChris Mason struct extent_map_tree extent_tree; 43*d352ac68SChris Mason 44*d352ac68SChris Mason /* the io_tree does range state (DIRTY, LOCKED etc) */ 45d1310b2eSChris Mason struct extent_io_tree io_tree; 46*d352ac68SChris Mason 47*d352ac68SChris Mason /* special utility tree used to record which mirrors have already been 48*d352ac68SChris Mason * tried when checksums fail for a given block 49*d352ac68SChris Mason */ 507e38326fSChris Mason struct extent_io_tree io_failure_tree; 51*d352ac68SChris Mason 52*d352ac68SChris Mason /* held while inserting checksums to avoid races */ 531b1e2135SChris Mason struct mutex csum_mutex; 54*d352ac68SChris Mason 55*d352ac68SChris Mason /* held while inesrting or deleting extents from files */ 56ee6e6504SChris Mason struct mutex extent_mutex; 57*d352ac68SChris Mason 58*d352ac68SChris Mason /* held while logging the inode in tree-log.c */ 59e02119d5SChris Mason struct mutex log_mutex; 60*d352ac68SChris Mason 61*d352ac68SChris Mason /* used to order data wrt metadata */ 62e6dcd2dcSChris Mason struct btrfs_ordered_inode_tree ordered_tree; 6315ee9bc7SJosef Bacik 64*d352ac68SChris Mason /* standard acl pointers */ 6533268eafSJosef Bacik struct posix_acl *i_acl; 6633268eafSJosef Bacik struct posix_acl *i_default_acl; 6733268eafSJosef Bacik 687b128766SJosef Bacik /* for keeping track of orphaned inodes */ 697b128766SJosef Bacik struct list_head i_orphan; 707b128766SJosef Bacik 71*d352ac68SChris Mason /* list of all the delalloc inodes in the FS. There are times we need 72*d352ac68SChris Mason * to write all the delalloc pages to disk, and this list is used 73*d352ac68SChris Mason * to walk them all. 74*d352ac68SChris Mason */ 75ea8c2819SChris Mason struct list_head delalloc_inodes; 76ea8c2819SChris Mason 77*d352ac68SChris Mason /* full 64 bit generation number, struct vfs_inode doesn't have a big 78*d352ac68SChris Mason * enough field for this. 79*d352ac68SChris Mason */ 80e02119d5SChris Mason u64 generation; 81e02119d5SChris Mason 8215ee9bc7SJosef Bacik /* 8315ee9bc7SJosef Bacik * transid of the trans_handle that last modified this inode 8415ee9bc7SJosef Bacik */ 8515ee9bc7SJosef Bacik u64 last_trans; 86e02119d5SChris Mason /* 87e02119d5SChris Mason * transid that last logged this inode 88e02119d5SChris Mason */ 89e02119d5SChris Mason u64 logged_trans; 9049eb7e46SChris Mason 91*d352ac68SChris Mason /* 92*d352ac68SChris Mason * trans that last made a change that should be fully fsync'd. This 93*d352ac68SChris Mason * gets reset to zero each time the inode is logged 94*d352ac68SChris Mason */ 9549eb7e46SChris Mason u64 log_dirty_trans; 96*d352ac68SChris Mason 97*d352ac68SChris Mason /* total number of bytes pending delalloc, used by stat to calc the 98*d352ac68SChris Mason * real block usage of the file 99*d352ac68SChris Mason */ 1009069218dSChris Mason u64 delalloc_bytes; 101*d352ac68SChris Mason 102*d352ac68SChris Mason /* 103*d352ac68SChris Mason * the size of the file stored in the metadata on disk. data=ordered 104*d352ac68SChris Mason * means the in-memory i_size might be larger than the size on disk 105*d352ac68SChris Mason * because not all the blocks are written yet. 106*d352ac68SChris Mason */ 107dbe674a9SChris Mason u64 disk_i_size; 108*d352ac68SChris Mason 109*d352ac68SChris Mason /* flags field from the on disk inode */ 110b98b6767SYan u32 flags; 111aec7477bSJosef Bacik 112aec7477bSJosef Bacik /* 113aec7477bSJosef Bacik * if this is a directory then index_cnt is the counter for the index 114aec7477bSJosef Bacik * number for new files that are created 115aec7477bSJosef Bacik */ 116aec7477bSJosef Bacik u64 index_cnt; 117*d352ac68SChris Mason 118*d352ac68SChris Mason struct inode vfs_inode; 1192c90e5d6SChris Mason }; 120dbe674a9SChris Mason 1212c90e5d6SChris Mason static inline struct btrfs_inode *BTRFS_I(struct inode *inode) 1222c90e5d6SChris Mason { 1232c90e5d6SChris Mason return container_of(inode, struct btrfs_inode, vfs_inode); 1242c90e5d6SChris Mason } 1252c90e5d6SChris Mason 126dbe674a9SChris Mason static inline void btrfs_i_size_write(struct inode *inode, u64 size) 127dbe674a9SChris Mason { 128dbe674a9SChris Mason inode->i_size = size; 129dbe674a9SChris Mason BTRFS_I(inode)->disk_i_size = size; 130dbe674a9SChris Mason } 131dbe674a9SChris Mason 132dbe674a9SChris Mason 1332c90e5d6SChris Mason #endif 134