Commit 4a092d737955301da22b9d5e07f5036da821a932

Authored by Theodore Ts'o
1 parent 766f44d46a

ext4: rationalize ext4_extents.h inclusion

Previously, ext4_extents.h was being included at the end of ext4.h,
which was bad for a number of reasons: (a) it was not being included
in the expected place, and (b) it caused the header to be included
multiple times.  There were #ifdef's to prevent this from causing any
problems, but it still was unnecessary.

By moving the function declarations that were in ext4_extents.h to
ext4.h, which is standard practice for where the function declarations
for the rest of ext4.h can be found, we can remove ext4_extents.h from
being included in ext4.h at all, and then we can only include
ext4_extents.h where it is needed in ext4's source files.

It should be possible to move a few more things into ext4.h, and
further reduce the number of source files that need to #include
ext4_extents.h, but that's a cleanup for another day.

Reported-by: Sachin Kamat <sachin.kamat@linaro.org>
Reported-by: Wei Yongjun <weiyj.lk@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

Showing 8 changed files with 37 additions and 30 deletions Side-by-side Diff

... ... @@ -57,6 +57,16 @@
57 57 #define ext4_debug(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
58 58 #endif
59 59  
  60 +/*
  61 + * Turn on EXT_DEBUG to get lots of info about extents operations.
  62 + */
  63 +#define EXT_DEBUG__
  64 +#ifdef EXT_DEBUG
  65 +#define ext_debug(fmt, ...) printk(fmt, ##__VA_ARGS__)
  66 +#else
  67 +#define ext_debug(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
  68 +#endif
  69 +
60 70 #define EXT4_ERROR_INODE(inode, fmt, a...) \
61 71 ext4_error_inode((inode), __func__, __LINE__, 0, (fmt), ## a)
62 72  
... ... @@ -2399,6 +2409,9 @@
2399 2409 struct inode *, __le32 *, unsigned int);
2400 2410  
2401 2411 /* extents.c */
  2412 +struct ext4_ext_path;
  2413 +struct ext4_extent;
  2414 +
2402 2415 extern int ext4_ext_tree_init(handle_t *handle, struct inode *);
2403 2416 extern int ext4_ext_writepage_trans_blocks(struct inode *, int);
2404 2417 extern int ext4_ext_index_trans_blocks(struct inode *inode, int nrblocks,
2405 2418  
... ... @@ -2416,8 +2429,27 @@
2416 2429 ssize_t len);
2417 2430 extern int ext4_map_blocks(handle_t *handle, struct inode *inode,
2418 2431 struct ext4_map_blocks *map, int flags);
  2432 +extern int ext4_ext_calc_metadata_amount(struct inode *inode,
  2433 + ext4_lblk_t lblocks);
  2434 +extern int ext4_extent_tree_init(handle_t *, struct inode *);
  2435 +extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode,
  2436 + int num,
  2437 + struct ext4_ext_path *path);
  2438 +extern int ext4_can_extents_be_merged(struct inode *inode,
  2439 + struct ext4_extent *ex1,
  2440 + struct ext4_extent *ex2);
  2441 +extern int ext4_ext_insert_extent(handle_t *, struct inode *,
  2442 + struct ext4_ext_path *,
  2443 + struct ext4_extent *, int);
  2444 +extern struct ext4_ext_path *ext4_ext_find_extent(struct inode *, ext4_lblk_t,
  2445 + struct ext4_ext_path *);
  2446 +extern void ext4_ext_drop_refs(struct ext4_ext_path *);
  2447 +extern int ext4_ext_check_inode(struct inode *inode);
  2448 +extern int ext4_find_delalloc_cluster(struct inode *inode, ext4_lblk_t lblk);
2419 2449 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2420 2450 __u64 start, __u64 len);
  2451 +
  2452 +
2421 2453 /* move_extent.c */
2422 2454 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
2423 2455 __u64 start_orig, __u64 start_donor,
... ... @@ -2504,8 +2536,6 @@
2504 2536 extern void ext4_resize_end(struct super_block *sb);
2505 2537  
2506 2538 #endif /* __KERNEL__ */
2507   -
2508   -#include "ext4_extents.h"
2509 2539  
2510 2540 #endif /* _EXT4_H */
fs/ext4/ext4_extents.h
... ... @@ -43,16 +43,6 @@
43 43 #define CHECK_BINSEARCH__
44 44  
45 45 /*
46   - * Turn on EXT_DEBUG to get lots of info about extents operations.
47   - */
48   -#define EXT_DEBUG__
49   -#ifdef EXT_DEBUG
50   -#define ext_debug(fmt, ...) printk(fmt, ##__VA_ARGS__)
51   -#else
52   -#define ext_debug(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
53   -#endif
54   -
55   -/*
56 46 * If EXT_STATS is defined then stats numbers are collected.
57 47 * These number will be displayed at umount time.
58 48 */
... ... @@ -286,20 +276,5 @@
286 276 0xffff);
287 277 }
288 278  
289   -extern int ext4_ext_calc_metadata_amount(struct inode *inode,
290   - ext4_lblk_t lblocks);
291   -extern int ext4_extent_tree_init(handle_t *, struct inode *);
292   -extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode,
293   - int num,
294   - struct ext4_ext_path *path);
295   -extern int ext4_can_extents_be_merged(struct inode *inode,
296   - struct ext4_extent *ex1,
297   - struct ext4_extent *ex2);
298   -extern int ext4_ext_insert_extent(handle_t *, struct inode *, struct ext4_ext_path *, struct ext4_extent *, int);
299   -extern struct ext4_ext_path *ext4_ext_find_extent(struct inode *, ext4_lblk_t,
300   - struct ext4_ext_path *);
301   -extern void ext4_ext_drop_refs(struct ext4_ext_path *);
302   -extern int ext4_ext_check_inode(struct inode *inode);
303   -extern int ext4_find_delalloc_cluster(struct inode *inode, ext4_lblk_t lblk);
304 279 #endif /* _EXT4_EXTENTS */
... ... @@ -41,6 +41,7 @@
41 41 #include <asm/uaccess.h>
42 42 #include <linux/fiemap.h>
43 43 #include "ext4_jbd2.h"
  44 +#include "ext4_extents.h"
44 45  
45 46 #include <trace/events/ext4.h>
46 47  
... ... @@ -22,6 +22,7 @@
22 22  
23 23 #include "ext4_jbd2.h"
24 24 #include "truncate.h"
  25 +#include "ext4_extents.h" /* Needed for EXT_MAX_BLOCKS */
25 26  
26 27 #include <trace/events/ext4.h>
27 28  
... ... @@ -14,6 +14,7 @@
14 14  
15 15 #include <linux/slab.h>
16 16 #include "ext4_jbd2.h"
  17 +#include "ext4_extents.h"
17 18  
18 19 /*
19 20 * The contiguous blocks details which can be
fs/ext4/move_extent.c
... ... @@ -18,6 +18,7 @@
18 18 #include <linux/slab.h>
19 19 #include "ext4_jbd2.h"
20 20 #include "ext4.h"
  21 +#include "ext4_extents.h"
21 22  
22 23 /**
23 24 * get_ext_path - Find an extent path for designated logical block number.
... ... @@ -27,7 +27,6 @@
27 27 #include "ext4_jbd2.h"
28 28 #include "xattr.h"
29 29 #include "acl.h"
30   -#include "ext4_extents.h"
31 30  
32 31 static struct kmem_cache *io_page_cachep, *io_end_cachep;
33 32  
... ... @@ -45,12 +45,11 @@
45 45 #include <linux/freezer.h>
46 46  
47 47 #include "ext4.h"
48   -#include "ext4_extents.h"
  48 +#include "ext4_extents.h" /* Needed for trace points definition */
49 49 #include "ext4_jbd2.h"
50 50 #include "xattr.h"
51 51 #include "acl.h"
52 52 #include "mballoc.h"
53   -#include "ext4_extents.h"
54 53  
55 54 #define CREATE_TRACE_POINTS
56 55 #include <trace/events/ext4.h>