diff options
| author | Ingo Molnar <mingo@elte.hu> | 2010-08-12 15:38:56 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2010-08-12 15:39:04 -0400 |
| commit | f46a6804135795f77d096ab0128f27531c7d051c (patch) | |
| tree | 7cd33f69e3661327739ae4c96e5a8389e7fc912e /fs/ext4 | |
| parent | b3e84ffa21f916e3354a12a7f19169c9febe96d0 (diff) | |
| parent | ad41a1e0cab07c5125456e8d38e5b1ab148d04aa (diff) | |
Merge branch 'linus' into perf/urgent
Merge reason: Fix upstream breakage introduced by:
de5d9bf: Move list types from <linux/list.h> to <linux/types.h>.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'fs/ext4')
| -rw-r--r-- | fs/ext4/acl.c | 1 | ||||
| -rw-r--r-- | fs/ext4/balloc.c | 6 | ||||
| -rw-r--r-- | fs/ext4/block_validity.c | 8 | ||||
| -rw-r--r-- | fs/ext4/dir.c | 23 | ||||
| -rw-r--r-- | fs/ext4/ext4.h | 155 | ||||
| -rw-r--r-- | fs/ext4/ext4_jbd2.c | 71 | ||||
| -rw-r--r-- | fs/ext4/ext4_jbd2.h | 56 | ||||
| -rw-r--r-- | fs/ext4/extents.c | 20 | ||||
| -rw-r--r-- | fs/ext4/file.c | 5 | ||||
| -rw-r--r-- | fs/ext4/ialloc.c | 6 | ||||
| -rw-r--r-- | fs/ext4/inode.c | 258 | ||||
| -rw-r--r-- | fs/ext4/mballoc.c | 155 | ||||
| -rw-r--r-- | fs/ext4/migrate.c | 2 | ||||
| -rw-r--r-- | fs/ext4/move_extent.c | 10 | ||||
| -rw-r--r-- | fs/ext4/namei.c | 40 | ||||
| -rw-r--r-- | fs/ext4/resize.c | 8 | ||||
| -rw-r--r-- | fs/ext4/super.c | 346 | ||||
| -rw-r--r-- | fs/ext4/xattr.c | 15 |
18 files changed, 712 insertions, 473 deletions
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c index feaf498feaa6..5e2ed4504ead 100644 --- a/fs/ext4/acl.c +++ b/fs/ext4/acl.c | |||
| @@ -204,6 +204,7 @@ ext4_set_acl(handle_t *handle, struct inode *inode, int type, | |||
| 204 | return error; | 204 | return error; |
| 205 | else { | 205 | else { |
| 206 | inode->i_mode = mode; | 206 | inode->i_mode = mode; |
| 207 | inode->i_ctime = ext4_current_time(inode); | ||
| 207 | ext4_mark_inode_dirty(handle, inode); | 208 | ext4_mark_inode_dirty(handle, inode); |
| 208 | if (error == 0) | 209 | if (error == 0) |
| 209 | acl = NULL; | 210 | acl = NULL; |
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index 95b7594c76f9..bd30799a43ed 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c | |||
| @@ -377,14 +377,11 @@ void ext4_add_groupblocks(handle_t *handle, struct super_block *sb, | |||
| 377 | ext4_grpblk_t bit; | 377 | ext4_grpblk_t bit; |
| 378 | unsigned int i; | 378 | unsigned int i; |
| 379 | struct ext4_group_desc *desc; | 379 | struct ext4_group_desc *desc; |
| 380 | struct ext4_super_block *es; | 380 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
| 381 | struct ext4_sb_info *sbi; | ||
| 382 | int err = 0, ret, blk_free_count; | 381 | int err = 0, ret, blk_free_count; |
| 383 | ext4_grpblk_t blocks_freed; | 382 | ext4_grpblk_t blocks_freed; |
| 384 | struct ext4_group_info *grp; | 383 | struct ext4_group_info *grp; |
| 385 | 384 | ||
| 386 | sbi = EXT4_SB(sb); | ||
| 387 | es = sbi->s_es; | ||
| 388 | ext4_debug("Adding block(s) %llu-%llu\n", block, block + count - 1); | 385 | ext4_debug("Adding block(s) %llu-%llu\n", block, block + count - 1); |
| 389 | 386 | ||
| 390 | ext4_get_group_no_and_offset(sb, block, &block_group, &bit); | 387 | ext4_get_group_no_and_offset(sb, block, &block_group, &bit); |
| @@ -477,7 +474,6 @@ void ext4_add_groupblocks(handle_t *handle, struct super_block *sb, | |||
| 477 | ret = ext4_handle_dirty_metadata(handle, NULL, gd_bh); | 474 | ret = ext4_handle_dirty_metadata(handle, NULL, gd_bh); |
| 478 | if (!err) | 475 | if (!err) |
| 479 | err = ret; | 476 | err = ret; |
| 480 | sb->s_dirt = 1; | ||
| 481 | 477 | ||
| 482 | error_return: | 478 | error_return: |
| 483 | brelse(bitmap_bh); | 479 | brelse(bitmap_bh); |
diff --git a/fs/ext4/block_validity.c b/fs/ext4/block_validity.c index 5b6973fbf1bd..3db5084db9bd 100644 --- a/fs/ext4/block_validity.c +++ b/fs/ext4/block_validity.c | |||
| @@ -229,16 +229,20 @@ int ext4_data_block_valid(struct ext4_sb_info *sbi, ext4_fsblk_t start_blk, | |||
| 229 | 229 | ||
| 230 | if ((start_blk <= le32_to_cpu(sbi->s_es->s_first_data_block)) || | 230 | if ((start_blk <= le32_to_cpu(sbi->s_es->s_first_data_block)) || |
| 231 | (start_blk + count < start_blk) || | 231 | (start_blk + count < start_blk) || |
| 232 | (start_blk + count > ext4_blocks_count(sbi->s_es))) | 232 | (start_blk + count > ext4_blocks_count(sbi->s_es))) { |
| 233 | sbi->s_es->s_last_error_block = cpu_to_le64(start_blk); | ||
| 233 | return 0; | 234 | return 0; |
| 235 | } | ||
| 234 | while (n) { | 236 | while (n) { |
| 235 | entry = rb_entry(n, struct ext4_system_zone, node); | 237 | entry = rb_entry(n, struct ext4_system_zone, node); |
| 236 | if (start_blk + count - 1 < entry->start_blk) | 238 | if (start_blk + count - 1 < entry->start_blk) |
| 237 | n = n->rb_left; | 239 | n = n->rb_left; |
| 238 | else if (start_blk >= (entry->start_blk + entry->count)) | 240 | else if (start_blk >= (entry->start_blk + entry->count)) |
| 239 | n = n->rb_right; | 241 | n = n->rb_right; |
| 240 | else | 242 | else { |
| 243 | sbi->s_es->s_last_error_block = cpu_to_le64(start_blk); | ||
| 241 | return 0; | 244 | return 0; |
| 245 | } | ||
| 242 | } | 246 | } |
| 243 | return 1; | 247 | return 1; |
| 244 | } | 248 | } |
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c index ea5e6cb7e2a5..374510f72baa 100644 --- a/fs/ext4/dir.c +++ b/fs/ext4/dir.c | |||
| @@ -61,10 +61,11 @@ static unsigned char get_dtype(struct super_block *sb, int filetype) | |||
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | 63 | ||
| 64 | int ext4_check_dir_entry(const char *function, struct inode *dir, | 64 | int __ext4_check_dir_entry(const char *function, unsigned int line, |
| 65 | struct ext4_dir_entry_2 *de, | 65 | struct inode *dir, |
| 66 | struct buffer_head *bh, | 66 | struct ext4_dir_entry_2 *de, |
| 67 | unsigned int offset) | 67 | struct buffer_head *bh, |
| 68 | unsigned int offset) | ||
| 68 | { | 69 | { |
| 69 | const char *error_msg = NULL; | 70 | const char *error_msg = NULL; |
| 70 | const int rlen = ext4_rec_len_from_disk(de->rec_len, | 71 | const int rlen = ext4_rec_len_from_disk(de->rec_len, |
| @@ -83,11 +84,10 @@ int ext4_check_dir_entry(const char *function, struct inode *dir, | |||
| 83 | error_msg = "inode out of bounds"; | 84 | error_msg = "inode out of bounds"; |
| 84 | 85 | ||
| 85 | if (error_msg != NULL) | 86 | if (error_msg != NULL) |
| 86 | ext4_error_inode(function, dir, | 87 | ext4_error_inode(dir, function, line, bh->b_blocknr, |
| 87 | "bad entry in directory: %s - block=%llu" | 88 | "bad entry in directory: %s - " |
| 88 | "offset=%u(%u), inode=%u, rec_len=%d, name_len=%d", | 89 | "offset=%u(%u), inode=%u, rec_len=%d, name_len=%d", |
| 89 | error_msg, (unsigned long long) bh->b_blocknr, | 90 | error_msg, (unsigned) (offset%bh->b_size), offset, |
| 90 | (unsigned) (offset%bh->b_size), offset, | ||
| 91 | le32_to_cpu(de->inode), | 91 | le32_to_cpu(de->inode), |
| 92 | rlen, de->name_len); | 92 | rlen, de->name_len); |
| 93 | return error_msg == NULL ? 1 : 0; | 93 | return error_msg == NULL ? 1 : 0; |
| @@ -121,7 +121,8 @@ static int ext4_readdir(struct file *filp, | |||
| 121 | * We don't set the inode dirty flag since it's not | 121 | * We don't set the inode dirty flag since it's not |
| 122 | * critical that it get flushed back to the disk. | 122 | * critical that it get flushed back to the disk. |
| 123 | */ | 123 | */ |
| 124 | ext4_clear_inode_flag(filp->f_path.dentry->d_inode, EXT4_INODE_INDEX); | 124 | ext4_clear_inode_flag(filp->f_path.dentry->d_inode, |
| 125 | EXT4_INODE_INDEX); | ||
| 125 | } | 126 | } |
| 126 | stored = 0; | 127 | stored = 0; |
| 127 | offset = filp->f_pos & (sb->s_blocksize - 1); | 128 | offset = filp->f_pos & (sb->s_blocksize - 1); |
| @@ -193,7 +194,7 @@ revalidate: | |||
| 193 | while (!error && filp->f_pos < inode->i_size | 194 | while (!error && filp->f_pos < inode->i_size |
| 194 | && offset < sb->s_blocksize) { | 195 | && offset < sb->s_blocksize) { |
| 195 | de = (struct ext4_dir_entry_2 *) (bh->b_data + offset); | 196 | de = (struct ext4_dir_entry_2 *) (bh->b_data + offset); |
| 196 | if (!ext4_check_dir_entry("ext4_readdir", inode, de, | 197 | if (!ext4_check_dir_entry(inode, de, |
| 197 | bh, offset)) { | 198 | bh, offset)) { |
| 198 | /* | 199 | /* |
| 199 | * On error, skip the f_pos to the next block | 200 | * On error, skip the f_pos to the next block |
| @@ -343,7 +344,7 @@ int ext4_htree_store_dirent(struct file *dir_file, __u32 hash, | |||
| 343 | struct dir_private_info *info; | 344 | struct dir_private_info *info; |
| 344 | int len; | 345 | int len; |
| 345 | 346 | ||
| 346 | info = (struct dir_private_info *) dir_file->private_data; | 347 | info = dir_file->private_data; |
| 347 | p = &info->root.rb_node; | 348 | p = &info->root.rb_node; |
| 348 | 349 | ||
| 349 | /* Create and allocate the fname structure */ | 350 | /* Create and allocate the fname structure */ |
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 19a4de57128a..889ec9d5e6ad 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 */ |
| 66 | typedef int ext4_grpblk_t; | 69 | typedef 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 |
| 169 | typedef struct ext4_io_end { | 172 | typedef 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 | ||
| 1148 | static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb) | 1177 | static 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 | */ | ||
| 1418 | static inline unsigned int | ||
| 1419 | ext4_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 | |||
| 1432 | static 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 */ |
| 1513 | extern int ext4_check_dir_entry(const char *, struct inode *, | 1583 | extern 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)) | ||
| 1516 | extern int ext4_htree_store_dirent(struct file *dir_file, __u32 hash, | 1588 | extern 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); |
| @@ -1571,7 +1643,8 @@ extern int ext4_write_inode(struct inode *, struct writeback_control *); | |||
| 1571 | extern int ext4_setattr(struct dentry *, struct iattr *); | 1643 | extern int ext4_setattr(struct dentry *, struct iattr *); |
| 1572 | extern int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry, | 1644 | extern int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry, |
| 1573 | struct kstat *stat); | 1645 | struct kstat *stat); |
| 1574 | extern void ext4_delete_inode(struct inode *); | 1646 | extern void ext4_evict_inode(struct inode *); |
| 1647 | extern void ext4_clear_inode(struct inode *); | ||
| 1575 | extern int ext4_sync_inode(handle_t *, struct inode *); | 1648 | extern int ext4_sync_inode(handle_t *, struct inode *); |
| 1576 | extern void ext4_dirty_inode(struct inode *); | 1649 | extern void ext4_dirty_inode(struct inode *); |
| 1577 | extern int ext4_change_inode_journal_flag(struct inode *, int); | 1650 | extern int ext4_change_inode_journal_flag(struct inode *, int); |
| @@ -1601,8 +1674,6 @@ extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long); | |||
| 1601 | extern int ext4_ext_migrate(struct inode *); | 1674 | extern int ext4_ext_migrate(struct inode *); |
| 1602 | 1675 | ||
| 1603 | /* namei.c */ | 1676 | /* namei.c */ |
| 1604 | extern unsigned int ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize); | ||
| 1605 | extern __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize); | ||
| 1606 | extern int ext4_orphan_add(handle_t *, struct inode *); | 1677 | extern int ext4_orphan_add(handle_t *, struct inode *); |
| 1607 | extern int ext4_orphan_del(handle_t *, struct inode *); | 1678 | extern int ext4_orphan_del(handle_t *, struct inode *); |
| 1608 | extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash, | 1679 | extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash, |
| @@ -1616,25 +1687,38 @@ extern int ext4_group_extend(struct super_block *sb, | |||
| 1616 | ext4_fsblk_t n_blocks_count); | 1687 | ext4_fsblk_t n_blocks_count); |
| 1617 | 1688 | ||
| 1618 | /* super.c */ | 1689 | /* super.c */ |
| 1619 | extern void __ext4_error(struct super_block *, const char *, const char *, ...) | 1690 | extern void __ext4_error(struct super_block *, const char *, unsigned int, |
| 1620 | __attribute__ ((format (printf, 3, 4))); | 1691 | const char *, ...) |
| 1621 | #define ext4_error(sb, message...) __ext4_error(sb, __func__, ## message) | 1692 | __attribute__ ((format (printf, 4, 5))); |
| 1622 | extern void ext4_error_inode(const char *, struct inode *, const char *, ...) | 1693 | #define ext4_error(sb, message...) __ext4_error(sb, __func__, \ |
| 1623 | __attribute__ ((format (printf, 3, 4))); | 1694 | __LINE__, ## message) |
| 1624 | extern void ext4_error_file(const char *, struct file *, const char *, ...) | 1695 | extern void ext4_error_inode(struct inode *, const char *, unsigned int, |
| 1625 | __attribute__ ((format (printf, 3, 4))); | 1696 | ext4_fsblk_t, const char *, ...) |
| 1626 | extern void __ext4_std_error(struct super_block *, const char *, int); | 1697 | __attribute__ ((format (printf, 5, 6))); |
| 1627 | extern void ext4_abort(struct super_block *, const char *, const char *, ...) | 1698 | extern void ext4_error_file(struct file *, const char *, unsigned int, |
| 1628 | __attribute__ ((format (printf, 3, 4))); | 1699 | const char *, ...) |
| 1629 | extern void __ext4_warning(struct super_block *, const char *, | 1700 | __attribute__ ((format (printf, 4, 5))); |
| 1701 | extern void __ext4_std_error(struct super_block *, const char *, | ||
| 1702 | unsigned int, int); | ||
| 1703 | extern void __ext4_abort(struct super_block *, const char *, unsigned int, | ||
| 1704 | const char *, ...) | ||
| 1705 | __attribute__ ((format (printf, 4, 5))); | ||
| 1706 | #define ext4_abort(sb, message...) __ext4_abort(sb, __func__, \ | ||
| 1707 | __LINE__, ## message) | ||
| 1708 | extern void __ext4_warning(struct super_block *, const char *, unsigned int, | ||
| 1630 | const char *, ...) | 1709 | const char *, ...) |
| 1631 | __attribute__ ((format (printf, 3, 4))); | 1710 | __attribute__ ((format (printf, 4, 5))); |
| 1632 | #define ext4_warning(sb, message...) __ext4_warning(sb, __func__, ## message) | 1711 | #define ext4_warning(sb, message...) __ext4_warning(sb, __func__, \ |
| 1712 | __LINE__, ## message) | ||
| 1633 | extern void ext4_msg(struct super_block *, const char *, const char *, ...) | 1713 | extern void ext4_msg(struct super_block *, const char *, const char *, ...) |
| 1634 | __attribute__ ((format (printf, 3, 4))); | 1714 | __attribute__ ((format (printf, 3, 4))); |
| 1635 | extern void ext4_grp_locked_error(struct super_block *, ext4_group_t, | 1715 | extern void __ext4_grp_locked_error(const char *, unsigned int, \ |
| 1636 | const char *, const char *, ...) | 1716 | struct super_block *, ext4_group_t, \ |
| 1637 | __attribute__ ((format (printf, 4, 5))); | 1717 | unsigned long, ext4_fsblk_t, \ |
| 1718 | const char *, ...) | ||
| 1719 | __attribute__ ((format (printf, 7, 8))); | ||
| 1720 | #define ext4_grp_locked_error(sb, grp, message...) \ | ||
| 1721 | __ext4_grp_locked_error(__func__, __LINE__, (sb), (grp), ## message) | ||
| 1638 | extern void ext4_update_dynamic_rev(struct super_block *sb); | 1722 | extern void ext4_update_dynamic_rev(struct super_block *sb); |
| 1639 | extern int ext4_update_compat_feature(handle_t *handle, struct super_block *sb, | 1723 | extern int ext4_update_compat_feature(handle_t *handle, struct super_block *sb, |
| 1640 | __u32 compat); | 1724 | __u32 compat); |
| @@ -1768,7 +1852,7 @@ static inline unsigned int ext4_flex_bg_size(struct ext4_sb_info *sbi) | |||
| 1768 | #define ext4_std_error(sb, errno) \ | 1852 | #define ext4_std_error(sb, errno) \ |
| 1769 | do { \ | 1853 | do { \ |
| 1770 | if ((errno)) \ | 1854 | if ((errno)) \ |
| 1771 | __ext4_std_error((sb), __func__, (errno)); \ | 1855 | __ext4_std_error((sb), __func__, __LINE__, (errno)); \ |
| 1772 | } while (0) | 1856 | } while (0) |
| 1773 | 1857 | ||
| 1774 | #ifdef CONFIG_SMP | 1858 | #ifdef CONFIG_SMP |
| @@ -1860,6 +1944,12 @@ static inline void ext4_unlock_group(struct super_block *sb, | |||
| 1860 | spin_unlock(ext4_group_lock_ptr(sb, group)); | 1944 | spin_unlock(ext4_group_lock_ptr(sb, group)); |
| 1861 | } | 1945 | } |
| 1862 | 1946 | ||
| 1947 | static inline void ext4_mark_super_dirty(struct super_block *sb) | ||
| 1948 | { | ||
| 1949 | if (EXT4_SB(sb)->s_journal == NULL) | ||
| 1950 | sb->s_dirt =1; | ||
| 1951 | } | ||
| 1952 | |||
| 1863 | /* | 1953 | /* |
| 1864 | * Inodes and files operations | 1954 | * Inodes and files operations |
| 1865 | */ | 1955 | */ |
| @@ -1905,9 +1995,6 @@ extern int ext4_convert_unwritten_extents(struct inode *inode, loff_t offset, | |||
| 1905 | ssize_t len); | 1995 | ssize_t len); |
| 1906 | extern int ext4_map_blocks(handle_t *handle, struct inode *inode, | 1996 | extern int ext4_map_blocks(handle_t *handle, struct inode *inode, |
| 1907 | struct ext4_map_blocks *map, int flags); | 1997 | struct ext4_map_blocks *map, int flags); |
| 1908 | extern 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); | ||
| 1911 | extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, | 1998 | extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, |
| 1912 | __u64 start, __u64 len); | 1999 | __u64 start, __u64 len); |
| 1913 | /* move_extent.c */ | 2000 | /* move_extent.c */ |
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c index 53d2764d71ca..6e272ef6ba96 100644 --- a/fs/ext4/ext4_jbd2.c +++ b/fs/ext4/ext4_jbd2.c | |||
| @@ -6,29 +6,29 @@ | |||
| 6 | 6 | ||
| 7 | #include <trace/events/ext4.h> | 7 | #include <trace/events/ext4.h> |
| 8 | 8 | ||
| 9 | int __ext4_journal_get_undo_access(const char *where, handle_t *handle, | 9 | int __ext4_journal_get_undo_access(const char *where, unsigned int line, |
| 10 | struct buffer_head *bh) | 10 | handle_t *handle, struct buffer_head *bh) |
| 11 | { | 11 | { |
| 12 | int err = 0; | 12 | int err = 0; |
| 13 | 13 | ||
| 14 | if (ext4_handle_valid(handle)) { | 14 | if (ext4_handle_valid(handle)) { |
| 15 | err = jbd2_journal_get_undo_access(handle, bh); | 15 | err = jbd2_journal_get_undo_access(handle, bh); |
| 16 | if (err) | 16 | if (err) |
| 17 | ext4_journal_abort_handle(where, __func__, bh, | 17 | ext4_journal_abort_handle(where, line, __func__, bh, |
| 18 | handle, err); | 18 | handle, err); |
| 19 | } | 19 | } |
| 20 | return err; | 20 | return err; |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | int __ext4_journal_get_write_access(const char *where, handle_t *handle, | 23 | int __ext4_journal_get_write_access(const char *where, unsigned int line, |
| 24 | struct buffer_head *bh) | 24 | handle_t *handle, struct buffer_head *bh) |
| 25 | { | 25 | { |
| 26 | int err = 0; | 26 | int err = 0; |
| 27 | 27 | ||
| 28 | if (ext4_handle_valid(handle)) { | 28 | if (ext4_handle_valid(handle)) { |
| 29 | err = jbd2_journal_get_write_access(handle, bh); | 29 | err = jbd2_journal_get_write_access(handle, bh); |
| 30 | if (err) | 30 | if (err) |
| 31 | ext4_journal_abort_handle(where, __func__, bh, | 31 | ext4_journal_abort_handle(where, line, __func__, bh, |
| 32 | handle, err); | 32 | handle, err); |
| 33 | } | 33 | } |
| 34 | return err; | 34 | return err; |
| @@ -46,9 +46,9 @@ int __ext4_journal_get_write_access(const char *where, handle_t *handle, | |||
| 46 | * If the handle isn't valid we're not journaling, but we still need to | 46 | * If the handle isn't valid we're not journaling, but we still need to |
| 47 | * call into ext4_journal_revoke() to put the buffer head. | 47 | * call into ext4_journal_revoke() to put the buffer head. |
| 48 | */ | 48 | */ |
| 49 | int __ext4_forget(const char *where, handle_t *handle, int is_metadata, | 49 | int __ext4_forget(const char *where, unsigned int line, handle_t *handle, |
| 50 | struct inode *inode, struct buffer_head *bh, | 50 | int is_metadata, struct inode *inode, |
| 51 | ext4_fsblk_t blocknr) | 51 | struct buffer_head *bh, ext4_fsblk_t blocknr) |
| 52 | { | 52 | { |
| 53 | int err; | 53 | int err; |
| 54 | 54 | ||
| @@ -79,8 +79,8 @@ int __ext4_forget(const char *where, handle_t *handle, int is_metadata, | |||
| 79 | BUFFER_TRACE(bh, "call jbd2_journal_forget"); | 79 | BUFFER_TRACE(bh, "call jbd2_journal_forget"); |
| 80 | err = jbd2_journal_forget(handle, bh); | 80 | err = jbd2_journal_forget(handle, bh); |
| 81 | if (err) | 81 | if (err) |
| 82 | ext4_journal_abort_handle(where, __func__, bh, | 82 | ext4_journal_abort_handle(where, line, __func__, |
| 83 | handle, err); | 83 | bh, handle, err); |
| 84 | return err; | 84 | return err; |
| 85 | } | 85 | } |
| 86 | return 0; | 86 | return 0; |
| @@ -92,15 +92,16 @@ int __ext4_forget(const char *where, handle_t *handle, int is_metadata, | |||
| 92 | BUFFER_TRACE(bh, "call jbd2_journal_revoke"); | 92 | BUFFER_TRACE(bh, "call jbd2_journal_revoke"); |
| 93 | err = jbd2_journal_revoke(handle, blocknr, bh); | 93 | err = jbd2_journal_revoke(handle, blocknr, bh); |
| 94 | if (err) { | 94 | if (err) { |
| 95 | ext4_journal_abort_handle(where, __func__, bh, handle, err); | 95 | ext4_journal_abort_handle(where, line, __func__, |
| 96 | ext4_abort(inode->i_sb, __func__, | 96 | bh, handle, err); |
| 97 | __ext4_abort(inode->i_sb, where, line, | ||
| 97 | "error %d when attempting revoke", err); | 98 | "error %d when attempting revoke", err); |
| 98 | } | 99 | } |
| 99 | BUFFER_TRACE(bh, "exit"); | 100 | BUFFER_TRACE(bh, "exit"); |
| 100 | return err; | 101 | return err; |
| 101 | } | 102 | } |
| 102 | 103 | ||
| 103 | int __ext4_journal_get_create_access(const char *where, | 104 | int __ext4_journal_get_create_access(const char *where, unsigned int line, |
| 104 | handle_t *handle, struct buffer_head *bh) | 105 | handle_t *handle, struct buffer_head *bh) |
| 105 | { | 106 | { |
| 106 | int err = 0; | 107 | int err = 0; |
| @@ -108,22 +109,23 @@ int __ext4_journal_get_create_access(const char *where, | |||
| 108 | if (ext4_handle_valid(handle)) { | 109 | if (ext4_handle_valid(handle)) { |
| 109 | err = jbd2_journal_get_create_access(handle, bh); | 110 | err = jbd2_journal_get_create_access(handle, bh); |
| 110 | if (err) | 111 | if (err) |
| 111 | ext4_journal_abort_handle(where, __func__, bh, | 112 | ext4_journal_abort_handle(where, line, __func__, |
| 112 | handle, err); | 113 | bh, handle, err); |
| 113 | } | 114 | } |
| 114 | return err; | 115 | return err; |
| 115 | } | 116 | } |
| 116 | 117 | ||
| 117 | int __ext4_handle_dirty_metadata(const char *where, handle_t *handle, | 118 | int __ext4_handle_dirty_metadata(const char *where, unsigned int line, |
| 118 | struct inode *inode, struct buffer_head *bh) | 119 | handle_t *handle, struct inode *inode, |
| 120 | struct buffer_head *bh) | ||
| 119 | { | 121 | { |
| 120 | int err = 0; | 122 | int err = 0; |
| 121 | 123 | ||
| 122 | if (ext4_handle_valid(handle)) { | 124 | if (ext4_handle_valid(handle)) { |
| 123 | err = jbd2_journal_dirty_metadata(handle, bh); | 125 | err = jbd2_journal_dirty_metadata(handle, bh); |
| 124 | if (err) | 126 | if (err) |
| 125 | ext4_journal_abort_handle(where, __func__, bh, | 127 | ext4_journal_abort_handle(where, line, __func__, |
| 126 | handle, err); | 128 | bh, handle, err); |
| 127 | } else { | 129 | } else { |
| 128 | if (inode) | 130 | if (inode) |
| 129 | mark_buffer_dirty_inode(bh, inode); | 131 | mark_buffer_dirty_inode(bh, inode); |
| @@ -132,14 +134,33 @@ int __ext4_handle_dirty_metadata(const char *where, handle_t *handle, | |||
| 132 | if (inode && inode_needs_sync(inode)) { | 134 | if (inode && inode_needs_sync(inode)) { |
| 133 | sync_dirty_buffer(bh); | 135 | sync_dirty_buffer(bh); |
| 134 | if (buffer_req(bh) && !buffer_uptodate(bh)) { | 136 | if (buffer_req(bh) && !buffer_uptodate(bh)) { |
| 135 | ext4_error(inode->i_sb, | 137 | struct ext4_super_block *es; |
| 136 | "IO error syncing inode, " | 138 | |
| 137 | "inode=%lu, block=%llu", | 139 | es = EXT4_SB(inode->i_sb)->s_es; |
| 138 | inode->i_ino, | 140 | es->s_last_error_block = |
| 139 | (unsigned long long) bh->b_blocknr); | 141 | cpu_to_le64(bh->b_blocknr); |
| 142 | ext4_error_inode(inode, where, line, | ||
| 143 | bh->b_blocknr, | ||
| 144 | "IO error syncing itable block"); | ||
| 140 | err = -EIO; | 145 | err = -EIO; |
| 141 | } | 146 | } |
| 142 | } | 147 | } |
| 143 | } | 148 | } |
| 144 | return err; | 149 | return err; |
| 145 | } | 150 | } |
| 151 | |||
| 152 | int __ext4_handle_dirty_super(const char *where, unsigned int line, | ||
| 153 | handle_t *handle, struct super_block *sb) | ||
| 154 | { | ||
| 155 | struct buffer_head *bh = EXT4_SB(sb)->s_sbh; | ||
| 156 | int err = 0; | ||
| 157 | |||
| 158 | if (ext4_handle_valid(handle)) { | ||
| 159 | err = jbd2_journal_dirty_metadata(handle, bh); | ||
| 160 | if (err) | ||
| 161 | ext4_journal_abort_handle(where, line, __func__, | ||
| 162 | bh, handle, err); | ||
| 163 | } else | ||
| 164 | sb->s_dirt = 1; | ||
| 165 | return err; | ||
| 166 | } | ||
diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h index dade0c024797..b0bd792c58c5 100644 --- a/fs/ext4/ext4_jbd2.h +++ b/fs/ext4/ext4_jbd2.h | |||
| @@ -122,39 +122,47 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode); | |||
| 122 | /* | 122 | /* |
| 123 | * Wrapper functions with which ext4 calls into JBD. | 123 | * Wrapper functions with which ext4 calls into JBD. |
| 124 | */ | 124 | */ |
| 125 | void ext4_journal_abort_handle(const char *caller, const char *err_fn, | 125 | void ext4_journal_abort_handle(const char *caller, unsigned int line, |
| 126 | const char *err_fn, | ||
| 126 | struct buffer_head *bh, handle_t *handle, int err); | 127 | struct buffer_head *bh, handle_t *handle, int err); |
| 127 | 128 | ||
| 128 | int __ext4_journal_get_undo_access(const char *where, handle_t *handle, | 129 | int __ext4_journal_get_undo_access(const char *where, unsigned int line, |
| 129 | struct buffer_head *bh); | 130 | handle_t *handle, struct buffer_head *bh); |
| 130 | 131 | ||
| 131 | int __ext4_journal_get_write_access(const char *where, handle_t *handle, | 132 | int __ext4_journal_get_write_access(const char *where, unsigned int line, |
| 132 | struct buffer_head *bh); | 133 | handle_t *handle, struct buffer_head *bh); |
| 133 | 134 | ||
| 134 | int __ext4_forget(const char *where, handle_t *handle, int is_metadata, | 135 | int __ext4_forget(const char *where, unsigned int line, handle_t *handle, |
| 135 | struct inode *inode, struct buffer_head *bh, | 136 | int is_metadata, struct inode *inode, |
| 136 | ext4_fsblk_t blocknr); | 137 | struct buffer_head *bh, ext4_fsblk_t blocknr); |
| 137 | 138 | ||
| 138 | int __ext4_journal_get_create_access(const char *where, | 139 | int __ext4_journal_get_create_access(const char *where, unsigned int line, |
| 139 | handle_t *handle, struct buffer_head *bh); | 140 | handle_t *handle, struct buffer_head *bh); |
| 140 | 141 | ||
| 141 | int __ext4_handle_dirty_metadata(const char *where, handle_t *handle, | 142 | int __ext4_handle_dirty_metadata(const char *where, unsigned int line, |
| 142 | struct inode *inode, struct buffer_head *bh); | 143 | handle_t *handle, struct inode *inode, |
| 144 | struct buffer_head *bh); | ||
| 145 | |||
| 146 | int __ext4_handle_dirty_super(const char *where, unsigned int line, | ||
| 147 | handle_t *handle, struct super_block *sb); | ||
| 143 | 148 | ||
| 144 | #define ext4_journal_get_undo_access(handle, bh) \ | 149 | #define ext4_journal_get_undo_access(handle, bh) \ |
| 145 | __ext4_journal_get_undo_access(__func__, (handle), (bh)) | 150 | __ext4_journal_get_undo_access(__func__, __LINE__, (handle), (bh)) |
| 146 | #define ext4_journal_get_write_access(handle, bh) \ | 151 | #define ext4_journal_get_write_access(handle, bh) \ |
| 147 | __ext4_journal_get_write_access(__func__, (handle), (bh)) | 152 | __ext4_journal_get_write_access(__func__, __LINE__, (handle), (bh)) |
| 148 | #define ext4_forget(handle, is_metadata, inode, bh, block_nr) \ | 153 | #define ext4_forget(handle, is_metadata, inode, bh, block_nr) \ |
| 149 | __ext4_forget(__func__, (handle), (is_metadata), (inode), (bh),\ | 154 | __ext4_forget(__func__, __LINE__, (handle), (is_metadata), (inode), \ |
| 150 | (block_nr)) | 155 | (bh), (block_nr)) |
| 151 | #define ext4_journal_get_create_access(handle, bh) \ | 156 | #define ext4_journal_get_create_access(handle, bh) \ |
| 152 | __ext4_journal_get_create_access(__func__, (handle), (bh)) | 157 | __ext4_journal_get_create_access(__func__, __LINE__, (handle), (bh)) |
| 153 | #define ext4_handle_dirty_metadata(handle, inode, bh) \ | 158 | #define ext4_handle_dirty_metadata(handle, inode, bh) \ |
| 154 | __ext4_handle_dirty_metadata(__func__, (handle), (inode), (bh)) | 159 | __ext4_handle_dirty_metadata(__func__, __LINE__, (handle), (inode), \ |
| 160 | (bh)) | ||
| 161 | #define ext4_handle_dirty_super(handle, sb) \ | ||
| 162 | __ext4_handle_dirty_super(__func__, __LINE__, (handle), (sb)) | ||
| 155 | 163 | ||
| 156 | handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks); | 164 | handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks); |
| 157 | int __ext4_journal_stop(const char *where, handle_t *handle); | 165 | int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle); |
| 158 | 166 | ||
| 159 | #define EXT4_NOJOURNAL_MAX_REF_COUNT ((unsigned long) 4096) | 167 | #define EXT4_NOJOURNAL_MAX_REF_COUNT ((unsigned long) 4096) |
| 160 | 168 | ||
| @@ -207,7 +215,7 @@ static inline handle_t *ext4_journal_start(struct inode *inode, int nblocks) | |||
| 207 | } | 215 | } |
| 208 | 216 | ||
| 209 | #define ext4_journal_stop(handle) \ | 217 | #define ext4_journal_stop(handle) \ |
| 210 | __ext4_journal_stop(__func__, (handle)) | 218 | __ext4_journal_stop(__func__, __LINE__, (handle)) |
| 211 | 219 | ||
| 212 | static inline handle_t *ext4_journal_current_handle(void) | 220 | static inline handle_t *ext4_journal_current_handle(void) |
| 213 | { | 221 | { |
| @@ -308,17 +316,15 @@ static inline int ext4_should_writeback_data(struct inode *inode) | |||
| 308 | * This function controls whether or not we should try to go down the | 316 | * This function controls whether or not we should try to go down the |
| 309 | * dioread_nolock code paths, which makes it safe to avoid taking | 317 | * dioread_nolock code paths, which makes it safe to avoid taking |
| 310 | * i_mutex for direct I/O reads. This only works for extent-based | 318 | * i_mutex for direct I/O reads. This only works for extent-based |
| 311 | * files, and it doesn't work for nobh or if data journaling is | 319 | * files, and it doesn't work if data journaling is enabled, since the |
| 312 | * enabled, since the dioread_nolock code uses b_private to pass | 320 | * dioread_nolock code uses b_private to pass information back to the |
| 313 | * information back to the I/O completion handler, and this conflicts | 321 | * I/O completion handler, and this conflicts with the jbd's use of |
| 314 | * with the jbd's use of b_private. | 322 | * b_private. |
| 315 | */ | 323 | */ |
| 316 | static inline int ext4_should_dioread_nolock(struct inode *inode) | 324 | static inline int ext4_should_dioread_nolock(struct inode *inode) |
| 317 | { | 325 | { |
| 318 | if (!test_opt(inode->i_sb, DIOREAD_NOLOCK)) | 326 | if (!test_opt(inode->i_sb, DIOREAD_NOLOCK)) |
| 319 | return 0; | 327 | return 0; |
| 320 | if (test_opt(inode->i_sb, NOBH)) | ||
| 321 | return 0; | ||
| 322 | if (!S_ISREG(inode->i_mode)) | 328 | if (!S_ISREG(inode->i_mode)) |
| 323 | return 0; | 329 | return 0; |
| 324 | if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) | 330 | if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) |
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 377309c1af65..06328d3e5717 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
| @@ -401,9 +401,9 @@ static int ext4_valid_extent_entries(struct inode *inode, | |||
| 401 | return 1; | 401 | return 1; |
| 402 | } | 402 | } |
| 403 | 403 | ||
| 404 | static int __ext4_ext_check(const char *function, struct inode *inode, | 404 | static int __ext4_ext_check(const char *function, unsigned int line, |
| 405 | struct ext4_extent_header *eh, | 405 | struct inode *inode, struct ext4_extent_header *eh, |
| 406 | int depth) | 406 | int depth) |
| 407 | { | 407 | { |
| 408 | const char *error_msg; | 408 | const char *error_msg; |
| 409 | int max = 0; | 409 | int max = 0; |
| @@ -436,7 +436,7 @@ static int __ext4_ext_check(const char *function, struct inode *inode, | |||
| 436 | return 0; | 436 | return 0; |
| 437 | 437 | ||
| 438 | corrupted: | 438 | corrupted: |
| 439 | ext4_error_inode(function, inode, | 439 | ext4_error_inode(inode, function, line, 0, |
| 440 | "bad header/extent: %s - magic %x, " | 440 | "bad header/extent: %s - magic %x, " |
| 441 | "entries %u, max %u(%u), depth %u(%u)", | 441 | "entries %u, max %u(%u), depth %u(%u)", |
| 442 | error_msg, le16_to_cpu(eh->eh_magic), | 442 | error_msg, le16_to_cpu(eh->eh_magic), |
| @@ -447,7 +447,7 @@ corrupted: | |||
| 447 | } | 447 | } |
| 448 | 448 | ||
| 449 | #define ext4_ext_check(inode, eh, depth) \ | 449 | #define ext4_ext_check(inode, eh, depth) \ |
| 450 | __ext4_ext_check(__func__, inode, eh, depth) | 450 | __ext4_ext_check(__func__, __LINE__, inode, eh, depth) |
| 451 | 451 | ||
| 452 | int ext4_ext_check_inode(struct inode *inode) | 452 | int ext4_ext_check_inode(struct inode *inode) |
| 453 | { | 453 | { |
| @@ -1083,7 +1083,6 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode, | |||
| 1083 | { | 1083 | { |
| 1084 | struct ext4_ext_path *curp = path; | 1084 | struct ext4_ext_path *curp = path; |
| 1085 | struct ext4_extent_header *neh; | 1085 | struct ext4_extent_header *neh; |
| 1086 | struct ext4_extent_idx *fidx; | ||
| 1087 | struct buffer_head *bh; | 1086 | struct buffer_head *bh; |
| 1088 | ext4_fsblk_t newblock; | 1087 | ext4_fsblk_t newblock; |
| 1089 | int err = 0; | 1088 | int err = 0; |
| @@ -1144,10 +1143,10 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode, | |||
| 1144 | ext4_idx_store_pblock(curp->p_idx, newblock); | 1143 | ext4_idx_store_pblock(curp->p_idx, newblock); |
| 1145 | 1144 | ||
| 1146 | neh = ext_inode_hdr(inode); | 1145 | neh = ext_inode_hdr(inode); |
| 1147 | fidx = EXT_FIRST_INDEX(neh); | ||
| 1148 | ext_debug("new root: num %d(%d), lblock %d, ptr %llu\n", | 1146 | ext_debug("new root: num %d(%d), lblock %d, ptr %llu\n", |
| 1149 | le16_to_cpu(neh->eh_entries), le16_to_cpu(neh->eh_max), | 1147 | le16_to_cpu(neh->eh_entries), le16_to_cpu(neh->eh_max), |
| 1150 | le32_to_cpu(fidx->ei_block), idx_pblock(fidx)); | 1148 | le32_to_cpu(EXT_FIRST_INDEX(neh)->ei_block), |
| 1149 | idx_pblock(EXT_FIRST_INDEX(neh))); | ||
| 1151 | 1150 | ||
| 1152 | neh->eh_depth = cpu_to_le16(path->p_depth + 1); | 1151 | neh->eh_depth = cpu_to_le16(path->p_depth + 1); |
| 1153 | err = ext4_ext_dirty(handle, inode, curp); | 1152 | err = ext4_ext_dirty(handle, inode, curp); |
| @@ -2937,7 +2936,7 @@ fix_extent_len: | |||
| 2937 | * One of more index blocks maybe needed if the extent tree grow after | 2936 | * One of more index blocks maybe needed if the extent tree grow after |
| 2938 | * the unintialized extent split. To prevent ENOSPC occur at the IO | 2937 | * the unintialized extent split. To prevent ENOSPC occur at the IO |
| 2939 | * complete, we need to split the uninitialized extent before DIO submit | 2938 | * complete, we need to split the uninitialized extent before DIO submit |
| 2940 | * the IO. The uninitilized extent called at this time will be split | 2939 | * the IO. The uninitialized extent called at this time will be split |
| 2941 | * into three uninitialized extent(at most). After IO complete, the part | 2940 | * into three uninitialized extent(at most). After IO complete, the part |
| 2942 | * being filled will be convert to initialized by the end_io callback function | 2941 | * being filled will be convert to initialized by the end_io callback function |
| 2943 | * via ext4_convert_unwritten_extents(). | 2942 | * via ext4_convert_unwritten_extents(). |
| @@ -2954,7 +2953,6 @@ static int ext4_split_unwritten_extents(handle_t *handle, | |||
| 2954 | struct ext4_extent *ex1 = NULL; | 2953 | struct ext4_extent *ex1 = NULL; |
| 2955 | struct ext4_extent *ex2 = NULL; | 2954 | struct ext4_extent *ex2 = NULL; |
| 2956 | struct ext4_extent *ex3 = NULL; | 2955 | struct ext4_extent *ex3 = NULL; |
| 2957 | struct ext4_extent_header *eh; | ||
| 2958 | ext4_lblk_t ee_block, eof_block; | 2956 | ext4_lblk_t ee_block, eof_block; |
| 2959 | unsigned int allocated, ee_len, depth; | 2957 | unsigned int allocated, ee_len, depth; |
| 2960 | ext4_fsblk_t newblock; | 2958 | ext4_fsblk_t newblock; |
| @@ -2971,7 +2969,6 @@ static int ext4_split_unwritten_extents(handle_t *handle, | |||
| 2971 | eof_block = map->m_lblk + map->m_len; | 2969 | eof_block = map->m_lblk + map->m_len; |
| 2972 | 2970 | ||
| 2973 | depth = ext_depth(inode); | 2971 | depth = ext_depth(inode); |
| 2974 | eh = path[depth].p_hdr; | ||
| 2975 | ex = path[depth].p_ext; | 2972 | ex = path[depth].p_ext; |
| 2976 | ee_block = le32_to_cpu(ex->ee_block); | 2973 | ee_block = le32_to_cpu(ex->ee_block); |
| 2977 | ee_len = ext4_ext_get_actual_len(ex); | 2974 | ee_len = ext4_ext_get_actual_len(ex); |
| @@ -3058,7 +3055,6 @@ static int ext4_split_unwritten_extents(handle_t *handle, | |||
| 3058 | err = PTR_ERR(path); | 3055 | err = PTR_ERR(path); |
| 3059 | goto out; | 3056 | goto out; |
| 3060 | } | 3057 | } |
| 3061 | eh = path[depth].p_hdr; | ||
| 3062 | ex = path[depth].p_ext; | 3058 | ex = path[depth].p_ext; |
| 3063 | if (ex2 != &newex) | 3059 | if (ex2 != &newex) |
| 3064 | ex2 = ex; | 3060 | ex2 = ex; |
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 5313ae4cda2d..ee92b66d4558 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c | |||
| @@ -70,7 +70,8 @@ ext4_file_write(struct kiocb *iocb, const struct iovec *iov, | |||
| 70 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); | 70 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); |
| 71 | size_t length = iov_length(iov, nr_segs); | 71 | size_t length = iov_length(iov, nr_segs); |
| 72 | 72 | ||
| 73 | if (pos > sbi->s_bitmap_maxbytes) | 73 | if ((pos > sbi->s_bitmap_maxbytes || |
| 74 | (pos == sbi->s_bitmap_maxbytes && length > 0))) | ||
| 74 | return -EFBIG; | 75 | return -EFBIG; |
| 75 | 76 | ||
| 76 | if (pos + length > sbi->s_bitmap_maxbytes) { | 77 | if (pos + length > sbi->s_bitmap_maxbytes) { |
| @@ -123,7 +124,7 @@ static int ext4_file_open(struct inode * inode, struct file * filp) | |||
| 123 | if (!IS_ERR(cp)) { | 124 | if (!IS_ERR(cp)) { |
| 124 | memcpy(sbi->s_es->s_last_mounted, cp, | 125 | memcpy(sbi->s_es->s_last_mounted, cp, |
| 125 | sizeof(sbi->s_es->s_last_mounted)); | 126 | sizeof(sbi->s_es->s_last_mounted)); |
| 126 | sb->s_dirt = 1; | 127 | ext4_mark_super_dirty(sb); |
| 127 | } | 128 | } |
| 128 | } | 129 | } |
| 129 | return dquot_file_open(inode, filp); | 130 | return dquot_file_open(inode, filp); |
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 25c4b3173fd9..45853e0d1f21 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c | |||
| @@ -222,7 +222,7 @@ void ext4_free_inode(handle_t *handle, struct inode *inode) | |||
| 222 | is_directory = S_ISDIR(inode->i_mode); | 222 | is_directory = S_ISDIR(inode->i_mode); |
| 223 | 223 | ||
| 224 | /* Do this BEFORE marking the inode not in use or returning an error */ | 224 | /* Do this BEFORE marking the inode not in use or returning an error */ |
| 225 | clear_inode(inode); | 225 | ext4_clear_inode(inode); |
| 226 | 226 | ||
| 227 | es = EXT4_SB(sb)->s_es; | 227 | es = EXT4_SB(sb)->s_es; |
| 228 | if (ino < EXT4_FIRST_INO(sb) || ino > le32_to_cpu(es->s_inodes_count)) { | 228 | if (ino < EXT4_FIRST_INO(sb) || ino > le32_to_cpu(es->s_inodes_count)) { |
| @@ -279,7 +279,7 @@ out: | |||
| 279 | err = ext4_handle_dirty_metadata(handle, NULL, bitmap_bh); | 279 | err = ext4_handle_dirty_metadata(handle, NULL, bitmap_bh); |
| 280 | if (!fatal) | 280 | if (!fatal) |
| 281 | fatal = err; | 281 | fatal = err; |
| 282 | sb->s_dirt = 1; | 282 | ext4_mark_super_dirty(sb); |
| 283 | } else | 283 | } else |
| 284 | ext4_error(sb, "bit already cleared for inode %lu", ino); | 284 | ext4_error(sb, "bit already cleared for inode %lu", ino); |
| 285 | 285 | ||
| @@ -965,7 +965,7 @@ got: | |||
| 965 | percpu_counter_dec(&sbi->s_freeinodes_counter); | 965 | percpu_counter_dec(&sbi->s_freeinodes_counter); |
| 966 | if (S_ISDIR(mode)) | 966 | if (S_ISDIR(mode)) |
| 967 | percpu_counter_inc(&sbi->s_dirs_counter); | 967 | percpu_counter_inc(&sbi->s_dirs_counter); |
| 968 | sb->s_dirt = 1; | 968 | ext4_mark_super_dirty(sb); |
| 969 | 969 | ||
| 970 | if (sbi->s_log_groups_per_flex) { | 970 | if (sbi->s_log_groups_per_flex) { |
| 971 | flex_group = ext4_flex_group(sbi, group); | 971 | flex_group = ext4_flex_group(sbi, group); |
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 42272d67955a..4b8debeb3965 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
| @@ -167,11 +167,16 @@ int ext4_truncate_restart_trans(handle_t *handle, struct inode *inode, | |||
| 167 | /* | 167 | /* |
| 168 | * Called at the last iput() if i_nlink is zero. | 168 | * Called at the last iput() if i_nlink is zero. |
| 169 | */ | 169 | */ |
| 170 | void ext4_delete_inode(struct inode *inode) | 170 | void ext4_evict_inode(struct inode *inode) |
| 171 | { | 171 | { |
| 172 | handle_t *handle; | 172 | handle_t *handle; |
| 173 | int err; | 173 | int err; |
| 174 | 174 | ||
| 175 | if (inode->i_nlink) { | ||
| 176 | truncate_inode_pages(&inode->i_data, 0); | ||
| 177 | goto no_delete; | ||
| 178 | } | ||
| 179 | |||
| 175 | if (!is_bad_inode(inode)) | 180 | if (!is_bad_inode(inode)) |
| 176 | dquot_initialize(inode); | 181 | dquot_initialize(inode); |
| 177 | 182 | ||
| @@ -221,6 +226,7 @@ void ext4_delete_inode(struct inode *inode) | |||
| 221 | "couldn't extend journal (err %d)", err); | 226 | "couldn't extend journal (err %d)", err); |
| 222 | stop_handle: | 227 | stop_handle: |
| 223 | ext4_journal_stop(handle); | 228 | ext4_journal_stop(handle); |
| 229 | ext4_orphan_del(NULL, inode); | ||
| 224 | goto no_delete; | 230 | goto no_delete; |
| 225 | } | 231 | } |
| 226 | } | 232 | } |
| @@ -245,13 +251,13 @@ void ext4_delete_inode(struct inode *inode) | |||
| 245 | */ | 251 | */ |
| 246 | if (ext4_mark_inode_dirty(handle, inode)) | 252 | if (ext4_mark_inode_dirty(handle, inode)) |
| 247 | /* If that failed, just do the required in-core inode clear. */ | 253 | /* If that failed, just do the required in-core inode clear. */ |
| 248 | clear_inode(inode); | 254 | ext4_clear_inode(inode); |
| 249 | else | 255 | else |
| 250 | ext4_free_inode(handle, inode); | 256 | ext4_free_inode(handle, inode); |
| 251 | ext4_journal_stop(handle); | 257 | ext4_journal_stop(handle); |
| 252 | return; | 258 | return; |
| 253 | no_delete: | 259 | no_delete: |
| 254 | clear_inode(inode); /* We must guarantee clearing of inode... */ | 260 | ext4_clear_inode(inode); /* We must guarantee clearing of inode... */ |
| 255 | } | 261 | } |
| 256 | 262 | ||
| 257 | typedef struct { | 263 | typedef struct { |
| @@ -337,9 +343,11 @@ static int ext4_block_to_path(struct inode *inode, | |||
| 337 | return n; | 343 | return n; |
| 338 | } | 344 | } |
| 339 | 345 | ||
| 340 | static int __ext4_check_blockref(const char *function, struct inode *inode, | 346 | static int __ext4_check_blockref(const char *function, unsigned int line, |
| 347 | struct inode *inode, | ||
| 341 | __le32 *p, unsigned int max) | 348 | __le32 *p, unsigned int max) |
| 342 | { | 349 | { |
| 350 | struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es; | ||
| 343 | __le32 *bref = p; | 351 | __le32 *bref = p; |
| 344 | unsigned int blk; | 352 | unsigned int blk; |
| 345 | 353 | ||
| @@ -348,8 +356,9 @@ static int __ext4_check_blockref(const char *function, struct inode *inode, | |||
| 348 | if (blk && | 356 | if (blk && |
| 349 | unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb), | 357 | unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb), |
| 350 | blk, 1))) { | 358 | blk, 1))) { |
| 351 | ext4_error_inode(function, inode, | 359 | es->s_last_error_block = cpu_to_le64(blk); |
| 352 | "invalid block reference %u", blk); | 360 | ext4_error_inode(inode, function, line, blk, |
| 361 | "invalid block"); | ||
| 353 | return -EIO; | 362 | return -EIO; |
| 354 | } | 363 | } |
| 355 | } | 364 | } |
| @@ -358,11 +367,13 @@ static int __ext4_check_blockref(const char *function, struct inode *inode, | |||
| 358 | 367 | ||
| 359 | 368 | ||
| 360 | #define ext4_check_indirect_blockref(inode, bh) \ | 369 | #define ext4_check_indirect_blockref(inode, bh) \ |
| 361 | __ext4_check_blockref(__func__, inode, (__le32 *)(bh)->b_data, \ | 370 | __ext4_check_blockref(__func__, __LINE__, inode, \ |
| 371 | (__le32 *)(bh)->b_data, \ | ||
| 362 | EXT4_ADDR_PER_BLOCK((inode)->i_sb)) | 372 | EXT4_ADDR_PER_BLOCK((inode)->i_sb)) |
| 363 | 373 | ||
| 364 | #define ext4_check_inode_blockref(inode) \ | 374 | #define ext4_check_inode_blockref(inode) \ |
| 365 | __ext4_check_blockref(__func__, inode, EXT4_I(inode)->i_data, \ | 375 | __ext4_check_blockref(__func__, __LINE__, inode, \ |
| 376 | EXT4_I(inode)->i_data, \ | ||
| 366 | EXT4_NDIR_BLOCKS) | 377 | EXT4_NDIR_BLOCKS) |
| 367 | 378 | ||
| 368 | /** | 379 | /** |
| @@ -1128,20 +1139,24 @@ void ext4_da_update_reserve_space(struct inode *inode, | |||
| 1128 | ext4_discard_preallocations(inode); | 1139 | ext4_discard_preallocations(inode); |
| 1129 | } | 1140 | } |
| 1130 | 1141 | ||
| 1131 | static int check_block_validity(struct inode *inode, const char *func, | 1142 | static int __check_block_validity(struct inode *inode, const char *func, |
| 1143 | unsigned int line, | ||
| 1132 | struct ext4_map_blocks *map) | 1144 | struct ext4_map_blocks *map) |
| 1133 | { | 1145 | { |
| 1134 | if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), map->m_pblk, | 1146 | if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), map->m_pblk, |
| 1135 | map->m_len)) { | 1147 | map->m_len)) { |
| 1136 | ext4_error_inode(func, inode, | 1148 | ext4_error_inode(inode, func, line, map->m_pblk, |
| 1137 | "lblock %lu mapped to illegal pblock %llu " | 1149 | "lblock %lu mapped to illegal pblock " |
| 1138 | "(length %d)", (unsigned long) map->m_lblk, | 1150 | "(length %d)", (unsigned long) map->m_lblk, |
| 1139 | map->m_pblk, map->m_len); | 1151 | map->m_len); |
| 1140 | return -EIO; | 1152 | return -EIO; |
| 1141 | } | 1153 | } |
| 1142 | return 0; | 1154 | return 0; |
| 1143 | } | 1155 | } |
| 1144 | 1156 | ||
| 1157 | #define check_block_validity(inode, map) \ | ||
| 1158 | __check_block_validity((inode), __func__, __LINE__, (map)) | ||
| 1159 | |||
| 1145 | /* | 1160 | /* |
| 1146 | * Return the number of contiguous dirty pages in a given inode | 1161 | * Return the number of contiguous dirty pages in a given inode |
| 1147 | * starting at page frame idx. | 1162 | * starting at page frame idx. |
| @@ -1244,7 +1259,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, | |||
| 1244 | up_read((&EXT4_I(inode)->i_data_sem)); | 1259 | up_read((&EXT4_I(inode)->i_data_sem)); |
| 1245 | 1260 | ||
| 1246 | if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) { | 1261 | if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) { |
| 1247 | int ret = check_block_validity(inode, __func__, map); | 1262 | int ret = check_block_validity(inode, map); |
| 1248 | if (ret != 0) | 1263 | if (ret != 0) |
| 1249 | return ret; | 1264 | return ret; |
| 1250 | } | 1265 | } |
| @@ -1324,9 +1339,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, | |||
| 1324 | 1339 | ||
| 1325 | up_write((&EXT4_I(inode)->i_data_sem)); | 1340 | up_write((&EXT4_I(inode)->i_data_sem)); |
| 1326 | if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) { | 1341 | if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) { |
| 1327 | int ret = check_block_validity(inode, | 1342 | int ret = check_block_validity(inode, map); |
| 1328 | "ext4_map_blocks_after_alloc", | ||
| 1329 | map); | ||
| 1330 | if (ret != 0) | 1343 | if (ret != 0) |
| 1331 | return ret; | 1344 | return ret; |
| 1332 | } | 1345 | } |
| @@ -1519,9 +1532,25 @@ static int walk_page_buffers(handle_t *handle, | |||
| 1519 | static int do_journal_get_write_access(handle_t *handle, | 1532 | static int do_journal_get_write_access(handle_t *handle, |
| 1520 | struct buffer_head *bh) | 1533 | struct buffer_head *bh) |
| 1521 | { | 1534 | { |
| 1535 | int dirty = buffer_dirty(bh); | ||
| 1536 | int ret; | ||
| 1537 | |||
| 1522 | if (!buffer_mapped(bh) || buffer_freed(bh)) | 1538 | if (!buffer_mapped(bh) || buffer_freed(bh)) |
| 1523 | return 0; | 1539 | return 0; |
| 1524 | return ext4_journal_get_write_access(handle, bh); | 1540 | /* |
| 1541 | * __block_prepare_write() could have dirtied some buffers. Clean | ||
| 1542 | * the dirty bit as jbd2_journal_get_write_access() could complain | ||
| 1543 | * otherwise about fs integrity issues. Setting of the dirty bit | ||
| 1544 | * by __block_prepare_write() isn't a real problem here as we clear | ||
| 1545 | * the bit before releasing a page lock and thus writeback cannot | ||
| 1546 | * ever write the buffer. | ||
| 1547 | */ | ||
| 1548 | if (dirty) | ||
| 1549 | clear_buffer_dirty(bh); | ||
| 1550 | ret = ext4_journal_get_write_access(handle, bh); | ||
| 1551 | if (!ret && dirty) | ||
| 1552 | ret = ext4_handle_dirty_metadata(handle, NULL, bh); | ||
| 1553 | return ret; | ||
| 1525 | } | 1554 | } |
| 1526 | 1555 | ||
| 1527 | /* | 1556 | /* |
| @@ -1578,11 +1607,9 @@ retry: | |||
| 1578 | *pagep = page; | 1607 | *pagep = page; |
| 1579 | 1608 | ||
| 1580 | if (ext4_should_dioread_nolock(inode)) | 1609 | if (ext4_should_dioread_nolock(inode)) |
| 1581 | ret = block_write_begin(file, mapping, pos, len, flags, pagep, | 1610 | ret = __block_write_begin(page, pos, len, ext4_get_block_write); |
| 1582 | fsdata, ext4_get_block_write); | ||
| 1583 | else | 1611 | else |
| 1584 | ret = block_write_begin(file, mapping, pos, len, flags, pagep, | 1612 | ret = __block_write_begin(page, pos, len, ext4_get_block); |
| 1585 | fsdata, ext4_get_block); | ||
| 1586 | 1613 | ||
| 1587 | if (!ret && ext4_should_journal_data(inode)) { | 1614 | if (!ret && ext4_should_journal_data(inode)) { |
| 1588 | ret = walk_page_buffers(handle, page_buffers(page), | 1615 | ret = walk_page_buffers(handle, page_buffers(page), |
| @@ -1593,7 +1620,7 @@ retry: | |||
| 1593 | unlock_page(page); | 1620 | unlock_page(page); |
| 1594 | page_cache_release(page); | 1621 | page_cache_release(page); |
| 1595 | /* | 1622 | /* |
| 1596 | * block_write_begin may have instantiated a few blocks | 1623 | * __block_write_begin may have instantiated a few blocks |
| 1597 | * outside i_size. Trim these off again. Don't need | 1624 | * outside i_size. Trim these off again. Don't need |
| 1598 | * i_size_read because we hold i_mutex. | 1625 | * i_size_read because we hold i_mutex. |
| 1599 | * | 1626 | * |
| @@ -2194,7 +2221,7 @@ static int mpage_da_map_blocks(struct mpage_da_data *mpd) | |||
| 2194 | BUG_ON(!handle); | 2221 | BUG_ON(!handle); |
| 2195 | 2222 | ||
| 2196 | /* | 2223 | /* |
| 2197 | * Call ext4_get_blocks() to allocate any delayed allocation | 2224 | * Call ext4_map_blocks() to allocate any delayed allocation |
| 2198 | * blocks, or to convert an uninitialized extent to be | 2225 | * blocks, or to convert an uninitialized extent to be |
| 2199 | * initialized (in the case where we have written into | 2226 | * initialized (in the case where we have written into |
| 2200 | * one or more preallocated blocks). | 2227 | * one or more preallocated blocks). |
| @@ -2203,7 +2230,7 @@ static int mpage_da_map_blocks(struct mpage_da_data *mpd) | |||
| 2203 | * indicate that we are on the delayed allocation path. This | 2230 | * indicate that we are on the delayed allocation path. This |
| 2204 | * affects functions in many different parts of the allocation | 2231 | * affects functions in many different parts of the allocation |
| 2205 | * call path. This flag exists primarily because we don't | 2232 | * call path. This flag exists primarily because we don't |
| 2206 | * want to change *many* call functions, so ext4_get_blocks() | 2233 | * want to change *many* call functions, so ext4_map_blocks() |
| 2207 | * will set the magic i_delalloc_reserved_flag once the | 2234 | * will set the magic i_delalloc_reserved_flag once the |
| 2208 | * inode's allocation semaphore is taken. | 2235 | * inode's allocation semaphore is taken. |
| 2209 | * | 2236 | * |
| @@ -2221,6 +2248,8 @@ static int mpage_da_map_blocks(struct mpage_da_data *mpd) | |||
| 2221 | 2248 | ||
| 2222 | blks = ext4_map_blocks(handle, mpd->inode, &map, get_blocks_flags); | 2249 | blks = ext4_map_blocks(handle, mpd->inode, &map, get_blocks_flags); |
| 2223 | if (blks < 0) { | 2250 | if (blks < 0) { |
| 2251 | struct super_block *sb = mpd->inode->i_sb; | ||
| 2252 | |||
| 2224 | err = blks; | 2253 | err = blks; |
| 2225 | /* | 2254 | /* |
| 2226 | * If get block returns with error we simply | 2255 | * If get block returns with error we simply |
| @@ -2231,7 +2260,7 @@ static int mpage_da_map_blocks(struct mpage_da_data *mpd) | |||
| 2231 | return 0; | 2260 | return 0; |
| 2232 | 2261 | ||
| 2233 | if (err == -ENOSPC && | 2262 | if (err == -ENOSPC && |
| 2234 | ext4_count_free_blocks(mpd->inode->i_sb)) { | 2263 | ext4_count_free_blocks(sb)) { |
| 2235 | mpd->retval = err; | 2264 | mpd->retval = err; |
| 2236 | return 0; | 2265 | return 0; |
| 2237 | } | 2266 | } |
| @@ -2243,16 +2272,17 @@ static int mpage_da_map_blocks(struct mpage_da_data *mpd) | |||
| 2243 | * writepage and writepages will again try to write | 2272 | * writepage and writepages will again try to write |
| 2244 | * the same. | 2273 | * the same. |
| 2245 | */ | 2274 | */ |
| 2246 | ext4_msg(mpd->inode->i_sb, KERN_CRIT, | 2275 | if (!(EXT4_SB(sb)->s_mount_flags & EXT4_MF_FS_ABORTED)) { |
| 2247 | "delayed block allocation failed for inode %lu at " | 2276 | ext4_msg(sb, KERN_CRIT, |
| 2248 | "logical offset %llu with max blocks %zd with " | 2277 | "delayed block allocation failed for inode %lu " |
| 2249 | "error %d", mpd->inode->i_ino, | 2278 | "at logical offset %llu with max blocks %zd " |
| 2250 | (unsigned long long) next, | 2279 | "with error %d", mpd->inode->i_ino, |
| 2251 | mpd->b_size >> mpd->inode->i_blkbits, err); | 2280 | (unsigned long long) next, |
| 2252 | printk(KERN_CRIT "This should not happen!! " | 2281 | mpd->b_size >> mpd->inode->i_blkbits, err); |
| 2253 | "Data will be lost\n"); | 2282 | ext4_msg(sb, KERN_CRIT, |
| 2254 | if (err == -ENOSPC) { | 2283 | "This should not happen!! Data will be lost\n"); |
| 2255 | ext4_print_free_blocks(mpd->inode); | 2284 | if (err == -ENOSPC) |
| 2285 | ext4_print_free_blocks(mpd->inode); | ||
| 2256 | } | 2286 | } |
| 2257 | /* invalidate all the pages */ | 2287 | /* invalidate all the pages */ |
| 2258 | ext4_da_block_invalidatepages(mpd, next, | 2288 | ext4_da_block_invalidatepages(mpd, next, |
| @@ -2320,7 +2350,7 @@ static void mpage_add_bh_to_extent(struct mpage_da_data *mpd, | |||
| 2320 | * XXX Don't go larger than mballoc is willing to allocate | 2350 | * XXX Don't go larger than mballoc is willing to allocate |
| 2321 | * This is a stopgap solution. We eventually need to fold | 2351 | * This is a stopgap solution. We eventually need to fold |
| 2322 | * mpage_da_submit_io() into this function and then call | 2352 | * mpage_da_submit_io() into this function and then call |
| 2323 | * ext4_get_blocks() multiple times in a loop | 2353 | * ext4_map_blocks() multiple times in a loop |
| 2324 | */ | 2354 | */ |
| 2325 | if (nrblocks >= 8*1024*1024/mpd->inode->i_sb->s_blocksize) | 2355 | if (nrblocks >= 8*1024*1024/mpd->inode->i_sb->s_blocksize) |
| 2326 | goto flush_it; | 2356 | goto flush_it; |
| @@ -2553,18 +2583,16 @@ static int ext4_da_get_block_prep(struct inode *inode, sector_t iblock, | |||
| 2553 | /* | 2583 | /* |
| 2554 | * This function is used as a standard get_block_t calback function | 2584 | * This function is used as a standard get_block_t calback function |
| 2555 | * when there is no desire to allocate any blocks. It is used as a | 2585 | * when there is no desire to allocate any blocks. It is used as a |
| 2556 | * callback function for block_prepare_write(), nobh_writepage(), and | 2586 | * callback function for block_prepare_write() and block_write_full_page(). |
| 2557 | * block_write_full_page(). These functions should only try to map a | 2587 | * These functions should only try to map a single block at a time. |
| 2558 | * single block at a time. | ||
| 2559 | * | 2588 | * |
| 2560 | * Since this function doesn't do block allocations even if the caller | 2589 | * Since this function doesn't do block allocations even if the caller |
| 2561 | * requests it by passing in create=1, it is critically important that | 2590 | * requests it by passing in create=1, it is critically important that |
| 2562 | * any caller checks to make sure that any buffer heads are returned | 2591 | * any caller checks to make sure that any buffer heads are returned |
| 2563 | * by this function are either all already mapped or marked for | 2592 | * by this function are either all already mapped or marked for |
| 2564 | * delayed allocation before calling nobh_writepage() or | 2593 | * delayed allocation before calling block_write_full_page(). Otherwise, |
| 2565 | * block_write_full_page(). Otherwise, b_blocknr could be left | 2594 | * b_blocknr could be left unitialized, and the page write functions will |
| 2566 | * unitialized, and the page write functions will be taken by | 2595 | * be taken by surprise. |
| 2567 | * surprise. | ||
| 2568 | */ | 2596 | */ |
| 2569 | static int noalloc_get_block_write(struct inode *inode, sector_t iblock, | 2597 | static int noalloc_get_block_write(struct inode *inode, sector_t iblock, |
| 2570 | struct buffer_head *bh_result, int create) | 2598 | struct buffer_head *bh_result, int create) |
| @@ -2749,9 +2777,7 @@ static int ext4_writepage(struct page *page, | |||
| 2749 | return __ext4_journalled_writepage(page, len); | 2777 | return __ext4_journalled_writepage(page, len); |
| 2750 | } | 2778 | } |
| 2751 | 2779 | ||
| 2752 | if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode)) | 2780 | if (page_bufs && buffer_uninit(page_bufs)) { |
| 2753 | ret = nobh_writepage(page, noalloc_get_block_write, wbc); | ||
| 2754 | else if (page_bufs && buffer_uninit(page_bufs)) { | ||
| 2755 | ext4_set_bh_endio(page_bufs, inode); | 2781 | ext4_set_bh_endio(page_bufs, inode); |
| 2756 | ret = block_write_full_page_endio(page, noalloc_get_block_write, | 2782 | ret = block_write_full_page_endio(page, noalloc_get_block_write, |
| 2757 | wbc, ext4_end_io_buffer_write); | 2783 | wbc, ext4_end_io_buffer_write); |
| @@ -3146,13 +3172,10 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping, | |||
| 3146 | int ret, retries = 0; | 3172 | int ret, retries = 0; |
| 3147 | struct page *page; | 3173 | struct page *page; |
| 3148 | pgoff_t index; | 3174 | pgoff_t index; |
| 3149 | unsigned from, to; | ||
| 3150 | struct inode *inode = mapping->host; | 3175 | struct inode *inode = mapping->host; |
| 3151 | handle_t *handle; | 3176 | handle_t *handle; |
| 3152 | 3177 | ||
| 3153 | index = pos >> PAGE_CACHE_SHIFT; | 3178 | index = pos >> PAGE_CACHE_SHIFT; |
| 3154 | from = pos & (PAGE_CACHE_SIZE - 1); | ||
| 3155 | to = from + len; | ||
| 3156 | 3179 | ||
| 3157 | if (ext4_nonda_switch(inode->i_sb)) { | 3180 | if (ext4_nonda_switch(inode->i_sb)) { |
| 3158 | *fsdata = (void *)FALL_BACK_TO_NONDELALLOC; | 3181 | *fsdata = (void *)FALL_BACK_TO_NONDELALLOC; |
| @@ -3185,8 +3208,7 @@ retry: | |||
| 3185 | } | 3208 | } |
| 3186 | *pagep = page; | 3209 | *pagep = page; |
| 3187 | 3210 | ||
| 3188 | ret = block_write_begin(file, mapping, pos, len, flags, pagep, fsdata, | 3211 | ret = __block_write_begin(page, pos, len, ext4_da_get_block_prep); |
| 3189 | ext4_da_get_block_prep); | ||
| 3190 | if (ret < 0) { | 3212 | if (ret < 0) { |
| 3191 | unlock_page(page); | 3213 | unlock_page(page); |
| 3192 | ext4_journal_stop(handle); | 3214 | ext4_journal_stop(handle); |
| @@ -3545,15 +3567,24 @@ static ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb, | |||
| 3545 | 3567 | ||
| 3546 | retry: | 3568 | retry: |
| 3547 | if (rw == READ && ext4_should_dioread_nolock(inode)) | 3569 | if (rw == READ && ext4_should_dioread_nolock(inode)) |
| 3548 | ret = blockdev_direct_IO_no_locking(rw, iocb, inode, | 3570 | ret = __blockdev_direct_IO(rw, iocb, inode, |
| 3549 | inode->i_sb->s_bdev, iov, | 3571 | inode->i_sb->s_bdev, iov, |
| 3550 | offset, nr_segs, | 3572 | offset, nr_segs, |
| 3551 | ext4_get_block, NULL); | 3573 | ext4_get_block, NULL, NULL, 0); |
| 3552 | else | 3574 | else { |
| 3553 | ret = blockdev_direct_IO(rw, iocb, inode, | 3575 | ret = blockdev_direct_IO(rw, iocb, inode, |
| 3554 | inode->i_sb->s_bdev, iov, | 3576 | inode->i_sb->s_bdev, iov, |
| 3555 | offset, nr_segs, | 3577 | offset, nr_segs, |
| 3556 | ext4_get_block, NULL); | 3578 | ext4_get_block, NULL); |
| 3579 | |||
| 3580 | if (unlikely((rw & WRITE) && ret < 0)) { | ||
| 3581 | loff_t isize = i_size_read(inode); | ||
| 3582 | loff_t end = offset + iov_length(iov, nr_segs); | ||
| 3583 | |||
| 3584 | if (end > isize) | ||
| 3585 | vmtruncate(inode, isize); | ||
| 3586 | } | ||
| 3587 | } | ||
| 3557 | if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) | 3588 | if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) |
| 3558 | goto retry; | 3589 | goto retry; |
| 3559 | 3590 | ||
| @@ -3668,6 +3699,8 @@ static int ext4_end_io_nolock(ext4_io_end_t *io) | |||
| 3668 | return ret; | 3699 | return ret; |
| 3669 | } | 3700 | } |
| 3670 | 3701 | ||
| 3702 | if (io->iocb) | ||
| 3703 | aio_complete(io->iocb, io->result, 0); | ||
| 3671 | /* clear the DIO AIO unwritten flag */ | 3704 | /* clear the DIO AIO unwritten flag */ |
| 3672 | io->flag = 0; | 3705 | io->flag = 0; |
| 3673 | return ret; | 3706 | return ret; |
| @@ -3767,6 +3800,8 @@ static ext4_io_end_t *ext4_init_io_end (struct inode *inode, gfp_t flags) | |||
| 3767 | io->offset = 0; | 3800 | io->offset = 0; |
| 3768 | io->size = 0; | 3801 | io->size = 0; |
| 3769 | io->page = NULL; | 3802 | io->page = NULL; |
| 3803 | io->iocb = NULL; | ||
| 3804 | io->result = 0; | ||
| 3770 | INIT_WORK(&io->work, ext4_end_io_work); | 3805 | INIT_WORK(&io->work, ext4_end_io_work); |
| 3771 | INIT_LIST_HEAD(&io->list); | 3806 | INIT_LIST_HEAD(&io->list); |
| 3772 | } | 3807 | } |
| @@ -3775,7 +3810,8 @@ static ext4_io_end_t *ext4_init_io_end (struct inode *inode, gfp_t flags) | |||
| 3775 | } | 3810 | } |
| 3776 | 3811 | ||
| 3777 | static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset, | 3812 | static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset, |
| 3778 | ssize_t size, void *private) | 3813 | ssize_t size, void *private, int ret, |
| 3814 | bool is_async) | ||
| 3779 | { | 3815 | { |
| 3780 | ext4_io_end_t *io_end = iocb->private; | 3816 | ext4_io_end_t *io_end = iocb->private; |
| 3781 | struct workqueue_struct *wq; | 3817 | struct workqueue_struct *wq; |
| @@ -3784,7 +3820,7 @@ static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset, | |||
| 3784 | 3820 | ||
| 3785 | /* if not async direct IO or dio with 0 bytes write, just return */ | 3821 | /* if not async direct IO or dio with 0 bytes write, just return */ |
| 3786 | if (!io_end || !size) | 3822 | if (!io_end || !size) |
| 3787 | return; | 3823 | goto out; |
| 3788 | 3824 | ||
| 3789 | ext_debug("ext4_end_io_dio(): io_end 0x%p" | 3825 | ext_debug("ext4_end_io_dio(): io_end 0x%p" |
| 3790 | "for inode %lu, iocb 0x%p, offset %llu, size %llu\n", | 3826 | "for inode %lu, iocb 0x%p, offset %llu, size %llu\n", |
| @@ -3795,12 +3831,18 @@ static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset, | |||
| 3795 | if (io_end->flag != EXT4_IO_UNWRITTEN){ | 3831 | if (io_end->flag != EXT4_IO_UNWRITTEN){ |
| 3796 | ext4_free_io_end(io_end); | 3832 | ext4_free_io_end(io_end); |
| 3797 | iocb->private = NULL; | 3833 | iocb->private = NULL; |
| 3834 | out: | ||
| 3835 | if (is_async) | ||
| 3836 | aio_complete(iocb, ret, 0); | ||
| 3798 | return; | 3837 | return; |
| 3799 | } | 3838 | } |
| 3800 | 3839 | ||
| 3801 | io_end->offset = offset; | 3840 | io_end->offset = offset; |
| 3802 | io_end->size = size; | 3841 | io_end->size = size; |
| 3803 | io_end->flag = EXT4_IO_UNWRITTEN; | 3842 | if (is_async) { |
| 3843 | io_end->iocb = iocb; | ||
| 3844 | io_end->result = ret; | ||
| 3845 | } | ||
| 3804 | wq = EXT4_SB(io_end->inode->i_sb)->dio_unwritten_wq; | 3846 | wq = EXT4_SB(io_end->inode->i_sb)->dio_unwritten_wq; |
| 3805 | 3847 | ||
| 3806 | /* queue the work to convert unwritten extents to written */ | 3848 | /* queue the work to convert unwritten extents to written */ |
| @@ -3937,7 +3979,7 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb, | |||
| 3937 | return -ENOMEM; | 3979 | return -ENOMEM; |
| 3938 | /* | 3980 | /* |
| 3939 | * we save the io structure for current async | 3981 | * we save the io structure for current async |
| 3940 | * direct IO, so that later ext4_get_blocks() | 3982 | * direct IO, so that later ext4_map_blocks() |
| 3941 | * could flag the io structure whether there | 3983 | * could flag the io structure whether there |
| 3942 | * is a unwritten extents needs to be converted | 3984 | * is a unwritten extents needs to be converted |
| 3943 | * when IO is completed. | 3985 | * when IO is completed. |
| @@ -4128,17 +4170,6 @@ int ext4_block_truncate_page(handle_t *handle, | |||
| 4128 | length = blocksize - (offset & (blocksize - 1)); | 4170 | length = blocksize - (offset & (blocksize - 1)); |
| 4129 | iblock = index << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits); | 4171 | iblock = index << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits); |
| 4130 | 4172 | ||
| 4131 | /* | ||
| 4132 | * For "nobh" option, we can only work if we don't need to | ||
| 4133 | * read-in the page - otherwise we create buffers to do the IO. | ||
| 4134 | */ | ||
| 4135 | if (!page_has_buffers(page) && test_opt(inode->i_sb, NOBH) && | ||
| 4136 | ext4_should_writeback_data(inode) && PageUptodate(page)) { | ||
| 4137 | zero_user(page, offset, length); | ||
| 4138 | set_page_dirty(page); | ||
| 4139 | goto unlock; | ||
| 4140 | } | ||
| 4141 | |||
| 4142 | if (!page_has_buffers(page)) | 4173 | if (!page_has_buffers(page)) |
| 4143 | create_empty_buffers(page, blocksize, 0); | 4174 | create_empty_buffers(page, blocksize, 0); |
| 4144 | 4175 | ||
| @@ -4488,9 +4519,8 @@ static void ext4_free_branches(handle_t *handle, struct inode *inode, | |||
| 4488 | * (should be rare). | 4519 | * (should be rare). |
| 4489 | */ | 4520 | */ |
| 4490 | if (!bh) { | 4521 | if (!bh) { |
| 4491 | EXT4_ERROR_INODE(inode, | 4522 | EXT4_ERROR_INODE_BLOCK(inode, nr, |
| 4492 | "Read failure block=%llu", | 4523 | "Read failure"); |
| 4493 | (unsigned long long) nr); | ||
| 4494 | continue; | 4524 | continue; |
| 4495 | } | 4525 | } |
| 4496 | 4526 | ||
| @@ -4502,27 +4532,6 @@ static void ext4_free_branches(handle_t *handle, struct inode *inode, | |||
| 4502 | depth); | 4532 | depth); |
| 4503 | 4533 | ||
| 4504 | /* | 4534 | /* |
| 4505 | * We've probably journalled the indirect block several | ||
| 4506 | * times during the truncate. But it's no longer | ||
| 4507 | * needed and we now drop it from the transaction via | ||
| 4508 | * jbd2_journal_revoke(). | ||
| 4509 | * | ||
| 4510 | * That's easy if it's exclusively part of this | ||
| 4511 | * transaction. But if it's part of the committing | ||
| 4512 | * transaction then jbd2_journal_forget() will simply | ||
| 4513 | * brelse() it. That means that if the underlying | ||
| 4514 | * block is reallocated in ext4_get_block(), | ||
| 4515 | * unmap_underlying_metadata() will find this block | ||
| 4516 | * and will try to get rid of it. damn, damn. | ||
| 4517 | * | ||
| 4518 | * If this block has already been committed to the | ||
| 4519 | * journal, a revoke record will be written. And | ||
| 4520 | * revoke records must be emitted *before* clearing | ||
| 4521 | * this block's bit in the bitmaps. | ||
| 4522 | */ | ||
| 4523 | ext4_forget(handle, 1, inode, bh, bh->b_blocknr); | ||
| 4524 | |||
| 4525 | /* | ||
| 4526 | * Everything below this this pointer has been | 4535 | * Everything below this this pointer has been |
| 4527 | * released. Now let this top-of-subtree go. | 4536 | * released. Now let this top-of-subtree go. |
| 4528 | * | 4537 | * |
| @@ -4546,8 +4555,20 @@ static void ext4_free_branches(handle_t *handle, struct inode *inode, | |||
| 4546 | blocks_for_truncate(inode)); | 4555 | blocks_for_truncate(inode)); |
| 4547 | } | 4556 | } |
| 4548 | 4557 | ||
| 4558 | /* | ||
| 4559 | * The forget flag here is critical because if | ||
| 4560 | * we are journaling (and not doing data | ||
| 4561 | * journaling), we have to make sure a revoke | ||
| 4562 | * record is written to prevent the journal | ||
| 4563 | * replay from overwriting the (former) | ||
| 4564 | * indirect block if it gets reallocated as a | ||
| 4565 | * data block. This must happen in the same | ||
| 4566 | * transaction where the data blocks are | ||
| 4567 | * actually freed. | ||
| 4568 | */ | ||
| 4549 | ext4_free_blocks(handle, inode, 0, nr, 1, | 4569 | ext4_free_blocks(handle, inode, 0, nr, 1, |
| 4550 | EXT4_FREE_BLOCKS_METADATA); | 4570 | EXT4_FREE_BLOCKS_METADATA| |
| 4571 | EXT4_FREE_BLOCKS_FORGET); | ||
| 4551 | 4572 | ||
| 4552 | if (parent_bh) { | 4573 | if (parent_bh) { |
| 4553 | /* | 4574 | /* |
| @@ -4805,8 +4826,8 @@ static int __ext4_get_inode_loc(struct inode *inode, | |||
| 4805 | 4826 | ||
| 4806 | bh = sb_getblk(sb, block); | 4827 | bh = sb_getblk(sb, block); |
| 4807 | if (!bh) { | 4828 | if (!bh) { |
| 4808 | EXT4_ERROR_INODE(inode, "unable to read inode block - " | 4829 | EXT4_ERROR_INODE_BLOCK(inode, block, |
| 4809 | "block %llu", block); | 4830 | "unable to read itable block"); |
| 4810 | return -EIO; | 4831 | return -EIO; |
| 4811 | } | 4832 | } |
| 4812 | if (!buffer_uptodate(bh)) { | 4833 | if (!buffer_uptodate(bh)) { |
| @@ -4904,8 +4925,8 @@ make_io: | |||
| 4904 | submit_bh(READ_META, bh); | 4925 | submit_bh(READ_META, bh); |
| 4905 | wait_on_buffer(bh); | 4926 | wait_on_buffer(bh); |
| 4906 | if (!buffer_uptodate(bh)) { | 4927 | if (!buffer_uptodate(bh)) { |
| 4907 | EXT4_ERROR_INODE(inode, "unable to read inode " | 4928 | EXT4_ERROR_INODE_BLOCK(inode, block, |
| 4908 | "block %llu", block); | 4929 | "unable to read itable block"); |
| 4909 | brelse(bh); | 4930 | brelse(bh); |
| 4910 | return -EIO; | 4931 | return -EIO; |
| 4911 | } | 4932 | } |
| @@ -4976,7 +4997,7 @@ static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode, | |||
| 4976 | /* we are using combined 48 bit field */ | 4997 | /* we are using combined 48 bit field */ |
| 4977 | i_blocks = ((u64)le16_to_cpu(raw_inode->i_blocks_high)) << 32 | | 4998 | i_blocks = ((u64)le16_to_cpu(raw_inode->i_blocks_high)) << 32 | |
| 4978 | le32_to_cpu(raw_inode->i_blocks_lo); | 4999 | le32_to_cpu(raw_inode->i_blocks_lo); |
| 4979 | if (ei->i_flags & EXT4_HUGE_FILE_FL) { | 5000 | if (ext4_test_inode_flag(inode, EXT4_INODE_HUGE_FILE)) { |
| 4980 | /* i_blocks represent file system block size */ | 5001 | /* i_blocks represent file system block size */ |
| 4981 | return i_blocks << (inode->i_blkbits - 9); | 5002 | return i_blocks << (inode->i_blkbits - 9); |
| 4982 | } else { | 5003 | } else { |
| @@ -5072,7 +5093,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) | |||
| 5072 | transaction_t *transaction; | 5093 | transaction_t *transaction; |
| 5073 | tid_t tid; | 5094 | tid_t tid; |
| 5074 | 5095 | ||
| 5075 | spin_lock(&journal->j_state_lock); | 5096 | read_lock(&journal->j_state_lock); |
| 5076 | if (journal->j_running_transaction) | 5097 | if (journal->j_running_transaction) |
| 5077 | transaction = journal->j_running_transaction; | 5098 | transaction = journal->j_running_transaction; |
| 5078 | else | 5099 | else |
| @@ -5081,7 +5102,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) | |||
| 5081 | tid = transaction->t_tid; | 5102 | tid = transaction->t_tid; |
| 5082 | else | 5103 | else |
| 5083 | tid = journal->j_commit_sequence; | 5104 | tid = journal->j_commit_sequence; |
| 5084 | spin_unlock(&journal->j_state_lock); | 5105 | read_unlock(&journal->j_state_lock); |
| 5085 | ei->i_sync_tid = tid; | 5106 | ei->i_sync_tid = tid; |
| 5086 | ei->i_datasync_tid = tid; | 5107 | ei->i_datasync_tid = tid; |
| 5087 | } | 5108 | } |
| @@ -5126,7 +5147,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) | |||
| 5126 | ei->i_file_acl); | 5147 | ei->i_file_acl); |
| 5127 | ret = -EIO; | 5148 | ret = -EIO; |
| 5128 | goto bad_inode; | 5149 | goto bad_inode; |
| 5129 | } else if (ei->i_flags & EXT4_EXTENTS_FL) { | 5150 | } else if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) { |
| 5130 | if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || | 5151 | if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || |
| 5131 | (S_ISLNK(inode->i_mode) && | 5152 | (S_ISLNK(inode->i_mode) && |
| 5132 | !ext4_inode_is_fast_symlink(inode))) | 5153 | !ext4_inode_is_fast_symlink(inode))) |
| @@ -5406,9 +5427,8 @@ int ext4_write_inode(struct inode *inode, struct writeback_control *wbc) | |||
| 5406 | if (wbc->sync_mode == WB_SYNC_ALL) | 5427 | if (wbc->sync_mode == WB_SYNC_ALL) |
| 5407 | sync_dirty_buffer(iloc.bh); | 5428 | sync_dirty_buffer(iloc.bh); |
| 5408 | if (buffer_req(iloc.bh) && !buffer_uptodate(iloc.bh)) { | 5429 | if (buffer_req(iloc.bh) && !buffer_uptodate(iloc.bh)) { |
| 5409 | EXT4_ERROR_INODE(inode, | 5430 | EXT4_ERROR_INODE_BLOCK(inode, iloc.bh->b_blocknr, |
| 5410 | "IO error syncing inode (block=%llu)", | 5431 | "IO error syncing inode"); |
| 5411 | (unsigned long long) iloc.bh->b_blocknr); | ||
| 5412 | err = -EIO; | 5432 | err = -EIO; |
| 5413 | } | 5433 | } |
| 5414 | brelse(iloc.bh); | 5434 | brelse(iloc.bh); |
| @@ -5483,10 +5503,8 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) | |||
| 5483 | if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) { | 5503 | if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) { |
| 5484 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); | 5504 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); |
| 5485 | 5505 | ||
| 5486 | if (attr->ia_size > sbi->s_bitmap_maxbytes) { | 5506 | if (attr->ia_size > sbi->s_bitmap_maxbytes) |
| 5487 | error = -EFBIG; | 5507 | return -EFBIG; |
| 5488 | goto err_out; | ||
| 5489 | } | ||
| 5490 | } | 5508 | } |
| 5491 | } | 5509 | } |
| 5492 | 5510 | ||
| @@ -5529,11 +5547,19 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) | |||
| 5529 | ext4_truncate(inode); | 5547 | ext4_truncate(inode); |
| 5530 | } | 5548 | } |
| 5531 | 5549 | ||
| 5532 | rc = inode_setattr(inode, attr); | 5550 | if ((attr->ia_valid & ATTR_SIZE) && |
| 5551 | attr->ia_size != i_size_read(inode)) | ||
| 5552 | rc = vmtruncate(inode, attr->ia_size); | ||
| 5553 | |||
| 5554 | if (!rc) { | ||
| 5555 | setattr_copy(inode, attr); | ||
| 5556 | mark_inode_dirty(inode); | ||
| 5557 | } | ||
| 5533 | 5558 | ||
| 5534 | /* If inode_setattr's call to ext4_truncate failed to get a | 5559 | /* |
| 5535 | * transaction handle at all, we need to clean up the in-core | 5560 | * If the call to ext4_truncate failed to get a transaction handle at |
| 5536 | * orphan list manually. */ | 5561 | * all, we need to clean up the in-core orphan list manually. |
| 5562 | */ | ||
| 5537 | if (inode->i_nlink) | 5563 | if (inode->i_nlink) |
| 5538 | ext4_orphan_del(NULL, inode); | 5564 | ext4_orphan_del(NULL, inode); |
| 5539 | 5565 | ||
| @@ -5688,7 +5714,7 @@ int ext4_writepage_trans_blocks(struct inode *inode) | |||
| 5688 | * Calculate the journal credits for a chunk of data modification. | 5714 | * Calculate the journal credits for a chunk of data modification. |
| 5689 | * | 5715 | * |
| 5690 | * This is called from DIO, fallocate or whoever calling | 5716 | * This is called from DIO, fallocate or whoever calling |
| 5691 | * ext4_get_blocks() to map/allocate a chunk of contiguous disk blocks. | 5717 | * ext4_map_blocks() to map/allocate a chunk of contiguous disk blocks. |
| 5692 | * | 5718 | * |
| 5693 | * journal buffers for data blocks are not included here, as DIO | 5719 | * journal buffers for data blocks are not included here, as DIO |
| 5694 | * and fallocate do no need to journal data buffers. | 5720 | * and fallocate do no need to journal data buffers. |
| @@ -5754,7 +5780,6 @@ static int ext4_expand_extra_isize(struct inode *inode, | |||
| 5754 | { | 5780 | { |
| 5755 | struct ext4_inode *raw_inode; | 5781 | struct ext4_inode *raw_inode; |
| 5756 | struct ext4_xattr_ibody_header *header; | 5782 | struct ext4_xattr_ibody_header *header; |
| 5757 | struct ext4_xattr_entry *entry; | ||
| 5758 | 5783 | ||
| 5759 | if (EXT4_I(inode)->i_extra_isize >= new_extra_isize) | 5784 | if (EXT4_I(inode)->i_extra_isize >= new_extra_isize) |
| 5760 | return 0; | 5785 | return 0; |
| @@ -5762,7 +5787,6 @@ static int ext4_expand_extra_isize(struct inode *inode, | |||
| 5762 | raw_inode = ext4_raw_inode(&iloc); | 5787 | raw_inode = ext4_raw_inode(&iloc); |
| 5763 | 5788 | ||
| 5764 | header = IHDR(inode, raw_inode); | 5789 | header = IHDR(inode, raw_inode); |
| 5765 | entry = IFIRST(header); | ||
| 5766 | 5790 | ||
| 5767 | /* No extended attributes present */ | 5791 | /* No extended attributes present */ |
| 5768 | if (!ext4_test_inode_state(inode, EXT4_STATE_XATTR) || | 5792 | if (!ext4_test_inode_state(inode, EXT4_STATE_XATTR) || |
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 12b3bc026a68..4b4ad4b7ce57 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
| @@ -446,10 +446,11 @@ static void mb_free_blocks_double(struct inode *inode, struct ext4_buddy *e4b, | |||
| 446 | blocknr = ext4_group_first_block_no(sb, e4b->bd_group); | 446 | blocknr = ext4_group_first_block_no(sb, e4b->bd_group); |
| 447 | blocknr += first + i; | 447 | blocknr += first + i; |
| 448 | ext4_grp_locked_error(sb, e4b->bd_group, | 448 | ext4_grp_locked_error(sb, e4b->bd_group, |
| 449 | __func__, "double-free of inode" | 449 | inode ? inode->i_ino : 0, |
| 450 | " %lu's block %llu(bit %u in group %u)", | 450 | blocknr, |
| 451 | inode ? inode->i_ino : 0, blocknr, | 451 | "freeing block already freed " |
| 452 | first + i, e4b->bd_group); | 452 | "(bit %u)", |
| 453 | first + i); | ||
| 453 | } | 454 | } |
| 454 | mb_clear_bit(first + i, e4b->bd_info->bb_bitmap); | 455 | mb_clear_bit(first + i, e4b->bd_info->bb_bitmap); |
| 455 | } | 456 | } |
| @@ -712,9 +713,9 @@ void ext4_mb_generate_buddy(struct super_block *sb, | |||
| 712 | grp->bb_fragments = fragments; | 713 | grp->bb_fragments = fragments; |
| 713 | 714 | ||
| 714 | if (free != grp->bb_free) { | 715 | if (free != grp->bb_free) { |
| 715 | ext4_grp_locked_error(sb, group, __func__, | 716 | ext4_grp_locked_error(sb, group, 0, 0, |
| 716 | "EXT4-fs: group %u: %u blocks in bitmap, %u in gd", | 717 | "%u blocks in bitmap, %u in gd", |
| 717 | group, free, grp->bb_free); | 718 | free, grp->bb_free); |
| 718 | /* | 719 | /* |
| 719 | * If we intent to continue, we consider group descritor | 720 | * If we intent to continue, we consider group descritor |
| 720 | * corrupt and update bb_free using bitmap value | 721 | * corrupt and update bb_free using bitmap value |
| @@ -1296,10 +1297,10 @@ static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b, | |||
| 1296 | blocknr = ext4_group_first_block_no(sb, e4b->bd_group); | 1297 | blocknr = ext4_group_first_block_no(sb, e4b->bd_group); |
| 1297 | blocknr += block; | 1298 | blocknr += block; |
| 1298 | ext4_grp_locked_error(sb, e4b->bd_group, | 1299 | ext4_grp_locked_error(sb, e4b->bd_group, |
| 1299 | __func__, "double-free of inode" | 1300 | inode ? inode->i_ino : 0, |
| 1300 | " %lu's block %llu(bit %u in group %u)", | 1301 | blocknr, |
| 1301 | inode ? inode->i_ino : 0, blocknr, block, | 1302 | "freeing already freed block " |
| 1302 | e4b->bd_group); | 1303 | "(bit %u)", block); |
| 1303 | } | 1304 | } |
| 1304 | mb_clear_bit(block, EXT4_MB_BITMAP(e4b)); | 1305 | mb_clear_bit(block, EXT4_MB_BITMAP(e4b)); |
| 1305 | e4b->bd_info->bb_counters[order]++; | 1306 | e4b->bd_info->bb_counters[order]++; |
| @@ -1788,8 +1789,8 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac, | |||
| 1788 | * free blocks even though group info says we | 1789 | * free blocks even though group info says we |
| 1789 | * we have free blocks | 1790 | * we have free blocks |
| 1790 | */ | 1791 | */ |
| 1791 | ext4_grp_locked_error(sb, e4b->bd_group, | 1792 | ext4_grp_locked_error(sb, e4b->bd_group, 0, 0, |
| 1792 | __func__, "%d free blocks as per " | 1793 | "%d free blocks as per " |
| 1793 | "group info. But bitmap says 0", | 1794 | "group info. But bitmap says 0", |
| 1794 | free); | 1795 | free); |
| 1795 | break; | 1796 | break; |
| @@ -1798,8 +1799,8 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac, | |||
| 1798 | mb_find_extent(e4b, 0, i, ac->ac_g_ex.fe_len, &ex); | 1799 | mb_find_extent(e4b, 0, i, ac->ac_g_ex.fe_len, &ex); |
| 1799 | BUG_ON(ex.fe_len <= 0); | 1800 | BUG_ON(ex.fe_len <= 0); |
| 1800 | if (free < ex.fe_len) { | 1801 | if (free < ex.fe_len) { |
| 1801 | ext4_grp_locked_error(sb, e4b->bd_group, | 1802 | ext4_grp_locked_error(sb, e4b->bd_group, 0, 0, |
| 1802 | __func__, "%d free blocks as per " | 1803 | "%d free blocks as per " |
| 1803 | "group info. But got %d blocks", | 1804 | "group info. But got %d blocks", |
| 1804 | free, ex.fe_len); | 1805 | free, ex.fe_len); |
| 1805 | /* | 1806 | /* |
| @@ -1821,8 +1822,7 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac, | |||
| 1821 | 1822 | ||
| 1822 | /* | 1823 | /* |
| 1823 | * This is a special case for storages like raid5 | 1824 | * This is a special case for storages like raid5 |
| 1824 | * we try to find stripe-aligned chunks for stripe-size requests | 1825 | * we try to find stripe-aligned chunks for stripe-size-multiple requests |
| 1825 | * XXX should do so at least for multiples of stripe size as well | ||
| 1826 | */ | 1826 | */ |
| 1827 | static noinline_for_stack | 1827 | static noinline_for_stack |
| 1828 | void ext4_mb_scan_aligned(struct ext4_allocation_context *ac, | 1828 | void ext4_mb_scan_aligned(struct ext4_allocation_context *ac, |
| @@ -1999,7 +1999,6 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac) | |||
| 1999 | ext4_group_t ngroups, group, i; | 1999 | ext4_group_t ngroups, group, i; |
| 2000 | int cr; | 2000 | int cr; |
| 2001 | int err = 0; | 2001 | int err = 0; |
| 2002 | int bsbits; | ||
| 2003 | struct ext4_sb_info *sbi; | 2002 | struct ext4_sb_info *sbi; |
| 2004 | struct super_block *sb; | 2003 | struct super_block *sb; |
| 2005 | struct ext4_buddy e4b; | 2004 | struct ext4_buddy e4b; |
| @@ -2041,8 +2040,6 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac) | |||
| 2041 | ac->ac_2order = i - 1; | 2040 | ac->ac_2order = i - 1; |
| 2042 | } | 2041 | } |
| 2043 | 2042 | ||
| 2044 | bsbits = ac->ac_sb->s_blocksize_bits; | ||
| 2045 | |||
| 2046 | /* if stream allocation is enabled, use global goal */ | 2043 | /* if stream allocation is enabled, use global goal */ |
| 2047 | if (ac->ac_flags & EXT4_MB_STREAM_ALLOC) { | 2044 | if (ac->ac_flags & EXT4_MB_STREAM_ALLOC) { |
| 2048 | /* TBD: may be hot point */ | 2045 | /* TBD: may be hot point */ |
| @@ -2094,8 +2091,8 @@ repeat: | |||
| 2094 | ac->ac_groups_scanned++; | 2091 | ac->ac_groups_scanned++; |
| 2095 | if (cr == 0) | 2092 | if (cr == 0) |
| 2096 | ext4_mb_simple_scan_group(ac, &e4b); | 2093 | ext4_mb_simple_scan_group(ac, &e4b); |
| 2097 | else if (cr == 1 && | 2094 | else if (cr == 1 && sbi->s_stripe && |
| 2098 | ac->ac_g_ex.fe_len == sbi->s_stripe) | 2095 | !(ac->ac_g_ex.fe_len % sbi->s_stripe)) |
| 2099 | ext4_mb_scan_aligned(ac, &e4b); | 2096 | ext4_mb_scan_aligned(ac, &e4b); |
| 2100 | else | 2097 | else |
| 2101 | ext4_mb_complex_scan_group(ac, &e4b); | 2098 | ext4_mb_complex_scan_group(ac, &e4b); |
| @@ -2221,7 +2218,7 @@ static int ext4_mb_seq_groups_open(struct inode *inode, struct file *file) | |||
| 2221 | 2218 | ||
| 2222 | rc = seq_open(file, &ext4_mb_seq_groups_ops); | 2219 | rc = seq_open(file, &ext4_mb_seq_groups_ops); |
| 2223 | if (rc == 0) { | 2220 | if (rc == 0) { |
| 2224 | struct seq_file *m = (struct seq_file *)file->private_data; | 2221 | struct seq_file *m = file->private_data; |
| 2225 | m->private = sb; | 2222 | m->private = sb; |
| 2226 | } | 2223 | } |
| 2227 | return rc; | 2224 | return rc; |
| @@ -2560,6 +2557,22 @@ int ext4_mb_release(struct super_block *sb) | |||
| 2560 | return 0; | 2557 | return 0; |
| 2561 | } | 2558 | } |
| 2562 | 2559 | ||
| 2560 | static inline void ext4_issue_discard(struct super_block *sb, | ||
| 2561 | ext4_group_t block_group, ext4_grpblk_t block, int count) | ||
| 2562 | { | ||
| 2563 | int ret; | ||
| 2564 | ext4_fsblk_t discard_block; | ||
| 2565 | |||
| 2566 | discard_block = block + ext4_group_first_block_no(sb, block_group); | ||
| 2567 | trace_ext4_discard_blocks(sb, | ||
| 2568 | (unsigned long long) discard_block, count); | ||
| 2569 | ret = sb_issue_discard(sb, discard_block, count); | ||
| 2570 | if (ret == EOPNOTSUPP) { | ||
| 2571 | ext4_warning(sb, "discard not supported, disabling"); | ||
| 2572 | clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD); | ||
| 2573 | } | ||
| 2574 | } | ||
| 2575 | |||
| 2563 | /* | 2576 | /* |
| 2564 | * This function is called by the jbd2 layer once the commit has finished, | 2577 | * This function is called by the jbd2 layer once the commit has finished, |
| 2565 | * so we know we can free the blocks that were released with that commit. | 2578 | * so we know we can free the blocks that were released with that commit. |
| @@ -2579,22 +2592,9 @@ static void release_blocks_on_commit(journal_t *journal, transaction_t *txn) | |||
| 2579 | mb_debug(1, "gonna free %u blocks in group %u (0x%p):", | 2592 | mb_debug(1, "gonna free %u blocks in group %u (0x%p):", |
| 2580 | entry->count, entry->group, entry); | 2593 | entry->count, entry->group, entry); |
| 2581 | 2594 | ||
| 2582 | if (test_opt(sb, DISCARD)) { | 2595 | if (test_opt(sb, DISCARD)) |
| 2583 | int ret; | 2596 | ext4_issue_discard(sb, entry->group, |
| 2584 | ext4_fsblk_t discard_block; | 2597 | entry->start_blk, entry->count); |
| 2585 | |||
| 2586 | discard_block = entry->start_blk + | ||
| 2587 | ext4_group_first_block_no(sb, entry->group); | ||
| 2588 | trace_ext4_discard_blocks(sb, | ||
| 2589 | (unsigned long long)discard_block, | ||
| 2590 | entry->count); | ||
| 2591 | ret = sb_issue_discard(sb, discard_block, entry->count); | ||
| 2592 | if (ret == EOPNOTSUPP) { | ||
| 2593 | ext4_warning(sb, | ||
| 2594 | "discard not supported, disabling"); | ||
| 2595 | clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD); | ||
| 2596 | } | ||
| 2597 | } | ||
| 2598 | 2598 | ||
| 2599 | err = ext4_mb_load_buddy(sb, entry->group, &e4b); | 2599 | err = ext4_mb_load_buddy(sb, entry->group, &e4b); |
| 2600 | /* we expect to find existing buddy because it's pinned */ | 2600 | /* we expect to find existing buddy because it's pinned */ |
| @@ -2704,7 +2704,7 @@ void exit_ext4_mballoc(void) | |||
| 2704 | 2704 | ||
| 2705 | 2705 | ||
| 2706 | /* | 2706 | /* |
| 2707 | * Check quota and mark choosed space (ac->ac_b_ex) non-free in bitmaps | 2707 | * Check quota and mark chosen space (ac->ac_b_ex) non-free in bitmaps |
| 2708 | * Returns 0 if success or error code | 2708 | * Returns 0 if success or error code |
| 2709 | */ | 2709 | */ |
| 2710 | static noinline_for_stack int | 2710 | static noinline_for_stack int |
| @@ -2712,7 +2712,6 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac, | |||
| 2712 | handle_t *handle, unsigned int reserv_blks) | 2712 | handle_t *handle, unsigned int reserv_blks) |
| 2713 | { | 2713 | { |
| 2714 | struct buffer_head *bitmap_bh = NULL; | 2714 | struct buffer_head *bitmap_bh = NULL; |
| 2715 | struct ext4_super_block *es; | ||
| 2716 | struct ext4_group_desc *gdp; | 2715 | struct ext4_group_desc *gdp; |
| 2717 | struct buffer_head *gdp_bh; | 2716 | struct buffer_head *gdp_bh; |
| 2718 | struct ext4_sb_info *sbi; | 2717 | struct ext4_sb_info *sbi; |
| @@ -2725,8 +2724,6 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac, | |||
| 2725 | 2724 | ||
| 2726 | sb = ac->ac_sb; | 2725 | sb = ac->ac_sb; |
| 2727 | sbi = EXT4_SB(sb); | 2726 | sbi = EXT4_SB(sb); |
| 2728 | es = sbi->s_es; | ||
| 2729 | |||
| 2730 | 2727 | ||
| 2731 | err = -EIO; | 2728 | err = -EIO; |
| 2732 | bitmap_bh = ext4_read_block_bitmap(sb, ac->ac_b_ex.fe_group); | 2729 | bitmap_bh = ext4_read_block_bitmap(sb, ac->ac_b_ex.fe_group); |
| @@ -2812,7 +2809,7 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac, | |||
| 2812 | err = ext4_handle_dirty_metadata(handle, NULL, gdp_bh); | 2809 | err = ext4_handle_dirty_metadata(handle, NULL, gdp_bh); |
| 2813 | 2810 | ||
| 2814 | out_err: | 2811 | out_err: |
| 2815 | sb->s_dirt = 1; | 2812 | ext4_mark_super_dirty(sb); |
| 2816 | brelse(bitmap_bh); | 2813 | brelse(bitmap_bh); |
| 2817 | return err; | 2814 | return err; |
| 2818 | } | 2815 | } |
| @@ -2850,7 +2847,7 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac, | |||
| 2850 | int bsbits, max; | 2847 | int bsbits, max; |
| 2851 | ext4_lblk_t end; | 2848 | ext4_lblk_t end; |
| 2852 | loff_t size, orig_size, start_off; | 2849 | loff_t size, orig_size, start_off; |
| 2853 | ext4_lblk_t start, orig_start; | 2850 | ext4_lblk_t start; |
| 2854 | struct ext4_inode_info *ei = EXT4_I(ac->ac_inode); | 2851 | struct ext4_inode_info *ei = EXT4_I(ac->ac_inode); |
| 2855 | struct ext4_prealloc_space *pa; | 2852 | struct ext4_prealloc_space *pa; |
| 2856 | 2853 | ||
| @@ -2881,6 +2878,7 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac, | |||
| 2881 | size = size << bsbits; | 2878 | size = size << bsbits; |
| 2882 | if (size < i_size_read(ac->ac_inode)) | 2879 | if (size < i_size_read(ac->ac_inode)) |
| 2883 | size = i_size_read(ac->ac_inode); | 2880 | size = i_size_read(ac->ac_inode); |
| 2881 | orig_size = size; | ||
| 2884 | 2882 | ||
| 2885 | /* max size of free chunks */ | 2883 | /* max size of free chunks */ |
| 2886 | max = 2 << bsbits; | 2884 | max = 2 << bsbits; |
| @@ -2922,8 +2920,8 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac, | |||
| 2922 | start_off = (loff_t)ac->ac_o_ex.fe_logical << bsbits; | 2920 | start_off = (loff_t)ac->ac_o_ex.fe_logical << bsbits; |
| 2923 | size = ac->ac_o_ex.fe_len << bsbits; | 2921 | size = ac->ac_o_ex.fe_len << bsbits; |
| 2924 | } | 2922 | } |
| 2925 | orig_size = size = size >> bsbits; | 2923 | size = size >> bsbits; |
| 2926 | orig_start = start = start_off >> bsbits; | 2924 | start = start_off >> bsbits; |
| 2927 | 2925 | ||
| 2928 | /* don't cover already allocated blocks in selected range */ | 2926 | /* don't cover already allocated blocks in selected range */ |
| 2929 | if (ar->pleft && start <= ar->lleft) { | 2927 | if (ar->pleft && start <= ar->lleft) { |
| @@ -3547,7 +3545,6 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh, | |||
| 3547 | ext4_group_t group; | 3545 | ext4_group_t group; |
| 3548 | ext4_grpblk_t bit; | 3546 | ext4_grpblk_t bit; |
| 3549 | unsigned long long grp_blk_start; | 3547 | unsigned long long grp_blk_start; |
| 3550 | sector_t start; | ||
| 3551 | int err = 0; | 3548 | int err = 0; |
| 3552 | int free = 0; | 3549 | int free = 0; |
| 3553 | 3550 | ||
| @@ -3567,10 +3564,9 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh, | |||
| 3567 | if (bit >= end) | 3564 | if (bit >= end) |
| 3568 | break; | 3565 | break; |
| 3569 | next = mb_find_next_bit(bitmap_bh->b_data, end, bit); | 3566 | next = mb_find_next_bit(bitmap_bh->b_data, end, bit); |
| 3570 | start = ext4_group_first_block_no(sb, group) + bit; | ||
| 3571 | mb_debug(1, " free preallocated %u/%u in group %u\n", | 3567 | mb_debug(1, " free preallocated %u/%u in group %u\n", |
| 3572 | (unsigned) start, (unsigned) next - bit, | 3568 | (unsigned) ext4_group_first_block_no(sb, group) + bit, |
| 3573 | (unsigned) group); | 3569 | (unsigned) next - bit, (unsigned) group); |
| 3574 | free += next - bit; | 3570 | free += next - bit; |
| 3575 | 3571 | ||
| 3576 | if (ac) { | 3572 | if (ac) { |
| @@ -3581,7 +3577,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh, | |||
| 3581 | trace_ext4_mballoc_discard(ac); | 3577 | trace_ext4_mballoc_discard(ac); |
| 3582 | } | 3578 | } |
| 3583 | 3579 | ||
| 3584 | trace_ext4_mb_release_inode_pa(ac, pa, grp_blk_start + bit, | 3580 | trace_ext4_mb_release_inode_pa(sb, ac, pa, grp_blk_start + bit, |
| 3585 | next - bit); | 3581 | next - bit); |
| 3586 | mb_free_blocks(pa->pa_inode, e4b, bit, next - bit); | 3582 | mb_free_blocks(pa->pa_inode, e4b, bit, next - bit); |
| 3587 | bit = next + 1; | 3583 | bit = next + 1; |
| @@ -3591,8 +3587,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh, | |||
| 3591 | pa, (unsigned long) pa->pa_lstart, | 3587 | pa, (unsigned long) pa->pa_lstart, |
| 3592 | (unsigned long) pa->pa_pstart, | 3588 | (unsigned long) pa->pa_pstart, |
| 3593 | (unsigned long) pa->pa_len); | 3589 | (unsigned long) pa->pa_len); |
| 3594 | ext4_grp_locked_error(sb, group, | 3590 | ext4_grp_locked_error(sb, group, 0, 0, "free %u, pa_free %u", |
| 3595 | __func__, "free %u, pa_free %u", | ||
| 3596 | free, pa->pa_free); | 3591 | free, pa->pa_free); |
| 3597 | /* | 3592 | /* |
| 3598 | * pa is already deleted so we use the value obtained | 3593 | * pa is already deleted so we use the value obtained |
| @@ -3613,7 +3608,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b, | |||
| 3613 | ext4_group_t group; | 3608 | ext4_group_t group; |
| 3614 | ext4_grpblk_t bit; | 3609 | ext4_grpblk_t bit; |
| 3615 | 3610 | ||
| 3616 | trace_ext4_mb_release_group_pa(ac, pa); | 3611 | trace_ext4_mb_release_group_pa(sb, ac, pa); |
| 3617 | BUG_ON(pa->pa_deleted == 0); | 3612 | BUG_ON(pa->pa_deleted == 0); |
| 3618 | ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit); | 3613 | ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit); |
| 3619 | BUG_ON(group != e4b->bd_group && pa->pa_len != 0); | 3614 | BUG_ON(group != e4b->bd_group && pa->pa_len != 0); |
| @@ -3889,6 +3884,9 @@ static void ext4_mb_show_ac(struct ext4_allocation_context *ac) | |||
| 3889 | struct super_block *sb = ac->ac_sb; | 3884 | struct super_block *sb = ac->ac_sb; |
| 3890 | ext4_group_t ngroups, i; | 3885 | ext4_group_t ngroups, i; |
| 3891 | 3886 | ||
| 3887 | if (EXT4_SB(sb)->s_mount_flags & EXT4_MF_FS_ABORTED) | ||
| 3888 | return; | ||
| 3889 | |||
| 3892 | printk(KERN_ERR "EXT4-fs: Can't allocate:" | 3890 | printk(KERN_ERR "EXT4-fs: Can't allocate:" |
| 3893 | " Allocation context details:\n"); | 3891 | " Allocation context details:\n"); |
| 3894 | printk(KERN_ERR "EXT4-fs: status %d flags %d\n", | 3892 | printk(KERN_ERR "EXT4-fs: status %d flags %d\n", |
| @@ -4255,7 +4253,7 @@ static int ext4_mb_discard_preallocations(struct super_block *sb, int needed) | |||
| 4255 | * to usual allocation | 4253 | * to usual allocation |
| 4256 | */ | 4254 | */ |
| 4257 | ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, | 4255 | ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, |
| 4258 | struct ext4_allocation_request *ar, int *errp) | 4256 | struct ext4_allocation_request *ar, int *errp) |
| 4259 | { | 4257 | { |
| 4260 | int freed; | 4258 | int freed; |
| 4261 | struct ext4_allocation_context *ac = NULL; | 4259 | struct ext4_allocation_context *ac = NULL; |
| @@ -4299,7 +4297,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, | |||
| 4299 | inquota = ar->len; | 4297 | inquota = ar->len; |
| 4300 | if (ar->len == 0) { | 4298 | if (ar->len == 0) { |
| 4301 | *errp = -EDQUOT; | 4299 | *errp = -EDQUOT; |
| 4302 | goto out3; | 4300 | goto out; |
| 4303 | } | 4301 | } |
| 4304 | } | 4302 | } |
| 4305 | 4303 | ||
| @@ -4307,13 +4305,13 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, | |||
| 4307 | if (!ac) { | 4305 | if (!ac) { |
| 4308 | ar->len = 0; | 4306 | ar->len = 0; |
| 4309 | *errp = -ENOMEM; | 4307 | *errp = -ENOMEM; |
| 4310 | goto out1; | 4308 | goto out; |
| 4311 | } | 4309 | } |
| 4312 | 4310 | ||
| 4313 | *errp = ext4_mb_initialize_context(ac, ar); | 4311 | *errp = ext4_mb_initialize_context(ac, ar); |
| 4314 | if (*errp) { | 4312 | if (*errp) { |
| 4315 | ar->len = 0; | 4313 | ar->len = 0; |
| 4316 | goto out2; | 4314 | goto out; |
| 4317 | } | 4315 | } |
| 4318 | 4316 | ||
| 4319 | ac->ac_op = EXT4_MB_HISTORY_PREALLOC; | 4317 | ac->ac_op = EXT4_MB_HISTORY_PREALLOC; |
| @@ -4322,7 +4320,9 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, | |||
| 4322 | ext4_mb_normalize_request(ac, ar); | 4320 | ext4_mb_normalize_request(ac, ar); |
| 4323 | repeat: | 4321 | repeat: |
| 4324 | /* allocate space in core */ | 4322 | /* allocate space in core */ |
| 4325 | ext4_mb_regular_allocator(ac); | 4323 | *errp = ext4_mb_regular_allocator(ac); |
| 4324 | if (*errp) | ||
| 4325 | goto errout; | ||
| 4326 | 4326 | ||
| 4327 | /* as we've just preallocated more space than | 4327 | /* as we've just preallocated more space than |
| 4328 | * user requested orinally, we store allocated | 4328 | * user requested orinally, we store allocated |
| @@ -4333,7 +4333,7 @@ repeat: | |||
| 4333 | } | 4333 | } |
| 4334 | if (likely(ac->ac_status == AC_STATUS_FOUND)) { | 4334 | if (likely(ac->ac_status == AC_STATUS_FOUND)) { |
| 4335 | *errp = ext4_mb_mark_diskspace_used(ac, handle, reserv_blks); | 4335 | *errp = ext4_mb_mark_diskspace_used(ac, handle, reserv_blks); |
| 4336 | if (*errp == -EAGAIN) { | 4336 | if (*errp == -EAGAIN) { |
| 4337 | /* | 4337 | /* |
| 4338 | * drop the reference that we took | 4338 | * drop the reference that we took |
| 4339 | * in ext4_mb_use_best_found | 4339 | * in ext4_mb_use_best_found |
| @@ -4344,12 +4344,10 @@ repeat: | |||
| 4344 | ac->ac_b_ex.fe_len = 0; | 4344 | ac->ac_b_ex.fe_len = 0; |
| 4345 | ac->ac_status = AC_STATUS_CONTINUE; | 4345 | ac->ac_status = AC_STATUS_CONTINUE; |
| 4346 | goto repeat; | 4346 | goto repeat; |
| 4347 | } else if (*errp) { | 4347 | } else if (*errp) |
| 4348 | errout: | ||
| 4348 | ext4_discard_allocated_blocks(ac); | 4349 | ext4_discard_allocated_blocks(ac); |
| 4349 | ac->ac_b_ex.fe_len = 0; | 4350 | else { |
| 4350 | ar->len = 0; | ||
| 4351 | ext4_mb_show_ac(ac); | ||
| 4352 | } else { | ||
| 4353 | block = ext4_grp_offs_to_block(sb, &ac->ac_b_ex); | 4351 | block = ext4_grp_offs_to_block(sb, &ac->ac_b_ex); |
| 4354 | ar->len = ac->ac_b_ex.fe_len; | 4352 | ar->len = ac->ac_b_ex.fe_len; |
| 4355 | } | 4353 | } |
| @@ -4358,19 +4356,19 @@ repeat: | |||
| 4358 | if (freed) | 4356 | if (freed) |
| 4359 | goto repeat; | 4357 | goto repeat; |
| 4360 | *errp = -ENOSPC; | 4358 | *errp = -ENOSPC; |
| 4359 | } | ||
| 4360 | |||
| 4361 | if (*errp) { | ||
| 4361 | ac->ac_b_ex.fe_len = 0; | 4362 | ac->ac_b_ex.fe_len = 0; |
| 4362 | ar->len = 0; | 4363 | ar->len = 0; |
| 4363 | ext4_mb_show_ac(ac); | 4364 | ext4_mb_show_ac(ac); |
| 4364 | } | 4365 | } |
| 4365 | |||
| 4366 | ext4_mb_release_context(ac); | 4366 | ext4_mb_release_context(ac); |
| 4367 | 4367 | out: | |
| 4368 | out2: | 4368 | if (ac) |
| 4369 | kmem_cache_free(ext4_ac_cachep, ac); | 4369 | kmem_cache_free(ext4_ac_cachep, ac); |
| 4370 | out1: | ||
| 4371 | if (inquota && ar->len < inquota) | 4370 | if (inquota && ar->len < inquota) |
| 4372 | dquot_free_block(ar->inode, inquota - ar->len); | 4371 | dquot_free_block(ar->inode, inquota - ar->len); |
| 4373 | out3: | ||
| 4374 | if (!ar->len) { | 4372 | if (!ar->len) { |
| 4375 | if (!EXT4_I(ar->inode)->i_delalloc_reserved_flag) | 4373 | if (!EXT4_I(ar->inode)->i_delalloc_reserved_flag) |
| 4376 | /* release all the reserved blocks if non delalloc */ | 4374 | /* release all the reserved blocks if non delalloc */ |
| @@ -4402,6 +4400,7 @@ static noinline_for_stack int | |||
| 4402 | ext4_mb_free_metadata(handle_t *handle, struct ext4_buddy *e4b, | 4400 | ext4_mb_free_metadata(handle_t *handle, struct ext4_buddy *e4b, |
| 4403 | struct ext4_free_data *new_entry) | 4401 | struct ext4_free_data *new_entry) |
| 4404 | { | 4402 | { |
| 4403 | ext4_group_t group = e4b->bd_group; | ||
| 4405 | ext4_grpblk_t block; | 4404 | ext4_grpblk_t block; |
| 4406 | struct ext4_free_data *entry; | 4405 | struct ext4_free_data *entry; |
| 4407 | struct ext4_group_info *db = e4b->bd_info; | 4406 | struct ext4_group_info *db = e4b->bd_info; |
| @@ -4434,9 +4433,9 @@ ext4_mb_free_metadata(handle_t *handle, struct ext4_buddy *e4b, | |||
| 4434 | else if (block >= (entry->start_blk + entry->count)) | 4433 | else if (block >= (entry->start_blk + entry->count)) |
| 4435 | n = &(*n)->rb_right; | 4434 | n = &(*n)->rb_right; |
| 4436 | else { | 4435 | else { |
| 4437 | ext4_grp_locked_error(sb, e4b->bd_group, __func__, | 4436 | ext4_grp_locked_error(sb, group, 0, |
| 4438 | "Double free of blocks %d (%d %d)", | 4437 | ext4_group_first_block_no(sb, group) + block, |
| 4439 | block, entry->start_blk, entry->count); | 4438 | "Block already on to-be-freed list"); |
| 4440 | return 0; | 4439 | return 0; |
| 4441 | } | 4440 | } |
| 4442 | } | 4441 | } |
| @@ -4494,7 +4493,6 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode, | |||
| 4494 | struct super_block *sb = inode->i_sb; | 4493 | struct super_block *sb = inode->i_sb; |
| 4495 | struct ext4_allocation_context *ac = NULL; | 4494 | struct ext4_allocation_context *ac = NULL; |
| 4496 | struct ext4_group_desc *gdp; | 4495 | struct ext4_group_desc *gdp; |
| 4497 | struct ext4_super_block *es; | ||
| 4498 | unsigned long freed = 0; | 4496 | unsigned long freed = 0; |
| 4499 | unsigned int overflow; | 4497 | unsigned int overflow; |
| 4500 | ext4_grpblk_t bit; | 4498 | ext4_grpblk_t bit; |
| @@ -4513,7 +4511,6 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode, | |||
| 4513 | } | 4511 | } |
| 4514 | 4512 | ||
| 4515 | sbi = EXT4_SB(sb); | 4513 | sbi = EXT4_SB(sb); |
| 4516 | es = EXT4_SB(sb)->s_es; | ||
| 4517 | if (!(flags & EXT4_FREE_BLOCKS_VALIDATED) && | 4514 | if (!(flags & EXT4_FREE_BLOCKS_VALIDATED) && |
| 4518 | !ext4_data_block_valid(sbi, block, count)) { | 4515 | !ext4_data_block_valid(sbi, block, count)) { |
| 4519 | ext4_error(sb, "Freeing blocks not in datazone - " | 4516 | ext4_error(sb, "Freeing blocks not in datazone - " |
| @@ -4647,6 +4644,8 @@ do_more: | |||
| 4647 | mb_clear_bits(bitmap_bh->b_data, bit, count); | 4644 | mb_clear_bits(bitmap_bh->b_data, bit, count); |
| 4648 | mb_free_blocks(inode, &e4b, bit, count); | 4645 | mb_free_blocks(inode, &e4b, bit, count); |
| 4649 | ext4_mb_return_to_preallocation(inode, &e4b, block, count); | 4646 | ext4_mb_return_to_preallocation(inode, &e4b, block, count); |
| 4647 | if (test_opt(sb, DISCARD)) | ||
| 4648 | ext4_issue_discard(sb, block_group, bit, count); | ||
| 4650 | } | 4649 | } |
| 4651 | 4650 | ||
| 4652 | ret = ext4_free_blks_count(sb, gdp) + count; | 4651 | ret = ext4_free_blks_count(sb, gdp) + count; |
| @@ -4680,7 +4679,7 @@ do_more: | |||
| 4680 | put_bh(bitmap_bh); | 4679 | put_bh(bitmap_bh); |
| 4681 | goto do_more; | 4680 | goto do_more; |
| 4682 | } | 4681 | } |
| 4683 | sb->s_dirt = 1; | 4682 | ext4_mark_super_dirty(sb); |
| 4684 | error_return: | 4683 | error_return: |
| 4685 | if (freed) | 4684 | if (freed) |
| 4686 | dquot_free_block(inode, freed); | 4685 | dquot_free_block(inode, freed); |
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c index 6f3a27ec30bf..1765c2c50a9b 100644 --- a/fs/ext4/migrate.c +++ b/fs/ext4/migrate.c | |||
| @@ -376,7 +376,7 @@ static int ext4_ext_swap_inode_data(handle_t *handle, struct inode *inode, | |||
| 376 | * We have the extent map build with the tmp inode. | 376 | * We have the extent map build with the tmp inode. |
| 377 | * Now copy the i_data across | 377 | * Now copy the i_data across |
| 378 | */ | 378 | */ |
| 379 | ei->i_flags |= EXT4_EXTENTS_FL; | 379 | ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS); |
| 380 | memcpy(ei->i_data, tmp_ei->i_data, sizeof(ei->i_data)); | 380 | memcpy(ei->i_data, tmp_ei->i_data, sizeof(ei->i_data)); |
| 381 | 381 | ||
| 382 | /* | 382 | /* |
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c index 52abfa12762a..5f1ed9fc913c 100644 --- a/fs/ext4/move_extent.c +++ b/fs/ext4/move_extent.c | |||
| @@ -148,17 +148,17 @@ mext_next_extent(struct inode *inode, struct ext4_ext_path *path, | |||
| 148 | */ | 148 | */ |
| 149 | static int | 149 | static int |
| 150 | mext_check_null_inode(struct inode *inode1, struct inode *inode2, | 150 | mext_check_null_inode(struct inode *inode1, struct inode *inode2, |
| 151 | const char *function) | 151 | const char *function, unsigned int line) |
| 152 | { | 152 | { |
| 153 | int ret = 0; | 153 | int ret = 0; |
| 154 | 154 | ||
| 155 | if (inode1 == NULL) { | 155 | if (inode1 == NULL) { |
| 156 | __ext4_error(inode2->i_sb, function, | 156 | __ext4_error(inode2->i_sb, function, line, |
| 157 | "Both inodes should not be NULL: " | 157 | "Both inodes should not be NULL: " |
| 158 | "inode1 NULL inode2 %lu", inode2->i_ino); | 158 | "inode1 NULL inode2 %lu", inode2->i_ino); |
| 159 | ret = -EIO; | 159 | ret = -EIO; |
| 160 | } else if (inode2 == NULL) { | 160 | } else if (inode2 == NULL) { |
| 161 | __ext4_error(inode1->i_sb, function, | 161 | __ext4_error(inode1->i_sb, function, line, |
| 162 | "Both inodes should not be NULL: " | 162 | "Both inodes should not be NULL: " |
| 163 | "inode1 %lu inode2 NULL", inode1->i_ino); | 163 | "inode1 %lu inode2 NULL", inode1->i_ino); |
| 164 | ret = -EIO; | 164 | ret = -EIO; |
| @@ -1084,7 +1084,7 @@ mext_inode_double_lock(struct inode *inode1, struct inode *inode2) | |||
| 1084 | 1084 | ||
| 1085 | BUG_ON(inode1 == NULL && inode2 == NULL); | 1085 | BUG_ON(inode1 == NULL && inode2 == NULL); |
| 1086 | 1086 | ||
| 1087 | ret = mext_check_null_inode(inode1, inode2, __func__); | 1087 | ret = mext_check_null_inode(inode1, inode2, __func__, __LINE__); |
| 1088 | if (ret < 0) | 1088 | if (ret < 0) |
| 1089 | goto out; | 1089 | goto out; |
| 1090 | 1090 | ||
| @@ -1121,7 +1121,7 @@ mext_inode_double_unlock(struct inode *inode1, struct inode *inode2) | |||
| 1121 | 1121 | ||
| 1122 | BUG_ON(inode1 == NULL && inode2 == NULL); | 1122 | BUG_ON(inode1 == NULL && inode2 == NULL); |
| 1123 | 1123 | ||
| 1124 | ret = mext_check_null_inode(inode1, inode2, __func__); | 1124 | ret = mext_check_null_inode(inode1, inode2, __func__, __LINE__); |
| 1125 | if (ret < 0) | 1125 | if (ret < 0) |
| 1126 | goto out; | 1126 | goto out; |
| 1127 | 1127 | ||
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index a43e6617b351..314c0d3b3fa9 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
| @@ -179,30 +179,6 @@ static struct buffer_head * ext4_dx_find_entry(struct inode *dir, | |||
| 179 | static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, | 179 | static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, |
| 180 | struct inode *inode); | 180 | struct inode *inode); |
| 181 | 181 | ||
| 182 | unsigned int ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize) | ||
| 183 | { | ||
| 184 | unsigned len = le16_to_cpu(dlen); | ||
| 185 | |||
| 186 | if (len == EXT4_MAX_REC_LEN || len == 0) | ||
| 187 | return blocksize; | ||
| 188 | return (len & 65532) | ((len & 3) << 16); | ||
| 189 | } | ||
| 190 | |||
| 191 | __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize) | ||
| 192 | { | ||
| 193 | if ((len > blocksize) || (blocksize > (1 << 18)) || (len & 3)) | ||
| 194 | BUG(); | ||
| 195 | if (len < 65536) | ||
| 196 | return cpu_to_le16(len); | ||
| 197 | if (len == blocksize) { | ||
| 198 | if (blocksize == 65536) | ||
| 199 | return cpu_to_le16(EXT4_MAX_REC_LEN); | ||
| 200 | else | ||
| 201 | return cpu_to_le16(0); | ||
| 202 | } | ||
| 203 | return cpu_to_le16((len & 65532) | ((len >> 16) & 3)); | ||
| 204 | } | ||
| 205 | |||
| 206 | /* | 182 | /* |
| 207 | * p is at least 6 bytes before the end of page | 183 | * p is at least 6 bytes before the end of page |
| 208 | */ | 184 | */ |
| @@ -605,7 +581,7 @@ static int htree_dirblock_to_tree(struct file *dir_file, | |||
| 605 | dir->i_sb->s_blocksize - | 581 | dir->i_sb->s_blocksize - |
| 606 | EXT4_DIR_REC_LEN(0)); | 582 | EXT4_DIR_REC_LEN(0)); |
| 607 | for (; de < top; de = ext4_next_entry(de, dir->i_sb->s_blocksize)) { | 583 | for (; de < top; de = ext4_next_entry(de, dir->i_sb->s_blocksize)) { |
| 608 | if (!ext4_check_dir_entry("htree_dirblock_to_tree", dir, de, bh, | 584 | if (!ext4_check_dir_entry(dir, de, bh, |
| 609 | (block<<EXT4_BLOCK_SIZE_BITS(dir->i_sb)) | 585 | (block<<EXT4_BLOCK_SIZE_BITS(dir->i_sb)) |
| 610 | +((char *)de - bh->b_data))) { | 586 | +((char *)de - bh->b_data))) { |
| 611 | /* On error, skip the f_pos to the next block. */ | 587 | /* On error, skip the f_pos to the next block. */ |
| @@ -844,8 +820,7 @@ static inline int search_dirblock(struct buffer_head *bh, | |||
| 844 | if ((char *) de + namelen <= dlimit && | 820 | if ((char *) de + namelen <= dlimit && |
| 845 | ext4_match (namelen, name, de)) { | 821 | ext4_match (namelen, name, de)) { |
| 846 | /* found a match - just to be sure, do a full check */ | 822 | /* found a match - just to be sure, do a full check */ |
| 847 | if (!ext4_check_dir_entry("ext4_find_entry", | 823 | if (!ext4_check_dir_entry(dir, de, bh, offset)) |
| 848 | dir, de, bh, offset)) | ||
| 849 | return -1; | 824 | return -1; |
| 850 | *res_dir = de; | 825 | *res_dir = de; |
| 851 | return 1; | 826 | return 1; |
| @@ -1019,7 +994,7 @@ static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct q | |||
| 1019 | int off = (block << EXT4_BLOCK_SIZE_BITS(sb)) | 994 | int off = (block << EXT4_BLOCK_SIZE_BITS(sb)) |
| 1020 | + ((char *) de - bh->b_data); | 995 | + ((char *) de - bh->b_data); |
| 1021 | 996 | ||
| 1022 | if (!ext4_check_dir_entry(__func__, dir, de, bh, off)) { | 997 | if (!ext4_check_dir_entry(dir, de, bh, off)) { |
| 1023 | brelse(bh); | 998 | brelse(bh); |
| 1024 | *err = ERR_BAD_DX_DIR; | 999 | *err = ERR_BAD_DX_DIR; |
| 1025 | goto errout; | 1000 | goto errout; |
| @@ -1088,7 +1063,6 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, stru | |||
| 1088 | struct dentry *ext4_get_parent(struct dentry *child) | 1063 | struct dentry *ext4_get_parent(struct dentry *child) |
| 1089 | { | 1064 | { |
| 1090 | __u32 ino; | 1065 | __u32 ino; |
| 1091 | struct inode *inode; | ||
| 1092 | static const struct qstr dotdot = { | 1066 | static const struct qstr dotdot = { |
| 1093 | .name = "..", | 1067 | .name = "..", |
| 1094 | .len = 2, | 1068 | .len = 2, |
| @@ -1097,7 +1071,6 @@ struct dentry *ext4_get_parent(struct dentry *child) | |||
| 1097 | struct buffer_head *bh; | 1071 | struct buffer_head *bh; |
| 1098 | 1072 | ||
| 1099 | bh = ext4_find_entry(child->d_inode, &dotdot, &de); | 1073 | bh = ext4_find_entry(child->d_inode, &dotdot, &de); |
| 1100 | inode = NULL; | ||
| 1101 | if (!bh) | 1074 | if (!bh) |
| 1102 | return ERR_PTR(-ENOENT); | 1075 | return ERR_PTR(-ENOENT); |
| 1103 | ino = le32_to_cpu(de->inode); | 1076 | ino = le32_to_cpu(de->inode); |
| @@ -1305,8 +1278,7 @@ static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry, | |||
| 1305 | de = (struct ext4_dir_entry_2 *)bh->b_data; | 1278 | de = (struct ext4_dir_entry_2 *)bh->b_data; |
| 1306 | top = bh->b_data + blocksize - reclen; | 1279 | top = bh->b_data + blocksize - reclen; |
| 1307 | while ((char *) de <= top) { | 1280 | while ((char *) de <= top) { |
| 1308 | if (!ext4_check_dir_entry("ext4_add_entry", dir, de, | 1281 | if (!ext4_check_dir_entry(dir, de, bh, offset)) |
| 1309 | bh, offset)) | ||
| 1310 | return -EIO; | 1282 | return -EIO; |
| 1311 | if (ext4_match(namelen, name, de)) | 1283 | if (ext4_match(namelen, name, de)) |
| 1312 | return -EEXIST; | 1284 | return -EEXIST; |
| @@ -1673,7 +1645,7 @@ static int ext4_delete_entry(handle_t *handle, | |||
| 1673 | pde = NULL; | 1645 | pde = NULL; |
| 1674 | de = (struct ext4_dir_entry_2 *) bh->b_data; | 1646 | de = (struct ext4_dir_entry_2 *) bh->b_data; |
| 1675 | while (i < bh->b_size) { | 1647 | while (i < bh->b_size) { |
| 1676 | if (!ext4_check_dir_entry("ext4_delete_entry", dir, de, bh, i)) | 1648 | if (!ext4_check_dir_entry(dir, de, bh, i)) |
| 1677 | return -EIO; | 1649 | return -EIO; |
| 1678 | if (de == de_del) { | 1650 | if (de == de_del) { |
| 1679 | BUFFER_TRACE(bh, "get_write_access"); | 1651 | BUFFER_TRACE(bh, "get_write_access"); |
| @@ -1956,7 +1928,7 @@ static int empty_dir(struct inode *inode) | |||
| 1956 | } | 1928 | } |
| 1957 | de = (struct ext4_dir_entry_2 *) bh->b_data; | 1929 | de = (struct ext4_dir_entry_2 *) bh->b_data; |
| 1958 | } | 1930 | } |
| 1959 | if (!ext4_check_dir_entry("empty_dir", inode, de, bh, offset)) { | 1931 | if (!ext4_check_dir_entry(inode, de, bh, offset)) { |
| 1960 | de = (struct ext4_dir_entry_2 *)(bh->b_data + | 1932 | de = (struct ext4_dir_entry_2 *)(bh->b_data + |
| 1961 | sb->s_blocksize); | 1933 | sb->s_blocksize); |
| 1962 | offset = (offset | (sb->s_blocksize - 1)) + 1; | 1934 | offset = (offset | (sb->s_blocksize - 1)) + 1; |
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index 6df797eb9aeb..ca5c8aa00a2f 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c | |||
| @@ -921,8 +921,7 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input) | |||
| 921 | &sbi->s_flex_groups[flex_group].free_inodes); | 921 | &sbi->s_flex_groups[flex_group].free_inodes); |
| 922 | } | 922 | } |
| 923 | 923 | ||
| 924 | ext4_handle_dirty_metadata(handle, NULL, sbi->s_sbh); | 924 | ext4_handle_dirty_super(handle, sb); |
| 925 | sb->s_dirt = 1; | ||
| 926 | 925 | ||
| 927 | exit_journal: | 926 | exit_journal: |
| 928 | mutex_unlock(&sbi->s_resize_lock); | 927 | mutex_unlock(&sbi->s_resize_lock); |
| @@ -953,7 +952,6 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es, | |||
| 953 | ext4_fsblk_t n_blocks_count) | 952 | ext4_fsblk_t n_blocks_count) |
| 954 | { | 953 | { |
| 955 | ext4_fsblk_t o_blocks_count; | 954 | ext4_fsblk_t o_blocks_count; |
| 956 | ext4_group_t o_groups_count; | ||
| 957 | ext4_grpblk_t last; | 955 | ext4_grpblk_t last; |
| 958 | ext4_grpblk_t add; | 956 | ext4_grpblk_t add; |
| 959 | struct buffer_head *bh; | 957 | struct buffer_head *bh; |
| @@ -965,7 +963,6 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es, | |||
| 965 | * yet: we're going to revalidate es->s_blocks_count after | 963 | * yet: we're going to revalidate es->s_blocks_count after |
| 966 | * taking the s_resize_lock below. */ | 964 | * taking the s_resize_lock below. */ |
| 967 | o_blocks_count = ext4_blocks_count(es); | 965 | o_blocks_count = ext4_blocks_count(es); |
| 968 | o_groups_count = EXT4_SB(sb)->s_groups_count; | ||
| 969 | 966 | ||
| 970 | if (test_opt(sb, DEBUG)) | 967 | if (test_opt(sb, DEBUG)) |
| 971 | printk(KERN_DEBUG "EXT4-fs: extending last group from %llu uto %llu blocks\n", | 968 | printk(KERN_DEBUG "EXT4-fs: extending last group from %llu uto %llu blocks\n", |
| @@ -1045,13 +1042,12 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es, | |||
| 1045 | goto exit_put; | 1042 | goto exit_put; |
| 1046 | } | 1043 | } |
| 1047 | ext4_blocks_count_set(es, o_blocks_count + add); | 1044 | ext4_blocks_count_set(es, o_blocks_count + add); |
| 1048 | ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh); | ||
| 1049 | sb->s_dirt = 1; | ||
| 1050 | mutex_unlock(&EXT4_SB(sb)->s_resize_lock); | 1045 | mutex_unlock(&EXT4_SB(sb)->s_resize_lock); |
| 1051 | ext4_debug("freeing blocks %llu through %llu\n", o_blocks_count, | 1046 | ext4_debug("freeing blocks %llu through %llu\n", o_blocks_count, |
| 1052 | o_blocks_count + add); | 1047 | o_blocks_count + add); |
| 1053 | /* We add the blocks to the bitmap and set the group need init bit */ | 1048 | /* We add the blocks to the bitmap and set the group need init bit */ |
| 1054 | ext4_add_groupblocks(handle, sb, o_blocks_count, add); | 1049 | ext4_add_groupblocks(handle, sb, o_blocks_count, add); |
| 1050 | ext4_handle_dirty_super(handle, sb); | ||
| 1055 | ext4_debug("freed blocks %llu through %llu\n", o_blocks_count, | 1051 | ext4_debug("freed blocks %llu through %llu\n", o_blocks_count, |
| 1056 | o_blocks_count + add); | 1052 | o_blocks_count + add); |
| 1057 | if ((err = ext4_journal_stop(handle))) | 1053 | if ((err = ext4_journal_stop(handle))) |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 4e8983a9811b..26147746c272 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
| @@ -241,14 +241,14 @@ handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks) | |||
| 241 | if (sb->s_flags & MS_RDONLY) | 241 | if (sb->s_flags & MS_RDONLY) |
| 242 | return ERR_PTR(-EROFS); | 242 | return ERR_PTR(-EROFS); |
| 243 | 243 | ||
| 244 | vfs_check_frozen(sb, SB_FREEZE_WRITE); | 244 | vfs_check_frozen(sb, SB_FREEZE_TRANS); |
| 245 | /* Special case here: if the journal has aborted behind our | 245 | /* Special case here: if the journal has aborted behind our |
| 246 | * backs (eg. EIO in the commit thread), then we still need to | 246 | * backs (eg. EIO in the commit thread), then we still need to |
| 247 | * take the FS itself readonly cleanly. */ | 247 | * take the FS itself readonly cleanly. */ |
| 248 | journal = EXT4_SB(sb)->s_journal; | 248 | journal = EXT4_SB(sb)->s_journal; |
| 249 | if (journal) { | 249 | if (journal) { |
| 250 | if (is_journal_aborted(journal)) { | 250 | if (is_journal_aborted(journal)) { |
| 251 | ext4_abort(sb, __func__, "Detected aborted journal"); | 251 | ext4_abort(sb, "Detected aborted journal"); |
| 252 | return ERR_PTR(-EROFS); | 252 | return ERR_PTR(-EROFS); |
| 253 | } | 253 | } |
| 254 | return jbd2_journal_start(journal, nblocks); | 254 | return jbd2_journal_start(journal, nblocks); |
| @@ -262,7 +262,7 @@ handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks) | |||
| 262 | * that sync() will call the filesystem's write_super callback if | 262 | * that sync() will call the filesystem's write_super callback if |
| 263 | * appropriate. | 263 | * appropriate. |
| 264 | */ | 264 | */ |
| 265 | int __ext4_journal_stop(const char *where, handle_t *handle) | 265 | int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle) |
| 266 | { | 266 | { |
| 267 | struct super_block *sb; | 267 | struct super_block *sb; |
| 268 | int err; | 268 | int err; |
| @@ -279,12 +279,13 @@ int __ext4_journal_stop(const char *where, handle_t *handle) | |||
| 279 | if (!err) | 279 | if (!err) |
| 280 | err = rc; | 280 | err = rc; |
| 281 | if (err) | 281 | if (err) |
| 282 | __ext4_std_error(sb, where, err); | 282 | __ext4_std_error(sb, where, line, err); |
| 283 | return err; | 283 | return err; |
| 284 | } | 284 | } |
| 285 | 285 | ||
| 286 | void ext4_journal_abort_handle(const char *caller, const char *err_fn, | 286 | void ext4_journal_abort_handle(const char *caller, unsigned int line, |
| 287 | struct buffer_head *bh, handle_t *handle, int err) | 287 | const char *err_fn, struct buffer_head *bh, |
| 288 | handle_t *handle, int err) | ||
| 288 | { | 289 | { |
| 289 | char nbuf[16]; | 290 | char nbuf[16]; |
| 290 | const char *errstr = ext4_decode_error(NULL, err, nbuf); | 291 | const char *errstr = ext4_decode_error(NULL, err, nbuf); |
| @@ -300,12 +301,47 @@ void ext4_journal_abort_handle(const char *caller, const char *err_fn, | |||
| 300 | if (is_handle_aborted(handle)) | 301 | if (is_handle_aborted(handle)) |
| 301 | return; | 302 | return; |
| 302 | 303 | ||
| 303 | printk(KERN_ERR "%s: aborting transaction: %s in %s\n", | 304 | printk(KERN_ERR "%s:%d: aborting transaction: %s in %s\n", |
| 304 | caller, errstr, err_fn); | 305 | caller, line, errstr, err_fn); |
| 305 | 306 | ||
| 306 | jbd2_journal_abort_handle(handle); | 307 | jbd2_journal_abort_handle(handle); |
| 307 | } | 308 | } |
| 308 | 309 | ||
| 310 | static void __save_error_info(struct super_block *sb, const char *func, | ||
| 311 | unsigned int line) | ||
| 312 | { | ||
| 313 | struct ext4_super_block *es = EXT4_SB(sb)->s_es; | ||
| 314 | |||
| 315 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; | ||
| 316 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); | ||
| 317 | es->s_last_error_time = cpu_to_le32(get_seconds()); | ||
| 318 | strncpy(es->s_last_error_func, func, sizeof(es->s_last_error_func)); | ||
| 319 | es->s_last_error_line = cpu_to_le32(line); | ||
| 320 | if (!es->s_first_error_time) { | ||
| 321 | es->s_first_error_time = es->s_last_error_time; | ||
| 322 | strncpy(es->s_first_error_func, func, | ||
| 323 | sizeof(es->s_first_error_func)); | ||
| 324 | es->s_first_error_line = cpu_to_le32(line); | ||
| 325 | es->s_first_error_ino = es->s_last_error_ino; | ||
| 326 | es->s_first_error_block = es->s_last_error_block; | ||
| 327 | } | ||
| 328 | /* | ||
| 329 | * Start the daily error reporting function if it hasn't been | ||
| 330 | * started already | ||
| 331 | */ | ||
| 332 | if (!es->s_error_count) | ||
| 333 | mod_timer(&EXT4_SB(sb)->s_err_report, jiffies + 24*60*60*HZ); | ||
| 334 | es->s_error_count = cpu_to_le32(le32_to_cpu(es->s_error_count) + 1); | ||
| 335 | } | ||
| 336 | |||
| 337 | static void save_error_info(struct super_block *sb, const char *func, | ||
| 338 | unsigned int line) | ||
| 339 | { | ||
| 340 | __save_error_info(sb, func, line); | ||
| 341 | ext4_commit_super(sb, 1); | ||
| 342 | } | ||
| 343 | |||
| 344 | |||
| 309 | /* Deal with the reporting of failure conditions on a filesystem such as | 345 | /* Deal with the reporting of failure conditions on a filesystem such as |
| 310 | * inconsistencies detected or read IO failures. | 346 | * inconsistencies detected or read IO failures. |
| 311 | * | 347 | * |
| @@ -323,11 +359,6 @@ void ext4_journal_abort_handle(const char *caller, const char *err_fn, | |||
| 323 | 359 | ||
| 324 | static void ext4_handle_error(struct super_block *sb) | 360 | static void ext4_handle_error(struct super_block *sb) |
| 325 | { | 361 | { |
| 326 | struct ext4_super_block *es = EXT4_SB(sb)->s_es; | ||
| 327 | |||
| 328 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; | ||
| 329 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); | ||
| 330 | |||
| 331 | if (sb->s_flags & MS_RDONLY) | 362 | if (sb->s_flags & MS_RDONLY) |
| 332 | return; | 363 | return; |
| 333 | 364 | ||
| @@ -342,19 +373,19 @@ static void ext4_handle_error(struct super_block *sb) | |||
| 342 | ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); | 373 | ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); |
| 343 | sb->s_flags |= MS_RDONLY; | 374 | sb->s_flags |= MS_RDONLY; |
| 344 | } | 375 | } |
| 345 | ext4_commit_super(sb, 1); | ||
| 346 | if (test_opt(sb, ERRORS_PANIC)) | 376 | if (test_opt(sb, ERRORS_PANIC)) |
| 347 | panic("EXT4-fs (device %s): panic forced after error\n", | 377 | panic("EXT4-fs (device %s): panic forced after error\n", |
| 348 | sb->s_id); | 378 | sb->s_id); |
| 349 | } | 379 | } |
| 350 | 380 | ||
| 351 | void __ext4_error(struct super_block *sb, const char *function, | 381 | void __ext4_error(struct super_block *sb, const char *function, |
| 352 | const char *fmt, ...) | 382 | unsigned int line, const char *fmt, ...) |
| 353 | { | 383 | { |
| 354 | va_list args; | 384 | va_list args; |
| 355 | 385 | ||
| 356 | va_start(args, fmt); | 386 | va_start(args, fmt); |
| 357 | printk(KERN_CRIT "EXT4-fs error (device %s): %s: ", sb->s_id, function); | 387 | printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: comm %s: ", |
| 388 | sb->s_id, function, line, current->comm); | ||
| 358 | vprintk(fmt, args); | 389 | vprintk(fmt, args); |
| 359 | printk("\n"); | 390 | printk("\n"); |
| 360 | va_end(args); | 391 | va_end(args); |
| @@ -362,14 +393,22 @@ void __ext4_error(struct super_block *sb, const char *function, | |||
| 362 | ext4_handle_error(sb); | 393 | ext4_handle_error(sb); |
| 363 | } | 394 | } |
| 364 | 395 | ||
| 365 | void ext4_error_inode(const char *function, struct inode *inode, | 396 | void ext4_error_inode(struct inode *inode, const char *function, |
| 397 | unsigned int line, ext4_fsblk_t block, | ||
| 366 | const char *fmt, ...) | 398 | const char *fmt, ...) |
| 367 | { | 399 | { |
| 368 | va_list args; | 400 | va_list args; |
| 401 | struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es; | ||
| 369 | 402 | ||
| 403 | es->s_last_error_ino = cpu_to_le32(inode->i_ino); | ||
| 404 | es->s_last_error_block = cpu_to_le64(block); | ||
| 405 | save_error_info(inode->i_sb, function, line); | ||
| 370 | va_start(args, fmt); | 406 | va_start(args, fmt); |
| 371 | printk(KERN_CRIT "EXT4-fs error (device %s): %s: inode #%lu: (comm %s) ", | 407 | printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: inode #%lu: ", |
| 372 | inode->i_sb->s_id, function, inode->i_ino, current->comm); | 408 | inode->i_sb->s_id, function, line, inode->i_ino); |
| 409 | if (block) | ||
| 410 | printk("block %llu: ", block); | ||
| 411 | printk("comm %s: ", current->comm); | ||
| 373 | vprintk(fmt, args); | 412 | vprintk(fmt, args); |
| 374 | printk("\n"); | 413 | printk("\n"); |
| 375 | va_end(args); | 414 | va_end(args); |
| @@ -377,20 +416,26 @@ void ext4_error_inode(const char *function, struct inode *inode, | |||
| 377 | ext4_handle_error(inode->i_sb); | 416 | ext4_handle_error(inode->i_sb); |
| 378 | } | 417 | } |
| 379 | 418 | ||
| 380 | void ext4_error_file(const char *function, struct file *file, | 419 | void ext4_error_file(struct file *file, const char *function, |
| 381 | const char *fmt, ...) | 420 | unsigned int line, const char *fmt, ...) |
| 382 | { | 421 | { |
| 383 | va_list args; | 422 | va_list args; |
| 423 | struct ext4_super_block *es; | ||
| 384 | struct inode *inode = file->f_dentry->d_inode; | 424 | struct inode *inode = file->f_dentry->d_inode; |
| 385 | char pathname[80], *path; | 425 | char pathname[80], *path; |
| 386 | 426 | ||
| 427 | es = EXT4_SB(inode->i_sb)->s_es; | ||
| 428 | es->s_last_error_ino = cpu_to_le32(inode->i_ino); | ||
| 429 | save_error_info(inode->i_sb, function, line); | ||
| 387 | va_start(args, fmt); | 430 | va_start(args, fmt); |
| 388 | path = d_path(&(file->f_path), pathname, sizeof(pathname)); | 431 | path = d_path(&(file->f_path), pathname, sizeof(pathname)); |
| 389 | if (!path) | 432 | if (!path) |
| 390 | path = "(unknown)"; | 433 | path = "(unknown)"; |
| 391 | printk(KERN_CRIT | 434 | printk(KERN_CRIT |
| 392 | "EXT4-fs error (device %s): %s: inode #%lu (comm %s path %s): ", | 435 | "EXT4-fs error (device %s): %s:%d: inode #%lu " |
| 393 | inode->i_sb->s_id, function, inode->i_ino, current->comm, path); | 436 | "(comm %s path %s): ", |
| 437 | inode->i_sb->s_id, function, line, inode->i_ino, | ||
| 438 | current->comm, path); | ||
| 394 | vprintk(fmt, args); | 439 | vprintk(fmt, args); |
| 395 | printk("\n"); | 440 | printk("\n"); |
| 396 | va_end(args); | 441 | va_end(args); |
| @@ -435,7 +480,8 @@ static const char *ext4_decode_error(struct super_block *sb, int errno, | |||
| 435 | /* __ext4_std_error decodes expected errors from journaling functions | 480 | /* __ext4_std_error decodes expected errors from journaling functions |
| 436 | * automatically and invokes the appropriate error response. */ | 481 | * automatically and invokes the appropriate error response. */ |
| 437 | 482 | ||
| 438 | void __ext4_std_error(struct super_block *sb, const char *function, int errno) | 483 | void __ext4_std_error(struct super_block *sb, const char *function, |
| 484 | unsigned int line, int errno) | ||
| 439 | { | 485 | { |
| 440 | char nbuf[16]; | 486 | char nbuf[16]; |
| 441 | const char *errstr; | 487 | const char *errstr; |
| @@ -448,8 +494,9 @@ void __ext4_std_error(struct super_block *sb, const char *function, int errno) | |||
| 448 | return; | 494 | return; |
| 449 | 495 | ||
| 450 | errstr = ext4_decode_error(sb, errno, nbuf); | 496 | errstr = ext4_decode_error(sb, errno, nbuf); |
| 451 | printk(KERN_CRIT "EXT4-fs error (device %s) in %s: %s\n", | 497 | printk(KERN_CRIT "EXT4-fs error (device %s) in %s:%d: %s\n", |
| 452 | sb->s_id, function, errstr); | 498 | sb->s_id, function, line, errstr); |
| 499 | save_error_info(sb, function, line); | ||
| 453 | 500 | ||
| 454 | ext4_handle_error(sb); | 501 | ext4_handle_error(sb); |
| 455 | } | 502 | } |
| @@ -464,29 +511,29 @@ void __ext4_std_error(struct super_block *sb, const char *function, int errno) | |||
| 464 | * case we take the easy way out and panic immediately. | 511 | * case we take the easy way out and panic immediately. |
| 465 | */ | 512 | */ |
| 466 | 513 | ||
| 467 | void ext4_abort(struct super_block *sb, const char *function, | 514 | void __ext4_abort(struct super_block *sb, const char *function, |
| 468 | const char *fmt, ...) | 515 | unsigned int line, const char *fmt, ...) |
| 469 | { | 516 | { |
| 470 | va_list args; | 517 | va_list args; |
| 471 | 518 | ||
| 519 | save_error_info(sb, function, line); | ||
| 472 | va_start(args, fmt); | 520 | va_start(args, fmt); |
| 473 | printk(KERN_CRIT "EXT4-fs error (device %s): %s: ", sb->s_id, function); | 521 | printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: ", sb->s_id, |
| 522 | function, line); | ||
| 474 | vprintk(fmt, args); | 523 | vprintk(fmt, args); |
| 475 | printk("\n"); | 524 | printk("\n"); |
| 476 | va_end(args); | 525 | va_end(args); |
| 477 | 526 | ||
| 527 | if ((sb->s_flags & MS_RDONLY) == 0) { | ||
| 528 | ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); | ||
| 529 | sb->s_flags |= MS_RDONLY; | ||
| 530 | EXT4_SB(sb)->s_mount_flags |= EXT4_MF_FS_ABORTED; | ||
| 531 | if (EXT4_SB(sb)->s_journal) | ||
| 532 | jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO); | ||
| 533 | save_error_info(sb, function, line); | ||
| 534 | } | ||
| 478 | if (test_opt(sb, ERRORS_PANIC)) | 535 | if (test_opt(sb, ERRORS_PANIC)) |
| 479 | panic("EXT4-fs panic from previous error\n"); | 536 | panic("EXT4-fs panic from previous error\n"); |
| 480 | |||
| 481 | if (sb->s_flags & MS_RDONLY) | ||
| 482 | return; | ||
| 483 | |||
| 484 | ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); | ||
| 485 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; | ||
| 486 | sb->s_flags |= MS_RDONLY; | ||
| 487 | EXT4_SB(sb)->s_mount_flags |= EXT4_MF_FS_ABORTED; | ||
| 488 | if (EXT4_SB(sb)->s_journal) | ||
| 489 | jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO); | ||
| 490 | } | 537 | } |
| 491 | 538 | ||
| 492 | void ext4_msg (struct super_block * sb, const char *prefix, | 539 | void ext4_msg (struct super_block * sb, const char *prefix, |
| @@ -502,38 +549,47 @@ void ext4_msg (struct super_block * sb, const char *prefix, | |||
| 502 | } | 549 | } |
| 503 | 550 | ||
| 504 | void __ext4_warning(struct super_block *sb, const char *function, | 551 | void __ext4_warning(struct super_block *sb, const char *function, |
| 505 | const char *fmt, ...) | 552 | unsigned int line, const char *fmt, ...) |
| 506 | { | 553 | { |
| 507 | va_list args; | 554 | va_list args; |
| 508 | 555 | ||
| 509 | va_start(args, fmt); | 556 | va_start(args, fmt); |
| 510 | printk(KERN_WARNING "EXT4-fs warning (device %s): %s: ", | 557 | printk(KERN_WARNING "EXT4-fs warning (device %s): %s:%d: ", |
| 511 | sb->s_id, function); | 558 | sb->s_id, function, line); |
| 512 | vprintk(fmt, args); | 559 | vprintk(fmt, args); |
| 513 | printk("\n"); | 560 | printk("\n"); |
| 514 | va_end(args); | 561 | va_end(args); |
| 515 | } | 562 | } |
| 516 | 563 | ||
| 517 | void ext4_grp_locked_error(struct super_block *sb, ext4_group_t grp, | 564 | void __ext4_grp_locked_error(const char *function, unsigned int line, |
| 518 | const char *function, const char *fmt, ...) | 565 | struct super_block *sb, ext4_group_t grp, |
| 566 | unsigned long ino, ext4_fsblk_t block, | ||
| 567 | const char *fmt, ...) | ||
| 519 | __releases(bitlock) | 568 | __releases(bitlock) |
| 520 | __acquires(bitlock) | 569 | __acquires(bitlock) |
| 521 | { | 570 | { |
| 522 | va_list args; | 571 | va_list args; |
| 523 | struct ext4_super_block *es = EXT4_SB(sb)->s_es; | 572 | struct ext4_super_block *es = EXT4_SB(sb)->s_es; |
| 524 | 573 | ||
| 574 | es->s_last_error_ino = cpu_to_le32(ino); | ||
| 575 | es->s_last_error_block = cpu_to_le64(block); | ||
| 576 | __save_error_info(sb, function, line); | ||
| 525 | va_start(args, fmt); | 577 | va_start(args, fmt); |
| 526 | printk(KERN_CRIT "EXT4-fs error (device %s): %s: ", sb->s_id, function); | 578 | printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: group %u", |
| 579 | sb->s_id, function, line, grp); | ||
| 580 | if (ino) | ||
| 581 | printk("inode %lu: ", ino); | ||
| 582 | if (block) | ||
| 583 | printk("block %llu:", (unsigned long long) block); | ||
| 527 | vprintk(fmt, args); | 584 | vprintk(fmt, args); |
| 528 | printk("\n"); | 585 | printk("\n"); |
| 529 | va_end(args); | 586 | va_end(args); |
| 530 | 587 | ||
| 531 | if (test_opt(sb, ERRORS_CONT)) { | 588 | if (test_opt(sb, ERRORS_CONT)) { |
| 532 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; | ||
| 533 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); | ||
| 534 | ext4_commit_super(sb, 0); | 589 | ext4_commit_super(sb, 0); |
| 535 | return; | 590 | return; |
| 536 | } | 591 | } |
| 592 | |||
| 537 | ext4_unlock_group(sb, grp); | 593 | ext4_unlock_group(sb, grp); |
| 538 | ext4_handle_error(sb); | 594 | ext4_handle_error(sb); |
| 539 | /* | 595 | /* |
| @@ -660,8 +716,7 @@ static void ext4_put_super(struct super_block *sb) | |||
| 660 | err = jbd2_journal_destroy(sbi->s_journal); | 716 | err = jbd2_journal_destroy(sbi->s_journal); |
| 661 | sbi->s_journal = NULL; | 717 | sbi->s_journal = NULL; |
| 662 | if (err < 0) | 718 | if (err < 0) |
| 663 | ext4_abort(sb, __func__, | 719 | ext4_abort(sb, "Couldn't clean up the journal"); |
| 664 | "Couldn't clean up the journal"); | ||
| 665 | } | 720 | } |
| 666 | 721 | ||
| 667 | ext4_release_system_zone(sb); | 722 | ext4_release_system_zone(sb); |
| @@ -813,8 +868,10 @@ static void destroy_inodecache(void) | |||
| 813 | kmem_cache_destroy(ext4_inode_cachep); | 868 | kmem_cache_destroy(ext4_inode_cachep); |
| 814 | } | 869 | } |
| 815 | 870 | ||
| 816 | static void ext4_clear_inode(struct inode *inode) | 871 | void ext4_clear_inode(struct inode *inode) |
| 817 | { | 872 | { |
| 873 | invalidate_inode_buffers(inode); | ||
| 874 | end_writeback(inode); | ||
| 818 | dquot_drop(inode); | 875 | dquot_drop(inode); |
| 819 | ext4_discard_preallocations(inode); | 876 | ext4_discard_preallocations(inode); |
| 820 | if (EXT4_JOURNAL(inode)) | 877 | if (EXT4_JOURNAL(inode)) |
| @@ -946,14 +1003,12 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
| 946 | seq_puts(seq, ",journal_async_commit"); | 1003 | seq_puts(seq, ",journal_async_commit"); |
| 947 | else if (test_opt(sb, JOURNAL_CHECKSUM)) | 1004 | else if (test_opt(sb, JOURNAL_CHECKSUM)) |
| 948 | seq_puts(seq, ",journal_checksum"); | 1005 | seq_puts(seq, ",journal_checksum"); |
| 949 | if (test_opt(sb, NOBH)) | ||
| 950 | seq_puts(seq, ",nobh"); | ||
| 951 | if (test_opt(sb, I_VERSION)) | 1006 | if (test_opt(sb, I_VERSION)) |
| 952 | seq_puts(seq, ",i_version"); | 1007 | seq_puts(seq, ",i_version"); |
| 953 | if (!test_opt(sb, DELALLOC)) | 1008 | if (!test_opt(sb, DELALLOC) && |
| 1009 | !(def_mount_opts & EXT4_DEFM_NODELALLOC)) | ||
| 954 | seq_puts(seq, ",nodelalloc"); | 1010 | seq_puts(seq, ",nodelalloc"); |
| 955 | 1011 | ||
| 956 | |||
| 957 | if (sbi->s_stripe) | 1012 | if (sbi->s_stripe) |
| 958 | seq_printf(seq, ",stripe=%lu", sbi->s_stripe); | 1013 | seq_printf(seq, ",stripe=%lu", sbi->s_stripe); |
| 959 | /* | 1014 | /* |
| @@ -977,7 +1032,7 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
| 977 | if (test_opt(sb, NO_AUTO_DA_ALLOC)) | 1032 | if (test_opt(sb, NO_AUTO_DA_ALLOC)) |
| 978 | seq_puts(seq, ",noauto_da_alloc"); | 1033 | seq_puts(seq, ",noauto_da_alloc"); |
| 979 | 1034 | ||
| 980 | if (test_opt(sb, DISCARD)) | 1035 | if (test_opt(sb, DISCARD) && !(def_mount_opts & EXT4_DEFM_DISCARD)) |
| 981 | seq_puts(seq, ",discard"); | 1036 | seq_puts(seq, ",discard"); |
| 982 | 1037 | ||
| 983 | if (test_opt(sb, NOLOAD)) | 1038 | if (test_opt(sb, NOLOAD)) |
| @@ -986,6 +1041,10 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
| 986 | if (test_opt(sb, DIOREAD_NOLOCK)) | 1041 | if (test_opt(sb, DIOREAD_NOLOCK)) |
| 987 | seq_puts(seq, ",dioread_nolock"); | 1042 | seq_puts(seq, ",dioread_nolock"); |
| 988 | 1043 | ||
| 1044 | if (test_opt(sb, BLOCK_VALIDITY) && | ||
| 1045 | !(def_mount_opts & EXT4_DEFM_BLOCK_VALIDITY)) | ||
| 1046 | seq_puts(seq, ",block_validity"); | ||
| 1047 | |||
| 989 | ext4_show_quota_options(seq, sb); | 1048 | ext4_show_quota_options(seq, sb); |
| 990 | 1049 | ||
| 991 | return 0; | 1050 | return 0; |
| @@ -1065,6 +1124,7 @@ static int ext4_mark_dquot_dirty(struct dquot *dquot); | |||
| 1065 | static int ext4_write_info(struct super_block *sb, int type); | 1124 | static int ext4_write_info(struct super_block *sb, int type); |
| 1066 | static int ext4_quota_on(struct super_block *sb, int type, int format_id, | 1125 | static int ext4_quota_on(struct super_block *sb, int type, int format_id, |
| 1067 | char *path); | 1126 | char *path); |
| 1127 | static int ext4_quota_off(struct super_block *sb, int type); | ||
| 1068 | static int ext4_quota_on_mount(struct super_block *sb, int type); | 1128 | static int ext4_quota_on_mount(struct super_block *sb, int type); |
| 1069 | static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data, | 1129 | static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data, |
| 1070 | size_t len, loff_t off); | 1130 | size_t len, loff_t off); |
| @@ -1086,7 +1146,7 @@ static const struct dquot_operations ext4_quota_operations = { | |||
| 1086 | 1146 | ||
| 1087 | static const struct quotactl_ops ext4_qctl_operations = { | 1147 | static const struct quotactl_ops ext4_qctl_operations = { |
| 1088 | .quota_on = ext4_quota_on, | 1148 | .quota_on = ext4_quota_on, |
| 1089 | .quota_off = dquot_quota_off, | 1149 | .quota_off = ext4_quota_off, |
| 1090 | .quota_sync = dquot_quota_sync, | 1150 | .quota_sync = dquot_quota_sync, |
| 1091 | .get_info = dquot_get_dqinfo, | 1151 | .get_info = dquot_get_dqinfo, |
| 1092 | .set_info = dquot_set_dqinfo, | 1152 | .set_info = dquot_set_dqinfo, |
| @@ -1100,14 +1160,13 @@ static const struct super_operations ext4_sops = { | |||
| 1100 | .destroy_inode = ext4_destroy_inode, | 1160 | .destroy_inode = ext4_destroy_inode, |
| 1101 | .write_inode = ext4_write_inode, | 1161 | .write_inode = ext4_write_inode, |
| 1102 | .dirty_inode = ext4_dirty_inode, | 1162 | .dirty_inode = ext4_dirty_inode, |
| 1103 | .delete_inode = ext4_delete_inode, | 1163 | .evict_inode = ext4_evict_inode, |
| 1104 | .put_super = ext4_put_super, | 1164 | .put_super = ext4_put_super, |
| 1105 | .sync_fs = ext4_sync_fs, | 1165 | .sync_fs = ext4_sync_fs, |
| 1106 | .freeze_fs = ext4_freeze, | 1166 | .freeze_fs = ext4_freeze, |
| 1107 | .unfreeze_fs = ext4_unfreeze, | 1167 | .unfreeze_fs = ext4_unfreeze, |
| 1108 | .statfs = ext4_statfs, | 1168 | .statfs = ext4_statfs, |
| 1109 | .remount_fs = ext4_remount, | 1169 | .remount_fs = ext4_remount, |
| 1110 | .clear_inode = ext4_clear_inode, | ||
| 1111 | .show_options = ext4_show_options, | 1170 | .show_options = ext4_show_options, |
| 1112 | #ifdef CONFIG_QUOTA | 1171 | #ifdef CONFIG_QUOTA |
| 1113 | .quota_read = ext4_quota_read, | 1172 | .quota_read = ext4_quota_read, |
| @@ -1121,12 +1180,11 @@ static const struct super_operations ext4_nojournal_sops = { | |||
| 1121 | .destroy_inode = ext4_destroy_inode, | 1180 | .destroy_inode = ext4_destroy_inode, |
| 1122 | .write_inode = ext4_write_inode, | 1181 | .write_inode = ext4_write_inode, |
| 1123 | .dirty_inode = ext4_dirty_inode, | 1182 | .dirty_inode = ext4_dirty_inode, |
| 1124 | .delete_inode = ext4_delete_inode, | 1183 | .evict_inode = ext4_evict_inode, |
| 1125 | .write_super = ext4_write_super, | 1184 | .write_super = ext4_write_super, |
| 1126 | .put_super = ext4_put_super, | 1185 | .put_super = ext4_put_super, |
| 1127 | .statfs = ext4_statfs, | 1186 | .statfs = ext4_statfs, |
| 1128 | .remount_fs = ext4_remount, | 1187 | .remount_fs = ext4_remount, |
| 1129 | .clear_inode = ext4_clear_inode, | ||
| 1130 | .show_options = ext4_show_options, | 1188 | .show_options = ext4_show_options, |
| 1131 | #ifdef CONFIG_QUOTA | 1189 | #ifdef CONFIG_QUOTA |
| 1132 | .quota_read = ext4_quota_read, | 1190 | .quota_read = ext4_quota_read, |
| @@ -1624,10 +1682,12 @@ set_qf_format: | |||
| 1624 | *n_blocks_count = option; | 1682 | *n_blocks_count = option; |
| 1625 | break; | 1683 | break; |
| 1626 | case Opt_nobh: | 1684 | case Opt_nobh: |
| 1627 | set_opt(sbi->s_mount_opt, NOBH); | 1685 | ext4_msg(sb, KERN_WARNING, |
| 1686 | "Ignoring deprecated nobh option"); | ||
| 1628 | break; | 1687 | break; |
| 1629 | case Opt_bh: | 1688 | case Opt_bh: |
| 1630 | clear_opt(sbi->s_mount_opt, NOBH); | 1689 | ext4_msg(sb, KERN_WARNING, |
| 1690 | "Ignoring deprecated bh option"); | ||
| 1631 | break; | 1691 | break; |
| 1632 | case Opt_i_version: | 1692 | case Opt_i_version: |
| 1633 | set_opt(sbi->s_mount_opt, I_VERSION); | 1693 | set_opt(sbi->s_mount_opt, I_VERSION); |
| @@ -2249,6 +2309,8 @@ static ssize_t session_write_kbytes_show(struct ext4_attr *a, | |||
| 2249 | { | 2309 | { |
| 2250 | struct super_block *sb = sbi->s_buddy_cache->i_sb; | 2310 | struct super_block *sb = sbi->s_buddy_cache->i_sb; |
| 2251 | 2311 | ||
| 2312 | if (!sb->s_bdev->bd_part) | ||
| 2313 | return snprintf(buf, PAGE_SIZE, "0\n"); | ||
| 2252 | return snprintf(buf, PAGE_SIZE, "%lu\n", | 2314 | return snprintf(buf, PAGE_SIZE, "%lu\n", |
| 2253 | (part_stat_read(sb->s_bdev->bd_part, sectors[1]) - | 2315 | (part_stat_read(sb->s_bdev->bd_part, sectors[1]) - |
| 2254 | sbi->s_sectors_written_start) >> 1); | 2316 | sbi->s_sectors_written_start) >> 1); |
| @@ -2259,6 +2321,8 @@ static ssize_t lifetime_write_kbytes_show(struct ext4_attr *a, | |||
| 2259 | { | 2321 | { |
| 2260 | struct super_block *sb = sbi->s_buddy_cache->i_sb; | 2322 | struct super_block *sb = sbi->s_buddy_cache->i_sb; |
| 2261 | 2323 | ||
| 2324 | if (!sb->s_bdev->bd_part) | ||
| 2325 | return snprintf(buf, PAGE_SIZE, "0\n"); | ||
| 2262 | return snprintf(buf, PAGE_SIZE, "%llu\n", | 2326 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 2263 | (unsigned long long)(sbi->s_kbytes_written + | 2327 | (unsigned long long)(sbi->s_kbytes_written + |
| 2264 | ((part_stat_read(sb->s_bdev->bd_part, sectors[1]) - | 2328 | ((part_stat_read(sb->s_bdev->bd_part, sectors[1]) - |
| @@ -2431,6 +2495,53 @@ static int ext4_feature_set_ok(struct super_block *sb, int readonly) | |||
| 2431 | return 1; | 2495 | return 1; |
| 2432 | } | 2496 | } |
| 2433 | 2497 | ||
| 2498 | /* | ||
| 2499 | * This function is called once a day if we have errors logged | ||
| 2500 | * on the file system | ||
| 2501 | */ | ||
| 2502 | static void print_daily_error_info(unsigned long arg) | ||
| 2503 | { | ||
| 2504 | struct super_block *sb = (struct super_block *) arg; | ||
| 2505 | struct ext4_sb_info *sbi; | ||
| 2506 | struct ext4_super_block *es; | ||
| 2507 | |||
| 2508 | sbi = EXT4_SB(sb); | ||
| 2509 | es = sbi->s_es; | ||
| 2510 | |||
| 2511 | if (es->s_error_count) | ||
| 2512 | ext4_msg(sb, KERN_NOTICE, "error count: %u", | ||
| 2513 | le32_to_cpu(es->s_error_count)); | ||
| 2514 | if (es->s_first_error_time) { | ||
| 2515 | printk(KERN_NOTICE "EXT4-fs (%s): initial error at %u: %.*s:%d", | ||
| 2516 | sb->s_id, le32_to_cpu(es->s_first_error_time), | ||
| 2517 | (int) sizeof(es->s_first_error_func), | ||
| 2518 | es->s_first_error_func, | ||
| 2519 | le32_to_cpu(es->s_first_error_line)); | ||
| 2520 | if (es->s_first_error_ino) | ||
| 2521 | printk(": inode %u", | ||
| 2522 | le32_to_cpu(es->s_first_error_ino)); | ||
| 2523 | if (es->s_first_error_block) | ||
| 2524 | printk(": block %llu", (unsigned long long) | ||
| 2525 | le64_to_cpu(es->s_first_error_block)); | ||
| 2526 | printk("\n"); | ||
| 2527 | } | ||
| 2528 | if (es->s_last_error_time) { | ||
| 2529 | printk(KERN_NOTICE "EXT4-fs (%s): last error at %u: %.*s:%d", | ||
| 2530 | sb->s_id, le32_to_cpu(es->s_last_error_time), | ||
| 2531 | (int) sizeof(es->s_last_error_func), | ||
| 2532 | es->s_last_error_func, | ||
| 2533 | le32_to_cpu(es->s_last_error_line)); | ||
| 2534 | if (es->s_last_error_ino) | ||
| 2535 | printk(": inode %u", | ||
| 2536 | le32_to_cpu(es->s_last_error_ino)); | ||
| 2537 | if (es->s_last_error_block) | ||
| 2538 | printk(": block %llu", (unsigned long long) | ||
| 2539 | le64_to_cpu(es->s_last_error_block)); | ||
| 2540 | printk("\n"); | ||
| 2541 | } | ||
| 2542 | mod_timer(&sbi->s_err_report, jiffies + 24*60*60*HZ); /* Once a day */ | ||
| 2543 | } | ||
| 2544 | |||
| 2434 | static int ext4_fill_super(struct super_block *sb, void *data, int silent) | 2545 | static int ext4_fill_super(struct super_block *sb, void *data, int silent) |
| 2435 | __releases(kernel_lock) | 2546 | __releases(kernel_lock) |
| 2436 | __acquires(kernel_lock) | 2547 | __acquires(kernel_lock) |
| @@ -2448,7 +2559,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
| 2448 | struct inode *root; | 2559 | struct inode *root; |
| 2449 | char *cp; | 2560 | char *cp; |
| 2450 | const char *descr; | 2561 | const char *descr; |
| 2451 | int ret = -EINVAL; | 2562 | int ret = -ENOMEM; |
| 2452 | int blocksize; | 2563 | int blocksize; |
| 2453 | unsigned int db_count; | 2564 | unsigned int db_count; |
| 2454 | unsigned int i; | 2565 | unsigned int i; |
| @@ -2459,13 +2570,13 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
| 2459 | 2570 | ||
| 2460 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); | 2571 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); |
| 2461 | if (!sbi) | 2572 | if (!sbi) |
| 2462 | return -ENOMEM; | 2573 | goto out_free_orig; |
| 2463 | 2574 | ||
| 2464 | sbi->s_blockgroup_lock = | 2575 | sbi->s_blockgroup_lock = |
| 2465 | kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL); | 2576 | kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL); |
| 2466 | if (!sbi->s_blockgroup_lock) { | 2577 | if (!sbi->s_blockgroup_lock) { |
| 2467 | kfree(sbi); | 2578 | kfree(sbi); |
| 2468 | return -ENOMEM; | 2579 | goto out_free_orig; |
| 2469 | } | 2580 | } |
| 2470 | sb->s_fs_info = sbi; | 2581 | sb->s_fs_info = sbi; |
| 2471 | sbi->s_mount_opt = 0; | 2582 | sbi->s_mount_opt = 0; |
| @@ -2473,8 +2584,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
| 2473 | sbi->s_resgid = EXT4_DEF_RESGID; | 2584 | sbi->s_resgid = EXT4_DEF_RESGID; |
| 2474 | sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS; | 2585 | sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS; |
| 2475 | sbi->s_sb_block = sb_block; | 2586 | sbi->s_sb_block = sb_block; |
| 2476 | sbi->s_sectors_written_start = part_stat_read(sb->s_bdev->bd_part, | 2587 | if (sb->s_bdev->bd_part) |
| 2477 | sectors[1]); | 2588 | sbi->s_sectors_written_start = |
| 2589 | part_stat_read(sb->s_bdev->bd_part, sectors[1]); | ||
| 2478 | 2590 | ||
| 2479 | unlock_kernel(); | 2591 | unlock_kernel(); |
| 2480 | 2592 | ||
| @@ -2482,6 +2594,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
| 2482 | for (cp = sb->s_id; (cp = strchr(cp, '/'));) | 2594 | for (cp = sb->s_id; (cp = strchr(cp, '/'));) |
| 2483 | *cp = '!'; | 2595 | *cp = '!'; |
| 2484 | 2596 | ||
| 2597 | ret = -EINVAL; | ||
| 2485 | blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE); | 2598 | blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE); |
| 2486 | if (!blocksize) { | 2599 | if (!blocksize) { |
| 2487 | ext4_msg(sb, KERN_ERR, "unable to set blocksize"); | 2600 | ext4_msg(sb, KERN_ERR, "unable to set blocksize"); |
| @@ -2546,6 +2659,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
| 2546 | set_opt(sbi->s_mount_opt, ERRORS_CONT); | 2659 | set_opt(sbi->s_mount_opt, ERRORS_CONT); |
| 2547 | else | 2660 | else |
| 2548 | set_opt(sbi->s_mount_opt, ERRORS_RO); | 2661 | set_opt(sbi->s_mount_opt, ERRORS_RO); |
| 2662 | if (def_mount_opts & EXT4_DEFM_BLOCK_VALIDITY) | ||
| 2663 | set_opt(sbi->s_mount_opt, BLOCK_VALIDITY); | ||
| 2664 | if (def_mount_opts & EXT4_DEFM_DISCARD) | ||
| 2665 | set_opt(sbi->s_mount_opt, DISCARD); | ||
| 2549 | 2666 | ||
| 2550 | sbi->s_resuid = le16_to_cpu(es->s_def_resuid); | 2667 | sbi->s_resuid = le16_to_cpu(es->s_def_resuid); |
| 2551 | sbi->s_resgid = le16_to_cpu(es->s_def_resgid); | 2668 | sbi->s_resgid = le16_to_cpu(es->s_def_resgid); |
| @@ -2553,15 +2670,23 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
| 2553 | sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME; | 2670 | sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME; |
| 2554 | sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME; | 2671 | sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME; |
| 2555 | 2672 | ||
| 2556 | set_opt(sbi->s_mount_opt, BARRIER); | 2673 | if ((def_mount_opts & EXT4_DEFM_NOBARRIER) == 0) |
| 2674 | set_opt(sbi->s_mount_opt, BARRIER); | ||
| 2557 | 2675 | ||
| 2558 | /* | 2676 | /* |
| 2559 | * enable delayed allocation by default | 2677 | * enable delayed allocation by default |
| 2560 | * Use -o nodelalloc to turn it off | 2678 | * Use -o nodelalloc to turn it off |
| 2561 | */ | 2679 | */ |
| 2562 | if (!IS_EXT3_SB(sb)) | 2680 | if (!IS_EXT3_SB(sb) && |
| 2681 | ((def_mount_opts & EXT4_DEFM_NODELALLOC) == 0)) | ||
| 2563 | set_opt(sbi->s_mount_opt, DELALLOC); | 2682 | set_opt(sbi->s_mount_opt, DELALLOC); |
| 2564 | 2683 | ||
| 2684 | if (!parse_options((char *) sbi->s_es->s_mount_opts, sb, | ||
| 2685 | &journal_devnum, &journal_ioprio, NULL, 0)) { | ||
| 2686 | ext4_msg(sb, KERN_WARNING, | ||
| 2687 | "failed to parse options in superblock: %s", | ||
| 2688 | sbi->s_es->s_mount_opts); | ||
| 2689 | } | ||
| 2565 | if (!parse_options((char *) data, sb, &journal_devnum, | 2690 | if (!parse_options((char *) data, sb, &journal_devnum, |
| 2566 | &journal_ioprio, NULL, 0)) | 2691 | &journal_ioprio, NULL, 0)) |
| 2567 | goto failed_mount; | 2692 | goto failed_mount; |
| @@ -2912,18 +3037,7 @@ no_journal: | |||
| 2912 | ext4_msg(sb, KERN_ERR, "insufficient memory"); | 3037 | ext4_msg(sb, KERN_ERR, "insufficient memory"); |
| 2913 | goto failed_mount_wq; | 3038 | goto failed_mount_wq; |
| 2914 | } | 3039 | } |
| 2915 | if (test_opt(sb, NOBH)) { | 3040 | |
| 2916 | if (!(test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)) { | ||
| 2917 | ext4_msg(sb, KERN_WARNING, "Ignoring nobh option - " | ||
| 2918 | "its supported only with writeback mode"); | ||
| 2919 | clear_opt(sbi->s_mount_opt, NOBH); | ||
| 2920 | } | ||
| 2921 | if (test_opt(sb, DIOREAD_NOLOCK)) { | ||
| 2922 | ext4_msg(sb, KERN_WARNING, "dioread_nolock option is " | ||
| 2923 | "not supported with nobh mode"); | ||
| 2924 | goto failed_mount_wq; | ||
| 2925 | } | ||
| 2926 | } | ||
| 2927 | EXT4_SB(sb)->dio_unwritten_wq = create_workqueue("ext4-dio-unwritten"); | 3041 | EXT4_SB(sb)->dio_unwritten_wq = create_workqueue("ext4-dio-unwritten"); |
| 2928 | if (!EXT4_SB(sb)->dio_unwritten_wq) { | 3042 | if (!EXT4_SB(sb)->dio_unwritten_wq) { |
| 2929 | printk(KERN_ERR "EXT4-fs: failed to create DIO workqueue\n"); | 3043 | printk(KERN_ERR "EXT4-fs: failed to create DIO workqueue\n"); |
| @@ -3010,7 +3124,7 @@ no_journal: | |||
| 3010 | ext4_ext_init(sb); | 3124 | ext4_ext_init(sb); |
| 3011 | err = ext4_mb_init(sb, needs_recovery); | 3125 | err = ext4_mb_init(sb, needs_recovery); |
| 3012 | if (err) { | 3126 | if (err) { |
| 3013 | ext4_msg(sb, KERN_ERR, "failed to initalize mballoc (%d)", | 3127 | ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)", |
| 3014 | err); | 3128 | err); |
| 3015 | goto failed_mount4; | 3129 | goto failed_mount4; |
| 3016 | } | 3130 | } |
| @@ -3043,7 +3157,14 @@ no_journal: | |||
| 3043 | descr = "out journal"; | 3157 | descr = "out journal"; |
| 3044 | 3158 | ||
| 3045 | ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. " | 3159 | ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. " |
| 3046 | "Opts: %s", descr, orig_data); | 3160 | "Opts: %s%s%s", descr, sbi->s_es->s_mount_opts, |
| 3161 | *sbi->s_es->s_mount_opts ? "; " : "", orig_data); | ||
| 3162 | |||
| 3163 | init_timer(&sbi->s_err_report); | ||
| 3164 | sbi->s_err_report.function = print_daily_error_info; | ||
| 3165 | sbi->s_err_report.data = (unsigned long) sb; | ||
| 3166 | if (es->s_error_count) | ||
| 3167 | mod_timer(&sbi->s_err_report, jiffies + 300*HZ); /* 5 minutes */ | ||
| 3047 | 3168 | ||
| 3048 | lock_kernel(); | 3169 | lock_kernel(); |
| 3049 | kfree(orig_data); | 3170 | kfree(orig_data); |
| @@ -3093,6 +3214,7 @@ out_fail: | |||
| 3093 | kfree(sbi->s_blockgroup_lock); | 3214 | kfree(sbi->s_blockgroup_lock); |
| 3094 | kfree(sbi); | 3215 | kfree(sbi); |
| 3095 | lock_kernel(); | 3216 | lock_kernel(); |
| 3217 | out_free_orig: | ||
| 3096 | kfree(orig_data); | 3218 | kfree(orig_data); |
| 3097 | return ret; | 3219 | return ret; |
| 3098 | } | 3220 | } |
| @@ -3110,7 +3232,7 @@ static void ext4_init_journal_params(struct super_block *sb, journal_t *journal) | |||
| 3110 | journal->j_min_batch_time = sbi->s_min_batch_time; | 3232 | journal->j_min_batch_time = sbi->s_min_batch_time; |
| 3111 | journal->j_max_batch_time = sbi->s_max_batch_time; | 3233 | journal->j_max_batch_time = sbi->s_max_batch_time; |
| 3112 | 3234 | ||
| 3113 | spin_lock(&journal->j_state_lock); | 3235 | write_lock(&journal->j_state_lock); |
| 3114 | if (test_opt(sb, BARRIER)) | 3236 | if (test_opt(sb, BARRIER)) |
| 3115 | journal->j_flags |= JBD2_BARRIER; | 3237 | journal->j_flags |= JBD2_BARRIER; |
| 3116 | else | 3238 | else |
| @@ -3119,7 +3241,7 @@ static void ext4_init_journal_params(struct super_block *sb, journal_t *journal) | |||
| 3119 | journal->j_flags |= JBD2_ABORT_ON_SYNCDATA_ERR; | 3241 | journal->j_flags |= JBD2_ABORT_ON_SYNCDATA_ERR; |
| 3120 | else | 3242 | else |
| 3121 | journal->j_flags &= ~JBD2_ABORT_ON_SYNCDATA_ERR; | 3243 | journal->j_flags &= ~JBD2_ABORT_ON_SYNCDATA_ERR; |
| 3122 | spin_unlock(&journal->j_state_lock); | 3244 | write_unlock(&journal->j_state_lock); |
| 3123 | } | 3245 | } |
| 3124 | 3246 | ||
| 3125 | static journal_t *ext4_get_journal(struct super_block *sb, | 3247 | static journal_t *ext4_get_journal(struct super_block *sb, |
| @@ -3327,8 +3449,17 @@ static int ext4_load_journal(struct super_block *sb, | |||
| 3327 | 3449 | ||
| 3328 | if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) | 3450 | if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) |
| 3329 | err = jbd2_journal_wipe(journal, !really_read_only); | 3451 | err = jbd2_journal_wipe(journal, !really_read_only); |
| 3330 | if (!err) | 3452 | if (!err) { |
| 3453 | char *save = kmalloc(EXT4_S_ERR_LEN, GFP_KERNEL); | ||
| 3454 | if (save) | ||
| 3455 | memcpy(save, ((char *) es) + | ||
| 3456 | EXT4_S_ERR_START, EXT4_S_ERR_LEN); | ||
| 3331 | err = jbd2_journal_load(journal); | 3457 | err = jbd2_journal_load(journal); |
| 3458 | if (save) | ||
| 3459 | memcpy(((char *) es) + EXT4_S_ERR_START, | ||
| 3460 | save, EXT4_S_ERR_LEN); | ||
| 3461 | kfree(save); | ||
| 3462 | } | ||
| 3332 | 3463 | ||
| 3333 | if (err) { | 3464 | if (err) { |
| 3334 | ext4_msg(sb, KERN_ERR, "error loading journal"); | 3465 | ext4_msg(sb, KERN_ERR, "error loading journal"); |
| @@ -3384,10 +3515,14 @@ static int ext4_commit_super(struct super_block *sb, int sync) | |||
| 3384 | */ | 3515 | */ |
| 3385 | if (!(sb->s_flags & MS_RDONLY)) | 3516 | if (!(sb->s_flags & MS_RDONLY)) |
| 3386 | es->s_wtime = cpu_to_le32(get_seconds()); | 3517 | es->s_wtime = cpu_to_le32(get_seconds()); |
| 3387 | es->s_kbytes_written = | 3518 | if (sb->s_bdev->bd_part) |
| 3388 | cpu_to_le64(EXT4_SB(sb)->s_kbytes_written + | 3519 | es->s_kbytes_written = |
| 3520 | cpu_to_le64(EXT4_SB(sb)->s_kbytes_written + | ||
| 3389 | ((part_stat_read(sb->s_bdev->bd_part, sectors[1]) - | 3521 | ((part_stat_read(sb->s_bdev->bd_part, sectors[1]) - |
| 3390 | EXT4_SB(sb)->s_sectors_written_start) >> 1)); | 3522 | EXT4_SB(sb)->s_sectors_written_start) >> 1)); |
| 3523 | else | ||
| 3524 | es->s_kbytes_written = | ||
| 3525 | cpu_to_le64(EXT4_SB(sb)->s_kbytes_written); | ||
| 3391 | ext4_free_blocks_count_set(es, percpu_counter_sum_positive( | 3526 | ext4_free_blocks_count_set(es, percpu_counter_sum_positive( |
| 3392 | &EXT4_SB(sb)->s_freeblocks_counter)); | 3527 | &EXT4_SB(sb)->s_freeblocks_counter)); |
| 3393 | es->s_free_inodes_count = cpu_to_le32(percpu_counter_sum_positive( | 3528 | es->s_free_inodes_count = cpu_to_le32(percpu_counter_sum_positive( |
| @@ -3491,7 +3626,7 @@ int ext4_force_commit(struct super_block *sb) | |||
| 3491 | 3626 | ||
| 3492 | journal = EXT4_SB(sb)->s_journal; | 3627 | journal = EXT4_SB(sb)->s_journal; |
| 3493 | if (journal) { | 3628 | if (journal) { |
| 3494 | vfs_check_frozen(sb, SB_FREEZE_WRITE); | 3629 | vfs_check_frozen(sb, SB_FREEZE_TRANS); |
| 3495 | ret = ext4_journal_force_commit(journal); | 3630 | ret = ext4_journal_force_commit(journal); |
| 3496 | } | 3631 | } |
| 3497 | 3632 | ||
| @@ -3616,7 +3751,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
| 3616 | } | 3751 | } |
| 3617 | 3752 | ||
| 3618 | if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED) | 3753 | if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED) |
| 3619 | ext4_abort(sb, __func__, "Abort forced by user"); | 3754 | ext4_abort(sb, "Abort forced by user"); |
| 3620 | 3755 | ||
| 3621 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | | 3756 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | |
| 3622 | (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0); | 3757 | (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0); |
| @@ -3981,6 +4116,18 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id, | |||
| 3981 | return err; | 4116 | return err; |
| 3982 | } | 4117 | } |
| 3983 | 4118 | ||
| 4119 | static int ext4_quota_off(struct super_block *sb, int type) | ||
| 4120 | { | ||
| 4121 | /* Force all delayed allocation blocks to be allocated */ | ||
| 4122 | if (test_opt(sb, DELALLOC)) { | ||
| 4123 | down_read(&sb->s_umount); | ||
| 4124 | sync_filesystem(sb); | ||
| 4125 | up_read(&sb->s_umount); | ||
| 4126 | } | ||
| 4127 | |||
| 4128 | return dquot_quota_off(sb, type); | ||
| 4129 | } | ||
| 4130 | |||
| 3984 | /* Read data from quotafile - avoid pagecache and such because we cannot afford | 4131 | /* Read data from quotafile - avoid pagecache and such because we cannot afford |
| 3985 | * acquiring the locks... As quota files are never truncated and quota code | 4132 | * acquiring the locks... As quota files are never truncated and quota code |
| 3986 | * itself serializes the operations (and noone else should touch the files) | 4133 | * itself serializes the operations (and noone else should touch the files) |
| @@ -4030,7 +4177,6 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type, | |||
| 4030 | ext4_lblk_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb); | 4177 | ext4_lblk_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb); |
| 4031 | int err = 0; | 4178 | int err = 0; |
| 4032 | int offset = off & (sb->s_blocksize - 1); | 4179 | int offset = off & (sb->s_blocksize - 1); |
| 4033 | int journal_quota = EXT4_SB(sb)->s_qf_names[type] != NULL; | ||
| 4034 | struct buffer_head *bh; | 4180 | struct buffer_head *bh; |
| 4035 | handle_t *handle = journal_current_handle(); | 4181 | handle_t *handle = journal_current_handle(); |
| 4036 | 4182 | ||
| @@ -4055,24 +4201,16 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type, | |||
| 4055 | bh = ext4_bread(handle, inode, blk, 1, &err); | 4201 | bh = ext4_bread(handle, inode, blk, 1, &err); |
| 4056 | if (!bh) | 4202 | if (!bh) |
| 4057 | goto out; | 4203 | goto out; |
| 4058 | if (journal_quota) { | 4204 | err = ext4_journal_get_write_access(handle, bh); |
| 4059 | err = ext4_journal_get_write_access(handle, bh); | 4205 | if (err) { |
| 4060 | if (err) { | 4206 | brelse(bh); |
| 4061 | brelse(bh); | 4207 | goto out; |
| 4062 | goto out; | ||
| 4063 | } | ||
| 4064 | } | 4208 | } |
| 4065 | lock_buffer(bh); | 4209 | lock_buffer(bh); |
| 4066 | memcpy(bh->b_data+offset, data, len); | 4210 | memcpy(bh->b_data+offset, data, len); |
| 4067 | flush_dcache_page(bh->b_page); | 4211 | flush_dcache_page(bh->b_page); |
| 4068 | unlock_buffer(bh); | 4212 | unlock_buffer(bh); |
| 4069 | if (journal_quota) | 4213 | err = ext4_handle_dirty_metadata(handle, NULL, bh); |
| 4070 | err = ext4_handle_dirty_metadata(handle, NULL, bh); | ||
| 4071 | else { | ||
| 4072 | /* Always do at least ordered writes for quotas */ | ||
| 4073 | err = ext4_jbd2_file_inode(handle, inode); | ||
| 4074 | mark_buffer_dirty(bh); | ||
| 4075 | } | ||
| 4076 | brelse(bh); | 4214 | brelse(bh); |
| 4077 | out: | 4215 | out: |
| 4078 | if (err) { | 4216 | if (err) { |
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 04338009793a..3a8cd8dff1ad 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c | |||
| @@ -458,8 +458,7 @@ static void ext4_xattr_update_super_block(handle_t *handle, | |||
| 458 | 458 | ||
| 459 | if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) { | 459 | if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) { |
| 460 | EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR); | 460 | EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR); |
| 461 | sb->s_dirt = 1; | 461 | ext4_handle_dirty_super(handle, sb); |
| 462 | ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh); | ||
| 463 | } | 462 | } |
| 464 | } | 463 | } |
| 465 | 464 | ||
| @@ -1418,7 +1417,7 @@ ext4_xattr_cache_insert(struct buffer_head *bh) | |||
| 1418 | ea_bdebug(bh, "out of memory"); | 1417 | ea_bdebug(bh, "out of memory"); |
| 1419 | return; | 1418 | return; |
| 1420 | } | 1419 | } |
| 1421 | error = mb_cache_entry_insert(ce, bh->b_bdev, bh->b_blocknr, &hash); | 1420 | error = mb_cache_entry_insert(ce, bh->b_bdev, bh->b_blocknr, hash); |
| 1422 | if (error) { | 1421 | if (error) { |
| 1423 | mb_cache_entry_free(ce); | 1422 | mb_cache_entry_free(ce); |
| 1424 | if (error == -EBUSY) { | 1423 | if (error == -EBUSY) { |
| @@ -1490,8 +1489,8 @@ ext4_xattr_cache_find(struct inode *inode, struct ext4_xattr_header *header, | |||
| 1490 | return NULL; /* never share */ | 1489 | return NULL; /* never share */ |
| 1491 | ea_idebug(inode, "looking for cached blocks [%x]", (int)hash); | 1490 | ea_idebug(inode, "looking for cached blocks [%x]", (int)hash); |
| 1492 | again: | 1491 | again: |
| 1493 | ce = mb_cache_entry_find_first(ext4_xattr_cache, 0, | 1492 | ce = mb_cache_entry_find_first(ext4_xattr_cache, inode->i_sb->s_bdev, |
| 1494 | inode->i_sb->s_bdev, hash); | 1493 | hash); |
| 1495 | while (ce) { | 1494 | while (ce) { |
| 1496 | struct buffer_head *bh; | 1495 | struct buffer_head *bh; |
| 1497 | 1496 | ||
| @@ -1515,7 +1514,7 @@ again: | |||
| 1515 | return bh; | 1514 | return bh; |
| 1516 | } | 1515 | } |
| 1517 | brelse(bh); | 1516 | brelse(bh); |
| 1518 | ce = mb_cache_entry_find_next(ce, 0, inode->i_sb->s_bdev, hash); | 1517 | ce = mb_cache_entry_find_next(ce, inode->i_sb->s_bdev, hash); |
| 1519 | } | 1518 | } |
| 1520 | return NULL; | 1519 | return NULL; |
| 1521 | } | 1520 | } |
| @@ -1591,9 +1590,7 @@ static void ext4_xattr_rehash(struct ext4_xattr_header *header, | |||
| 1591 | int __init | 1590 | int __init |
| 1592 | init_ext4_xattr(void) | 1591 | init_ext4_xattr(void) |
| 1593 | { | 1592 | { |
| 1594 | ext4_xattr_cache = mb_cache_create("ext4_xattr", NULL, | 1593 | ext4_xattr_cache = mb_cache_create("ext4_xattr", 6); |
| 1595 | sizeof(struct mb_cache_entry) + | ||
| 1596 | sizeof(((struct mb_cache_entry *) 0)->e_indexes[0]), 1, 6); | ||
| 1597 | if (!ext4_xattr_cache) | 1594 | if (!ext4_xattr_cache) |
| 1598 | return -ENOMEM; | 1595 | return -ENOMEM; |
| 1599 | return 0; | 1596 | return 0; |
