Blame view

fs/exofs/exofs.h 9.1 KB
b14f8ab28   Boaz Harrosh   exofs: Kbuild, He...
1
2
  /*
   * Copyright (C) 2005, 2006
27d2e1491   Boaz Harrosh   exofs: Remove IBM...
3
   * Avishay Traeger (avishay@gmail.com)
b14f8ab28   Boaz Harrosh   exofs: Kbuild, He...
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
30
31
32
   * Copyright (C) 2008, 2009
   * Boaz Harrosh <bharrosh@panasas.com>
   *
   * Copyrights for code taken from ext2:
   *     Copyright (C) 1992, 1993, 1994, 1995
   *     Remy Card (card@masi.ibp.fr)
   *     Laboratoire MASI - Institut Blaise Pascal
   *     Universite Pierre et Marie Curie (Paris VI)
   *     from
   *     linux/fs/minix/inode.c
   *     Copyright (C) 1991, 1992  Linus Torvalds
   *
   * This file is part of exofs.
   *
   * exofs 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.  Since it is based on ext2, and the only
   * valid version of GPL for the Linux kernel is version 2, the only valid
   * version of GPL for exofs is version 2.
   *
   * exofs 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 exofs; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   */
06886a5a3   Boaz Harrosh   exofs: Move all o...
33
34
  #ifndef __EXOFS_H__
  #define __EXOFS_H__
b14f8ab28   Boaz Harrosh   exofs: Kbuild, He...
35
36
37
  
  #include <linux/fs.h>
  #include <linux/time.h>
b3d0ab7e6   Jens Axboe   exofs: add bdi ba...
38
  #include <linux/backing-dev.h>
b14f8ab28   Boaz Harrosh   exofs: Kbuild, He...
39
  #include "common.h"
04dc1e88a   Boaz Harrosh   exofs: Multi-devi...
40
41
42
43
  /* FIXME: Remove once pnfs hits mainline
   * #include <linux/exportfs/pnfs_osd_xdr.h>
   */
  #include "pnfs.h"
b14f8ab28   Boaz Harrosh   exofs: Kbuild, He...
44
45
46
47
48
49
50
51
52
53
54
55
  #define EXOFS_ERR(fmt, a...) printk(KERN_ERR "exofs: " fmt, ##a)
  
  #ifdef CONFIG_EXOFS_DEBUG
  #define EXOFS_DBGMSG(fmt, a...) \
  	printk(KERN_NOTICE "exofs @%s:%d: " fmt, __func__, __LINE__, ##a)
  #else
  #define EXOFS_DBGMSG(fmt, a...) \
  	do { if (0) printk(fmt, ##a); } while (0)
  #endif
  
  /* u64 has problems with printk this will cast it to unsigned long long */
  #define _LLU(x) (unsigned long long)(x)
45d3abcb1   Boaz Harrosh   exofs: Move layou...
56
57
  struct exofs_layout {
  	osd_id		s_pid;			/* partition ID of file system*/
5d952b839   Boaz Harrosh   exofs: RAID0 support
58
59
60
61
62
  	/* Our way of looking at the data_map */
  	unsigned stripe_unit;
  	unsigned mirrors_p1;
  
  	unsigned group_width;
50a76fd3c   Boaz Harrosh   exofs: groups sup...
63
64
  	u64	 group_depth;
  	unsigned group_count;
5d952b839   Boaz Harrosh   exofs: RAID0 support
65
66
  
  	enum exofs_inode_layout_gen_functions lay_func;
45d3abcb1   Boaz Harrosh   exofs: Move layou...
67
68
69
  	unsigned	s_numdevs;		/* Num of devices in array    */
  	struct osd_dev	*s_ods[0];		/* Variable length            */
  };
b14f8ab28   Boaz Harrosh   exofs: Kbuild, He...
70
71
72
73
  /*
   * our extension to the in-memory superblock
   */
  struct exofs_sb_info {
06886a5a3   Boaz Harrosh   exofs: Move all o...
74
  	struct exofs_fscb s_fscb;		/* Written often, pre-allocate*/
b14f8ab28   Boaz Harrosh   exofs: Kbuild, He...
75
76
77
78
79
80
  	int		s_timeout;		/* timeout for OSD operations */
  	uint64_t	s_nextid;		/* highest object ID used     */
  	uint32_t	s_numfiles;		/* number of files on fs      */
  	spinlock_t	s_next_gen_lock;	/* spinlock for gen # update  */
  	u32		s_next_generation;	/* next gen # to use          */
  	atomic_t	s_curr_pending;		/* number of pending commands */
04dc1e88a   Boaz Harrosh   exofs: Multi-devi...
81
  	uint8_t		s_cred[OSD_CAP_LEN];	/* credential for the fscb    */
a36fed12a   Boaz Harrosh   exofs: Fix "add b...
82
  	struct 		backing_dev_info bdi;	/* register our bdi with VFS  */
04dc1e88a   Boaz Harrosh   exofs: Multi-devi...
83

45d3abcb1   Boaz Harrosh   exofs: Move layou...
84
85
86
87
88
89
90
91
  	struct pnfs_osd_data_map data_map;	/* Default raid to use
  						 * FIXME: Needed ?
  						 */
  /*	struct exofs_layout	dir_layout;*/	/* Default dir layout */
  	struct exofs_layout	layout;		/* Default files layout,
  						 * contains the variable osd_dev
  						 * array. Keep last */
  	struct osd_dev	*_min_one_dev[1];	/* Place holder for one dev   */
b14f8ab28   Boaz Harrosh   exofs: Kbuild, He...
92
93
94
95
96
97
  };
  
  /*
   * our extension to the in-memory inode
   */
  struct exofs_i_info {
518f167a3   Boaz Harrosh   exofs: Micro-opti...
98
99
  	struct inode   vfs_inode;          /* normal in-memory inode          */
  	wait_queue_head_t i_wq;            /* wait queue for inode            */
b14f8ab28   Boaz Harrosh   exofs: Kbuild, He...
100
101
102
  	unsigned long  i_flags;            /* various atomic flags            */
  	uint32_t       i_data[EXOFS_IDATA];/*short symlink names and device #s*/
  	uint32_t       i_dir_start_lookup; /* which page to start lookup      */
b14f8ab28   Boaz Harrosh   exofs: Kbuild, He...
103
104
  	uint64_t       i_commit_size;      /* the object's written length     */
  	uint8_t        i_cred[OSD_CAP_LEN];/* all-powerful credential         */
b14f8ab28   Boaz Harrosh   exofs: Kbuild, He...
105
  };
06886a5a3   Boaz Harrosh   exofs: Move all o...
106
107
108
109
110
111
112
113
114
115
116
117
118
  static inline osd_id exofs_oi_objno(struct exofs_i_info *oi)
  {
  	return oi->vfs_inode.i_ino + EXOFS_OBJ_OFF;
  }
  
  struct exofs_io_state;
  typedef void (*exofs_io_done_fn)(struct exofs_io_state *or, void *private);
  
  struct exofs_io_state {
  	struct kref		kref;
  
  	void			*private;
  	exofs_io_done_fn	done;
45d3abcb1   Boaz Harrosh   exofs: Move layou...
119
  	struct exofs_layout	*layout;
06886a5a3   Boaz Harrosh   exofs: Move all o...
120
121
122
123
124
125
126
  	struct osd_obj_id	obj;
  	u8			*cred;
  
  	/* Global read/write IO*/
  	loff_t			offset;
  	unsigned long		length;
  	void			*kern_buff;
86093aaff   Boaz Harrosh   exofs: convert io...
127
128
129
130
  
  	struct page		**pages;
  	unsigned		nr_pages;
  	unsigned		pgbase;
50a76fd3c   Boaz Harrosh   exofs: groups sup...
131
  	unsigned		pages_consumed;
06886a5a3   Boaz Harrosh   exofs: Move all o...
132
133
134
135
136
137
138
139
140
141
142
143
  
  	/* Attributes */
  	unsigned		in_attr_len;
  	struct osd_attr 	*in_attr;
  	unsigned		out_attr_len;
  	struct osd_attr 	*out_attr;
  
  	/* Variable array of size numdevs */
  	unsigned numdevs;
  	struct exofs_per_dev_state {
  		struct osd_request *or;
  		struct bio *bio;
5d952b839   Boaz Harrosh   exofs: RAID0 support
144
145
146
  		loff_t offset;
  		unsigned length;
  		unsigned dev;
06886a5a3   Boaz Harrosh   exofs: Move all o...
147
148
149
150
151
152
153
154
  	} per_dev[];
  };
  
  static inline unsigned exofs_io_state_size(unsigned numdevs)
  {
  	return sizeof(struct exofs_io_state) +
  		sizeof(struct exofs_per_dev_state) * numdevs;
  }
b14f8ab28   Boaz Harrosh   exofs: Kbuild, He...
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
  /*
   * our inode flags
   */
  #define OBJ_2BCREATED	0	/* object will be created soon*/
  #define OBJ_CREATED	1	/* object has been created on the osd*/
  
  static inline int obj_2bcreated(struct exofs_i_info *oi)
  {
  	return test_bit(OBJ_2BCREATED, &oi->i_flags);
  }
  
  static inline void set_obj_2bcreated(struct exofs_i_info *oi)
  {
  	set_bit(OBJ_2BCREATED, &oi->i_flags);
  }
  
  static inline int obj_created(struct exofs_i_info *oi)
  {
  	return test_bit(OBJ_CREATED, &oi->i_flags);
  }
  
  static inline void set_obj_created(struct exofs_i_info *oi)
  {
  	set_bit(OBJ_CREATED, &oi->i_flags);
  }
  
  int __exofs_wait_obj_created(struct exofs_i_info *oi);
  static inline int wait_obj_created(struct exofs_i_info *oi)
  {
  	if (likely(obj_created(oi)))
  		return 0;
  
  	return __exofs_wait_obj_created(oi);
  }
  
  /*
   * get to our inode from the vfs inode
   */
  static inline struct exofs_i_info *exofs_i(struct inode *inode)
  {
  	return container_of(inode, struct exofs_i_info, vfs_inode);
  }
e6af00f1d   Boaz Harrosh   exofs: dir_inode ...
197
  /*
d9c740d22   Boaz Harrosh   exofs: Define on-...
198
199
200
201
202
203
   * Given a layout, object_number and stripe_index return the associated global
   * dev_index
   */
  unsigned exofs_layout_od_id(struct exofs_layout *layout,
  			    osd_id obj_no, unsigned layout_index);
  /*
e6af00f1d   Boaz Harrosh   exofs: dir_inode ...
204
205
206
   * Maximum count of links to a file
   */
  #define EXOFS_LINK_MAX           32000
e80627191   Boaz Harrosh   exofs: file and f...
207
208
209
  /*************************
   * function declarations *
   *************************/
06886a5a3   Boaz Harrosh   exofs: Move all o...
210
211
212
213
214
215
  
  /* ios.c */
  void exofs_make_credential(u8 cred_a[OSD_CAP_LEN],
  			   const struct osd_obj_id *obj);
  int exofs_read_kern(struct osd_dev *od, u8 *cred, struct osd_obj_id *obj,
  		    u64 offset, void *p, unsigned length);
45d3abcb1   Boaz Harrosh   exofs: Move layou...
216
217
  int  exofs_get_io_state(struct exofs_layout *layout,
  			struct exofs_io_state **ios);
06886a5a3   Boaz Harrosh   exofs: Move all o...
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
  void exofs_put_io_state(struct exofs_io_state *ios);
  
  int exofs_check_io(struct exofs_io_state *ios, u64 *resid);
  
  int exofs_sbi_create(struct exofs_io_state *ios);
  int exofs_sbi_remove(struct exofs_io_state *ios);
  int exofs_sbi_write(struct exofs_io_state *ios);
  int exofs_sbi_read(struct exofs_io_state *ios);
  
  int extract_attr_from_ios(struct exofs_io_state *ios, struct osd_attr *attr);
  
  int exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
  static inline int exofs_oi_write(struct exofs_i_info *oi,
  				 struct exofs_io_state *ios)
  {
  	ios->obj.id = exofs_oi_objno(oi);
  	ios->cred = oi->i_cred;
  	return exofs_sbi_write(ios);
  }
  
  static inline int exofs_oi_read(struct exofs_i_info *oi,
  				struct exofs_io_state *ios)
  {
  	ios->obj.id = exofs_oi_objno(oi);
  	ios->cred = oi->i_cred;
  	return exofs_sbi_read(ios);
  }
e80627191   Boaz Harrosh   exofs: file and f...
245
246
247
  /* inode.c               */
  void exofs_truncate(struct inode *inode);
  int exofs_setattr(struct dentry *, struct iattr *);
beaec07ba   Boaz Harrosh   exofs: address_sp...
248
249
250
  int exofs_write_begin(struct file *file, struct address_space *mapping,
  		loff_t pos, unsigned len, unsigned flags,
  		struct page **pagep, void **fsdata);
e6af00f1d   Boaz Harrosh   exofs: dir_inode ...
251
252
  extern struct inode *exofs_iget(struct super_block *, unsigned long);
  struct inode *exofs_new_inode(struct inode *, int);
a9185b41a   Christoph Hellwig   pass writeback_co...
253
  extern int exofs_write_inode(struct inode *, struct writeback_control *wbc);
ba9e5e98c   Boaz Harrosh   exofs: super_oper...
254
  extern void exofs_delete_inode(struct inode *);
e6af00f1d   Boaz Harrosh   exofs: dir_inode ...
255
256
257
258
259
260
261
262
263
264
  
  /* dir.c:                */
  int exofs_add_link(struct dentry *, struct inode *);
  ino_t exofs_inode_by_name(struct inode *, struct dentry *);
  int exofs_delete_entry(struct exofs_dir_entry *, struct page *);
  int exofs_make_empty(struct inode *, struct inode *);
  struct exofs_dir_entry *exofs_find_entry(struct inode *, struct dentry *,
  					 struct page **);
  int exofs_empty_dir(struct inode *);
  struct exofs_dir_entry *exofs_dotdot(struct inode *, struct page **);
8cf74b393   Boaz Harrosh   exofs: export_ope...
265
  ino_t exofs_parent_ino(struct dentry *child);
e6af00f1d   Boaz Harrosh   exofs: dir_inode ...
266
267
  int exofs_set_link(struct inode *, struct exofs_dir_entry *, struct page *,
  		    struct inode *);
e80627191   Boaz Harrosh   exofs: file and f...
268

baaf94cdc   Boaz Harrosh   exofs: Avoid usin...
269
270
  /* super.c               */
  int exofs_sync_fs(struct super_block *sb, int wait);
e80627191   Boaz Harrosh   exofs: file and f...
271
272
273
  /*********************
   * operation vectors *
   *********************/
e6af00f1d   Boaz Harrosh   exofs: dir_inode ...
274
275
  /* dir.c:            */
  extern const struct file_operations exofs_dir_operations;
e80627191   Boaz Harrosh   exofs: file and f...
276
277
278
  /* file.c            */
  extern const struct inode_operations exofs_file_inode_operations;
  extern const struct file_operations exofs_file_operations;
beaec07ba   Boaz Harrosh   exofs: address_sp...
279
280
  /* inode.c           */
  extern const struct address_space_operations exofs_aops;
06886a5a3   Boaz Harrosh   exofs: Move all o...
281
  extern const struct osd_attr g_attr_logical_length;
beaec07ba   Boaz Harrosh   exofs: address_sp...
282

e6af00f1d   Boaz Harrosh   exofs: dir_inode ...
283
284
285
  /* namei.c           */
  extern const struct inode_operations exofs_dir_inode_operations;
  extern const struct inode_operations exofs_special_inode_operations;
982980d75   Boaz Harrosh   exofs: symlink_in...
286
287
288
  /* symlink.c         */
  extern const struct inode_operations exofs_symlink_inode_operations;
  extern const struct inode_operations exofs_fast_symlink_inode_operations;
b14f8ab28   Boaz Harrosh   exofs: Kbuild, He...
289
  #endif