1
2
3
4
5
6
7
8
9
10
11
12
13
14#include <linux/fs.h>
15#include <linux/ext2_fs.h>
16#include <linux/blockgroup_lock.h>
17#include <linux/percpu_counter.h>
18#include <linux/rbtree.h>
19
20
21
22
23typedef int ext2_grpblk_t;
24
25
26typedef unsigned long ext2_fsblk_t;
27
28#define E2FSBLK "%lu"
29
30struct ext2_reserve_window {
31 ext2_fsblk_t _rsv_start;
32 ext2_fsblk_t _rsv_end;
33};
34
35struct ext2_reserve_window_node {
36 struct rb_node rsv_node;
37 __u32 rsv_goal_size;
38 __u32 rsv_alloc_hit;
39 struct ext2_reserve_window rsv_window;
40};
41
42struct ext2_block_alloc_info {
43
44 struct ext2_reserve_window_node rsv_window_node;
45
46
47
48
49
50
51 __u32 last_alloc_logical_block;
52
53
54
55
56
57
58
59 ext2_fsblk_t last_alloc_physical_block;
60};
61
62#define rsv_start rsv_window._rsv_start
63#define rsv_end rsv_window._rsv_end
64
65struct mb_cache;
66
67
68
69
70struct ext2_sb_info {
71 unsigned long s_frag_size;
72 unsigned long s_frags_per_block;
73 unsigned long s_inodes_per_block;
74 unsigned long s_frags_per_group;
75 unsigned long s_blocks_per_group;
76 unsigned long s_inodes_per_group;
77 unsigned long s_itb_per_group;
78 unsigned long s_gdb_count;
79 unsigned long s_desc_per_block;
80 unsigned long s_groups_count;
81 unsigned long s_overhead_last;
82 unsigned long s_blocks_last;
83 struct buffer_head * s_sbh;
84 struct ext2_super_block * s_es;
85 struct buffer_head ** s_group_desc;
86 unsigned long s_mount_opt;
87 unsigned long s_sb_block;
88 kuid_t s_resuid;
89 kgid_t s_resgid;
90 unsigned short s_mount_state;
91 unsigned short s_pad;
92 int s_addr_per_block_bits;
93 int s_desc_per_block_bits;
94 int s_inode_size;
95 int s_first_ino;
96 spinlock_t s_next_gen_lock;
97 u32 s_next_generation;
98 unsigned long s_dir_count;
99 u8 *s_debts;
100 struct percpu_counter s_freeblocks_counter;
101 struct percpu_counter s_freeinodes_counter;
102 struct percpu_counter s_dirs_counter;
103 struct blockgroup_lock *s_blockgroup_lock;
104
105 spinlock_t s_rsv_window_lock;
106 struct rb_root s_rsv_window_root;
107 struct ext2_reserve_window_node s_rsv_window_head;
108
109
110
111
112
113
114
115
116 spinlock_t s_lock;
117 struct mb_cache *s_ea_block_cache;
118 struct dax_device *s_daxdev;
119};
120
121static inline spinlock_t *
122sb_bgl_lock(struct ext2_sb_info *sbi, unsigned int block_group)
123{
124 return bgl_lock_ptr(sbi->s_blockgroup_lock, block_group);
125}
126
127
128
129
130#undef EXT2FS_DEBUG
131
132
133
134
135#define EXT2_DEFAULT_RESERVE_BLOCKS 8
136
137#define EXT2_MAX_RESERVE_BLOCKS 1027
138#define EXT2_RESERVE_WINDOW_NOT_ALLOCATED 0
139
140
141
142#define EXT2FS_DATE "95/08/09"
143#define EXT2FS_VERSION "0.5b"
144
145
146
147
148#ifdef EXT2FS_DEBUG
149# define ext2_debug(f, a...) { \
150 printk ("EXT2-fs DEBUG (%s, %d): %s:", \
151 __FILE__, __LINE__, __func__); \
152 printk (f, ## a); \
153 }
154#else
155# define ext2_debug(f, a...)
156#endif
157
158
159
160
161#define EXT2_BAD_INO 1
162#define EXT2_ROOT_INO 2
163#define EXT2_BOOT_LOADER_INO 5
164#define EXT2_UNDEL_DIR_INO 6
165
166
167#define EXT2_GOOD_OLD_FIRST_INO 11
168
169static inline struct ext2_sb_info *EXT2_SB(struct super_block *sb)
170{
171 return sb->s_fs_info;
172}
173
174
175
176
177#define EXT2_MIN_BLOCK_SIZE 1024
178#define EXT2_MAX_BLOCK_SIZE 4096
179#define EXT2_MIN_BLOCK_LOG_SIZE 10
180#define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize)
181#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32))
182#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
183#define EXT2_ADDR_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_addr_per_block_bits)
184#define EXT2_INODE_SIZE(s) (EXT2_SB(s)->s_inode_size)
185#define EXT2_FIRST_INO(s) (EXT2_SB(s)->s_first_ino)
186
187
188
189
190#define EXT2_MIN_FRAG_SIZE 1024
191#define EXT2_MAX_FRAG_SIZE 4096
192#define EXT2_MIN_FRAG_LOG_SIZE 10
193#define EXT2_FRAG_SIZE(s) (EXT2_SB(s)->s_frag_size)
194#define EXT2_FRAGS_PER_BLOCK(s) (EXT2_SB(s)->s_frags_per_block)
195
196
197
198
199struct ext2_group_desc
200{
201 __le32 bg_block_bitmap;
202 __le32 bg_inode_bitmap;
203 __le32 bg_inode_table;
204 __le16 bg_free_blocks_count;
205 __le16 bg_free_inodes_count;
206 __le16 bg_used_dirs_count;
207 __le16 bg_pad;
208 __le32 bg_reserved[3];
209};
210
211
212
213
214#define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group)
215#define EXT2_DESC_PER_BLOCK(s) (EXT2_SB(s)->s_desc_per_block)
216#define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group)
217#define EXT2_DESC_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_desc_per_block_bits)
218
219
220
221
222#define EXT2_NDIR_BLOCKS 12
223#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
224#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
225#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
226#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
227
228
229
230
231#define EXT2_SECRM_FL FS_SECRM_FL
232#define EXT2_UNRM_FL FS_UNRM_FL
233#define EXT2_COMPR_FL FS_COMPR_FL
234#define EXT2_SYNC_FL FS_SYNC_FL
235#define EXT2_IMMUTABLE_FL FS_IMMUTABLE_FL
236#define EXT2_APPEND_FL FS_APPEND_FL
237#define EXT2_NODUMP_FL FS_NODUMP_FL
238#define EXT2_NOATIME_FL FS_NOATIME_FL
239
240#define EXT2_DIRTY_FL FS_DIRTY_FL
241#define EXT2_COMPRBLK_FL FS_COMPRBLK_FL
242#define EXT2_NOCOMP_FL FS_NOCOMP_FL
243#define EXT2_ECOMPR_FL FS_ECOMPR_FL
244
245#define EXT2_BTREE_FL FS_BTREE_FL
246#define EXT2_INDEX_FL FS_INDEX_FL
247#define EXT2_IMAGIC_FL FS_IMAGIC_FL
248#define EXT2_JOURNAL_DATA_FL FS_JOURNAL_DATA_FL
249#define EXT2_NOTAIL_FL FS_NOTAIL_FL
250#define EXT2_DIRSYNC_FL FS_DIRSYNC_FL
251#define EXT2_TOPDIR_FL FS_TOPDIR_FL
252#define EXT2_RESERVED_FL FS_RESERVED_FL
253
254#define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE
255#define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE
256
257
258#define EXT2_FL_INHERITED (EXT2_SECRM_FL | EXT2_UNRM_FL | EXT2_COMPR_FL |\
259 EXT2_SYNC_FL | EXT2_NODUMP_FL |\
260 EXT2_NOATIME_FL | EXT2_COMPRBLK_FL |\
261 EXT2_NOCOMP_FL | EXT2_JOURNAL_DATA_FL |\
262 EXT2_NOTAIL_FL | EXT2_DIRSYNC_FL)
263
264
265#define EXT2_REG_FLMASK (~(EXT2_DIRSYNC_FL | EXT2_TOPDIR_FL))
266
267
268#define EXT2_OTHER_FLMASK (EXT2_NODUMP_FL | EXT2_NOATIME_FL)
269
270
271static inline __u32 ext2_mask_flags(umode_t mode, __u32 flags)
272{
273 if (S_ISDIR(mode))
274 return flags;
275 else if (S_ISREG(mode))
276 return flags & EXT2_REG_FLMASK;
277 else
278 return flags & EXT2_OTHER_FLMASK;
279}
280
281
282
283
284#define EXT2_IOC_GETFLAGS FS_IOC_GETFLAGS
285#define EXT2_IOC_SETFLAGS FS_IOC_SETFLAGS
286#define EXT2_IOC_GETVERSION FS_IOC_GETVERSION
287#define EXT2_IOC_SETVERSION FS_IOC_SETVERSION
288#define EXT2_IOC_GETRSVSZ _IOR('f', 5, long)
289#define EXT2_IOC_SETRSVSZ _IOW('f', 6, long)
290
291
292
293
294#define EXT2_IOC32_GETFLAGS FS_IOC32_GETFLAGS
295#define EXT2_IOC32_SETFLAGS FS_IOC32_SETFLAGS
296#define EXT2_IOC32_GETVERSION FS_IOC32_GETVERSION
297#define EXT2_IOC32_SETVERSION FS_IOC32_SETVERSION
298
299
300
301
302struct ext2_inode {
303 __le16 i_mode;
304 __le16 i_uid;
305 __le32 i_size;
306 __le32 i_atime;
307 __le32 i_ctime;
308 __le32 i_mtime;
309 __le32 i_dtime;
310 __le16 i_gid;
311 __le16 i_links_count;
312 __le32 i_blocks;
313 __le32 i_flags;
314 union {
315 struct {
316 __le32 l_i_reserved1;
317 } linux1;
318 struct {
319 __le32 h_i_translator;
320 } hurd1;
321 struct {
322 __le32 m_i_reserved1;
323 } masix1;
324 } osd1;
325 __le32 i_block[EXT2_N_BLOCKS];
326 __le32 i_generation;
327 __le32 i_file_acl;
328 __le32 i_dir_acl;
329 __le32 i_faddr;
330 union {
331 struct {
332 __u8 l_i_frag;
333 __u8 l_i_fsize;
334 __u16 i_pad1;
335 __le16 l_i_uid_high;
336 __le16 l_i_gid_high;
337 __u32 l_i_reserved2;
338 } linux2;
339 struct {
340 __u8 h_i_frag;
341 __u8 h_i_fsize;
342 __le16 h_i_mode_high;
343 __le16 h_i_uid_high;
344 __le16 h_i_gid_high;
345 __le32 h_i_author;
346 } hurd2;
347 struct {
348 __u8 m_i_frag;
349 __u8 m_i_fsize;
350 __u16 m_pad1;
351 __u32 m_i_reserved2[2];
352 } masix2;
353 } osd2;
354};
355
356#define i_size_high i_dir_acl
357
358#define i_reserved1 osd1.linux1.l_i_reserved1
359#define i_frag osd2.linux2.l_i_frag
360#define i_fsize osd2.linux2.l_i_fsize
361#define i_uid_low i_uid
362#define i_gid_low i_gid
363#define i_uid_high osd2.linux2.l_i_uid_high
364#define i_gid_high osd2.linux2.l_i_gid_high
365#define i_reserved2 osd2.linux2.l_i_reserved2
366
367
368
369
370#define EXT2_VALID_FS 0x0001
371#define EXT2_ERROR_FS 0x0002
372#define EFSCORRUPTED EUCLEAN
373
374
375
376
377#define EXT2_MOUNT_CHECK 0x000001
378#define EXT2_MOUNT_OLDALLOC 0x000002
379#define EXT2_MOUNT_GRPID 0x000004
380#define EXT2_MOUNT_DEBUG 0x000008
381#define EXT2_MOUNT_ERRORS_CONT 0x000010
382#define EXT2_MOUNT_ERRORS_RO 0x000020
383#define EXT2_MOUNT_ERRORS_PANIC 0x000040
384#define EXT2_MOUNT_MINIX_DF 0x000080
385#define EXT2_MOUNT_NOBH 0x000100
386#define EXT2_MOUNT_NO_UID32 0x000200
387#define EXT2_MOUNT_XATTR_USER 0x004000
388#define EXT2_MOUNT_POSIX_ACL 0x008000
389#define EXT2_MOUNT_XIP 0x010000
390#define EXT2_MOUNT_USRQUOTA 0x020000
391#define EXT2_MOUNT_GRPQUOTA 0x040000
392#define EXT2_MOUNT_RESERVATION 0x080000
393#ifdef CONFIG_FS_DAX
394#define EXT2_MOUNT_DAX 0x100000
395#else
396#define EXT2_MOUNT_DAX 0
397#endif
398
399
400#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
401#define set_opt(o, opt) o |= EXT2_MOUNT_##opt
402#define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \
403 EXT2_MOUNT_##opt)
404
405
406
407#define EXT2_DFL_MAX_MNT_COUNT 20
408#define EXT2_DFL_CHECKINTERVAL 0
409
410
411
412
413#define EXT2_ERRORS_CONTINUE 1
414#define EXT2_ERRORS_RO 2
415#define EXT2_ERRORS_PANIC 3
416#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
417
418
419
420
421struct ext2_super_block {
422 __le32 s_inodes_count;
423 __le32 s_blocks_count;
424 __le32 s_r_blocks_count;
425 __le32 s_free_blocks_count;
426 __le32 s_free_inodes_count;
427 __le32 s_first_data_block;
428 __le32 s_log_block_size;
429 __le32 s_log_frag_size;
430 __le32 s_blocks_per_group;
431 __le32 s_frags_per_group;
432 __le32 s_inodes_per_group;
433 __le32 s_mtime;
434 __le32 s_wtime;
435 __le16 s_mnt_count;
436 __le16 s_max_mnt_count;
437 __le16 s_magic;
438 __le16 s_state;
439 __le16 s_errors;
440 __le16 s_minor_rev_level;
441 __le32 s_lastcheck;
442 __le32 s_checkinterval;
443 __le32 s_creator_os;
444 __le32 s_rev_level;
445 __le16 s_def_resuid;
446 __le16 s_def_resgid;
447
448
449
450
451
452
453
454
455
456
457
458
459
460 __le32 s_first_ino;
461 __le16 s_inode_size;
462 __le16 s_block_group_nr;
463 __le32 s_feature_compat;
464 __le32 s_feature_incompat;
465 __le32 s_feature_ro_compat;
466 __u8 s_uuid[16];
467 char s_volume_name[16];
468 char s_last_mounted[64];
469 __le32 s_algorithm_usage_bitmap;
470
471
472
473
474 __u8 s_prealloc_blocks;
475 __u8 s_prealloc_dir_blocks;
476 __u16 s_padding1;
477
478
479
480 __u8 s_journal_uuid[16];
481 __u32 s_journal_inum;
482 __u32 s_journal_dev;
483 __u32 s_last_orphan;
484 __u32 s_hash_seed[4];
485 __u8 s_def_hash_version;
486 __u8 s_reserved_char_pad;
487 __u16 s_reserved_word_pad;
488 __le32 s_default_mount_opts;
489 __le32 s_first_meta_bg;
490 __u32 s_reserved[190];
491};
492
493
494
495
496#define EXT2_OS_LINUX 0
497#define EXT2_OS_HURD 1
498#define EXT2_OS_MASIX 2
499#define EXT2_OS_FREEBSD 3
500#define EXT2_OS_LITES 4
501
502
503
504
505#define EXT2_GOOD_OLD_REV 0
506#define EXT2_DYNAMIC_REV 1
507
508#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
509#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
510
511#define EXT2_GOOD_OLD_INODE_SIZE 128
512
513
514
515
516
517#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \
518 ( EXT2_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )
519#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \
520 ( EXT2_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) )
521#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
522 ( EXT2_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) )
523#define EXT2_SET_COMPAT_FEATURE(sb,mask) \
524 EXT2_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask)
525#define EXT2_SET_RO_COMPAT_FEATURE(sb,mask) \
526 EXT2_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask)
527#define EXT2_SET_INCOMPAT_FEATURE(sb,mask) \
528 EXT2_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask)
529#define EXT2_CLEAR_COMPAT_FEATURE(sb,mask) \
530 EXT2_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask)
531#define EXT2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
532 EXT2_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask)
533#define EXT2_CLEAR_INCOMPAT_FEATURE(sb,mask) \
534 EXT2_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask)
535
536#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
537#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
538#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
539#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008
540#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010
541#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
542#define EXT2_FEATURE_COMPAT_ANY 0xffffffff
543
544#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
545#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
546#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
547#define EXT2_FEATURE_RO_COMPAT_ANY 0xffffffff
548
549#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
550#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
551#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004
552#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
553#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
554#define EXT2_FEATURE_INCOMPAT_ANY 0xffffffff
555
556#define EXT2_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
557#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
558 EXT2_FEATURE_INCOMPAT_META_BG)
559#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
560 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
561 EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
562#define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED ~EXT2_FEATURE_RO_COMPAT_SUPP
563#define EXT2_FEATURE_INCOMPAT_UNSUPPORTED ~EXT2_FEATURE_INCOMPAT_SUPP
564
565
566
567
568#define EXT2_DEF_RESUID 0
569#define EXT2_DEF_RESGID 0
570
571
572
573
574#define EXT2_DEFM_DEBUG 0x0001
575#define EXT2_DEFM_BSDGROUPS 0x0002
576#define EXT2_DEFM_XATTR_USER 0x0004
577#define EXT2_DEFM_ACL 0x0008
578#define EXT2_DEFM_UID16 0x0010
579
580#define EXT3_DEFM_JMODE 0x0060
581#define EXT3_DEFM_JMODE_DATA 0x0020
582#define EXT3_DEFM_JMODE_ORDERED 0x0040
583#define EXT3_DEFM_JMODE_WBACK 0x0060
584
585
586
587
588
589struct ext2_dir_entry {
590 __le32 inode;
591 __le16 rec_len;
592 __le16 name_len;
593 char name[];
594};
595
596
597
598
599
600
601
602struct ext2_dir_entry_2 {
603 __le32 inode;
604 __le16 rec_len;
605 __u8 name_len;
606 __u8 file_type;
607 char name[];
608};
609
610
611
612
613
614enum {
615 EXT2_FT_UNKNOWN = 0,
616 EXT2_FT_REG_FILE = 1,
617 EXT2_FT_DIR = 2,
618 EXT2_FT_CHRDEV = 3,
619 EXT2_FT_BLKDEV = 4,
620 EXT2_FT_FIFO = 5,
621 EXT2_FT_SOCK = 6,
622 EXT2_FT_SYMLINK = 7,
623 EXT2_FT_MAX
624};
625
626
627
628
629
630
631#define EXT2_DIR_PAD 4
632#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
633#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
634 ~EXT2_DIR_ROUND)
635#define EXT2_MAX_REC_LEN ((1<<16)-1)
636
637static inline void verify_offsets(void)
638{
639#define A(x,y) BUILD_BUG_ON(x != offsetof(struct ext2_super_block, y));
640 A(EXT2_SB_MAGIC_OFFSET, s_magic);
641 A(EXT2_SB_BLOCKS_OFFSET, s_blocks_count);
642 A(EXT2_SB_BSIZE_OFFSET, s_log_block_size);
643#undef A
644}
645
646
647
648
649struct ext2_mount_options {
650 unsigned long s_mount_opt;
651 kuid_t s_resuid;
652 kgid_t s_resgid;
653};
654
655
656
657
658struct ext2_inode_info {
659 __le32 i_data[15];
660 __u32 i_flags;
661 __u32 i_faddr;
662 __u8 i_frag_no;
663 __u8 i_frag_size;
664 __u16 i_state;
665 __u32 i_file_acl;
666 __u32 i_dir_acl;
667 __u32 i_dtime;
668
669
670
671
672
673
674
675
676 __u32 i_block_group;
677
678
679 struct ext2_block_alloc_info *i_block_alloc_info;
680
681 __u32 i_dir_start_lookup;
682#ifdef CONFIG_EXT2_FS_XATTR
683
684
685
686
687
688
689
690 struct rw_semaphore xattr_sem;
691#endif
692 rwlock_t i_meta_lock;
693#ifdef CONFIG_FS_DAX
694 struct rw_semaphore dax_sem;
695#endif
696
697
698
699
700
701
702
703 struct mutex truncate_mutex;
704 struct inode vfs_inode;
705 struct list_head i_orphan;
706#ifdef CONFIG_QUOTA
707 struct dquot *i_dquot[MAXQUOTAS];
708#endif
709};
710
711#ifdef CONFIG_FS_DAX
712#define dax_sem_down_write(ext2_inode) down_write(&(ext2_inode)->dax_sem)
713#define dax_sem_up_write(ext2_inode) up_write(&(ext2_inode)->dax_sem)
714#else
715#define dax_sem_down_write(ext2_inode)
716#define dax_sem_up_write(ext2_inode)
717#endif
718
719
720
721
722#define EXT2_STATE_NEW 0x00000001
723
724
725
726
727
728
729
730
731
732
733
734static inline struct ext2_inode_info *EXT2_I(struct inode *inode)
735{
736 return container_of(inode, struct ext2_inode_info, vfs_inode);
737}
738
739
740extern int ext2_bg_has_super(struct super_block *sb, int group);
741extern unsigned long ext2_bg_num_gdb(struct super_block *sb, int group);
742extern ext2_fsblk_t ext2_new_block(struct inode *, unsigned long, int *);
743extern ext2_fsblk_t ext2_new_blocks(struct inode *, unsigned long,
744 unsigned long *, int *);
745extern int ext2_data_block_valid(struct ext2_sb_info *sbi, ext2_fsblk_t start_blk,
746 unsigned int count);
747extern void ext2_free_blocks (struct inode *, unsigned long,
748 unsigned long);
749extern unsigned long ext2_count_free_blocks (struct super_block *);
750extern unsigned long ext2_count_dirs (struct super_block *);
751extern void ext2_check_blocks_bitmap (struct super_block *);
752extern struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
753 unsigned int block_group,
754 struct buffer_head ** bh);
755extern void ext2_discard_reservation (struct inode *);
756extern int ext2_should_retry_alloc(struct super_block *sb, int *retries);
757extern void ext2_init_block_alloc_info(struct inode *);
758extern void ext2_rsv_window_add(struct super_block *sb, struct ext2_reserve_window_node *rsv);
759
760
761extern int ext2_add_link (struct dentry *, struct inode *);
762extern ino_t ext2_inode_by_name(struct inode *, const struct qstr *);
763extern int ext2_make_empty(struct inode *, struct inode *);
764extern struct ext2_dir_entry_2 * ext2_find_entry (struct inode *,const struct qstr *, struct page **);
765extern int ext2_delete_entry (struct ext2_dir_entry_2 *, struct page *);
766extern int ext2_empty_dir (struct inode *);
767extern struct ext2_dir_entry_2 * ext2_dotdot (struct inode *, struct page **);
768extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, struct inode *, int);
769
770
771extern struct inode * ext2_new_inode (struct inode *, umode_t, const struct qstr *);
772extern void ext2_free_inode (struct inode *);
773extern unsigned long ext2_count_free_inodes (struct super_block *);
774extern void ext2_check_inodes_bitmap (struct super_block *);
775extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
776
777
778extern struct inode *ext2_iget (struct super_block *, unsigned long);
779extern int ext2_write_inode (struct inode *, struct writeback_control *);
780extern void ext2_evict_inode(struct inode *);
781extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int);
782extern int ext2_setattr (struct dentry *, struct iattr *);
783extern void ext2_set_inode_flags(struct inode *inode);
784extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
785 u64 start, u64 len);
786
787
788extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
789extern long ext2_compat_ioctl(struct file *, unsigned int, unsigned long);
790
791
792struct dentry *ext2_get_parent(struct dentry *child);
793
794
795extern __printf(3, 4)
796void ext2_error(struct super_block *, const char *, const char *, ...);
797extern __printf(3, 4)
798void ext2_msg(struct super_block *, const char *, const char *, ...);
799extern void ext2_update_dynamic_rev (struct super_block *sb);
800extern void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es,
801 int wait);
802
803
804
805
806
807
808extern const struct file_operations ext2_dir_operations;
809
810
811extern int ext2_fsync(struct file *file, loff_t start, loff_t end,
812 int datasync);
813extern const struct inode_operations ext2_file_inode_operations;
814extern const struct file_operations ext2_file_operations;
815
816
817extern const struct address_space_operations ext2_aops;
818extern const struct address_space_operations ext2_nobh_aops;
819extern const struct iomap_ops ext2_iomap_ops;
820
821
822extern const struct inode_operations ext2_dir_inode_operations;
823extern const struct inode_operations ext2_special_inode_operations;
824
825
826extern const struct inode_operations ext2_fast_symlink_inode_operations;
827extern const struct inode_operations ext2_symlink_inode_operations;
828
829static inline ext2_fsblk_t
830ext2_group_first_block_no(struct super_block *sb, unsigned long group_no)
831{
832 return group_no * (ext2_fsblk_t)EXT2_BLOCKS_PER_GROUP(sb) +
833 le32_to_cpu(EXT2_SB(sb)->s_es->s_first_data_block);
834}
835
836#define ext2_set_bit __test_and_set_bit_le
837#define ext2_clear_bit __test_and_clear_bit_le
838#define ext2_test_bit test_bit_le
839#define ext2_find_first_zero_bit find_first_zero_bit_le
840#define ext2_find_next_zero_bit find_next_zero_bit_le
841