aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/ext4.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/ext4.h')
-rw-r--r--fs/ext4/ext4.h152
1 files changed, 119 insertions, 33 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 19a4de57128a..e03841d9f30b 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -57,10 +57,13 @@
57#endif 57#endif
58 58
59#define EXT4_ERROR_INODE(inode, fmt, a...) \ 59#define EXT4_ERROR_INODE(inode, fmt, a...) \
60 ext4_error_inode(__func__, (inode), (fmt), ## a) 60 ext4_error_inode((inode), __func__, __LINE__, 0, (fmt), ## a)
61
62#define EXT4_ERROR_INODE_BLOCK(inode, block, fmt, a...) \
63 ext4_error_inode((inode), __func__, __LINE__, (block), (fmt), ## a)
61 64
62#define EXT4_ERROR_FILE(file, fmt, a...) \ 65#define EXT4_ERROR_FILE(file, fmt, a...) \
63 ext4_error_file(__func__, (file), (fmt), ## a) 66 ext4_error_file(__func__, __LINE__, (file), (fmt), ## a)
64 67
65/* data type for block offset of block group */ 68/* data type for block offset of block group */
66typedef int ext4_grpblk_t; 69typedef int ext4_grpblk_t;
@@ -167,13 +170,15 @@ struct mpage_da_data {
167}; 170};
168#define EXT4_IO_UNWRITTEN 0x1 171#define EXT4_IO_UNWRITTEN 0x1
169typedef struct ext4_io_end { 172typedef struct ext4_io_end {
170 struct list_head list; /* per-file finished AIO list */ 173 struct list_head list; /* per-file finished IO list */
171 struct inode *inode; /* file being written to */ 174 struct inode *inode; /* file being written to */
172 unsigned int flag; /* unwritten or not */ 175 unsigned int flag; /* unwritten or not */
173 struct page *page; /* page struct for buffer write */ 176 struct page *page; /* page struct for buffer write */
174 loff_t offset; /* offset in the file */ 177 loff_t offset; /* offset in the file */
175 ssize_t size; /* size of the extent */ 178 ssize_t size; /* size of the extent */
176 struct work_struct work; /* data work queue */ 179 struct work_struct work; /* data work queue */
180 struct kiocb *iocb; /* iocb struct for AIO */
181 int result; /* error value for AIO */
177} ext4_io_end_t; 182} ext4_io_end_t;
178 183
179/* 184/*
@@ -460,7 +465,7 @@ struct ext4_new_group_data {
460}; 465};
461 466
462/* 467/*
463 * Flags used by ext4_get_blocks() 468 * Flags used by ext4_map_blocks()
464 */ 469 */
465 /* Allocate any needed blocks and/or convert an unitialized 470 /* Allocate any needed blocks and/or convert an unitialized
466 extent to be an initialized ext4 */ 471 extent to be an initialized ext4 */
@@ -873,7 +878,6 @@ struct ext4_inode_info {
873#define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */ 878#define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
874#define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */ 879#define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
875#define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */ 880#define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
876#define EXT4_MOUNT_NOBH 0x40000 /* No bufferheads */
877#define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */ 881#define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
878#define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */ 882#define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
879#define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */ 883#define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
@@ -982,7 +986,7 @@ struct ext4_super_block {
982 __le32 s_last_orphan; /* start of list of inodes to delete */ 986 __le32 s_last_orphan; /* start of list of inodes to delete */
983 __le32 s_hash_seed[4]; /* HTREE hash seed */ 987 __le32 s_hash_seed[4]; /* HTREE hash seed */
984 __u8 s_def_hash_version; /* Default hash version to use */ 988 __u8 s_def_hash_version; /* Default hash version to use */
985 __u8 s_reserved_char_pad; 989 __u8 s_jnl_backup_type;
986 __le16 s_desc_size; /* size of group descriptor */ 990 __le16 s_desc_size; /* size of group descriptor */
987/*100*/ __le32 s_default_mount_opts; 991/*100*/ __le32 s_default_mount_opts;
988 __le32 s_first_meta_bg; /* First metablock block group */ 992 __le32 s_first_meta_bg; /* First metablock block group */
@@ -1000,12 +1004,34 @@ struct ext4_super_block {
1000 __le64 s_mmp_block; /* Block for multi-mount protection */ 1004 __le64 s_mmp_block; /* Block for multi-mount protection */
1001 __le32 s_raid_stripe_width; /* blocks on all data disks (N*stride)*/ 1005 __le32 s_raid_stripe_width; /* blocks on all data disks (N*stride)*/
1002 __u8 s_log_groups_per_flex; /* FLEX_BG group size */ 1006 __u8 s_log_groups_per_flex; /* FLEX_BG group size */
1003 __u8 s_reserved_char_pad2; 1007 __u8 s_reserved_char_pad;
1004 __le16 s_reserved_pad; 1008 __le16 s_reserved_pad;
1005 __le64 s_kbytes_written; /* nr of lifetime kilobytes written */ 1009 __le64 s_kbytes_written; /* nr of lifetime kilobytes written */
1006 __u32 s_reserved[160]; /* Padding to the end of the block */ 1010 __le32 s_snapshot_inum; /* Inode number of active snapshot */
1011 __le32 s_snapshot_id; /* sequential ID of active snapshot */
1012 __le64 s_snapshot_r_blocks_count; /* reserved blocks for active
1013 snapshot's future use */
1014 __le32 s_snapshot_list; /* inode number of the head of the
1015 on-disk snapshot list */
1016#define EXT4_S_ERR_START offsetof(struct ext4_super_block, s_error_count)
1017 __le32 s_error_count; /* number of fs errors */
1018 __le32 s_first_error_time; /* first time an error happened */
1019 __le32 s_first_error_ino; /* inode involved in first error */
1020 __le64 s_first_error_block; /* block involved of first error */
1021 __u8 s_first_error_func[32]; /* function where the error happened */
1022 __le32 s_first_error_line; /* line number where error happened */
1023 __le32 s_last_error_time; /* most recent time of an error */
1024 __le32 s_last_error_ino; /* inode involved in last error */
1025 __le32 s_last_error_line; /* line number where error happened */
1026 __le64 s_last_error_block; /* block involved of last error */
1027 __u8 s_last_error_func[32]; /* function where the error happened */
1028#define EXT4_S_ERR_END offsetof(struct ext4_super_block, s_mount_opts)
1029 __u8 s_mount_opts[64];
1030 __le32 s_reserved[112]; /* Padding to the end of the block */
1007}; 1031};
1008 1032
1033#define EXT4_S_ERR_LEN (EXT4_S_ERR_END - EXT4_S_ERR_START)
1034
1009#ifdef __KERNEL__ 1035#ifdef __KERNEL__
1010 1036
1011/* 1037/*
@@ -1143,6 +1169,9 @@ struct ext4_sb_info {
1143 1169
1144 /* workqueue for dio unwritten */ 1170 /* workqueue for dio unwritten */
1145 struct workqueue_struct *dio_unwritten_wq; 1171 struct workqueue_struct *dio_unwritten_wq;
1172
1173 /* timer for periodic error stats printing */
1174 struct timer_list s_err_report;
1146}; 1175};
1147 1176
1148static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb) 1177static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb)
@@ -1313,6 +1342,10 @@ EXT4_INODE_BIT_FNS(state, state_flags)
1313#define EXT4_DEFM_JMODE_DATA 0x0020 1342#define EXT4_DEFM_JMODE_DATA 0x0020
1314#define EXT4_DEFM_JMODE_ORDERED 0x0040 1343#define EXT4_DEFM_JMODE_ORDERED 0x0040
1315#define EXT4_DEFM_JMODE_WBACK 0x0060 1344#define EXT4_DEFM_JMODE_WBACK 0x0060
1345#define EXT4_DEFM_NOBARRIER 0x0100
1346#define EXT4_DEFM_BLOCK_VALIDITY 0x0200
1347#define EXT4_DEFM_DISCARD 0x0400
1348#define EXT4_DEFM_NODELALLOC 0x0800
1316 1349
1317/* 1350/*
1318 * Default journal batch times 1351 * Default journal batch times
@@ -1379,6 +1412,43 @@ struct ext4_dir_entry_2 {
1379#define EXT4_MAX_REC_LEN ((1<<16)-1) 1412#define EXT4_MAX_REC_LEN ((1<<16)-1)
1380 1413
1381/* 1414/*
1415 * If we ever get support for fs block sizes > page_size, we'll need
1416 * to remove the #if statements in the next two functions...
1417 */
1418static inline unsigned int
1419ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize)
1420{
1421 unsigned len = le16_to_cpu(dlen);
1422
1423#if (PAGE_CACHE_SIZE >= 65536)
1424 if (len == EXT4_MAX_REC_LEN || len == 0)
1425 return blocksize;
1426 return (len & 65532) | ((len & 3) << 16);
1427#else
1428 return len;
1429#endif
1430}
1431
1432static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)
1433{
1434 if ((len > blocksize) || (blocksize > (1 << 18)) || (len & 3))
1435 BUG();
1436#if (PAGE_CACHE_SIZE >= 65536)
1437 if (len < 65536)
1438 return cpu_to_le16(len);
1439 if (len == blocksize) {
1440 if (blocksize == 65536)
1441 return cpu_to_le16(EXT4_MAX_REC_LEN);
1442 else
1443 return cpu_to_le16(0);
1444 }
1445 return cpu_to_le16((len & 65532) | ((len >> 16) & 3));
1446#else
1447 return cpu_to_le16(len);
1448#endif
1449}
1450
1451/*
1382 * Hash Tree Directory indexing 1452 * Hash Tree Directory indexing
1383 * (c) Daniel Phillips, 2001 1453 * (c) Daniel Phillips, 2001
1384 */ 1454 */
@@ -1510,9 +1580,11 @@ extern unsigned ext4_init_block_bitmap(struct super_block *sb,
1510 ext4_init_block_bitmap(sb, NULL, group, desc) 1580 ext4_init_block_bitmap(sb, NULL, group, desc)
1511 1581
1512/* dir.c */ 1582/* dir.c */
1513extern int ext4_check_dir_entry(const char *, struct inode *, 1583extern int __ext4_check_dir_entry(const char *, unsigned int, struct inode *,
1514 struct ext4_dir_entry_2 *, 1584 struct ext4_dir_entry_2 *,
1515 struct buffer_head *, unsigned int); 1585 struct buffer_head *, unsigned int);
1586#define ext4_check_dir_entry(dir, de, bh, offset) \
1587 __ext4_check_dir_entry(__func__, __LINE__, (dir), (de), (bh), (offset))
1516extern int ext4_htree_store_dirent(struct file *dir_file, __u32 hash, 1588extern int ext4_htree_store_dirent(struct file *dir_file, __u32 hash,
1517 __u32 minor_hash, 1589 __u32 minor_hash,
1518 struct ext4_dir_entry_2 *dirent); 1590 struct ext4_dir_entry_2 *dirent);
@@ -1601,8 +1673,6 @@ extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long);
1601extern int ext4_ext_migrate(struct inode *); 1673extern int ext4_ext_migrate(struct inode *);
1602 1674
1603/* namei.c */ 1675/* namei.c */
1604extern unsigned int ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize);
1605extern __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize);
1606extern int ext4_orphan_add(handle_t *, struct inode *); 1676extern int ext4_orphan_add(handle_t *, struct inode *);
1607extern int ext4_orphan_del(handle_t *, struct inode *); 1677extern int ext4_orphan_del(handle_t *, struct inode *);
1608extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash, 1678extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
@@ -1616,25 +1686,38 @@ extern int ext4_group_extend(struct super_block *sb,
1616 ext4_fsblk_t n_blocks_count); 1686 ext4_fsblk_t n_blocks_count);
1617 1687
1618/* super.c */ 1688/* super.c */
1619extern void __ext4_error(struct super_block *, const char *, const char *, ...) 1689extern void __ext4_error(struct super_block *, const char *, unsigned int,
1620 __attribute__ ((format (printf, 3, 4))); 1690 const char *, ...)
1621#define ext4_error(sb, message...) __ext4_error(sb, __func__, ## message) 1691 __attribute__ ((format (printf, 4, 5)));
1622extern void ext4_error_inode(const char *, struct inode *, const char *, ...) 1692#define ext4_error(sb, message...) __ext4_error(sb, __func__, \
1623 __attribute__ ((format (printf, 3, 4))); 1693 __LINE__, ## message)
1624extern void ext4_error_file(const char *, struct file *, const char *, ...) 1694extern void ext4_error_inode(struct inode *, const char *, unsigned int,
1625 __attribute__ ((format (printf, 3, 4))); 1695 ext4_fsblk_t, const char *, ...)
1626extern void __ext4_std_error(struct super_block *, const char *, int); 1696 __attribute__ ((format (printf, 5, 6)));
1627extern void ext4_abort(struct super_block *, const char *, const char *, ...) 1697extern void ext4_error_file(struct file *, const char *, unsigned int,
1628 __attribute__ ((format (printf, 3, 4))); 1698 const char *, ...)
1629extern void __ext4_warning(struct super_block *, const char *, 1699 __attribute__ ((format (printf, 4, 5)));
1700extern void __ext4_std_error(struct super_block *, const char *,
1701 unsigned int, int);
1702extern void __ext4_abort(struct super_block *, const char *, unsigned int,
1703 const char *, ...)
1704 __attribute__ ((format (printf, 4, 5)));
1705#define ext4_abort(sb, message...) __ext4_abort(sb, __func__, \
1706 __LINE__, ## message)
1707extern void __ext4_warning(struct super_block *, const char *, unsigned int,
1630 const char *, ...) 1708 const char *, ...)
1631 __attribute__ ((format (printf, 3, 4))); 1709 __attribute__ ((format (printf, 4, 5)));
1632#define ext4_warning(sb, message...) __ext4_warning(sb, __func__, ## message) 1710#define ext4_warning(sb, message...) __ext4_warning(sb, __func__, \
1711 __LINE__, ## message)
1633extern void ext4_msg(struct super_block *, const char *, const char *, ...) 1712extern void ext4_msg(struct super_block *, const char *, const char *, ...)
1634 __attribute__ ((format (printf, 3, 4))); 1713 __attribute__ ((format (printf, 3, 4)));
1635extern void ext4_grp_locked_error(struct super_block *, ext4_group_t, 1714extern void __ext4_grp_locked_error(const char *, unsigned int, \
1636 const char *, const char *, ...) 1715 struct super_block *, ext4_group_t, \
1637 __attribute__ ((format (printf, 4, 5))); 1716 unsigned long, ext4_fsblk_t, \
1717 const char *, ...)
1718 __attribute__ ((format (printf, 7, 8)));
1719#define ext4_grp_locked_error(sb, grp, message...) \
1720 __ext4_grp_locked_error(__func__, __LINE__, (sb), (grp), ## message)
1638extern void ext4_update_dynamic_rev(struct super_block *sb); 1721extern void ext4_update_dynamic_rev(struct super_block *sb);
1639extern int ext4_update_compat_feature(handle_t *handle, struct super_block *sb, 1722extern int ext4_update_compat_feature(handle_t *handle, struct super_block *sb,
1640 __u32 compat); 1723 __u32 compat);
@@ -1768,7 +1851,7 @@ static inline unsigned int ext4_flex_bg_size(struct ext4_sb_info *sbi)
1768#define ext4_std_error(sb, errno) \ 1851#define ext4_std_error(sb, errno) \
1769do { \ 1852do { \
1770 if ((errno)) \ 1853 if ((errno)) \
1771 __ext4_std_error((sb), __func__, (errno)); \ 1854 __ext4_std_error((sb), __func__, __LINE__, (errno)); \
1772} while (0) 1855} while (0)
1773 1856
1774#ifdef CONFIG_SMP 1857#ifdef CONFIG_SMP
@@ -1860,6 +1943,12 @@ static inline void ext4_unlock_group(struct super_block *sb,
1860 spin_unlock(ext4_group_lock_ptr(sb, group)); 1943 spin_unlock(ext4_group_lock_ptr(sb, group));
1861} 1944}
1862 1945
1946static inline void ext4_mark_super_dirty(struct super_block *sb)
1947{
1948 if (EXT4_SB(sb)->s_journal == NULL)
1949 sb->s_dirt =1;
1950}
1951
1863/* 1952/*
1864 * Inodes and files operations 1953 * Inodes and files operations
1865 */ 1954 */
@@ -1905,9 +1994,6 @@ extern int ext4_convert_unwritten_extents(struct inode *inode, loff_t offset,
1905 ssize_t len); 1994 ssize_t len);
1906extern int ext4_map_blocks(handle_t *handle, struct inode *inode, 1995extern int ext4_map_blocks(handle_t *handle, struct inode *inode,
1907 struct ext4_map_blocks *map, int flags); 1996 struct ext4_map_blocks *map, int flags);
1908extern int ext4_get_blocks(handle_t *handle, struct inode *inode,
1909 sector_t block, unsigned int max_blocks,
1910 struct buffer_head *bh, int flags);
1911extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, 1997extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
1912 __u64 start, __u64 len); 1998 __u64 start, __u64 len);
1913/* move_extent.c */ 1999/* move_extent.c */