Blame view

fs/nilfs2/mdt.h 3.76 KB
5eb563f5f   Ryusuke Konishi   nilfs2: meta data...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  /*
   * mdt.h - NILFS meta data file prototype and definitions
   *
   * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation; either version 2 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   *
   * Written by Ryusuke Konishi <ryusuke@osrg.net>
   */
  
  #ifndef _NILFS_MDT_H
  #define _NILFS_MDT_H
  
  #include <linux/buffer_head.h>
  #include <linux/blockgroup_lock.h>
  #include "nilfs.h"
  #include "page.h"
ebdfed4dc   Ryusuke Konishi   nilfs2: add routi...
30
31
32
33
34
35
  struct nilfs_shadow_map {
  	struct nilfs_bmap_store bmap_store;
  	struct address_space frozen_data;
  	struct address_space frozen_btnodes;
  	struct list_head frozen_buffers;
  };
5eb563f5f   Ryusuke Konishi   nilfs2: meta data...
36
37
  /**
   * struct nilfs_mdt_info - on-memory private data of meta data files
5eb563f5f   Ryusuke Konishi   nilfs2: meta data...
38
39
40
41
42
   * @mi_sem: reader/writer semaphore for meta data operations
   * @mi_bgl: per-blockgroup locking
   * @mi_entry_size: size of an entry
   * @mi_first_entry_offset: offset to the first entry
   * @mi_entries_per_block: number of entries in a block
db38d5ad3   Ryusuke Konishi   nilfs2: add cache...
43
   * @mi_palloc_cache: persistent object allocator cache
ebdfed4dc   Ryusuke Konishi   nilfs2: add routi...
44
   * @mi_shadow: shadow of bmap and page caches
5eb563f5f   Ryusuke Konishi   nilfs2: meta data...
45
46
47
48
   * @mi_blocks_per_group: number of blocks in a group
   * @mi_blocks_per_desc_block: number of blocks per descriptor block
   */
  struct nilfs_mdt_info {
5eb563f5f   Ryusuke Konishi   nilfs2: meta data...
49
50
51
52
53
  	struct rw_semaphore	mi_sem;
  	struct blockgroup_lock *mi_bgl;
  	unsigned		mi_entry_size;
  	unsigned		mi_first_entry_offset;
  	unsigned long		mi_entries_per_block;
db38d5ad3   Ryusuke Konishi   nilfs2: add cache...
54
  	struct nilfs_palloc_cache *mi_palloc_cache;
ebdfed4dc   Ryusuke Konishi   nilfs2: add routi...
55
  	struct nilfs_shadow_map *mi_shadow;
5eb563f5f   Ryusuke Konishi   nilfs2: meta data...
56
57
58
59
60
61
62
63
  	unsigned long		mi_blocks_per_group;
  	unsigned long		mi_blocks_per_desc_block;
  };
  
  static inline struct nilfs_mdt_info *NILFS_MDT(const struct inode *inode)
  {
  	return inode->i_private;
  }
5eb563f5f   Ryusuke Konishi   nilfs2: meta data...
64
65
66
67
68
69
70
71
72
73
74
  /* Default GFP flags using highmem */
  #define NILFS_MDT_GFP      (__GFP_WAIT | __GFP_IO | __GFP_HIGHMEM)
  
  int nilfs_mdt_get_block(struct inode *, unsigned long, int,
  			void (*init_block)(struct inode *,
  					   struct buffer_head *, void *),
  			struct buffer_head **);
  int nilfs_mdt_delete_block(struct inode *, unsigned long);
  int nilfs_mdt_forget_block(struct inode *, unsigned long);
  int nilfs_mdt_mark_block_dirty(struct inode *, unsigned long);
  int nilfs_mdt_fetch_dirty(struct inode *);
f1e89c86f   Ryusuke Konishi   nilfs2: use iget ...
75
  int nilfs_mdt_init(struct inode *inode, gfp_t gfp_mask, size_t objsz);
5eb563f5f   Ryusuke Konishi   nilfs2: meta data...
76
  void nilfs_mdt_set_entry_size(struct inode *, unsigned, unsigned);
5eb563f5f   Ryusuke Konishi   nilfs2: meta data...
77

ebdfed4dc   Ryusuke Konishi   nilfs2: add routi...
78
79
80
81
82
  int nilfs_mdt_setup_shadow_map(struct inode *inode,
  			       struct nilfs_shadow_map *shadow);
  int nilfs_mdt_save_to_shadow_map(struct inode *inode);
  void nilfs_mdt_restore_from_shadow_map(struct inode *inode);
  void nilfs_mdt_clear_shadow_map(struct inode *inode);
b1f6a4f29   Ryusuke Konishi   nilfs2: add routi...
83
84
85
  int nilfs_mdt_freeze_buffer(struct inode *inode, struct buffer_head *bh);
  struct buffer_head *nilfs_mdt_get_frozen_buffer(struct inode *inode,
  						struct buffer_head *bh);
5eb563f5f   Ryusuke Konishi   nilfs2: meta data...
86

5eb563f5f   Ryusuke Konishi   nilfs2: meta data...
87
88
89
90
91
92
93
94
95
96
97
98
99
  static inline void nilfs_mdt_mark_dirty(struct inode *inode)
  {
  	if (!test_bit(NILFS_I_DIRTY, &NILFS_I(inode)->i_state))
  		set_bit(NILFS_I_DIRTY, &NILFS_I(inode)->i_state);
  }
  
  static inline void nilfs_mdt_clear_dirty(struct inode *inode)
  {
  	clear_bit(NILFS_I_DIRTY, &NILFS_I(inode)->i_state);
  }
  
  static inline __u64 nilfs_mdt_cno(struct inode *inode)
  {
0ef28f9ae   Ryusuke Konishi   nilfs2: get rid o...
100
  	return ((struct the_nilfs *)inode->i_sb->s_fs_info)->ns_cno;
5eb563f5f   Ryusuke Konishi   nilfs2: meta data...
101
102
103
104
  }
  
  #define nilfs_mdt_bgl_lock(inode, bg) \
  	(&NILFS_MDT(inode)->mi_bgl->locks[(bg) & (NR_BG_LOCKS-1)].lock)
5eb563f5f   Ryusuke Konishi   nilfs2: meta data...
105
  #endif /* _NILFS_MDT_H */