diff options
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/acl.c | 11 | ||||
-rw-r--r-- | fs/ext4/acl.h | 2 | ||||
-rw-r--r-- | fs/ext4/balloc.c | 3 | ||||
-rw-r--r-- | fs/ext4/dir.c | 56 | ||||
-rw-r--r-- | fs/ext4/ext4.h | 93 | ||||
-rw-r--r-- | fs/ext4/ext4_extents.h | 8 | ||||
-rw-r--r-- | fs/ext4/ext4_jbd2.h | 2 | ||||
-rw-r--r-- | fs/ext4/extents.c | 88 | ||||
-rw-r--r-- | fs/ext4/file.c | 22 | ||||
-rw-r--r-- | fs/ext4/fsync.c | 4 | ||||
-rw-r--r-- | fs/ext4/ialloc.c | 2 | ||||
-rw-r--r-- | fs/ext4/inode.c | 75 | ||||
-rw-r--r-- | fs/ext4/mballoc.c | 55 | ||||
-rw-r--r-- | fs/ext4/migrate.c | 2 | ||||
-rw-r--r-- | fs/ext4/namei.c | 69 | ||||
-rw-r--r-- | fs/ext4/page-io.c | 7 | ||||
-rw-r--r-- | fs/ext4/resize.c | 69 | ||||
-rw-r--r-- | fs/ext4/super.c | 297 | ||||
-rw-r--r-- | fs/ext4/xattr.c | 28 |
19 files changed, 545 insertions, 348 deletions
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c index 5e2ed4504ead..e0270d1f8d82 100644 --- a/fs/ext4/acl.c +++ b/fs/ext4/acl.c | |||
@@ -238,10 +238,17 @@ ext4_set_acl(handle_t *handle, struct inode *inode, int type, | |||
238 | } | 238 | } |
239 | 239 | ||
240 | int | 240 | int |
241 | ext4_check_acl(struct inode *inode, int mask) | 241 | ext4_check_acl(struct inode *inode, int mask, unsigned int flags) |
242 | { | 242 | { |
243 | struct posix_acl *acl = ext4_get_acl(inode, ACL_TYPE_ACCESS); | 243 | struct posix_acl *acl; |
244 | |||
245 | if (flags & IPERM_FLAG_RCU) { | ||
246 | if (!negative_cached_acl(inode, ACL_TYPE_ACCESS)) | ||
247 | return -ECHILD; | ||
248 | return -EAGAIN; | ||
249 | } | ||
244 | 250 | ||
251 | acl = ext4_get_acl(inode, ACL_TYPE_ACCESS); | ||
245 | if (IS_ERR(acl)) | 252 | if (IS_ERR(acl)) |
246 | return PTR_ERR(acl); | 253 | return PTR_ERR(acl); |
247 | if (acl) { | 254 | if (acl) { |
diff --git a/fs/ext4/acl.h b/fs/ext4/acl.h index 9d843d5deac4..dec821168fd4 100644 --- a/fs/ext4/acl.h +++ b/fs/ext4/acl.h | |||
@@ -54,7 +54,7 @@ static inline int ext4_acl_count(size_t size) | |||
54 | #ifdef CONFIG_EXT4_FS_POSIX_ACL | 54 | #ifdef CONFIG_EXT4_FS_POSIX_ACL |
55 | 55 | ||
56 | /* acl.c */ | 56 | /* acl.c */ |
57 | extern int ext4_check_acl(struct inode *, int); | 57 | extern int ext4_check_acl(struct inode *, int, unsigned int); |
58 | extern int ext4_acl_chmod(struct inode *); | 58 | extern int ext4_acl_chmod(struct inode *); |
59 | extern int ext4_init_acl(handle_t *, struct inode *, struct inode *); | 59 | extern int ext4_init_acl(handle_t *, struct inode *, struct inode *); |
60 | 60 | ||
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index 14c3af26c671..adf96b822781 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c | |||
@@ -592,7 +592,8 @@ ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode, | |||
592 | * Account for the allocated meta blocks. We will never | 592 | * Account for the allocated meta blocks. We will never |
593 | * fail EDQUOT for metdata, but we do account for it. | 593 | * fail EDQUOT for metdata, but we do account for it. |
594 | */ | 594 | */ |
595 | if (!(*errp) && EXT4_I(inode)->i_delalloc_reserved_flag) { | 595 | if (!(*errp) && |
596 | ext4_test_inode_state(inode, EXT4_STATE_DELALLOC_RESERVED)) { | ||
596 | spin_lock(&EXT4_I(inode)->i_block_reservation_lock); | 597 | spin_lock(&EXT4_I(inode)->i_block_reservation_lock); |
597 | EXT4_I(inode)->i_allocated_meta_blocks += ar.len; | 598 | EXT4_I(inode)->i_allocated_meta_blocks += ar.len; |
598 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); | 599 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); |
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c index ece76fb6a40c..164c56092e58 100644 --- a/fs/ext4/dir.c +++ b/fs/ext4/dir.c | |||
@@ -60,9 +60,13 @@ static unsigned char get_dtype(struct super_block *sb, int filetype) | |||
60 | return (ext4_filetype_table[filetype]); | 60 | return (ext4_filetype_table[filetype]); |
61 | } | 61 | } |
62 | 62 | ||
63 | 63 | /* | |
64 | * Return 0 if the directory entry is OK, and 1 if there is a problem | ||
65 | * | ||
66 | * Note: this is the opposite of what ext2 and ext3 historically returned... | ||
67 | */ | ||
64 | int __ext4_check_dir_entry(const char *function, unsigned int line, | 68 | int __ext4_check_dir_entry(const char *function, unsigned int line, |
65 | struct inode *dir, | 69 | struct inode *dir, struct file *filp, |
66 | struct ext4_dir_entry_2 *de, | 70 | struct ext4_dir_entry_2 *de, |
67 | struct buffer_head *bh, | 71 | struct buffer_head *bh, |
68 | unsigned int offset) | 72 | unsigned int offset) |
@@ -71,26 +75,37 @@ int __ext4_check_dir_entry(const char *function, unsigned int line, | |||
71 | const int rlen = ext4_rec_len_from_disk(de->rec_len, | 75 | const int rlen = ext4_rec_len_from_disk(de->rec_len, |
72 | dir->i_sb->s_blocksize); | 76 | dir->i_sb->s_blocksize); |
73 | 77 | ||
74 | if (rlen < EXT4_DIR_REC_LEN(1)) | 78 | if (unlikely(rlen < EXT4_DIR_REC_LEN(1))) |
75 | error_msg = "rec_len is smaller than minimal"; | 79 | error_msg = "rec_len is smaller than minimal"; |
76 | else if (rlen % 4 != 0) | 80 | else if (unlikely(rlen % 4 != 0)) |
77 | error_msg = "rec_len % 4 != 0"; | 81 | error_msg = "rec_len % 4 != 0"; |
78 | else if (rlen < EXT4_DIR_REC_LEN(de->name_len)) | 82 | else if (unlikely(rlen < EXT4_DIR_REC_LEN(de->name_len))) |
79 | error_msg = "rec_len is too small for name_len"; | 83 | error_msg = "rec_len is too small for name_len"; |
80 | else if (((char *) de - bh->b_data) + rlen > dir->i_sb->s_blocksize) | 84 | else if (unlikely(((char *) de - bh->b_data) + rlen > |
85 | dir->i_sb->s_blocksize)) | ||
81 | error_msg = "directory entry across blocks"; | 86 | error_msg = "directory entry across blocks"; |
82 | else if (le32_to_cpu(de->inode) > | 87 | else if (unlikely(le32_to_cpu(de->inode) > |
83 | le32_to_cpu(EXT4_SB(dir->i_sb)->s_es->s_inodes_count)) | 88 | le32_to_cpu(EXT4_SB(dir->i_sb)->s_es->s_inodes_count))) |
84 | error_msg = "inode out of bounds"; | 89 | error_msg = "inode out of bounds"; |
90 | else | ||
91 | return 0; | ||
85 | 92 | ||
86 | if (error_msg != NULL) | 93 | if (filp) |
87 | ext4_error_inode(dir, function, line, bh->b_blocknr, | 94 | ext4_error_file(filp, function, line, bh ? bh->b_blocknr : 0, |
88 | "bad entry in directory: %s - " | 95 | "bad entry in directory: %s - offset=%u(%u), " |
89 | "offset=%u(%u), inode=%u, rec_len=%d, name_len=%d", | 96 | "inode=%u, rec_len=%d, name_len=%d", |
90 | error_msg, (unsigned) (offset%bh->b_size), offset, | 97 | error_msg, (unsigned) (offset%bh->b_size), |
91 | le32_to_cpu(de->inode), | 98 | offset, le32_to_cpu(de->inode), |
92 | rlen, de->name_len); | 99 | rlen, de->name_len); |
93 | return error_msg == NULL ? 1 : 0; | 100 | else |
101 | ext4_error_inode(dir, function, line, bh ? bh->b_blocknr : 0, | ||
102 | "bad entry in directory: %s - offset=%u(%u), " | ||
103 | "inode=%u, rec_len=%d, name_len=%d", | ||
104 | error_msg, (unsigned) (offset%bh->b_size), | ||
105 | offset, le32_to_cpu(de->inode), | ||
106 | rlen, de->name_len); | ||
107 | |||
108 | return 1; | ||
94 | } | 109 | } |
95 | 110 | ||
96 | static int ext4_readdir(struct file *filp, | 111 | static int ext4_readdir(struct file *filp, |
@@ -152,8 +167,9 @@ static int ext4_readdir(struct file *filp, | |||
152 | */ | 167 | */ |
153 | if (!bh) { | 168 | if (!bh) { |
154 | if (!dir_has_error) { | 169 | if (!dir_has_error) { |
155 | EXT4_ERROR_INODE(inode, "directory " | 170 | EXT4_ERROR_FILE(filp, 0, |
156 | "contains a hole at offset %Lu", | 171 | "directory contains a " |
172 | "hole at offset %llu", | ||
157 | (unsigned long long) filp->f_pos); | 173 | (unsigned long long) filp->f_pos); |
158 | dir_has_error = 1; | 174 | dir_has_error = 1; |
159 | } | 175 | } |
@@ -194,8 +210,8 @@ revalidate: | |||
194 | while (!error && filp->f_pos < inode->i_size | 210 | while (!error && filp->f_pos < inode->i_size |
195 | && offset < sb->s_blocksize) { | 211 | && offset < sb->s_blocksize) { |
196 | de = (struct ext4_dir_entry_2 *) (bh->b_data + offset); | 212 | de = (struct ext4_dir_entry_2 *) (bh->b_data + offset); |
197 | if (!ext4_check_dir_entry(inode, de, | 213 | if (ext4_check_dir_entry(inode, filp, de, |
198 | bh, offset)) { | 214 | bh, offset)) { |
199 | /* | 215 | /* |
200 | * On error, skip the f_pos to the next block | 216 | * On error, skip the f_pos to the next block |
201 | */ | 217 | */ |
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 1f253a9a141d..1de65f572033 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -62,8 +62,8 @@ | |||
62 | #define EXT4_ERROR_INODE_BLOCK(inode, block, fmt, a...) \ | 62 | #define EXT4_ERROR_INODE_BLOCK(inode, block, fmt, a...) \ |
63 | ext4_error_inode((inode), __func__, __LINE__, (block), (fmt), ## a) | 63 | ext4_error_inode((inode), __func__, __LINE__, (block), (fmt), ## a) |
64 | 64 | ||
65 | #define EXT4_ERROR_FILE(file, fmt, a...) \ | 65 | #define EXT4_ERROR_FILE(file, block, fmt, a...) \ |
66 | ext4_error_file(__func__, __LINE__, (file), (fmt), ## a) | 66 | ext4_error_file((file), __func__, __LINE__, (block), (fmt), ## a) |
67 | 67 | ||
68 | /* data type for block offset of block group */ | 68 | /* data type for block offset of block group */ |
69 | typedef int ext4_grpblk_t; | 69 | typedef int ext4_grpblk_t; |
@@ -561,22 +561,6 @@ struct ext4_new_group_data { | |||
561 | #define EXT4_IOC32_SETVERSION_OLD FS_IOC32_SETVERSION | 561 | #define EXT4_IOC32_SETVERSION_OLD FS_IOC32_SETVERSION |
562 | #endif | 562 | #endif |
563 | 563 | ||
564 | |||
565 | /* | ||
566 | * Mount options | ||
567 | */ | ||
568 | struct ext4_mount_options { | ||
569 | unsigned long s_mount_opt; | ||
570 | uid_t s_resuid; | ||
571 | gid_t s_resgid; | ||
572 | unsigned long s_commit_interval; | ||
573 | u32 s_min_batch_time, s_max_batch_time; | ||
574 | #ifdef CONFIG_QUOTA | ||
575 | int s_jquota_fmt; | ||
576 | char *s_qf_names[MAXQUOTAS]; | ||
577 | #endif | ||
578 | }; | ||
579 | |||
580 | /* Max physical block we can address w/o extents */ | 564 | /* Max physical block we can address w/o extents */ |
581 | #define EXT4_MAX_BLOCK_FILE_PHYS 0xFFFFFFFF | 565 | #define EXT4_MAX_BLOCK_FILE_PHYS 0xFFFFFFFF |
582 | 566 | ||
@@ -709,6 +693,8 @@ do { \ | |||
709 | if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) \ | 693 | if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) \ |
710 | ext4_decode_extra_time(&(inode)->xtime, \ | 694 | ext4_decode_extra_time(&(inode)->xtime, \ |
711 | raw_inode->xtime ## _extra); \ | 695 | raw_inode->xtime ## _extra); \ |
696 | else \ | ||
697 | (inode)->xtime.tv_nsec = 0; \ | ||
712 | } while (0) | 698 | } while (0) |
713 | 699 | ||
714 | #define EXT4_EINODE_GET_XTIME(xtime, einode, raw_inode) \ | 700 | #define EXT4_EINODE_GET_XTIME(xtime, einode, raw_inode) \ |
@@ -719,6 +705,8 @@ do { \ | |||
719 | if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime ## _extra)) \ | 705 | if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime ## _extra)) \ |
720 | ext4_decode_extra_time(&(einode)->xtime, \ | 706 | ext4_decode_extra_time(&(einode)->xtime, \ |
721 | raw_inode->xtime ## _extra); \ | 707 | raw_inode->xtime ## _extra); \ |
708 | else \ | ||
709 | (einode)->xtime.tv_nsec = 0; \ | ||
722 | } while (0) | 710 | } while (0) |
723 | 711 | ||
724 | #define i_disk_version osd1.linux1.l_i_version | 712 | #define i_disk_version osd1.linux1.l_i_version |
@@ -750,12 +738,13 @@ do { \ | |||
750 | 738 | ||
751 | /* | 739 | /* |
752 | * storage for cached extent | 740 | * storage for cached extent |
741 | * If ec_len == 0, then the cache is invalid. | ||
742 | * If ec_start == 0, then the cache represents a gap (null mapping) | ||
753 | */ | 743 | */ |
754 | struct ext4_ext_cache { | 744 | struct ext4_ext_cache { |
755 | ext4_fsblk_t ec_start; | 745 | ext4_fsblk_t ec_start; |
756 | ext4_lblk_t ec_block; | 746 | ext4_lblk_t ec_block; |
757 | __u32 ec_len; /* must be 32bit to return holes */ | 747 | __u32 ec_len; /* must be 32bit to return holes */ |
758 | __u32 ec_type; | ||
759 | }; | 748 | }; |
760 | 749 | ||
761 | /* | 750 | /* |
@@ -774,10 +763,12 @@ struct ext4_inode_info { | |||
774 | * near to their parent directory's inode. | 763 | * near to their parent directory's inode. |
775 | */ | 764 | */ |
776 | ext4_group_t i_block_group; | 765 | ext4_group_t i_block_group; |
766 | ext4_lblk_t i_dir_start_lookup; | ||
767 | #if (BITS_PER_LONG < 64) | ||
777 | unsigned long i_state_flags; /* Dynamic state flags */ | 768 | unsigned long i_state_flags; /* Dynamic state flags */ |
769 | #endif | ||
778 | unsigned long i_flags; | 770 | unsigned long i_flags; |
779 | 771 | ||
780 | ext4_lblk_t i_dir_start_lookup; | ||
781 | #ifdef CONFIG_EXT4_FS_XATTR | 772 | #ifdef CONFIG_EXT4_FS_XATTR |
782 | /* | 773 | /* |
783 | * Extended attributes can be read independently of the main file | 774 | * Extended attributes can be read independently of the main file |
@@ -820,7 +811,7 @@ struct ext4_inode_info { | |||
820 | */ | 811 | */ |
821 | struct rw_semaphore i_data_sem; | 812 | struct rw_semaphore i_data_sem; |
822 | struct inode vfs_inode; | 813 | struct inode vfs_inode; |
823 | struct jbd2_inode jinode; | 814 | struct jbd2_inode *jinode; |
824 | 815 | ||
825 | struct ext4_ext_cache i_cached_extent; | 816 | struct ext4_ext_cache i_cached_extent; |
826 | /* | 817 | /* |
@@ -840,14 +831,12 @@ struct ext4_inode_info { | |||
840 | unsigned int i_reserved_data_blocks; | 831 | unsigned int i_reserved_data_blocks; |
841 | unsigned int i_reserved_meta_blocks; | 832 | unsigned int i_reserved_meta_blocks; |
842 | unsigned int i_allocated_meta_blocks; | 833 | unsigned int i_allocated_meta_blocks; |
843 | unsigned short i_delalloc_reserved_flag; | 834 | ext4_lblk_t i_da_metadata_calc_last_lblock; |
844 | sector_t i_da_metadata_calc_last_lblock; | ||
845 | int i_da_metadata_calc_len; | 835 | int i_da_metadata_calc_len; |
846 | 836 | ||
847 | /* on-disk additional length */ | 837 | /* on-disk additional length */ |
848 | __u16 i_extra_isize; | 838 | __u16 i_extra_isize; |
849 | 839 | ||
850 | spinlock_t i_block_reservation_lock; | ||
851 | #ifdef CONFIG_QUOTA | 840 | #ifdef CONFIG_QUOTA |
852 | /* quota space reservation, managed internally by quota code */ | 841 | /* quota space reservation, managed internally by quota code */ |
853 | qsize_t i_reserved_quota; | 842 | qsize_t i_reserved_quota; |
@@ -856,9 +845,11 @@ struct ext4_inode_info { | |||
856 | /* completed IOs that might need unwritten extents handling */ | 845 | /* completed IOs that might need unwritten extents handling */ |
857 | struct list_head i_completed_io_list; | 846 | struct list_head i_completed_io_list; |
858 | spinlock_t i_completed_io_lock; | 847 | spinlock_t i_completed_io_lock; |
848 | atomic_t i_ioend_count; /* Number of outstanding io_end structs */ | ||
859 | /* current io_end structure for async DIO write*/ | 849 | /* current io_end structure for async DIO write*/ |
860 | ext4_io_end_t *cur_aio_dio; | 850 | ext4_io_end_t *cur_aio_dio; |
861 | atomic_t i_ioend_count; /* Number of outstanding io_end structs */ | 851 | |
852 | spinlock_t i_block_reservation_lock; | ||
862 | 853 | ||
863 | /* | 854 | /* |
864 | * Transactions that contain inode's metadata needed to complete | 855 | * Transactions that contain inode's metadata needed to complete |
@@ -917,11 +908,20 @@ struct ext4_inode_info { | |||
917 | #define EXT4_MOUNT_DISCARD 0x40000000 /* Issue DISCARD requests */ | 908 | #define EXT4_MOUNT_DISCARD 0x40000000 /* Issue DISCARD requests */ |
918 | #define EXT4_MOUNT_INIT_INODE_TABLE 0x80000000 /* Initialize uninitialized itables */ | 909 | #define EXT4_MOUNT_INIT_INODE_TABLE 0x80000000 /* Initialize uninitialized itables */ |
919 | 910 | ||
920 | #define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt | 911 | #define clear_opt(sb, opt) EXT4_SB(sb)->s_mount_opt &= \ |
921 | #define set_opt(o, opt) o |= EXT4_MOUNT_##opt | 912 | ~EXT4_MOUNT_##opt |
913 | #define set_opt(sb, opt) EXT4_SB(sb)->s_mount_opt |= \ | ||
914 | EXT4_MOUNT_##opt | ||
922 | #define test_opt(sb, opt) (EXT4_SB(sb)->s_mount_opt & \ | 915 | #define test_opt(sb, opt) (EXT4_SB(sb)->s_mount_opt & \ |
923 | EXT4_MOUNT_##opt) | 916 | EXT4_MOUNT_##opt) |
924 | 917 | ||
918 | #define clear_opt2(sb, opt) EXT4_SB(sb)->s_mount_opt2 &= \ | ||
919 | ~EXT4_MOUNT2_##opt | ||
920 | #define set_opt2(sb, opt) EXT4_SB(sb)->s_mount_opt2 |= \ | ||
921 | EXT4_MOUNT2_##opt | ||
922 | #define test_opt2(sb, opt) (EXT4_SB(sb)->s_mount_opt2 & \ | ||
923 | EXT4_MOUNT2_##opt) | ||
924 | |||
925 | #define ext4_set_bit ext2_set_bit | 925 | #define ext4_set_bit ext2_set_bit |
926 | #define ext4_set_bit_atomic ext2_set_bit_atomic | 926 | #define ext4_set_bit_atomic ext2_set_bit_atomic |
927 | #define ext4_clear_bit ext2_clear_bit | 927 | #define ext4_clear_bit ext2_clear_bit |
@@ -1087,6 +1087,7 @@ struct ext4_sb_info { | |||
1087 | struct ext4_super_block *s_es; /* Pointer to the super block in the buffer */ | 1087 | struct ext4_super_block *s_es; /* Pointer to the super block in the buffer */ |
1088 | struct buffer_head **s_group_desc; | 1088 | struct buffer_head **s_group_desc; |
1089 | unsigned int s_mount_opt; | 1089 | unsigned int s_mount_opt; |
1090 | unsigned int s_mount_opt2; | ||
1090 | unsigned int s_mount_flags; | 1091 | unsigned int s_mount_flags; |
1091 | ext4_fsblk_t s_sb_block; | 1092 | ext4_fsblk_t s_sb_block; |
1092 | uid_t s_resuid; | 1093 | uid_t s_resuid; |
@@ -1237,24 +1238,39 @@ enum { | |||
1237 | EXT4_STATE_EXT_MIGRATE, /* Inode is migrating */ | 1238 | EXT4_STATE_EXT_MIGRATE, /* Inode is migrating */ |
1238 | EXT4_STATE_DIO_UNWRITTEN, /* need convert on dio done*/ | 1239 | EXT4_STATE_DIO_UNWRITTEN, /* need convert on dio done*/ |
1239 | EXT4_STATE_NEWENTRY, /* File just added to dir */ | 1240 | EXT4_STATE_NEWENTRY, /* File just added to dir */ |
1241 | EXT4_STATE_DELALLOC_RESERVED, /* blks already reserved for delalloc */ | ||
1240 | }; | 1242 | }; |
1241 | 1243 | ||
1242 | #define EXT4_INODE_BIT_FNS(name, field) \ | 1244 | #define EXT4_INODE_BIT_FNS(name, field, offset) \ |
1243 | static inline int ext4_test_inode_##name(struct inode *inode, int bit) \ | 1245 | static inline int ext4_test_inode_##name(struct inode *inode, int bit) \ |
1244 | { \ | 1246 | { \ |
1245 | return test_bit(bit, &EXT4_I(inode)->i_##field); \ | 1247 | return test_bit(bit + (offset), &EXT4_I(inode)->i_##field); \ |
1246 | } \ | 1248 | } \ |
1247 | static inline void ext4_set_inode_##name(struct inode *inode, int bit) \ | 1249 | static inline void ext4_set_inode_##name(struct inode *inode, int bit) \ |
1248 | { \ | 1250 | { \ |
1249 | set_bit(bit, &EXT4_I(inode)->i_##field); \ | 1251 | set_bit(bit + (offset), &EXT4_I(inode)->i_##field); \ |
1250 | } \ | 1252 | } \ |
1251 | static inline void ext4_clear_inode_##name(struct inode *inode, int bit) \ | 1253 | static inline void ext4_clear_inode_##name(struct inode *inode, int bit) \ |
1252 | { \ | 1254 | { \ |
1253 | clear_bit(bit, &EXT4_I(inode)->i_##field); \ | 1255 | clear_bit(bit + (offset), &EXT4_I(inode)->i_##field); \ |
1254 | } | 1256 | } |
1255 | 1257 | ||
1256 | EXT4_INODE_BIT_FNS(flag, flags) | 1258 | EXT4_INODE_BIT_FNS(flag, flags, 0) |
1257 | EXT4_INODE_BIT_FNS(state, state_flags) | 1259 | #if (BITS_PER_LONG < 64) |
1260 | EXT4_INODE_BIT_FNS(state, state_flags, 0) | ||
1261 | |||
1262 | static inline void ext4_clear_state_flags(struct ext4_inode_info *ei) | ||
1263 | { | ||
1264 | (ei)->i_state_flags = 0; | ||
1265 | } | ||
1266 | #else | ||
1267 | EXT4_INODE_BIT_FNS(state, flags, 32) | ||
1268 | |||
1269 | static inline void ext4_clear_state_flags(struct ext4_inode_info *ei) | ||
1270 | { | ||
1271 | /* We depend on the fact that callers will set i_flags */ | ||
1272 | } | ||
1273 | #endif | ||
1258 | #else | 1274 | #else |
1259 | /* Assume that user mode programs are passing in an ext4fs superblock, not | 1275 | /* Assume that user mode programs are passing in an ext4fs superblock, not |
1260 | * a kernel struct super_block. This will allow us to call the feature-test | 1276 | * a kernel struct super_block. This will allow us to call the feature-test |
@@ -1642,10 +1658,12 @@ extern unsigned ext4_init_block_bitmap(struct super_block *sb, | |||
1642 | 1658 | ||
1643 | /* dir.c */ | 1659 | /* dir.c */ |
1644 | extern int __ext4_check_dir_entry(const char *, unsigned int, struct inode *, | 1660 | extern int __ext4_check_dir_entry(const char *, unsigned int, struct inode *, |
1661 | struct file *, | ||
1645 | struct ext4_dir_entry_2 *, | 1662 | struct ext4_dir_entry_2 *, |
1646 | struct buffer_head *, unsigned int); | 1663 | struct buffer_head *, unsigned int); |
1647 | #define ext4_check_dir_entry(dir, de, bh, offset) \ | 1664 | #define ext4_check_dir_entry(dir, filp, de, bh, offset) \ |
1648 | __ext4_check_dir_entry(__func__, __LINE__, (dir), (de), (bh), (offset)) | 1665 | unlikely(__ext4_check_dir_entry(__func__, __LINE__, (dir), (filp), \ |
1666 | (de), (bh), (offset))) | ||
1649 | extern int ext4_htree_store_dirent(struct file *dir_file, __u32 hash, | 1667 | extern int ext4_htree_store_dirent(struct file *dir_file, __u32 hash, |
1650 | __u32 minor_hash, | 1668 | __u32 minor_hash, |
1651 | struct ext4_dir_entry_2 *dirent); | 1669 | struct ext4_dir_entry_2 *dirent); |
@@ -1653,6 +1671,7 @@ extern void ext4_htree_free_dir_info(struct dir_private_info *p); | |||
1653 | 1671 | ||
1654 | /* fsync.c */ | 1672 | /* fsync.c */ |
1655 | extern int ext4_sync_file(struct file *, int); | 1673 | extern int ext4_sync_file(struct file *, int); |
1674 | extern int ext4_flush_completed_IO(struct inode *); | ||
1656 | 1675 | ||
1657 | /* hash.c */ | 1676 | /* hash.c */ |
1658 | extern int ext4fs_dirhash(const char *name, int len, struct | 1677 | extern int ext4fs_dirhash(const char *name, int len, struct |
@@ -1752,8 +1771,8 @@ extern void ext4_error_inode(struct inode *, const char *, unsigned int, | |||
1752 | ext4_fsblk_t, const char *, ...) | 1771 | ext4_fsblk_t, const char *, ...) |
1753 | __attribute__ ((format (printf, 5, 6))); | 1772 | __attribute__ ((format (printf, 5, 6))); |
1754 | extern void ext4_error_file(struct file *, const char *, unsigned int, | 1773 | extern void ext4_error_file(struct file *, const char *, unsigned int, |
1755 | const char *, ...) | 1774 | ext4_fsblk_t, const char *, ...) |
1756 | __attribute__ ((format (printf, 4, 5))); | 1775 | __attribute__ ((format (printf, 5, 6))); |
1757 | extern void __ext4_std_error(struct super_block *, const char *, | 1776 | extern void __ext4_std_error(struct super_block *, const char *, |
1758 | unsigned int, int); | 1777 | unsigned int, int); |
1759 | extern void __ext4_abort(struct super_block *, const char *, unsigned int, | 1778 | extern void __ext4_abort(struct super_block *, const char *, unsigned int, |
diff --git a/fs/ext4/ext4_extents.h b/fs/ext4/ext4_extents.h index 28ce70fd9cd0..2e29abb30f76 100644 --- a/fs/ext4/ext4_extents.h +++ b/fs/ext4/ext4_extents.h | |||
@@ -119,10 +119,6 @@ struct ext4_ext_path { | |||
119 | * structure for external API | 119 | * structure for external API |
120 | */ | 120 | */ |
121 | 121 | ||
122 | #define EXT4_EXT_CACHE_NO 0 | ||
123 | #define EXT4_EXT_CACHE_GAP 1 | ||
124 | #define EXT4_EXT_CACHE_EXTENT 2 | ||
125 | |||
126 | /* | 122 | /* |
127 | * to be called by ext4_ext_walk_space() | 123 | * to be called by ext4_ext_walk_space() |
128 | * negative retcode - error | 124 | * negative retcode - error |
@@ -197,7 +193,7 @@ static inline unsigned short ext_depth(struct inode *inode) | |||
197 | static inline void | 193 | static inline void |
198 | ext4_ext_invalidate_cache(struct inode *inode) | 194 | ext4_ext_invalidate_cache(struct inode *inode) |
199 | { | 195 | { |
200 | EXT4_I(inode)->i_cached_extent.ec_type = EXT4_EXT_CACHE_NO; | 196 | EXT4_I(inode)->i_cached_extent.ec_len = 0; |
201 | } | 197 | } |
202 | 198 | ||
203 | static inline void ext4_ext_mark_uninitialized(struct ext4_extent *ext) | 199 | static inline void ext4_ext_mark_uninitialized(struct ext4_extent *ext) |
@@ -278,7 +274,7 @@ static inline void ext4_idx_store_pblock(struct ext4_extent_idx *ix, | |||
278 | } | 274 | } |
279 | 275 | ||
280 | extern int ext4_ext_calc_metadata_amount(struct inode *inode, | 276 | extern int ext4_ext_calc_metadata_amount(struct inode *inode, |
281 | sector_t lblocks); | 277 | ext4_lblk_t lblocks); |
282 | extern int ext4_extent_tree_init(handle_t *, struct inode *); | 278 | extern int ext4_extent_tree_init(handle_t *, struct inode *); |
283 | extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode, | 279 | extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode, |
284 | int num, | 280 | int num, |
diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h index b0bd792c58c5..d8b992e658c1 100644 --- a/fs/ext4/ext4_jbd2.h +++ b/fs/ext4/ext4_jbd2.h | |||
@@ -253,7 +253,7 @@ static inline int ext4_journal_force_commit(journal_t *journal) | |||
253 | static inline int ext4_jbd2_file_inode(handle_t *handle, struct inode *inode) | 253 | static inline int ext4_jbd2_file_inode(handle_t *handle, struct inode *inode) |
254 | { | 254 | { |
255 | if (ext4_handle_valid(handle)) | 255 | if (ext4_handle_valid(handle)) |
256 | return jbd2_journal_file_inode(handle, &EXT4_I(inode)->jinode); | 256 | return jbd2_journal_file_inode(handle, EXT4_I(inode)->jinode); |
257 | return 0; | 257 | return 0; |
258 | } | 258 | } |
259 | 259 | ||
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 966ecb0d8f86..d202d765dad2 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -117,11 +117,33 @@ static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode, | |||
117 | struct ext4_extent *ex; | 117 | struct ext4_extent *ex; |
118 | depth = path->p_depth; | 118 | depth = path->p_depth; |
119 | 119 | ||
120 | /* try to predict block placement */ | 120 | /* |
121 | * Try to predict block placement assuming that we are | ||
122 | * filling in a file which will eventually be | ||
123 | * non-sparse --- i.e., in the case of libbfd writing | ||
124 | * an ELF object sections out-of-order but in a way | ||
125 | * the eventually results in a contiguous object or | ||
126 | * executable file, or some database extending a table | ||
127 | * space file. However, this is actually somewhat | ||
128 | * non-ideal if we are writing a sparse file such as | ||
129 | * qemu or KVM writing a raw image file that is going | ||
130 | * to stay fairly sparse, since it will end up | ||
131 | * fragmenting the file system's free space. Maybe we | ||
132 | * should have some hueristics or some way to allow | ||
133 | * userspace to pass a hint to file system, | ||
134 | * especiially if the latter case turns out to be | ||
135 | * common. | ||
136 | */ | ||
121 | ex = path[depth].p_ext; | 137 | ex = path[depth].p_ext; |
122 | if (ex) | 138 | if (ex) { |
123 | return (ext4_ext_pblock(ex) + | 139 | ext4_fsblk_t ext_pblk = ext4_ext_pblock(ex); |
124 | (block - le32_to_cpu(ex->ee_block))); | 140 | ext4_lblk_t ext_block = le32_to_cpu(ex->ee_block); |
141 | |||
142 | if (block > ext_block) | ||
143 | return ext_pblk + (block - ext_block); | ||
144 | else | ||
145 | return ext_pblk - (ext_block - block); | ||
146 | } | ||
125 | 147 | ||
126 | /* it looks like index is empty; | 148 | /* it looks like index is empty; |
127 | * try to find starting block from index itself */ | 149 | * try to find starting block from index itself */ |
@@ -244,7 +266,7 @@ static inline int ext4_ext_space_root_idx(struct inode *inode, int check) | |||
244 | * to allocate @blocks | 266 | * to allocate @blocks |
245 | * Worse case is one block per extent | 267 | * Worse case is one block per extent |
246 | */ | 268 | */ |
247 | int ext4_ext_calc_metadata_amount(struct inode *inode, sector_t lblock) | 269 | int ext4_ext_calc_metadata_amount(struct inode *inode, ext4_lblk_t lblock) |
248 | { | 270 | { |
249 | struct ext4_inode_info *ei = EXT4_I(inode); | 271 | struct ext4_inode_info *ei = EXT4_I(inode); |
250 | int idxs, num = 0; | 272 | int idxs, num = 0; |
@@ -1872,12 +1894,10 @@ static int ext4_ext_walk_space(struct inode *inode, ext4_lblk_t block, | |||
1872 | cbex.ec_block = start; | 1894 | cbex.ec_block = start; |
1873 | cbex.ec_len = end - start; | 1895 | cbex.ec_len = end - start; |
1874 | cbex.ec_start = 0; | 1896 | cbex.ec_start = 0; |
1875 | cbex.ec_type = EXT4_EXT_CACHE_GAP; | ||
1876 | } else { | 1897 | } else { |
1877 | cbex.ec_block = le32_to_cpu(ex->ee_block); | 1898 | cbex.ec_block = le32_to_cpu(ex->ee_block); |
1878 | cbex.ec_len = ext4_ext_get_actual_len(ex); | 1899 | cbex.ec_len = ext4_ext_get_actual_len(ex); |
1879 | cbex.ec_start = ext4_ext_pblock(ex); | 1900 | cbex.ec_start = ext4_ext_pblock(ex); |
1880 | cbex.ec_type = EXT4_EXT_CACHE_EXTENT; | ||
1881 | } | 1901 | } |
1882 | 1902 | ||
1883 | if (unlikely(cbex.ec_len == 0)) { | 1903 | if (unlikely(cbex.ec_len == 0)) { |
@@ -1917,13 +1937,12 @@ static int ext4_ext_walk_space(struct inode *inode, ext4_lblk_t block, | |||
1917 | 1937 | ||
1918 | static void | 1938 | static void |
1919 | ext4_ext_put_in_cache(struct inode *inode, ext4_lblk_t block, | 1939 | ext4_ext_put_in_cache(struct inode *inode, ext4_lblk_t block, |
1920 | __u32 len, ext4_fsblk_t start, int type) | 1940 | __u32 len, ext4_fsblk_t start) |
1921 | { | 1941 | { |
1922 | struct ext4_ext_cache *cex; | 1942 | struct ext4_ext_cache *cex; |
1923 | BUG_ON(len == 0); | 1943 | BUG_ON(len == 0); |
1924 | spin_lock(&EXT4_I(inode)->i_block_reservation_lock); | 1944 | spin_lock(&EXT4_I(inode)->i_block_reservation_lock); |
1925 | cex = &EXT4_I(inode)->i_cached_extent; | 1945 | cex = &EXT4_I(inode)->i_cached_extent; |
1926 | cex->ec_type = type; | ||
1927 | cex->ec_block = block; | 1946 | cex->ec_block = block; |
1928 | cex->ec_len = len; | 1947 | cex->ec_len = len; |
1929 | cex->ec_start = start; | 1948 | cex->ec_start = start; |
@@ -1976,15 +1995,18 @@ ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path, | |||
1976 | } | 1995 | } |
1977 | 1996 | ||
1978 | ext_debug(" -> %u:%lu\n", lblock, len); | 1997 | ext_debug(" -> %u:%lu\n", lblock, len); |
1979 | ext4_ext_put_in_cache(inode, lblock, len, 0, EXT4_EXT_CACHE_GAP); | 1998 | ext4_ext_put_in_cache(inode, lblock, len, 0); |
1980 | } | 1999 | } |
1981 | 2000 | ||
2001 | /* | ||
2002 | * Return 0 if cache is invalid; 1 if the cache is valid | ||
2003 | */ | ||
1982 | static int | 2004 | static int |
1983 | ext4_ext_in_cache(struct inode *inode, ext4_lblk_t block, | 2005 | ext4_ext_in_cache(struct inode *inode, ext4_lblk_t block, |
1984 | struct ext4_extent *ex) | 2006 | struct ext4_extent *ex) |
1985 | { | 2007 | { |
1986 | struct ext4_ext_cache *cex; | 2008 | struct ext4_ext_cache *cex; |
1987 | int ret = EXT4_EXT_CACHE_NO; | 2009 | int ret = 0; |
1988 | 2010 | ||
1989 | /* | 2011 | /* |
1990 | * We borrow i_block_reservation_lock to protect i_cached_extent | 2012 | * We borrow i_block_reservation_lock to protect i_cached_extent |
@@ -1993,11 +2015,9 @@ ext4_ext_in_cache(struct inode *inode, ext4_lblk_t block, | |||
1993 | cex = &EXT4_I(inode)->i_cached_extent; | 2015 | cex = &EXT4_I(inode)->i_cached_extent; |
1994 | 2016 | ||
1995 | /* has cache valid data? */ | 2017 | /* has cache valid data? */ |
1996 | if (cex->ec_type == EXT4_EXT_CACHE_NO) | 2018 | if (cex->ec_len == 0) |
1997 | goto errout; | 2019 | goto errout; |
1998 | 2020 | ||
1999 | BUG_ON(cex->ec_type != EXT4_EXT_CACHE_GAP && | ||
2000 | cex->ec_type != EXT4_EXT_CACHE_EXTENT); | ||
2001 | if (in_range(block, cex->ec_block, cex->ec_len)) { | 2021 | if (in_range(block, cex->ec_block, cex->ec_len)) { |
2002 | ex->ee_block = cpu_to_le32(cex->ec_block); | 2022 | ex->ee_block = cpu_to_le32(cex->ec_block); |
2003 | ext4_ext_store_pblock(ex, cex->ec_start); | 2023 | ext4_ext_store_pblock(ex, cex->ec_start); |
@@ -2005,7 +2025,7 @@ ext4_ext_in_cache(struct inode *inode, ext4_lblk_t block, | |||
2005 | ext_debug("%u cached by %u:%u:%llu\n", | 2025 | ext_debug("%u cached by %u:%u:%llu\n", |
2006 | block, | 2026 | block, |
2007 | cex->ec_block, cex->ec_len, cex->ec_start); | 2027 | cex->ec_block, cex->ec_len, cex->ec_start); |
2008 | ret = cex->ec_type; | 2028 | ret = 1; |
2009 | } | 2029 | } |
2010 | errout: | 2030 | errout: |
2011 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); | 2031 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); |
@@ -3082,7 +3102,7 @@ static void unmap_underlying_metadata_blocks(struct block_device *bdev, | |||
3082 | * Handle EOFBLOCKS_FL flag, clearing it if necessary | 3102 | * Handle EOFBLOCKS_FL flag, clearing it if necessary |
3083 | */ | 3103 | */ |
3084 | static int check_eofblocks_fl(handle_t *handle, struct inode *inode, | 3104 | static int check_eofblocks_fl(handle_t *handle, struct inode *inode, |
3085 | struct ext4_map_blocks *map, | 3105 | ext4_lblk_t lblk, |
3086 | struct ext4_ext_path *path, | 3106 | struct ext4_ext_path *path, |
3087 | unsigned int len) | 3107 | unsigned int len) |
3088 | { | 3108 | { |
@@ -3112,7 +3132,7 @@ static int check_eofblocks_fl(handle_t *handle, struct inode *inode, | |||
3112 | * this turns out to be false, we can bail out from this | 3132 | * this turns out to be false, we can bail out from this |
3113 | * function immediately. | 3133 | * function immediately. |
3114 | */ | 3134 | */ |
3115 | if (map->m_lblk + len < le32_to_cpu(last_ex->ee_block) + | 3135 | if (lblk + len < le32_to_cpu(last_ex->ee_block) + |
3116 | ext4_ext_get_actual_len(last_ex)) | 3136 | ext4_ext_get_actual_len(last_ex)) |
3117 | return 0; | 3137 | return 0; |
3118 | /* | 3138 | /* |
@@ -3168,8 +3188,8 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode, | |||
3168 | path); | 3188 | path); |
3169 | if (ret >= 0) { | 3189 | if (ret >= 0) { |
3170 | ext4_update_inode_fsync_trans(handle, inode, 1); | 3190 | ext4_update_inode_fsync_trans(handle, inode, 1); |
3171 | err = check_eofblocks_fl(handle, inode, map, path, | 3191 | err = check_eofblocks_fl(handle, inode, map->m_lblk, |
3172 | map->m_len); | 3192 | path, map->m_len); |
3173 | } else | 3193 | } else |
3174 | err = ret; | 3194 | err = ret; |
3175 | goto out2; | 3195 | goto out2; |
@@ -3199,7 +3219,8 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode, | |||
3199 | ret = ext4_ext_convert_to_initialized(handle, inode, map, path); | 3219 | ret = ext4_ext_convert_to_initialized(handle, inode, map, path); |
3200 | if (ret >= 0) { | 3220 | if (ret >= 0) { |
3201 | ext4_update_inode_fsync_trans(handle, inode, 1); | 3221 | ext4_update_inode_fsync_trans(handle, inode, 1); |
3202 | err = check_eofblocks_fl(handle, inode, map, path, map->m_len); | 3222 | err = check_eofblocks_fl(handle, inode, map->m_lblk, path, |
3223 | map->m_len); | ||
3203 | if (err < 0) | 3224 | if (err < 0) |
3204 | goto out2; | 3225 | goto out2; |
3205 | } | 3226 | } |
@@ -3276,7 +3297,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, | |||
3276 | struct ext4_extent_header *eh; | 3297 | struct ext4_extent_header *eh; |
3277 | struct ext4_extent newex, *ex; | 3298 | struct ext4_extent newex, *ex; |
3278 | ext4_fsblk_t newblock; | 3299 | ext4_fsblk_t newblock; |
3279 | int err = 0, depth, ret, cache_type; | 3300 | int err = 0, depth, ret; |
3280 | unsigned int allocated = 0; | 3301 | unsigned int allocated = 0; |
3281 | struct ext4_allocation_request ar; | 3302 | struct ext4_allocation_request ar; |
3282 | ext4_io_end_t *io = EXT4_I(inode)->cur_aio_dio; | 3303 | ext4_io_end_t *io = EXT4_I(inode)->cur_aio_dio; |
@@ -3285,9 +3306,8 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, | |||
3285 | map->m_lblk, map->m_len, inode->i_ino); | 3306 | map->m_lblk, map->m_len, inode->i_ino); |
3286 | 3307 | ||
3287 | /* check in cache */ | 3308 | /* check in cache */ |
3288 | cache_type = ext4_ext_in_cache(inode, map->m_lblk, &newex); | 3309 | if (ext4_ext_in_cache(inode, map->m_lblk, &newex)) { |
3289 | if (cache_type) { | 3310 | if (!newex.ee_start_lo && !newex.ee_start_hi) { |
3290 | if (cache_type == EXT4_EXT_CACHE_GAP) { | ||
3291 | if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) { | 3311 | if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) { |
3292 | /* | 3312 | /* |
3293 | * block isn't allocated yet and | 3313 | * block isn't allocated yet and |
@@ -3296,7 +3316,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, | |||
3296 | goto out2; | 3316 | goto out2; |
3297 | } | 3317 | } |
3298 | /* we should allocate requested block */ | 3318 | /* we should allocate requested block */ |
3299 | } else if (cache_type == EXT4_EXT_CACHE_EXTENT) { | 3319 | } else { |
3300 | /* block is already allocated */ | 3320 | /* block is already allocated */ |
3301 | newblock = map->m_lblk | 3321 | newblock = map->m_lblk |
3302 | - le32_to_cpu(newex.ee_block) | 3322 | - le32_to_cpu(newex.ee_block) |
@@ -3305,8 +3325,6 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, | |||
3305 | allocated = ext4_ext_get_actual_len(&newex) - | 3325 | allocated = ext4_ext_get_actual_len(&newex) - |
3306 | (map->m_lblk - le32_to_cpu(newex.ee_block)); | 3326 | (map->m_lblk - le32_to_cpu(newex.ee_block)); |
3307 | goto out; | 3327 | goto out; |
3308 | } else { | ||
3309 | BUG(); | ||
3310 | } | 3328 | } |
3311 | } | 3329 | } |
3312 | 3330 | ||
@@ -3357,8 +3375,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, | |||
3357 | /* Do not put uninitialized extent in the cache */ | 3375 | /* Do not put uninitialized extent in the cache */ |
3358 | if (!ext4_ext_is_uninitialized(ex)) { | 3376 | if (!ext4_ext_is_uninitialized(ex)) { |
3359 | ext4_ext_put_in_cache(inode, ee_block, | 3377 | ext4_ext_put_in_cache(inode, ee_block, |
3360 | ee_len, ee_start, | 3378 | ee_len, ee_start); |
3361 | EXT4_EXT_CACHE_EXTENT); | ||
3362 | goto out; | 3379 | goto out; |
3363 | } | 3380 | } |
3364 | ret = ext4_ext_handle_uninitialized_extents(handle, | 3381 | ret = ext4_ext_handle_uninitialized_extents(handle, |
@@ -3456,7 +3473,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, | |||
3456 | map->m_flags |= EXT4_MAP_UNINIT; | 3473 | map->m_flags |= EXT4_MAP_UNINIT; |
3457 | } | 3474 | } |
3458 | 3475 | ||
3459 | err = check_eofblocks_fl(handle, inode, map, path, ar.len); | 3476 | err = check_eofblocks_fl(handle, inode, map->m_lblk, path, ar.len); |
3460 | if (err) | 3477 | if (err) |
3461 | goto out2; | 3478 | goto out2; |
3462 | 3479 | ||
@@ -3490,8 +3507,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, | |||
3490 | * when it is _not_ an uninitialized extent. | 3507 | * when it is _not_ an uninitialized extent. |
3491 | */ | 3508 | */ |
3492 | if ((flags & EXT4_GET_BLOCKS_UNINIT_EXT) == 0) { | 3509 | if ((flags & EXT4_GET_BLOCKS_UNINIT_EXT) == 0) { |
3493 | ext4_ext_put_in_cache(inode, map->m_lblk, allocated, newblock, | 3510 | ext4_ext_put_in_cache(inode, map->m_lblk, allocated, newblock); |
3494 | EXT4_EXT_CACHE_EXTENT); | ||
3495 | ext4_update_inode_fsync_trans(handle, inode, 1); | 3511 | ext4_update_inode_fsync_trans(handle, inode, 1); |
3496 | } else | 3512 | } else |
3497 | ext4_update_inode_fsync_trans(handle, inode, 0); | 3513 | ext4_update_inode_fsync_trans(handle, inode, 0); |
@@ -3519,6 +3535,12 @@ void ext4_ext_truncate(struct inode *inode) | |||
3519 | int err = 0; | 3535 | int err = 0; |
3520 | 3536 | ||
3521 | /* | 3537 | /* |
3538 | * finish any pending end_io work so we won't run the risk of | ||
3539 | * converting any truncated blocks to initialized later | ||
3540 | */ | ||
3541 | ext4_flush_completed_IO(inode); | ||
3542 | |||
3543 | /* | ||
3522 | * probably first extent we're gonna free will be last in block | 3544 | * probably first extent we're gonna free will be last in block |
3523 | */ | 3545 | */ |
3524 | err = ext4_writepage_trans_blocks(inode); | 3546 | err = ext4_writepage_trans_blocks(inode); |
@@ -3767,7 +3789,7 @@ static int ext4_ext_fiemap_cb(struct inode *inode, struct ext4_ext_path *path, | |||
3767 | 3789 | ||
3768 | logical = (__u64)newex->ec_block << blksize_bits; | 3790 | logical = (__u64)newex->ec_block << blksize_bits; |
3769 | 3791 | ||
3770 | if (newex->ec_type == EXT4_EXT_CACHE_GAP) { | 3792 | if (newex->ec_start == 0) { |
3771 | pgoff_t offset; | 3793 | pgoff_t offset; |
3772 | struct page *page; | 3794 | struct page *page; |
3773 | struct buffer_head *bh = NULL; | 3795 | struct buffer_head *bh = NULL; |
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 5a5c55ddceef..bb003dc9ffff 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c | |||
@@ -104,6 +104,7 @@ static int ext4_file_open(struct inode * inode, struct file * filp) | |||
104 | { | 104 | { |
105 | struct super_block *sb = inode->i_sb; | 105 | struct super_block *sb = inode->i_sb; |
106 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); | 106 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); |
107 | struct ext4_inode_info *ei = EXT4_I(inode); | ||
107 | struct vfsmount *mnt = filp->f_path.mnt; | 108 | struct vfsmount *mnt = filp->f_path.mnt; |
108 | struct path path; | 109 | struct path path; |
109 | char buf[64], *cp; | 110 | char buf[64], *cp; |
@@ -127,6 +128,27 @@ static int ext4_file_open(struct inode * inode, struct file * filp) | |||
127 | ext4_mark_super_dirty(sb); | 128 | ext4_mark_super_dirty(sb); |
128 | } | 129 | } |
129 | } | 130 | } |
131 | /* | ||
132 | * Set up the jbd2_inode if we are opening the inode for | ||
133 | * writing and the journal is present | ||
134 | */ | ||
135 | if (sbi->s_journal && !ei->jinode && (filp->f_mode & FMODE_WRITE)) { | ||
136 | struct jbd2_inode *jinode = jbd2_alloc_inode(GFP_KERNEL); | ||
137 | |||
138 | spin_lock(&inode->i_lock); | ||
139 | if (!ei->jinode) { | ||
140 | if (!jinode) { | ||
141 | spin_unlock(&inode->i_lock); | ||
142 | return -ENOMEM; | ||
143 | } | ||
144 | ei->jinode = jinode; | ||
145 | jbd2_journal_init_jbd_inode(ei->jinode, inode); | ||
146 | jinode = NULL; | ||
147 | } | ||
148 | spin_unlock(&inode->i_lock); | ||
149 | if (unlikely(jinode != NULL)) | ||
150 | jbd2_free_inode(jinode); | ||
151 | } | ||
130 | return dquot_file_open(inode, filp); | 152 | return dquot_file_open(inode, filp); |
131 | } | 153 | } |
132 | 154 | ||
diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c index c1a7bc923cf6..7829b287822a 100644 --- a/fs/ext4/fsync.c +++ b/fs/ext4/fsync.c | |||
@@ -75,7 +75,7 @@ static void dump_completed_IO(struct inode * inode) | |||
75 | * to written. | 75 | * to written. |
76 | * The function return the number of pending IOs on success. | 76 | * The function return the number of pending IOs on success. |
77 | */ | 77 | */ |
78 | static int flush_completed_IO(struct inode *inode) | 78 | extern int ext4_flush_completed_IO(struct inode *inode) |
79 | { | 79 | { |
80 | ext4_io_end_t *io; | 80 | ext4_io_end_t *io; |
81 | struct ext4_inode_info *ei = EXT4_I(inode); | 81 | struct ext4_inode_info *ei = EXT4_I(inode); |
@@ -169,7 +169,7 @@ int ext4_sync_file(struct file *file, int datasync) | |||
169 | if (inode->i_sb->s_flags & MS_RDONLY) | 169 | if (inode->i_sb->s_flags & MS_RDONLY) |
170 | return 0; | 170 | return 0; |
171 | 171 | ||
172 | ret = flush_completed_IO(inode); | 172 | ret = ext4_flush_completed_IO(inode); |
173 | if (ret < 0) | 173 | if (ret < 0) |
174 | return ret; | 174 | return ret; |
175 | 175 | ||
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 1ce240a23ebb..eb9097aec6f0 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c | |||
@@ -1027,7 +1027,7 @@ got: | |||
1027 | inode->i_generation = sbi->s_next_generation++; | 1027 | inode->i_generation = sbi->s_next_generation++; |
1028 | spin_unlock(&sbi->s_next_gen_lock); | 1028 | spin_unlock(&sbi->s_next_gen_lock); |
1029 | 1029 | ||
1030 | ei->i_state_flags = 0; | 1030 | ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */ |
1031 | ext4_set_inode_state(inode, EXT4_STATE_NEW); | 1031 | ext4_set_inode_state(inode, EXT4_STATE_NEW); |
1032 | 1032 | ||
1033 | ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize; | 1033 | ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize; |
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index ef9d5be0b2a8..9f7f9e49914f 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -39,7 +39,9 @@ | |||
39 | #include <linux/bio.h> | 39 | #include <linux/bio.h> |
40 | #include <linux/workqueue.h> | 40 | #include <linux/workqueue.h> |
41 | #include <linux/kernel.h> | 41 | #include <linux/kernel.h> |
42 | #include <linux/printk.h> | ||
42 | #include <linux/slab.h> | 43 | #include <linux/slab.h> |
44 | #include <linux/ratelimit.h> | ||
43 | 45 | ||
44 | #include "ext4_jbd2.h" | 46 | #include "ext4_jbd2.h" |
45 | #include "xattr.h" | 47 | #include "xattr.h" |
@@ -54,10 +56,17 @@ static inline int ext4_begin_ordered_truncate(struct inode *inode, | |||
54 | loff_t new_size) | 56 | loff_t new_size) |
55 | { | 57 | { |
56 | trace_ext4_begin_ordered_truncate(inode, new_size); | 58 | trace_ext4_begin_ordered_truncate(inode, new_size); |
57 | return jbd2_journal_begin_ordered_truncate( | 59 | /* |
58 | EXT4_SB(inode->i_sb)->s_journal, | 60 | * If jinode is zero, then we never opened the file for |
59 | &EXT4_I(inode)->jinode, | 61 | * writing, so there's no need to call |
60 | new_size); | 62 | * jbd2_journal_begin_ordered_truncate() since there's no |
63 | * outstanding writes we need to flush. | ||
64 | */ | ||
65 | if (!EXT4_I(inode)->jinode) | ||
66 | return 0; | ||
67 | return jbd2_journal_begin_ordered_truncate(EXT4_JOURNAL(inode), | ||
68 | EXT4_I(inode)->jinode, | ||
69 | new_size); | ||
61 | } | 70 | } |
62 | 71 | ||
63 | static void ext4_invalidatepage(struct page *page, unsigned long offset); | 72 | static void ext4_invalidatepage(struct page *page, unsigned long offset); |
@@ -552,7 +561,7 @@ static ext4_fsblk_t ext4_find_goal(struct inode *inode, ext4_lblk_t block, | |||
552 | } | 561 | } |
553 | 562 | ||
554 | /** | 563 | /** |
555 | * ext4_blks_to_allocate: Look up the block map and count the number | 564 | * ext4_blks_to_allocate - Look up the block map and count the number |
556 | * of direct blocks need to be allocated for the given branch. | 565 | * of direct blocks need to be allocated for the given branch. |
557 | * | 566 | * |
558 | * @branch: chain of indirect blocks | 567 | * @branch: chain of indirect blocks |
@@ -591,13 +600,19 @@ static int ext4_blks_to_allocate(Indirect *branch, int k, unsigned int blks, | |||
591 | 600 | ||
592 | /** | 601 | /** |
593 | * ext4_alloc_blocks: multiple allocate blocks needed for a branch | 602 | * ext4_alloc_blocks: multiple allocate blocks needed for a branch |
603 | * @handle: handle for this transaction | ||
604 | * @inode: inode which needs allocated blocks | ||
605 | * @iblock: the logical block to start allocated at | ||
606 | * @goal: preferred physical block of allocation | ||
594 | * @indirect_blks: the number of blocks need to allocate for indirect | 607 | * @indirect_blks: the number of blocks need to allocate for indirect |
595 | * blocks | 608 | * blocks |
596 | * | 609 | * @blks: number of desired blocks |
597 | * @new_blocks: on return it will store the new block numbers for | 610 | * @new_blocks: on return it will store the new block numbers for |
598 | * the indirect blocks(if needed) and the first direct block, | 611 | * the indirect blocks(if needed) and the first direct block, |
599 | * @blks: on return it will store the total number of allocated | 612 | * @err: on return it will store the error code |
600 | * direct blocks | 613 | * |
614 | * This function will return the number of blocks allocated as | ||
615 | * requested by the passed-in parameters. | ||
601 | */ | 616 | */ |
602 | static int ext4_alloc_blocks(handle_t *handle, struct inode *inode, | 617 | static int ext4_alloc_blocks(handle_t *handle, struct inode *inode, |
603 | ext4_lblk_t iblock, ext4_fsblk_t goal, | 618 | ext4_lblk_t iblock, ext4_fsblk_t goal, |
@@ -711,9 +726,11 @@ failed_out: | |||
711 | 726 | ||
712 | /** | 727 | /** |
713 | * ext4_alloc_branch - allocate and set up a chain of blocks. | 728 | * ext4_alloc_branch - allocate and set up a chain of blocks. |
729 | * @handle: handle for this transaction | ||
714 | * @inode: owner | 730 | * @inode: owner |
715 | * @indirect_blks: number of allocated indirect blocks | 731 | * @indirect_blks: number of allocated indirect blocks |
716 | * @blks: number of allocated direct blocks | 732 | * @blks: number of allocated direct blocks |
733 | * @goal: preferred place for allocation | ||
717 | * @offsets: offsets (in the blocks) to store the pointers to next. | 734 | * @offsets: offsets (in the blocks) to store the pointers to next. |
718 | * @branch: place to store the chain in. | 735 | * @branch: place to store the chain in. |
719 | * | 736 | * |
@@ -826,6 +843,7 @@ failed: | |||
826 | 843 | ||
827 | /** | 844 | /** |
828 | * ext4_splice_branch - splice the allocated branch onto inode. | 845 | * ext4_splice_branch - splice the allocated branch onto inode. |
846 | * @handle: handle for this transaction | ||
829 | * @inode: owner | 847 | * @inode: owner |
830 | * @block: (logical) number of block we are adding | 848 | * @block: (logical) number of block we are adding |
831 | * @chain: chain of indirect blocks (with a missing link - see | 849 | * @chain: chain of indirect blocks (with a missing link - see |
@@ -1081,7 +1099,7 @@ static int ext4_indirect_calc_metadata_amount(struct inode *inode, | |||
1081 | * Calculate the number of metadata blocks need to reserve | 1099 | * Calculate the number of metadata blocks need to reserve |
1082 | * to allocate a block located at @lblock | 1100 | * to allocate a block located at @lblock |
1083 | */ | 1101 | */ |
1084 | static int ext4_calc_metadata_amount(struct inode *inode, sector_t lblock) | 1102 | static int ext4_calc_metadata_amount(struct inode *inode, ext4_lblk_t lblock) |
1085 | { | 1103 | { |
1086 | if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) | 1104 | if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) |
1087 | return ext4_ext_calc_metadata_amount(inode, lblock); | 1105 | return ext4_ext_calc_metadata_amount(inode, lblock); |
@@ -1320,7 +1338,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, | |||
1320 | * avoid double accounting | 1338 | * avoid double accounting |
1321 | */ | 1339 | */ |
1322 | if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) | 1340 | if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) |
1323 | EXT4_I(inode)->i_delalloc_reserved_flag = 1; | 1341 | ext4_set_inode_state(inode, EXT4_STATE_DELALLOC_RESERVED); |
1324 | /* | 1342 | /* |
1325 | * We need to check for EXT4 here because migrate | 1343 | * We need to check for EXT4 here because migrate |
1326 | * could have changed the inode type in between | 1344 | * could have changed the inode type in between |
@@ -1350,7 +1368,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, | |||
1350 | ext4_da_update_reserve_space(inode, retval, 1); | 1368 | ext4_da_update_reserve_space(inode, retval, 1); |
1351 | } | 1369 | } |
1352 | if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) | 1370 | if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) |
1353 | EXT4_I(inode)->i_delalloc_reserved_flag = 0; | 1371 | ext4_clear_inode_state(inode, EXT4_STATE_DELALLOC_RESERVED); |
1354 | 1372 | ||
1355 | up_write((&EXT4_I(inode)->i_data_sem)); | 1373 | up_write((&EXT4_I(inode)->i_data_sem)); |
1356 | if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) { | 1374 | if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) { |
@@ -1878,7 +1896,7 @@ static int ext4_journalled_write_end(struct file *file, | |||
1878 | /* | 1896 | /* |
1879 | * Reserve a single block located at lblock | 1897 | * Reserve a single block located at lblock |
1880 | */ | 1898 | */ |
1881 | static int ext4_da_reserve_space(struct inode *inode, sector_t lblock) | 1899 | static int ext4_da_reserve_space(struct inode *inode, ext4_lblk_t lblock) |
1882 | { | 1900 | { |
1883 | int retries = 0; | 1901 | int retries = 0; |
1884 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); | 1902 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); |
@@ -2239,7 +2257,7 @@ static void mpage_da_map_and_submit(struct mpage_da_data *mpd) | |||
2239 | * affects functions in many different parts of the allocation | 2257 | * affects functions in many different parts of the allocation |
2240 | * call path. This flag exists primarily because we don't | 2258 | * call path. This flag exists primarily because we don't |
2241 | * want to change *many* call functions, so ext4_map_blocks() | 2259 | * want to change *many* call functions, so ext4_map_blocks() |
2242 | * will set the magic i_delalloc_reserved_flag once the | 2260 | * will set the EXT4_STATE_DELALLOC_RESERVED flag once the |
2243 | * inode's allocation semaphore is taken. | 2261 | * inode's allocation semaphore is taken. |
2244 | * | 2262 | * |
2245 | * If the blocks in questions were delalloc blocks, set | 2263 | * If the blocks in questions were delalloc blocks, set |
@@ -3720,8 +3738,7 @@ static int ext4_set_bh_endio(struct buffer_head *bh, struct inode *inode) | |||
3720 | retry: | 3738 | retry: |
3721 | io_end = ext4_init_io_end(inode, GFP_ATOMIC); | 3739 | io_end = ext4_init_io_end(inode, GFP_ATOMIC); |
3722 | if (!io_end) { | 3740 | if (!io_end) { |
3723 | if (printk_ratelimit()) | 3741 | pr_warn_ratelimited("%s: allocation fail\n", __func__); |
3724 | printk(KERN_WARNING "%s: allocation fail\n", __func__); | ||
3725 | schedule(); | 3742 | schedule(); |
3726 | goto retry; | 3743 | goto retry; |
3727 | } | 3744 | } |
@@ -4045,7 +4062,7 @@ int ext4_block_truncate_page(handle_t *handle, | |||
4045 | if (ext4_should_journal_data(inode)) { | 4062 | if (ext4_should_journal_data(inode)) { |
4046 | err = ext4_handle_dirty_metadata(handle, inode, bh); | 4063 | err = ext4_handle_dirty_metadata(handle, inode, bh); |
4047 | } else { | 4064 | } else { |
4048 | if (ext4_should_order_data(inode)) | 4065 | if (ext4_should_order_data(inode) && EXT4_I(inode)->jinode) |
4049 | err = ext4_jbd2_file_inode(handle, inode); | 4066 | err = ext4_jbd2_file_inode(handle, inode); |
4050 | mark_buffer_dirty(bh); | 4067 | mark_buffer_dirty(bh); |
4051 | } | 4068 | } |
@@ -4169,6 +4186,7 @@ static int ext4_clear_blocks(handle_t *handle, struct inode *inode, | |||
4169 | { | 4186 | { |
4170 | __le32 *p; | 4187 | __le32 *p; |
4171 | int flags = EXT4_FREE_BLOCKS_FORGET | EXT4_FREE_BLOCKS_VALIDATED; | 4188 | int flags = EXT4_FREE_BLOCKS_FORGET | EXT4_FREE_BLOCKS_VALIDATED; |
4189 | int err; | ||
4172 | 4190 | ||
4173 | if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) | 4191 | if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) |
4174 | flags |= EXT4_FREE_BLOCKS_METADATA; | 4192 | flags |= EXT4_FREE_BLOCKS_METADATA; |
@@ -4184,11 +4202,23 @@ static int ext4_clear_blocks(handle_t *handle, struct inode *inode, | |||
4184 | if (try_to_extend_transaction(handle, inode)) { | 4202 | if (try_to_extend_transaction(handle, inode)) { |
4185 | if (bh) { | 4203 | if (bh) { |
4186 | BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); | 4204 | BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); |
4187 | ext4_handle_dirty_metadata(handle, inode, bh); | 4205 | err = ext4_handle_dirty_metadata(handle, inode, bh); |
4206 | if (unlikely(err)) { | ||
4207 | ext4_std_error(inode->i_sb, err); | ||
4208 | return 1; | ||
4209 | } | ||
4210 | } | ||
4211 | err = ext4_mark_inode_dirty(handle, inode); | ||
4212 | if (unlikely(err)) { | ||
4213 | ext4_std_error(inode->i_sb, err); | ||
4214 | return 1; | ||
4215 | } | ||
4216 | err = ext4_truncate_restart_trans(handle, inode, | ||
4217 | blocks_for_truncate(inode)); | ||
4218 | if (unlikely(err)) { | ||
4219 | ext4_std_error(inode->i_sb, err); | ||
4220 | return 1; | ||
4188 | } | 4221 | } |
4189 | ext4_mark_inode_dirty(handle, inode); | ||
4190 | ext4_truncate_restart_trans(handle, inode, | ||
4191 | blocks_for_truncate(inode)); | ||
4192 | if (bh) { | 4222 | if (bh) { |
4193 | BUFFER_TRACE(bh, "retaking write access"); | 4223 | BUFFER_TRACE(bh, "retaking write access"); |
4194 | ext4_journal_get_write_access(handle, bh); | 4224 | ext4_journal_get_write_access(handle, bh); |
@@ -4349,6 +4379,7 @@ static void ext4_free_branches(handle_t *handle, struct inode *inode, | |||
4349 | (__le32 *) bh->b_data, | 4379 | (__le32 *) bh->b_data, |
4350 | (__le32 *) bh->b_data + addr_per_block, | 4380 | (__le32 *) bh->b_data + addr_per_block, |
4351 | depth); | 4381 | depth); |
4382 | brelse(bh); | ||
4352 | 4383 | ||
4353 | /* | 4384 | /* |
4354 | * Everything below this this pointer has been | 4385 | * Everything below this this pointer has been |
@@ -4859,7 +4890,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) | |||
4859 | } | 4890 | } |
4860 | inode->i_nlink = le16_to_cpu(raw_inode->i_links_count); | 4891 | inode->i_nlink = le16_to_cpu(raw_inode->i_links_count); |
4861 | 4892 | ||
4862 | ei->i_state_flags = 0; | 4893 | ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */ |
4863 | ei->i_dir_start_lookup = 0; | 4894 | ei->i_dir_start_lookup = 0; |
4864 | ei->i_dtime = le32_to_cpu(raw_inode->i_dtime); | 4895 | ei->i_dtime = le32_to_cpu(raw_inode->i_dtime); |
4865 | /* We now have enough fields to check if the inode was active or not. | 4896 | /* We now have enough fields to check if the inode was active or not. |
@@ -5118,7 +5149,7 @@ static int ext4_do_update_inode(handle_t *handle, | |||
5118 | if (ext4_inode_blocks_set(handle, raw_inode, ei)) | 5149 | if (ext4_inode_blocks_set(handle, raw_inode, ei)) |
5119 | goto out_brelse; | 5150 | goto out_brelse; |
5120 | raw_inode->i_dtime = cpu_to_le32(ei->i_dtime); | 5151 | raw_inode->i_dtime = cpu_to_le32(ei->i_dtime); |
5121 | raw_inode->i_flags = cpu_to_le32(ei->i_flags); | 5152 | raw_inode->i_flags = cpu_to_le32(ei->i_flags & 0xFFFFFFFF); |
5122 | if (EXT4_SB(inode->i_sb)->s_es->s_creator_os != | 5153 | if (EXT4_SB(inode->i_sb)->s_es->s_creator_os != |
5123 | cpu_to_le32(EXT4_OS_HURD)) | 5154 | cpu_to_le32(EXT4_OS_HURD)) |
5124 | raw_inode->i_file_acl_high = | 5155 | raw_inode->i_file_acl_high = |
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 5b4d4e3a4d58..851f49b2f9d2 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -2608,18 +2608,12 @@ int ext4_mb_release(struct super_block *sb) | |||
2608 | static inline int ext4_issue_discard(struct super_block *sb, | 2608 | static inline int ext4_issue_discard(struct super_block *sb, |
2609 | ext4_group_t block_group, ext4_grpblk_t block, int count) | 2609 | ext4_group_t block_group, ext4_grpblk_t block, int count) |
2610 | { | 2610 | { |
2611 | int ret; | ||
2612 | ext4_fsblk_t discard_block; | 2611 | ext4_fsblk_t discard_block; |
2613 | 2612 | ||
2614 | discard_block = block + ext4_group_first_block_no(sb, block_group); | 2613 | discard_block = block + ext4_group_first_block_no(sb, block_group); |
2615 | trace_ext4_discard_blocks(sb, | 2614 | trace_ext4_discard_blocks(sb, |
2616 | (unsigned long long) discard_block, count); | 2615 | (unsigned long long) discard_block, count); |
2617 | ret = sb_issue_discard(sb, discard_block, count, GFP_NOFS, 0); | 2616 | return sb_issue_discard(sb, discard_block, count, GFP_NOFS, 0); |
2618 | if (ret == -EOPNOTSUPP) { | ||
2619 | ext4_warning(sb, "discard not supported, disabling"); | ||
2620 | clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD); | ||
2621 | } | ||
2622 | return ret; | ||
2623 | } | 2617 | } |
2624 | 2618 | ||
2625 | /* | 2619 | /* |
@@ -2631,7 +2625,7 @@ static void release_blocks_on_commit(journal_t *journal, transaction_t *txn) | |||
2631 | struct super_block *sb = journal->j_private; | 2625 | struct super_block *sb = journal->j_private; |
2632 | struct ext4_buddy e4b; | 2626 | struct ext4_buddy e4b; |
2633 | struct ext4_group_info *db; | 2627 | struct ext4_group_info *db; |
2634 | int err, count = 0, count2 = 0; | 2628 | int err, ret, count = 0, count2 = 0; |
2635 | struct ext4_free_data *entry; | 2629 | struct ext4_free_data *entry; |
2636 | struct list_head *l, *ltmp; | 2630 | struct list_head *l, *ltmp; |
2637 | 2631 | ||
@@ -2641,9 +2635,15 @@ static void release_blocks_on_commit(journal_t *journal, transaction_t *txn) | |||
2641 | mb_debug(1, "gonna free %u blocks in group %u (0x%p):", | 2635 | mb_debug(1, "gonna free %u blocks in group %u (0x%p):", |
2642 | entry->count, entry->group, entry); | 2636 | entry->count, entry->group, entry); |
2643 | 2637 | ||
2644 | if (test_opt(sb, DISCARD)) | 2638 | if (test_opt(sb, DISCARD)) { |
2645 | ext4_issue_discard(sb, entry->group, | 2639 | ret = ext4_issue_discard(sb, entry->group, |
2646 | entry->start_blk, entry->count); | 2640 | entry->start_blk, entry->count); |
2641 | if (unlikely(ret == -EOPNOTSUPP)) { | ||
2642 | ext4_warning(sb, "discard not supported, " | ||
2643 | "disabling"); | ||
2644 | clear_opt(sb, DISCARD); | ||
2645 | } | ||
2646 | } | ||
2647 | 2647 | ||
2648 | err = ext4_mb_load_buddy(sb, entry->group, &e4b); | 2648 | err = ext4_mb_load_buddy(sb, entry->group, &e4b); |
2649 | /* we expect to find existing buddy because it's pinned */ | 2649 | /* we expect to find existing buddy because it's pinned */ |
@@ -3881,19 +3881,6 @@ repeat: | |||
3881 | } | 3881 | } |
3882 | } | 3882 | } |
3883 | 3883 | ||
3884 | /* | ||
3885 | * finds all preallocated spaces and return blocks being freed to them | ||
3886 | * if preallocated space becomes full (no block is used from the space) | ||
3887 | * then the function frees space in buddy | ||
3888 | * XXX: at the moment, truncate (which is the only way to free blocks) | ||
3889 | * discards all preallocations | ||
3890 | */ | ||
3891 | static void ext4_mb_return_to_preallocation(struct inode *inode, | ||
3892 | struct ext4_buddy *e4b, | ||
3893 | sector_t block, int count) | ||
3894 | { | ||
3895 | BUG_ON(!list_empty(&EXT4_I(inode)->i_prealloc_list)); | ||
3896 | } | ||
3897 | #ifdef CONFIG_EXT4_DEBUG | 3884 | #ifdef CONFIG_EXT4_DEBUG |
3898 | static void ext4_mb_show_ac(struct ext4_allocation_context *ac) | 3885 | static void ext4_mb_show_ac(struct ext4_allocation_context *ac) |
3899 | { | 3886 | { |
@@ -4283,7 +4270,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, | |||
4283 | * EDQUOT check, as blocks and quotas have been already | 4270 | * EDQUOT check, as blocks and quotas have been already |
4284 | * reserved when data being copied into pagecache. | 4271 | * reserved when data being copied into pagecache. |
4285 | */ | 4272 | */ |
4286 | if (EXT4_I(ar->inode)->i_delalloc_reserved_flag) | 4273 | if (ext4_test_inode_state(ar->inode, EXT4_STATE_DELALLOC_RESERVED)) |
4287 | ar->flags |= EXT4_MB_DELALLOC_RESERVED; | 4274 | ar->flags |= EXT4_MB_DELALLOC_RESERVED; |
4288 | else { | 4275 | else { |
4289 | /* Without delayed allocation we need to verify | 4276 | /* Without delayed allocation we need to verify |
@@ -4380,7 +4367,8 @@ out: | |||
4380 | if (inquota && ar->len < inquota) | 4367 | if (inquota && ar->len < inquota) |
4381 | dquot_free_block(ar->inode, inquota - ar->len); | 4368 | dquot_free_block(ar->inode, inquota - ar->len); |
4382 | if (!ar->len) { | 4369 | if (!ar->len) { |
4383 | if (!EXT4_I(ar->inode)->i_delalloc_reserved_flag) | 4370 | if (!ext4_test_inode_state(ar->inode, |
4371 | EXT4_STATE_DELALLOC_RESERVED)) | ||
4384 | /* release all the reserved blocks if non delalloc */ | 4372 | /* release all the reserved blocks if non delalloc */ |
4385 | percpu_counter_sub(&sbi->s_dirtyblocks_counter, | 4373 | percpu_counter_sub(&sbi->s_dirtyblocks_counter, |
4386 | reserv_blks); | 4374 | reserv_blks); |
@@ -4626,7 +4614,11 @@ do_more: | |||
4626 | * blocks being freed are metadata. these blocks shouldn't | 4614 | * blocks being freed are metadata. these blocks shouldn't |
4627 | * be used until this transaction is committed | 4615 | * be used until this transaction is committed |
4628 | */ | 4616 | */ |
4629 | new_entry = kmem_cache_alloc(ext4_free_ext_cachep, GFP_NOFS); | 4617 | new_entry = kmem_cache_alloc(ext4_free_ext_cachep, GFP_NOFS); |
4618 | if (!new_entry) { | ||
4619 | err = -ENOMEM; | ||
4620 | goto error_return; | ||
4621 | } | ||
4630 | new_entry->start_blk = bit; | 4622 | new_entry->start_blk = bit; |
4631 | new_entry->group = block_group; | 4623 | new_entry->group = block_group; |
4632 | new_entry->count = count; | 4624 | new_entry->count = count; |
@@ -4643,7 +4635,6 @@ do_more: | |||
4643 | ext4_lock_group(sb, block_group); | 4635 | ext4_lock_group(sb, block_group); |
4644 | mb_clear_bits(bitmap_bh->b_data, bit, count); | 4636 | mb_clear_bits(bitmap_bh->b_data, bit, count); |
4645 | mb_free_blocks(inode, &e4b, bit, count); | 4637 | mb_free_blocks(inode, &e4b, bit, count); |
4646 | ext4_mb_return_to_preallocation(inode, &e4b, block, count); | ||
4647 | } | 4638 | } |
4648 | 4639 | ||
4649 | ret = ext4_free_blks_count(sb, gdp) + count; | 4640 | ret = ext4_free_blks_count(sb, gdp) + count; |
@@ -4718,8 +4709,6 @@ static int ext4_trim_extent(struct super_block *sb, int start, int count, | |||
4718 | ext4_unlock_group(sb, group); | 4709 | ext4_unlock_group(sb, group); |
4719 | 4710 | ||
4720 | ret = ext4_issue_discard(sb, group, start, count); | 4711 | ret = ext4_issue_discard(sb, group, start, count); |
4721 | if (ret) | ||
4722 | ext4_std_error(sb, ret); | ||
4723 | 4712 | ||
4724 | ext4_lock_group(sb, group); | 4713 | ext4_lock_group(sb, group); |
4725 | mb_free_blocks(NULL, e4b, start, ex.fe_len); | 4714 | mb_free_blocks(NULL, e4b, start, ex.fe_len); |
@@ -4819,6 +4808,8 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range) | |||
4819 | ext4_group_t group, ngroups = ext4_get_groups_count(sb); | 4808 | ext4_group_t group, ngroups = ext4_get_groups_count(sb); |
4820 | ext4_grpblk_t cnt = 0, first_block, last_block; | 4809 | ext4_grpblk_t cnt = 0, first_block, last_block; |
4821 | uint64_t start, len, minlen, trimmed; | 4810 | uint64_t start, len, minlen, trimmed; |
4811 | ext4_fsblk_t first_data_blk = | ||
4812 | le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block); | ||
4822 | int ret = 0; | 4813 | int ret = 0; |
4823 | 4814 | ||
4824 | start = range->start >> sb->s_blocksize_bits; | 4815 | start = range->start >> sb->s_blocksize_bits; |
@@ -4828,6 +4819,10 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range) | |||
4828 | 4819 | ||
4829 | if (unlikely(minlen > EXT4_BLOCKS_PER_GROUP(sb))) | 4820 | if (unlikely(minlen > EXT4_BLOCKS_PER_GROUP(sb))) |
4830 | return -EINVAL; | 4821 | return -EINVAL; |
4822 | if (start < first_data_blk) { | ||
4823 | len -= first_data_blk - start; | ||
4824 | start = first_data_blk; | ||
4825 | } | ||
4831 | 4826 | ||
4832 | /* Determine first and last group to examine based on start and len */ | 4827 | /* Determine first and last group to examine based on start and len */ |
4833 | ext4_get_group_no_and_offset(sb, (ext4_fsblk_t) start, | 4828 | ext4_get_group_no_and_offset(sb, (ext4_fsblk_t) start, |
@@ -4851,7 +4846,7 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range) | |||
4851 | if (len >= EXT4_BLOCKS_PER_GROUP(sb)) | 4846 | if (len >= EXT4_BLOCKS_PER_GROUP(sb)) |
4852 | len -= (EXT4_BLOCKS_PER_GROUP(sb) - first_block); | 4847 | len -= (EXT4_BLOCKS_PER_GROUP(sb) - first_block); |
4853 | else | 4848 | else |
4854 | last_block = len; | 4849 | last_block = first_block + len; |
4855 | 4850 | ||
4856 | if (e4b.bd_info->bb_free >= minlen) { | 4851 | if (e4b.bd_info->bb_free >= minlen) { |
4857 | cnt = ext4_trim_all_free(sb, &e4b, first_block, | 4852 | cnt = ext4_trim_all_free(sb, &e4b, first_block, |
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c index 25f3a974b725..b0a126f23c20 100644 --- a/fs/ext4/migrate.c +++ b/fs/ext4/migrate.c | |||
@@ -496,7 +496,7 @@ int ext4_ext_migrate(struct inode *inode) | |||
496 | goal = (((inode->i_ino - 1) / EXT4_INODES_PER_GROUP(inode->i_sb)) * | 496 | goal = (((inode->i_ino - 1) / EXT4_INODES_PER_GROUP(inode->i_sb)) * |
497 | EXT4_INODES_PER_GROUP(inode->i_sb)) + 1; | 497 | EXT4_INODES_PER_GROUP(inode->i_sb)) + 1; |
498 | tmp_inode = ext4_new_inode(handle, inode->i_sb->s_root->d_inode, | 498 | tmp_inode = ext4_new_inode(handle, inode->i_sb->s_root->d_inode, |
499 | S_IFREG, 0, goal); | 499 | S_IFREG, NULL, goal); |
500 | if (IS_ERR(tmp_inode)) { | 500 | if (IS_ERR(tmp_inode)) { |
501 | retval = -ENOMEM; | 501 | retval = -ENOMEM; |
502 | ext4_journal_stop(handle); | 502 | ext4_journal_stop(handle); |
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index dc40e75cba88..5485390d32c5 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
@@ -581,9 +581,9 @@ static int htree_dirblock_to_tree(struct file *dir_file, | |||
581 | dir->i_sb->s_blocksize - | 581 | dir->i_sb->s_blocksize - |
582 | EXT4_DIR_REC_LEN(0)); | 582 | EXT4_DIR_REC_LEN(0)); |
583 | 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)) { |
584 | if (!ext4_check_dir_entry(dir, de, bh, | 584 | if (ext4_check_dir_entry(dir, NULL, de, bh, |
585 | (block<<EXT4_BLOCK_SIZE_BITS(dir->i_sb)) | 585 | (block<<EXT4_BLOCK_SIZE_BITS(dir->i_sb)) |
586 | +((char *)de - bh->b_data))) { | 586 | + ((char *)de - bh->b_data))) { |
587 | /* On error, skip the f_pos to the next block. */ | 587 | /* On error, skip the f_pos to the next block. */ |
588 | dir_file->f_pos = (dir_file->f_pos | | 588 | dir_file->f_pos = (dir_file->f_pos | |
589 | (dir->i_sb->s_blocksize - 1)) + 1; | 589 | (dir->i_sb->s_blocksize - 1)) + 1; |
@@ -820,7 +820,7 @@ static inline int search_dirblock(struct buffer_head *bh, | |||
820 | if ((char *) de + namelen <= dlimit && | 820 | if ((char *) de + namelen <= dlimit && |
821 | ext4_match (namelen, name, de)) { | 821 | ext4_match (namelen, name, de)) { |
822 | /* found a match - just to be sure, do a full check */ | 822 | /* found a match - just to be sure, do a full check */ |
823 | if (!ext4_check_dir_entry(dir, de, bh, offset)) | 823 | if (ext4_check_dir_entry(dir, NULL, de, bh, offset)) |
824 | return -1; | 824 | return -1; |
825 | *res_dir = de; | 825 | *res_dir = de; |
826 | return 1; | 826 | return 1; |
@@ -1036,7 +1036,7 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, stru | |||
1036 | return ERR_PTR(-EIO); | 1036 | return ERR_PTR(-EIO); |
1037 | } | 1037 | } |
1038 | inode = ext4_iget(dir->i_sb, ino); | 1038 | inode = ext4_iget(dir->i_sb, ino); |
1039 | if (unlikely(IS_ERR(inode))) { | 1039 | if (IS_ERR(inode)) { |
1040 | if (PTR_ERR(inode) == -ESTALE) { | 1040 | if (PTR_ERR(inode) == -ESTALE) { |
1041 | EXT4_ERROR_INODE(dir, | 1041 | EXT4_ERROR_INODE(dir, |
1042 | "deleted inode referenced: %u", | 1042 | "deleted inode referenced: %u", |
@@ -1269,7 +1269,7 @@ static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry, | |||
1269 | de = (struct ext4_dir_entry_2 *)bh->b_data; | 1269 | de = (struct ext4_dir_entry_2 *)bh->b_data; |
1270 | top = bh->b_data + blocksize - reclen; | 1270 | top = bh->b_data + blocksize - reclen; |
1271 | while ((char *) de <= top) { | 1271 | while ((char *) de <= top) { |
1272 | if (!ext4_check_dir_entry(dir, de, bh, offset)) | 1272 | if (ext4_check_dir_entry(dir, NULL, de, bh, offset)) |
1273 | return -EIO; | 1273 | return -EIO; |
1274 | if (ext4_match(namelen, name, de)) | 1274 | if (ext4_match(namelen, name, de)) |
1275 | return -EEXIST; | 1275 | return -EEXIST; |
@@ -1602,7 +1602,11 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, | |||
1602 | if (err) | 1602 | if (err) |
1603 | goto journal_error; | 1603 | goto journal_error; |
1604 | } | 1604 | } |
1605 | ext4_handle_dirty_metadata(handle, inode, frames[0].bh); | 1605 | err = ext4_handle_dirty_metadata(handle, inode, frames[0].bh); |
1606 | if (err) { | ||
1607 | ext4_std_error(inode->i_sb, err); | ||
1608 | goto cleanup; | ||
1609 | } | ||
1606 | } | 1610 | } |
1607 | de = do_split(handle, dir, &bh, frame, &hinfo, &err); | 1611 | de = do_split(handle, dir, &bh, frame, &hinfo, &err); |
1608 | if (!de) | 1612 | if (!de) |
@@ -1630,17 +1634,21 @@ static int ext4_delete_entry(handle_t *handle, | |||
1630 | { | 1634 | { |
1631 | struct ext4_dir_entry_2 *de, *pde; | 1635 | struct ext4_dir_entry_2 *de, *pde; |
1632 | unsigned int blocksize = dir->i_sb->s_blocksize; | 1636 | unsigned int blocksize = dir->i_sb->s_blocksize; |
1633 | int i; | 1637 | int i, err; |
1634 | 1638 | ||
1635 | i = 0; | 1639 | i = 0; |
1636 | pde = NULL; | 1640 | pde = NULL; |
1637 | de = (struct ext4_dir_entry_2 *) bh->b_data; | 1641 | de = (struct ext4_dir_entry_2 *) bh->b_data; |
1638 | while (i < bh->b_size) { | 1642 | while (i < bh->b_size) { |
1639 | if (!ext4_check_dir_entry(dir, de, bh, i)) | 1643 | if (ext4_check_dir_entry(dir, NULL, de, bh, i)) |
1640 | return -EIO; | 1644 | return -EIO; |
1641 | if (de == de_del) { | 1645 | if (de == de_del) { |
1642 | BUFFER_TRACE(bh, "get_write_access"); | 1646 | BUFFER_TRACE(bh, "get_write_access"); |
1643 | ext4_journal_get_write_access(handle, bh); | 1647 | err = ext4_journal_get_write_access(handle, bh); |
1648 | if (unlikely(err)) { | ||
1649 | ext4_std_error(dir->i_sb, err); | ||
1650 | return err; | ||
1651 | } | ||
1644 | if (pde) | 1652 | if (pde) |
1645 | pde->rec_len = ext4_rec_len_to_disk( | 1653 | pde->rec_len = ext4_rec_len_to_disk( |
1646 | ext4_rec_len_from_disk(pde->rec_len, | 1654 | ext4_rec_len_from_disk(pde->rec_len, |
@@ -1652,7 +1660,11 @@ static int ext4_delete_entry(handle_t *handle, | |||
1652 | de->inode = 0; | 1660 | de->inode = 0; |
1653 | dir->i_version++; | 1661 | dir->i_version++; |
1654 | BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); | 1662 | BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); |
1655 | ext4_handle_dirty_metadata(handle, dir, bh); | 1663 | err = ext4_handle_dirty_metadata(handle, dir, bh); |
1664 | if (unlikely(err)) { | ||
1665 | ext4_std_error(dir->i_sb, err); | ||
1666 | return err; | ||
1667 | } | ||
1656 | return 0; | 1668 | return 0; |
1657 | } | 1669 | } |
1658 | i += ext4_rec_len_from_disk(de->rec_len, blocksize); | 1670 | i += ext4_rec_len_from_disk(de->rec_len, blocksize); |
@@ -1789,7 +1801,7 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
1789 | { | 1801 | { |
1790 | handle_t *handle; | 1802 | handle_t *handle; |
1791 | struct inode *inode; | 1803 | struct inode *inode; |
1792 | struct buffer_head *dir_block; | 1804 | struct buffer_head *dir_block = NULL; |
1793 | struct ext4_dir_entry_2 *de; | 1805 | struct ext4_dir_entry_2 *de; |
1794 | unsigned int blocksize = dir->i_sb->s_blocksize; | 1806 | unsigned int blocksize = dir->i_sb->s_blocksize; |
1795 | int err, retries = 0; | 1807 | int err, retries = 0; |
@@ -1822,7 +1834,9 @@ retry: | |||
1822 | if (!dir_block) | 1834 | if (!dir_block) |
1823 | goto out_clear_inode; | 1835 | goto out_clear_inode; |
1824 | BUFFER_TRACE(dir_block, "get_write_access"); | 1836 | BUFFER_TRACE(dir_block, "get_write_access"); |
1825 | ext4_journal_get_write_access(handle, dir_block); | 1837 | err = ext4_journal_get_write_access(handle, dir_block); |
1838 | if (err) | ||
1839 | goto out_clear_inode; | ||
1826 | de = (struct ext4_dir_entry_2 *) dir_block->b_data; | 1840 | de = (struct ext4_dir_entry_2 *) dir_block->b_data; |
1827 | de->inode = cpu_to_le32(inode->i_ino); | 1841 | de->inode = cpu_to_le32(inode->i_ino); |
1828 | de->name_len = 1; | 1842 | de->name_len = 1; |
@@ -1839,10 +1853,12 @@ retry: | |||
1839 | ext4_set_de_type(dir->i_sb, de, S_IFDIR); | 1853 | ext4_set_de_type(dir->i_sb, de, S_IFDIR); |
1840 | inode->i_nlink = 2; | 1854 | inode->i_nlink = 2; |
1841 | BUFFER_TRACE(dir_block, "call ext4_handle_dirty_metadata"); | 1855 | BUFFER_TRACE(dir_block, "call ext4_handle_dirty_metadata"); |
1842 | ext4_handle_dirty_metadata(handle, dir, dir_block); | 1856 | err = ext4_handle_dirty_metadata(handle, dir, dir_block); |
1843 | brelse(dir_block); | 1857 | if (err) |
1844 | ext4_mark_inode_dirty(handle, inode); | 1858 | goto out_clear_inode; |
1845 | err = ext4_add_entry(handle, dentry, inode); | 1859 | err = ext4_mark_inode_dirty(handle, inode); |
1860 | if (!err) | ||
1861 | err = ext4_add_entry(handle, dentry, inode); | ||
1846 | if (err) { | 1862 | if (err) { |
1847 | out_clear_inode: | 1863 | out_clear_inode: |
1848 | clear_nlink(inode); | 1864 | clear_nlink(inode); |
@@ -1853,10 +1869,13 @@ out_clear_inode: | |||
1853 | } | 1869 | } |
1854 | ext4_inc_count(handle, dir); | 1870 | ext4_inc_count(handle, dir); |
1855 | ext4_update_dx_flag(dir); | 1871 | ext4_update_dx_flag(dir); |
1856 | ext4_mark_inode_dirty(handle, dir); | 1872 | err = ext4_mark_inode_dirty(handle, dir); |
1873 | if (err) | ||
1874 | goto out_clear_inode; | ||
1857 | d_instantiate(dentry, inode); | 1875 | d_instantiate(dentry, inode); |
1858 | unlock_new_inode(inode); | 1876 | unlock_new_inode(inode); |
1859 | out_stop: | 1877 | out_stop: |
1878 | brelse(dir_block); | ||
1860 | ext4_journal_stop(handle); | 1879 | ext4_journal_stop(handle); |
1861 | if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) | 1880 | if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) |
1862 | goto retry; | 1881 | goto retry; |
@@ -1919,7 +1938,7 @@ static int empty_dir(struct inode *inode) | |||
1919 | } | 1938 | } |
1920 | de = (struct ext4_dir_entry_2 *) bh->b_data; | 1939 | de = (struct ext4_dir_entry_2 *) bh->b_data; |
1921 | } | 1940 | } |
1922 | if (!ext4_check_dir_entry(inode, de, bh, offset)) { | 1941 | if (ext4_check_dir_entry(inode, NULL, de, bh, offset)) { |
1923 | de = (struct ext4_dir_entry_2 *)(bh->b_data + | 1942 | de = (struct ext4_dir_entry_2 *)(bh->b_data + |
1924 | sb->s_blocksize); | 1943 | sb->s_blocksize); |
1925 | offset = (offset | (sb->s_blocksize - 1)) + 1; | 1944 | offset = (offset | (sb->s_blocksize - 1)) + 1; |
@@ -2407,7 +2426,11 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
2407 | ext4_current_time(new_dir); | 2426 | ext4_current_time(new_dir); |
2408 | ext4_mark_inode_dirty(handle, new_dir); | 2427 | ext4_mark_inode_dirty(handle, new_dir); |
2409 | BUFFER_TRACE(new_bh, "call ext4_handle_dirty_metadata"); | 2428 | BUFFER_TRACE(new_bh, "call ext4_handle_dirty_metadata"); |
2410 | ext4_handle_dirty_metadata(handle, new_dir, new_bh); | 2429 | retval = ext4_handle_dirty_metadata(handle, new_dir, new_bh); |
2430 | if (unlikely(retval)) { | ||
2431 | ext4_std_error(new_dir->i_sb, retval); | ||
2432 | goto end_rename; | ||
2433 | } | ||
2411 | brelse(new_bh); | 2434 | brelse(new_bh); |
2412 | new_bh = NULL; | 2435 | new_bh = NULL; |
2413 | } | 2436 | } |
@@ -2459,7 +2482,11 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
2459 | PARENT_INO(dir_bh->b_data, new_dir->i_sb->s_blocksize) = | 2482 | PARENT_INO(dir_bh->b_data, new_dir->i_sb->s_blocksize) = |
2460 | cpu_to_le32(new_dir->i_ino); | 2483 | cpu_to_le32(new_dir->i_ino); |
2461 | BUFFER_TRACE(dir_bh, "call ext4_handle_dirty_metadata"); | 2484 | BUFFER_TRACE(dir_bh, "call ext4_handle_dirty_metadata"); |
2462 | ext4_handle_dirty_metadata(handle, old_dir, dir_bh); | 2485 | retval = ext4_handle_dirty_metadata(handle, old_dir, dir_bh); |
2486 | if (retval) { | ||
2487 | ext4_std_error(old_dir->i_sb, retval); | ||
2488 | goto end_rename; | ||
2489 | } | ||
2463 | ext4_dec_count(handle, old_dir); | 2490 | ext4_dec_count(handle, old_dir); |
2464 | if (new_inode) { | 2491 | if (new_inode) { |
2465 | /* checked empty_dir above, can't have another parent, | 2492 | /* checked empty_dir above, can't have another parent, |
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index beacce11ac50..7270dcfca92a 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c | |||
@@ -44,7 +44,7 @@ int __init ext4_init_pageio(void) | |||
44 | if (io_page_cachep == NULL) | 44 | if (io_page_cachep == NULL) |
45 | return -ENOMEM; | 45 | return -ENOMEM; |
46 | io_end_cachep = KMEM_CACHE(ext4_io_end, SLAB_RECLAIM_ACCOUNT); | 46 | io_end_cachep = KMEM_CACHE(ext4_io_end, SLAB_RECLAIM_ACCOUNT); |
47 | if (io_page_cachep == NULL) { | 47 | if (io_end_cachep == NULL) { |
48 | kmem_cache_destroy(io_page_cachep); | 48 | kmem_cache_destroy(io_page_cachep); |
49 | return -ENOMEM; | 49 | return -ENOMEM; |
50 | } | 50 | } |
@@ -158,11 +158,8 @@ static void ext4_end_io_work(struct work_struct *work) | |||
158 | 158 | ||
159 | ext4_io_end_t *ext4_init_io_end(struct inode *inode, gfp_t flags) | 159 | ext4_io_end_t *ext4_init_io_end(struct inode *inode, gfp_t flags) |
160 | { | 160 | { |
161 | ext4_io_end_t *io = NULL; | 161 | ext4_io_end_t *io = kmem_cache_zalloc(io_end_cachep, flags); |
162 | |||
163 | io = kmem_cache_alloc(io_end_cachep, flags); | ||
164 | if (io) { | 162 | if (io) { |
165 | memset(io, 0, sizeof(*io)); | ||
166 | atomic_inc(&EXT4_I(inode)->i_ioend_count); | 163 | atomic_inc(&EXT4_I(inode)->i_ioend_count); |
167 | io->inode = inode; | 164 | io->inode = inode; |
168 | INIT_WORK(&io->work, ext4_end_io_work); | 165 | INIT_WORK(&io->work, ext4_end_io_work); |
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index dc963929de65..3ecc6e45d2f9 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c | |||
@@ -220,7 +220,11 @@ static int setup_new_group_blocks(struct super_block *sb, | |||
220 | memcpy(gdb->b_data, sbi->s_group_desc[i]->b_data, gdb->b_size); | 220 | memcpy(gdb->b_data, sbi->s_group_desc[i]->b_data, gdb->b_size); |
221 | set_buffer_uptodate(gdb); | 221 | set_buffer_uptodate(gdb); |
222 | unlock_buffer(gdb); | 222 | unlock_buffer(gdb); |
223 | ext4_handle_dirty_metadata(handle, NULL, gdb); | 223 | err = ext4_handle_dirty_metadata(handle, NULL, gdb); |
224 | if (unlikely(err)) { | ||
225 | brelse(gdb); | ||
226 | goto exit_bh; | ||
227 | } | ||
224 | ext4_set_bit(bit, bh->b_data); | 228 | ext4_set_bit(bit, bh->b_data); |
225 | brelse(gdb); | 229 | brelse(gdb); |
226 | } | 230 | } |
@@ -232,6 +236,8 @@ static int setup_new_group_blocks(struct super_block *sb, | |||
232 | GFP_NOFS); | 236 | GFP_NOFS); |
233 | if (err) | 237 | if (err) |
234 | goto exit_bh; | 238 | goto exit_bh; |
239 | for (i = 0, bit = gdblocks + 1; i < reserved_gdb; i++, bit++) | ||
240 | ext4_set_bit(bit, bh->b_data); | ||
235 | 241 | ||
236 | ext4_debug("mark block bitmap %#04llx (+%llu)\n", input->block_bitmap, | 242 | ext4_debug("mark block bitmap %#04llx (+%llu)\n", input->block_bitmap, |
237 | input->block_bitmap - start); | 243 | input->block_bitmap - start); |
@@ -247,13 +253,20 @@ static int setup_new_group_blocks(struct super_block *sb, | |||
247 | err = sb_issue_zeroout(sb, block, sbi->s_itb_per_group, GFP_NOFS); | 253 | err = sb_issue_zeroout(sb, block, sbi->s_itb_per_group, GFP_NOFS); |
248 | if (err) | 254 | if (err) |
249 | goto exit_bh; | 255 | goto exit_bh; |
256 | for (i = 0, bit = input->inode_table - start; | ||
257 | i < sbi->s_itb_per_group; i++, bit++) | ||
258 | ext4_set_bit(bit, bh->b_data); | ||
250 | 259 | ||
251 | if ((err = extend_or_restart_transaction(handle, 2, bh))) | 260 | if ((err = extend_or_restart_transaction(handle, 2, bh))) |
252 | goto exit_bh; | 261 | goto exit_bh; |
253 | 262 | ||
254 | ext4_mark_bitmap_end(input->blocks_count, sb->s_blocksize * 8, | 263 | ext4_mark_bitmap_end(input->blocks_count, sb->s_blocksize * 8, |
255 | bh->b_data); | 264 | bh->b_data); |
256 | ext4_handle_dirty_metadata(handle, NULL, bh); | 265 | err = ext4_handle_dirty_metadata(handle, NULL, bh); |
266 | if (unlikely(err)) { | ||
267 | ext4_std_error(sb, err); | ||
268 | goto exit_bh; | ||
269 | } | ||
257 | brelse(bh); | 270 | brelse(bh); |
258 | /* Mark unused entries in inode bitmap used */ | 271 | /* Mark unused entries in inode bitmap used */ |
259 | ext4_debug("clear inode bitmap %#04llx (+%llu)\n", | 272 | ext4_debug("clear inode bitmap %#04llx (+%llu)\n", |
@@ -265,7 +278,9 @@ static int setup_new_group_blocks(struct super_block *sb, | |||
265 | 278 | ||
266 | ext4_mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), sb->s_blocksize * 8, | 279 | ext4_mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), sb->s_blocksize * 8, |
267 | bh->b_data); | 280 | bh->b_data); |
268 | ext4_handle_dirty_metadata(handle, NULL, bh); | 281 | err = ext4_handle_dirty_metadata(handle, NULL, bh); |
282 | if (unlikely(err)) | ||
283 | ext4_std_error(sb, err); | ||
269 | exit_bh: | 284 | exit_bh: |
270 | brelse(bh); | 285 | brelse(bh); |
271 | 286 | ||
@@ -417,17 +432,21 @@ static int add_new_gdb(handle_t *handle, struct inode *inode, | |||
417 | goto exit_dind; | 432 | goto exit_dind; |
418 | } | 433 | } |
419 | 434 | ||
420 | if ((err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh))) | 435 | err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh); |
436 | if (unlikely(err)) | ||
421 | goto exit_dind; | 437 | goto exit_dind; |
422 | 438 | ||
423 | if ((err = ext4_journal_get_write_access(handle, *primary))) | 439 | err = ext4_journal_get_write_access(handle, *primary); |
440 | if (unlikely(err)) | ||
424 | goto exit_sbh; | 441 | goto exit_sbh; |
425 | 442 | ||
426 | if ((err = ext4_journal_get_write_access(handle, dind))) | 443 | err = ext4_journal_get_write_access(handle, dind); |
427 | goto exit_primary; | 444 | if (unlikely(err)) |
445 | ext4_std_error(sb, err); | ||
428 | 446 | ||
429 | /* ext4_reserve_inode_write() gets a reference on the iloc */ | 447 | /* ext4_reserve_inode_write() gets a reference on the iloc */ |
430 | if ((err = ext4_reserve_inode_write(handle, inode, &iloc))) | 448 | err = ext4_reserve_inode_write(handle, inode, &iloc); |
449 | if (unlikely(err)) | ||
431 | goto exit_dindj; | 450 | goto exit_dindj; |
432 | 451 | ||
433 | n_group_desc = kmalloc((gdb_num + 1) * sizeof(struct buffer_head *), | 452 | n_group_desc = kmalloc((gdb_num + 1) * sizeof(struct buffer_head *), |
@@ -449,12 +468,20 @@ static int add_new_gdb(handle_t *handle, struct inode *inode, | |||
449 | * reserved inode, and will become GDT blocks (primary and backup). | 468 | * reserved inode, and will become GDT blocks (primary and backup). |
450 | */ | 469 | */ |
451 | data[gdb_num % EXT4_ADDR_PER_BLOCK(sb)] = 0; | 470 | data[gdb_num % EXT4_ADDR_PER_BLOCK(sb)] = 0; |
452 | ext4_handle_dirty_metadata(handle, NULL, dind); | 471 | err = ext4_handle_dirty_metadata(handle, NULL, dind); |
453 | brelse(dind); | 472 | if (unlikely(err)) { |
473 | ext4_std_error(sb, err); | ||
474 | goto exit_inode; | ||
475 | } | ||
454 | inode->i_blocks -= (gdbackups + 1) * sb->s_blocksize >> 9; | 476 | inode->i_blocks -= (gdbackups + 1) * sb->s_blocksize >> 9; |
455 | ext4_mark_iloc_dirty(handle, inode, &iloc); | 477 | ext4_mark_iloc_dirty(handle, inode, &iloc); |
456 | memset((*primary)->b_data, 0, sb->s_blocksize); | 478 | memset((*primary)->b_data, 0, sb->s_blocksize); |
457 | ext4_handle_dirty_metadata(handle, NULL, *primary); | 479 | err = ext4_handle_dirty_metadata(handle, NULL, *primary); |
480 | if (unlikely(err)) { | ||
481 | ext4_std_error(sb, err); | ||
482 | goto exit_inode; | ||
483 | } | ||
484 | brelse(dind); | ||
458 | 485 | ||
459 | o_group_desc = EXT4_SB(sb)->s_group_desc; | 486 | o_group_desc = EXT4_SB(sb)->s_group_desc; |
460 | memcpy(n_group_desc, o_group_desc, | 487 | memcpy(n_group_desc, o_group_desc, |
@@ -465,19 +492,19 @@ static int add_new_gdb(handle_t *handle, struct inode *inode, | |||
465 | kfree(o_group_desc); | 492 | kfree(o_group_desc); |
466 | 493 | ||
467 | le16_add_cpu(&es->s_reserved_gdt_blocks, -1); | 494 | le16_add_cpu(&es->s_reserved_gdt_blocks, -1); |
468 | ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh); | 495 | err = ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh); |
496 | if (err) | ||
497 | ext4_std_error(sb, err); | ||
469 | 498 | ||
470 | return 0; | 499 | return err; |
471 | 500 | ||
472 | exit_inode: | 501 | exit_inode: |
473 | /* ext4_journal_release_buffer(handle, iloc.bh); */ | 502 | /* ext4_journal_release_buffer(handle, iloc.bh); */ |
474 | brelse(iloc.bh); | 503 | brelse(iloc.bh); |
475 | exit_dindj: | 504 | exit_dindj: |
476 | /* ext4_journal_release_buffer(handle, dind); */ | 505 | /* ext4_journal_release_buffer(handle, dind); */ |
477 | exit_primary: | ||
478 | /* ext4_journal_release_buffer(handle, *primary); */ | ||
479 | exit_sbh: | 506 | exit_sbh: |
480 | /* ext4_journal_release_buffer(handle, *primary); */ | 507 | /* ext4_journal_release_buffer(handle, EXT4_SB(sb)->s_sbh); */ |
481 | exit_dind: | 508 | exit_dind: |
482 | brelse(dind); | 509 | brelse(dind); |
483 | exit_bh: | 510 | exit_bh: |
@@ -660,7 +687,9 @@ static void update_backups(struct super_block *sb, | |||
660 | memset(bh->b_data + size, 0, rest); | 687 | memset(bh->b_data + size, 0, rest); |
661 | set_buffer_uptodate(bh); | 688 | set_buffer_uptodate(bh); |
662 | unlock_buffer(bh); | 689 | unlock_buffer(bh); |
663 | ext4_handle_dirty_metadata(handle, NULL, bh); | 690 | err = ext4_handle_dirty_metadata(handle, NULL, bh); |
691 | if (unlikely(err)) | ||
692 | ext4_std_error(sb, err); | ||
664 | brelse(bh); | 693 | brelse(bh); |
665 | } | 694 | } |
666 | if ((err2 = ext4_journal_stop(handle)) && !err) | 695 | if ((err2 = ext4_journal_stop(handle)) && !err) |
@@ -878,7 +907,11 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input) | |||
878 | /* Update the global fs size fields */ | 907 | /* Update the global fs size fields */ |
879 | sbi->s_groups_count++; | 908 | sbi->s_groups_count++; |
880 | 909 | ||
881 | ext4_handle_dirty_metadata(handle, NULL, primary); | 910 | err = ext4_handle_dirty_metadata(handle, NULL, primary); |
911 | if (unlikely(err)) { | ||
912 | ext4_std_error(sb, err); | ||
913 | goto exit_journal; | ||
914 | } | ||
882 | 915 | ||
883 | /* Update the reserved block counts only once the new group is | 916 | /* Update the reserved block counts only once the new group is |
884 | * active. */ | 917 | * active. */ |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index fb15c9c0be74..29c80f6d8b27 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -388,13 +388,14 @@ static void ext4_handle_error(struct super_block *sb) | |||
388 | void __ext4_error(struct super_block *sb, const char *function, | 388 | void __ext4_error(struct super_block *sb, const char *function, |
389 | unsigned int line, const char *fmt, ...) | 389 | unsigned int line, const char *fmt, ...) |
390 | { | 390 | { |
391 | struct va_format vaf; | ||
391 | va_list args; | 392 | va_list args; |
392 | 393 | ||
393 | va_start(args, fmt); | 394 | va_start(args, fmt); |
394 | printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: comm %s: ", | 395 | vaf.fmt = fmt; |
395 | sb->s_id, function, line, current->comm); | 396 | vaf.va = &args; |
396 | vprintk(fmt, args); | 397 | printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: comm %s: %pV\n", |
397 | printk("\n"); | 398 | sb->s_id, function, line, current->comm, &vaf); |
398 | va_end(args); | 399 | va_end(args); |
399 | 400 | ||
400 | ext4_handle_error(sb); | 401 | ext4_handle_error(sb); |
@@ -405,28 +406,31 @@ void ext4_error_inode(struct inode *inode, const char *function, | |||
405 | const char *fmt, ...) | 406 | const char *fmt, ...) |
406 | { | 407 | { |
407 | va_list args; | 408 | va_list args; |
409 | struct va_format vaf; | ||
408 | struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es; | 410 | struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es; |
409 | 411 | ||
410 | es->s_last_error_ino = cpu_to_le32(inode->i_ino); | 412 | es->s_last_error_ino = cpu_to_le32(inode->i_ino); |
411 | es->s_last_error_block = cpu_to_le64(block); | 413 | es->s_last_error_block = cpu_to_le64(block); |
412 | save_error_info(inode->i_sb, function, line); | 414 | save_error_info(inode->i_sb, function, line); |
413 | va_start(args, fmt); | 415 | va_start(args, fmt); |
416 | vaf.fmt = fmt; | ||
417 | vaf.va = &args; | ||
414 | printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: inode #%lu: ", | 418 | printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: inode #%lu: ", |
415 | inode->i_sb->s_id, function, line, inode->i_ino); | 419 | inode->i_sb->s_id, function, line, inode->i_ino); |
416 | if (block) | 420 | if (block) |
417 | printk("block %llu: ", block); | 421 | printk(KERN_CONT "block %llu: ", block); |
418 | printk("comm %s: ", current->comm); | 422 | printk(KERN_CONT "comm %s: %pV\n", current->comm, &vaf); |
419 | vprintk(fmt, args); | ||
420 | printk("\n"); | ||
421 | va_end(args); | 423 | va_end(args); |
422 | 424 | ||
423 | ext4_handle_error(inode->i_sb); | 425 | ext4_handle_error(inode->i_sb); |
424 | } | 426 | } |
425 | 427 | ||
426 | void ext4_error_file(struct file *file, const char *function, | 428 | void ext4_error_file(struct file *file, const char *function, |
427 | unsigned int line, const char *fmt, ...) | 429 | unsigned int line, ext4_fsblk_t block, |
430 | const char *fmt, ...) | ||
428 | { | 431 | { |
429 | va_list args; | 432 | va_list args; |
433 | struct va_format vaf; | ||
430 | struct ext4_super_block *es; | 434 | struct ext4_super_block *es; |
431 | struct inode *inode = file->f_dentry->d_inode; | 435 | struct inode *inode = file->f_dentry->d_inode; |
432 | char pathname[80], *path; | 436 | char pathname[80], *path; |
@@ -434,17 +438,18 @@ void ext4_error_file(struct file *file, const char *function, | |||
434 | es = EXT4_SB(inode->i_sb)->s_es; | 438 | es = EXT4_SB(inode->i_sb)->s_es; |
435 | es->s_last_error_ino = cpu_to_le32(inode->i_ino); | 439 | es->s_last_error_ino = cpu_to_le32(inode->i_ino); |
436 | save_error_info(inode->i_sb, function, line); | 440 | save_error_info(inode->i_sb, function, line); |
437 | va_start(args, fmt); | ||
438 | path = d_path(&(file->f_path), pathname, sizeof(pathname)); | 441 | path = d_path(&(file->f_path), pathname, sizeof(pathname)); |
439 | if (!path) | 442 | if (IS_ERR(path)) |
440 | path = "(unknown)"; | 443 | path = "(unknown)"; |
441 | printk(KERN_CRIT | 444 | printk(KERN_CRIT |
442 | "EXT4-fs error (device %s): %s:%d: inode #%lu " | 445 | "EXT4-fs error (device %s): %s:%d: inode #%lu: ", |
443 | "(comm %s path %s): ", | 446 | inode->i_sb->s_id, function, line, inode->i_ino); |
444 | inode->i_sb->s_id, function, line, inode->i_ino, | 447 | if (block) |
445 | current->comm, path); | 448 | printk(KERN_CONT "block %llu: ", block); |
446 | vprintk(fmt, args); | 449 | va_start(args, fmt); |
447 | printk("\n"); | 450 | vaf.fmt = fmt; |
451 | vaf.va = &args; | ||
452 | printk(KERN_CONT "comm %s: path %s: %pV\n", current->comm, path, &vaf); | ||
448 | va_end(args); | 453 | va_end(args); |
449 | 454 | ||
450 | ext4_handle_error(inode->i_sb); | 455 | ext4_handle_error(inode->i_sb); |
@@ -543,28 +548,29 @@ void __ext4_abort(struct super_block *sb, const char *function, | |||
543 | panic("EXT4-fs panic from previous error\n"); | 548 | panic("EXT4-fs panic from previous error\n"); |
544 | } | 549 | } |
545 | 550 | ||
546 | void ext4_msg (struct super_block * sb, const char *prefix, | 551 | void ext4_msg(struct super_block *sb, const char *prefix, const char *fmt, ...) |
547 | const char *fmt, ...) | ||
548 | { | 552 | { |
553 | struct va_format vaf; | ||
549 | va_list args; | 554 | va_list args; |
550 | 555 | ||
551 | va_start(args, fmt); | 556 | va_start(args, fmt); |
552 | printk("%sEXT4-fs (%s): ", prefix, sb->s_id); | 557 | vaf.fmt = fmt; |
553 | vprintk(fmt, args); | 558 | vaf.va = &args; |
554 | printk("\n"); | 559 | printk("%sEXT4-fs (%s): %pV\n", prefix, sb->s_id, &vaf); |
555 | va_end(args); | 560 | va_end(args); |
556 | } | 561 | } |
557 | 562 | ||
558 | void __ext4_warning(struct super_block *sb, const char *function, | 563 | void __ext4_warning(struct super_block *sb, const char *function, |
559 | unsigned int line, const char *fmt, ...) | 564 | unsigned int line, const char *fmt, ...) |
560 | { | 565 | { |
566 | struct va_format vaf; | ||
561 | va_list args; | 567 | va_list args; |
562 | 568 | ||
563 | va_start(args, fmt); | 569 | va_start(args, fmt); |
564 | printk(KERN_WARNING "EXT4-fs warning (device %s): %s:%d: ", | 570 | vaf.fmt = fmt; |
565 | sb->s_id, function, line); | 571 | vaf.va = &args; |
566 | vprintk(fmt, args); | 572 | printk(KERN_WARNING "EXT4-fs warning (device %s): %s:%d: %pV\n", |
567 | printk("\n"); | 573 | sb->s_id, function, line, &vaf); |
568 | va_end(args); | 574 | va_end(args); |
569 | } | 575 | } |
570 | 576 | ||
@@ -575,21 +581,25 @@ void __ext4_grp_locked_error(const char *function, unsigned int line, | |||
575 | __releases(bitlock) | 581 | __releases(bitlock) |
576 | __acquires(bitlock) | 582 | __acquires(bitlock) |
577 | { | 583 | { |
584 | struct va_format vaf; | ||
578 | va_list args; | 585 | va_list args; |
579 | struct ext4_super_block *es = EXT4_SB(sb)->s_es; | 586 | struct ext4_super_block *es = EXT4_SB(sb)->s_es; |
580 | 587 | ||
581 | es->s_last_error_ino = cpu_to_le32(ino); | 588 | es->s_last_error_ino = cpu_to_le32(ino); |
582 | es->s_last_error_block = cpu_to_le64(block); | 589 | es->s_last_error_block = cpu_to_le64(block); |
583 | __save_error_info(sb, function, line); | 590 | __save_error_info(sb, function, line); |
591 | |||
584 | va_start(args, fmt); | 592 | va_start(args, fmt); |
593 | |||
594 | vaf.fmt = fmt; | ||
595 | vaf.va = &args; | ||
585 | printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: group %u", | 596 | printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: group %u", |
586 | sb->s_id, function, line, grp); | 597 | sb->s_id, function, line, grp); |
587 | if (ino) | 598 | if (ino) |
588 | printk("inode %lu: ", ino); | 599 | printk(KERN_CONT "inode %lu: ", ino); |
589 | if (block) | 600 | if (block) |
590 | printk("block %llu:", (unsigned long long) block); | 601 | printk(KERN_CONT "block %llu:", (unsigned long long) block); |
591 | vprintk(fmt, args); | 602 | printk(KERN_CONT "%pV\n", &vaf); |
592 | printk("\n"); | ||
593 | va_end(args); | 603 | va_end(args); |
594 | 604 | ||
595 | if (test_opt(sb, ERRORS_CONT)) { | 605 | if (test_opt(sb, ERRORS_CONT)) { |
@@ -808,21 +818,15 @@ static struct inode *ext4_alloc_inode(struct super_block *sb) | |||
808 | memset(&ei->i_cached_extent, 0, sizeof(struct ext4_ext_cache)); | 818 | memset(&ei->i_cached_extent, 0, sizeof(struct ext4_ext_cache)); |
809 | INIT_LIST_HEAD(&ei->i_prealloc_list); | 819 | INIT_LIST_HEAD(&ei->i_prealloc_list); |
810 | spin_lock_init(&ei->i_prealloc_lock); | 820 | spin_lock_init(&ei->i_prealloc_lock); |
811 | /* | ||
812 | * Note: We can be called before EXT4_SB(sb)->s_journal is set, | ||
813 | * therefore it can be null here. Don't check it, just initialize | ||
814 | * jinode. | ||
815 | */ | ||
816 | jbd2_journal_init_jbd_inode(&ei->jinode, &ei->vfs_inode); | ||
817 | ei->i_reserved_data_blocks = 0; | 821 | ei->i_reserved_data_blocks = 0; |
818 | ei->i_reserved_meta_blocks = 0; | 822 | ei->i_reserved_meta_blocks = 0; |
819 | ei->i_allocated_meta_blocks = 0; | 823 | ei->i_allocated_meta_blocks = 0; |
820 | ei->i_da_metadata_calc_len = 0; | 824 | ei->i_da_metadata_calc_len = 0; |
821 | ei->i_delalloc_reserved_flag = 0; | ||
822 | spin_lock_init(&(ei->i_block_reservation_lock)); | 825 | spin_lock_init(&(ei->i_block_reservation_lock)); |
823 | #ifdef CONFIG_QUOTA | 826 | #ifdef CONFIG_QUOTA |
824 | ei->i_reserved_quota = 0; | 827 | ei->i_reserved_quota = 0; |
825 | #endif | 828 | #endif |
829 | ei->jinode = NULL; | ||
826 | INIT_LIST_HEAD(&ei->i_completed_io_list); | 830 | INIT_LIST_HEAD(&ei->i_completed_io_list); |
827 | spin_lock_init(&ei->i_completed_io_lock); | 831 | spin_lock_init(&ei->i_completed_io_lock); |
828 | ei->cur_aio_dio = NULL; | 832 | ei->cur_aio_dio = NULL; |
@@ -841,6 +845,13 @@ static int ext4_drop_inode(struct inode *inode) | |||
841 | return drop; | 845 | return drop; |
842 | } | 846 | } |
843 | 847 | ||
848 | static void ext4_i_callback(struct rcu_head *head) | ||
849 | { | ||
850 | struct inode *inode = container_of(head, struct inode, i_rcu); | ||
851 | INIT_LIST_HEAD(&inode->i_dentry); | ||
852 | kmem_cache_free(ext4_inode_cachep, EXT4_I(inode)); | ||
853 | } | ||
854 | |||
844 | static void ext4_destroy_inode(struct inode *inode) | 855 | static void ext4_destroy_inode(struct inode *inode) |
845 | { | 856 | { |
846 | ext4_ioend_wait(inode); | 857 | ext4_ioend_wait(inode); |
@@ -853,7 +864,7 @@ static void ext4_destroy_inode(struct inode *inode) | |||
853 | true); | 864 | true); |
854 | dump_stack(); | 865 | dump_stack(); |
855 | } | 866 | } |
856 | kmem_cache_free(ext4_inode_cachep, EXT4_I(inode)); | 867 | call_rcu(&inode->i_rcu, ext4_i_callback); |
857 | } | 868 | } |
858 | 869 | ||
859 | static void init_once(void *foo) | 870 | static void init_once(void *foo) |
@@ -891,9 +902,12 @@ void ext4_clear_inode(struct inode *inode) | |||
891 | end_writeback(inode); | 902 | end_writeback(inode); |
892 | dquot_drop(inode); | 903 | dquot_drop(inode); |
893 | ext4_discard_preallocations(inode); | 904 | ext4_discard_preallocations(inode); |
894 | if (EXT4_JOURNAL(inode)) | 905 | if (EXT4_I(inode)->jinode) { |
895 | jbd2_journal_release_jbd_inode(EXT4_SB(inode->i_sb)->s_journal, | 906 | jbd2_journal_release_jbd_inode(EXT4_JOURNAL(inode), |
896 | &EXT4_I(inode)->jinode); | 907 | EXT4_I(inode)->jinode); |
908 | jbd2_free_inode(EXT4_I(inode)->jinode); | ||
909 | EXT4_I(inode)->jinode = NULL; | ||
910 | } | ||
897 | } | 911 | } |
898 | 912 | ||
899 | static inline void ext4_show_quota_options(struct seq_file *seq, | 913 | static inline void ext4_show_quota_options(struct seq_file *seq, |
@@ -1386,7 +1400,7 @@ static int set_qf_name(struct super_block *sb, int qtype, substring_t *args) | |||
1386 | sbi->s_qf_names[qtype] = NULL; | 1400 | sbi->s_qf_names[qtype] = NULL; |
1387 | return 0; | 1401 | return 0; |
1388 | } | 1402 | } |
1389 | set_opt(sbi->s_mount_opt, QUOTA); | 1403 | set_opt(sb, QUOTA); |
1390 | return 1; | 1404 | return 1; |
1391 | } | 1405 | } |
1392 | 1406 | ||
@@ -1441,21 +1455,21 @@ static int parse_options(char *options, struct super_block *sb, | |||
1441 | switch (token) { | 1455 | switch (token) { |
1442 | case Opt_bsd_df: | 1456 | case Opt_bsd_df: |
1443 | ext4_msg(sb, KERN_WARNING, deprecated_msg, p, "2.6.38"); | 1457 | ext4_msg(sb, KERN_WARNING, deprecated_msg, p, "2.6.38"); |
1444 | clear_opt(sbi->s_mount_opt, MINIX_DF); | 1458 | clear_opt(sb, MINIX_DF); |
1445 | break; | 1459 | break; |
1446 | case Opt_minix_df: | 1460 | case Opt_minix_df: |
1447 | ext4_msg(sb, KERN_WARNING, deprecated_msg, p, "2.6.38"); | 1461 | ext4_msg(sb, KERN_WARNING, deprecated_msg, p, "2.6.38"); |
1448 | set_opt(sbi->s_mount_opt, MINIX_DF); | 1462 | set_opt(sb, MINIX_DF); |
1449 | 1463 | ||
1450 | break; | 1464 | break; |
1451 | case Opt_grpid: | 1465 | case Opt_grpid: |
1452 | ext4_msg(sb, KERN_WARNING, deprecated_msg, p, "2.6.38"); | 1466 | ext4_msg(sb, KERN_WARNING, deprecated_msg, p, "2.6.38"); |
1453 | set_opt(sbi->s_mount_opt, GRPID); | 1467 | set_opt(sb, GRPID); |
1454 | 1468 | ||
1455 | break; | 1469 | break; |
1456 | case Opt_nogrpid: | 1470 | case Opt_nogrpid: |
1457 | ext4_msg(sb, KERN_WARNING, deprecated_msg, p, "2.6.38"); | 1471 | ext4_msg(sb, KERN_WARNING, deprecated_msg, p, "2.6.38"); |
1458 | clear_opt(sbi->s_mount_opt, GRPID); | 1472 | clear_opt(sb, GRPID); |
1459 | 1473 | ||
1460 | break; | 1474 | break; |
1461 | case Opt_resuid: | 1475 | case Opt_resuid: |
@@ -1473,38 +1487,38 @@ static int parse_options(char *options, struct super_block *sb, | |||
1473 | /* *sb_block = match_int(&args[0]); */ | 1487 | /* *sb_block = match_int(&args[0]); */ |
1474 | break; | 1488 | break; |
1475 | case Opt_err_panic: | 1489 | case Opt_err_panic: |
1476 | clear_opt(sbi->s_mount_opt, ERRORS_CONT); | 1490 | clear_opt(sb, ERRORS_CONT); |
1477 | clear_opt(sbi->s_mount_opt, ERRORS_RO); | 1491 | clear_opt(sb, ERRORS_RO); |
1478 | set_opt(sbi->s_mount_opt, ERRORS_PANIC); | 1492 | set_opt(sb, ERRORS_PANIC); |
1479 | break; | 1493 | break; |
1480 | case Opt_err_ro: | 1494 | case Opt_err_ro: |
1481 | clear_opt(sbi->s_mount_opt, ERRORS_CONT); | 1495 | clear_opt(sb, ERRORS_CONT); |
1482 | clear_opt(sbi->s_mount_opt, ERRORS_PANIC); | 1496 | clear_opt(sb, ERRORS_PANIC); |
1483 | set_opt(sbi->s_mount_opt, ERRORS_RO); | 1497 | set_opt(sb, ERRORS_RO); |
1484 | break; | 1498 | break; |
1485 | case Opt_err_cont: | 1499 | case Opt_err_cont: |
1486 | clear_opt(sbi->s_mount_opt, ERRORS_RO); | 1500 | clear_opt(sb, ERRORS_RO); |
1487 | clear_opt(sbi->s_mount_opt, ERRORS_PANIC); | 1501 | clear_opt(sb, ERRORS_PANIC); |
1488 | set_opt(sbi->s_mount_opt, ERRORS_CONT); | 1502 | set_opt(sb, ERRORS_CONT); |
1489 | break; | 1503 | break; |
1490 | case Opt_nouid32: | 1504 | case Opt_nouid32: |
1491 | set_opt(sbi->s_mount_opt, NO_UID32); | 1505 | set_opt(sb, NO_UID32); |
1492 | break; | 1506 | break; |
1493 | case Opt_debug: | 1507 | case Opt_debug: |
1494 | set_opt(sbi->s_mount_opt, DEBUG); | 1508 | set_opt(sb, DEBUG); |
1495 | break; | 1509 | break; |
1496 | case Opt_oldalloc: | 1510 | case Opt_oldalloc: |
1497 | set_opt(sbi->s_mount_opt, OLDALLOC); | 1511 | set_opt(sb, OLDALLOC); |
1498 | break; | 1512 | break; |
1499 | case Opt_orlov: | 1513 | case Opt_orlov: |
1500 | clear_opt(sbi->s_mount_opt, OLDALLOC); | 1514 | clear_opt(sb, OLDALLOC); |
1501 | break; | 1515 | break; |
1502 | #ifdef CONFIG_EXT4_FS_XATTR | 1516 | #ifdef CONFIG_EXT4_FS_XATTR |
1503 | case Opt_user_xattr: | 1517 | case Opt_user_xattr: |
1504 | set_opt(sbi->s_mount_opt, XATTR_USER); | 1518 | set_opt(sb, XATTR_USER); |
1505 | break; | 1519 | break; |
1506 | case Opt_nouser_xattr: | 1520 | case Opt_nouser_xattr: |
1507 | clear_opt(sbi->s_mount_opt, XATTR_USER); | 1521 | clear_opt(sb, XATTR_USER); |
1508 | break; | 1522 | break; |
1509 | #else | 1523 | #else |
1510 | case Opt_user_xattr: | 1524 | case Opt_user_xattr: |
@@ -1514,10 +1528,10 @@ static int parse_options(char *options, struct super_block *sb, | |||
1514 | #endif | 1528 | #endif |
1515 | #ifdef CONFIG_EXT4_FS_POSIX_ACL | 1529 | #ifdef CONFIG_EXT4_FS_POSIX_ACL |
1516 | case Opt_acl: | 1530 | case Opt_acl: |
1517 | set_opt(sbi->s_mount_opt, POSIX_ACL); | 1531 | set_opt(sb, POSIX_ACL); |
1518 | break; | 1532 | break; |
1519 | case Opt_noacl: | 1533 | case Opt_noacl: |
1520 | clear_opt(sbi->s_mount_opt, POSIX_ACL); | 1534 | clear_opt(sb, POSIX_ACL); |
1521 | break; | 1535 | break; |
1522 | #else | 1536 | #else |
1523 | case Opt_acl: | 1537 | case Opt_acl: |
@@ -1536,7 +1550,7 @@ static int parse_options(char *options, struct super_block *sb, | |||
1536 | "Cannot specify journal on remount"); | 1550 | "Cannot specify journal on remount"); |
1537 | return 0; | 1551 | return 0; |
1538 | } | 1552 | } |
1539 | set_opt(sbi->s_mount_opt, UPDATE_JOURNAL); | 1553 | set_opt(sb, UPDATE_JOURNAL); |
1540 | break; | 1554 | break; |
1541 | case Opt_journal_dev: | 1555 | case Opt_journal_dev: |
1542 | if (is_remount) { | 1556 | if (is_remount) { |
@@ -1549,14 +1563,14 @@ static int parse_options(char *options, struct super_block *sb, | |||
1549 | *journal_devnum = option; | 1563 | *journal_devnum = option; |
1550 | break; | 1564 | break; |
1551 | case Opt_journal_checksum: | 1565 | case Opt_journal_checksum: |
1552 | set_opt(sbi->s_mount_opt, JOURNAL_CHECKSUM); | 1566 | set_opt(sb, JOURNAL_CHECKSUM); |
1553 | break; | 1567 | break; |
1554 | case Opt_journal_async_commit: | 1568 | case Opt_journal_async_commit: |
1555 | set_opt(sbi->s_mount_opt, JOURNAL_ASYNC_COMMIT); | 1569 | set_opt(sb, JOURNAL_ASYNC_COMMIT); |
1556 | set_opt(sbi->s_mount_opt, JOURNAL_CHECKSUM); | 1570 | set_opt(sb, JOURNAL_CHECKSUM); |
1557 | break; | 1571 | break; |
1558 | case Opt_noload: | 1572 | case Opt_noload: |
1559 | set_opt(sbi->s_mount_opt, NOLOAD); | 1573 | set_opt(sb, NOLOAD); |
1560 | break; | 1574 | break; |
1561 | case Opt_commit: | 1575 | case Opt_commit: |
1562 | if (match_int(&args[0], &option)) | 1576 | if (match_int(&args[0], &option)) |
@@ -1599,15 +1613,15 @@ static int parse_options(char *options, struct super_block *sb, | |||
1599 | return 0; | 1613 | return 0; |
1600 | } | 1614 | } |
1601 | } else { | 1615 | } else { |
1602 | clear_opt(sbi->s_mount_opt, DATA_FLAGS); | 1616 | clear_opt(sb, DATA_FLAGS); |
1603 | sbi->s_mount_opt |= data_opt; | 1617 | sbi->s_mount_opt |= data_opt; |
1604 | } | 1618 | } |
1605 | break; | 1619 | break; |
1606 | case Opt_data_err_abort: | 1620 | case Opt_data_err_abort: |
1607 | set_opt(sbi->s_mount_opt, DATA_ERR_ABORT); | 1621 | set_opt(sb, DATA_ERR_ABORT); |
1608 | break; | 1622 | break; |
1609 | case Opt_data_err_ignore: | 1623 | case Opt_data_err_ignore: |
1610 | clear_opt(sbi->s_mount_opt, DATA_ERR_ABORT); | 1624 | clear_opt(sb, DATA_ERR_ABORT); |
1611 | break; | 1625 | break; |
1612 | #ifdef CONFIG_QUOTA | 1626 | #ifdef CONFIG_QUOTA |
1613 | case Opt_usrjquota: | 1627 | case Opt_usrjquota: |
@@ -1647,12 +1661,12 @@ set_qf_format: | |||
1647 | break; | 1661 | break; |
1648 | case Opt_quota: | 1662 | case Opt_quota: |
1649 | case Opt_usrquota: | 1663 | case Opt_usrquota: |
1650 | set_opt(sbi->s_mount_opt, QUOTA); | 1664 | set_opt(sb, QUOTA); |
1651 | set_opt(sbi->s_mount_opt, USRQUOTA); | 1665 | set_opt(sb, USRQUOTA); |
1652 | break; | 1666 | break; |
1653 | case Opt_grpquota: | 1667 | case Opt_grpquota: |
1654 | set_opt(sbi->s_mount_opt, QUOTA); | 1668 | set_opt(sb, QUOTA); |
1655 | set_opt(sbi->s_mount_opt, GRPQUOTA); | 1669 | set_opt(sb, GRPQUOTA); |
1656 | break; | 1670 | break; |
1657 | case Opt_noquota: | 1671 | case Opt_noquota: |
1658 | if (sb_any_quota_loaded(sb)) { | 1672 | if (sb_any_quota_loaded(sb)) { |
@@ -1660,9 +1674,9 @@ set_qf_format: | |||
1660 | "options when quota turned on"); | 1674 | "options when quota turned on"); |
1661 | return 0; | 1675 | return 0; |
1662 | } | 1676 | } |
1663 | clear_opt(sbi->s_mount_opt, QUOTA); | 1677 | clear_opt(sb, QUOTA); |
1664 | clear_opt(sbi->s_mount_opt, USRQUOTA); | 1678 | clear_opt(sb, USRQUOTA); |
1665 | clear_opt(sbi->s_mount_opt, GRPQUOTA); | 1679 | clear_opt(sb, GRPQUOTA); |
1666 | break; | 1680 | break; |
1667 | #else | 1681 | #else |
1668 | case Opt_quota: | 1682 | case Opt_quota: |
@@ -1688,7 +1702,7 @@ set_qf_format: | |||
1688 | sbi->s_mount_flags |= EXT4_MF_FS_ABORTED; | 1702 | sbi->s_mount_flags |= EXT4_MF_FS_ABORTED; |
1689 | break; | 1703 | break; |
1690 | case Opt_nobarrier: | 1704 | case Opt_nobarrier: |
1691 | clear_opt(sbi->s_mount_opt, BARRIER); | 1705 | clear_opt(sb, BARRIER); |
1692 | break; | 1706 | break; |
1693 | case Opt_barrier: | 1707 | case Opt_barrier: |
1694 | if (args[0].from) { | 1708 | if (args[0].from) { |
@@ -1697,9 +1711,9 @@ set_qf_format: | |||
1697 | } else | 1711 | } else |
1698 | option = 1; /* No argument, default to 1 */ | 1712 | option = 1; /* No argument, default to 1 */ |
1699 | if (option) | 1713 | if (option) |
1700 | set_opt(sbi->s_mount_opt, BARRIER); | 1714 | set_opt(sb, BARRIER); |
1701 | else | 1715 | else |
1702 | clear_opt(sbi->s_mount_opt, BARRIER); | 1716 | clear_opt(sb, BARRIER); |
1703 | break; | 1717 | break; |
1704 | case Opt_ignore: | 1718 | case Opt_ignore: |
1705 | break; | 1719 | break; |
@@ -1723,17 +1737,17 @@ set_qf_format: | |||
1723 | "Ignoring deprecated bh option"); | 1737 | "Ignoring deprecated bh option"); |
1724 | break; | 1738 | break; |
1725 | case Opt_i_version: | 1739 | case Opt_i_version: |
1726 | set_opt(sbi->s_mount_opt, I_VERSION); | 1740 | set_opt(sb, I_VERSION); |
1727 | sb->s_flags |= MS_I_VERSION; | 1741 | sb->s_flags |= MS_I_VERSION; |
1728 | break; | 1742 | break; |
1729 | case Opt_nodelalloc: | 1743 | case Opt_nodelalloc: |
1730 | clear_opt(sbi->s_mount_opt, DELALLOC); | 1744 | clear_opt(sb, DELALLOC); |
1731 | break; | 1745 | break; |
1732 | case Opt_mblk_io_submit: | 1746 | case Opt_mblk_io_submit: |
1733 | set_opt(sbi->s_mount_opt, MBLK_IO_SUBMIT); | 1747 | set_opt(sb, MBLK_IO_SUBMIT); |
1734 | break; | 1748 | break; |
1735 | case Opt_nomblk_io_submit: | 1749 | case Opt_nomblk_io_submit: |
1736 | clear_opt(sbi->s_mount_opt, MBLK_IO_SUBMIT); | 1750 | clear_opt(sb, MBLK_IO_SUBMIT); |
1737 | break; | 1751 | break; |
1738 | case Opt_stripe: | 1752 | case Opt_stripe: |
1739 | if (match_int(&args[0], &option)) | 1753 | if (match_int(&args[0], &option)) |
@@ -1743,13 +1757,13 @@ set_qf_format: | |||
1743 | sbi->s_stripe = option; | 1757 | sbi->s_stripe = option; |
1744 | break; | 1758 | break; |
1745 | case Opt_delalloc: | 1759 | case Opt_delalloc: |
1746 | set_opt(sbi->s_mount_opt, DELALLOC); | 1760 | set_opt(sb, DELALLOC); |
1747 | break; | 1761 | break; |
1748 | case Opt_block_validity: | 1762 | case Opt_block_validity: |
1749 | set_opt(sbi->s_mount_opt, BLOCK_VALIDITY); | 1763 | set_opt(sb, BLOCK_VALIDITY); |
1750 | break; | 1764 | break; |
1751 | case Opt_noblock_validity: | 1765 | case Opt_noblock_validity: |
1752 | clear_opt(sbi->s_mount_opt, BLOCK_VALIDITY); | 1766 | clear_opt(sb, BLOCK_VALIDITY); |
1753 | break; | 1767 | break; |
1754 | case Opt_inode_readahead_blks: | 1768 | case Opt_inode_readahead_blks: |
1755 | if (match_int(&args[0], &option)) | 1769 | if (match_int(&args[0], &option)) |
@@ -1773,7 +1787,7 @@ set_qf_format: | |||
1773 | option); | 1787 | option); |
1774 | break; | 1788 | break; |
1775 | case Opt_noauto_da_alloc: | 1789 | case Opt_noauto_da_alloc: |
1776 | set_opt(sbi->s_mount_opt,NO_AUTO_DA_ALLOC); | 1790 | set_opt(sb, NO_AUTO_DA_ALLOC); |
1777 | break; | 1791 | break; |
1778 | case Opt_auto_da_alloc: | 1792 | case Opt_auto_da_alloc: |
1779 | if (args[0].from) { | 1793 | if (args[0].from) { |
@@ -1782,24 +1796,24 @@ set_qf_format: | |||
1782 | } else | 1796 | } else |
1783 | option = 1; /* No argument, default to 1 */ | 1797 | option = 1; /* No argument, default to 1 */ |
1784 | if (option) | 1798 | if (option) |
1785 | clear_opt(sbi->s_mount_opt, NO_AUTO_DA_ALLOC); | 1799 | clear_opt(sb, NO_AUTO_DA_ALLOC); |
1786 | else | 1800 | else |
1787 | set_opt(sbi->s_mount_opt,NO_AUTO_DA_ALLOC); | 1801 | set_opt(sb,NO_AUTO_DA_ALLOC); |
1788 | break; | 1802 | break; |
1789 | case Opt_discard: | 1803 | case Opt_discard: |
1790 | set_opt(sbi->s_mount_opt, DISCARD); | 1804 | set_opt(sb, DISCARD); |
1791 | break; | 1805 | break; |
1792 | case Opt_nodiscard: | 1806 | case Opt_nodiscard: |
1793 | clear_opt(sbi->s_mount_opt, DISCARD); | 1807 | clear_opt(sb, DISCARD); |
1794 | break; | 1808 | break; |
1795 | case Opt_dioread_nolock: | 1809 | case Opt_dioread_nolock: |
1796 | set_opt(sbi->s_mount_opt, DIOREAD_NOLOCK); | 1810 | set_opt(sb, DIOREAD_NOLOCK); |
1797 | break; | 1811 | break; |
1798 | case Opt_dioread_lock: | 1812 | case Opt_dioread_lock: |
1799 | clear_opt(sbi->s_mount_opt, DIOREAD_NOLOCK); | 1813 | clear_opt(sb, DIOREAD_NOLOCK); |
1800 | break; | 1814 | break; |
1801 | case Opt_init_inode_table: | 1815 | case Opt_init_inode_table: |
1802 | set_opt(sbi->s_mount_opt, INIT_INODE_TABLE); | 1816 | set_opt(sb, INIT_INODE_TABLE); |
1803 | if (args[0].from) { | 1817 | if (args[0].from) { |
1804 | if (match_int(&args[0], &option)) | 1818 | if (match_int(&args[0], &option)) |
1805 | return 0; | 1819 | return 0; |
@@ -1810,7 +1824,7 @@ set_qf_format: | |||
1810 | sbi->s_li_wait_mult = option; | 1824 | sbi->s_li_wait_mult = option; |
1811 | break; | 1825 | break; |
1812 | case Opt_noinit_inode_table: | 1826 | case Opt_noinit_inode_table: |
1813 | clear_opt(sbi->s_mount_opt, INIT_INODE_TABLE); | 1827 | clear_opt(sb, INIT_INODE_TABLE); |
1814 | break; | 1828 | break; |
1815 | default: | 1829 | default: |
1816 | ext4_msg(sb, KERN_ERR, | 1830 | ext4_msg(sb, KERN_ERR, |
@@ -1822,10 +1836,10 @@ set_qf_format: | |||
1822 | #ifdef CONFIG_QUOTA | 1836 | #ifdef CONFIG_QUOTA |
1823 | if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) { | 1837 | if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) { |
1824 | if (test_opt(sb, USRQUOTA) && sbi->s_qf_names[USRQUOTA]) | 1838 | if (test_opt(sb, USRQUOTA) && sbi->s_qf_names[USRQUOTA]) |
1825 | clear_opt(sbi->s_mount_opt, USRQUOTA); | 1839 | clear_opt(sb, USRQUOTA); |
1826 | 1840 | ||
1827 | if (test_opt(sb, GRPQUOTA) && sbi->s_qf_names[GRPQUOTA]) | 1841 | if (test_opt(sb, GRPQUOTA) && sbi->s_qf_names[GRPQUOTA]) |
1828 | clear_opt(sbi->s_mount_opt, GRPQUOTA); | 1842 | clear_opt(sb, GRPQUOTA); |
1829 | 1843 | ||
1830 | if (test_opt(sb, GRPQUOTA) || test_opt(sb, USRQUOTA)) { | 1844 | if (test_opt(sb, GRPQUOTA) || test_opt(sb, USRQUOTA)) { |
1831 | ext4_msg(sb, KERN_ERR, "old and new quota " | 1845 | ext4_msg(sb, KERN_ERR, "old and new quota " |
@@ -1895,12 +1909,12 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es, | |||
1895 | ext4_commit_super(sb, 1); | 1909 | ext4_commit_super(sb, 1); |
1896 | if (test_opt(sb, DEBUG)) | 1910 | if (test_opt(sb, DEBUG)) |
1897 | printk(KERN_INFO "[EXT4 FS bs=%lu, gc=%u, " | 1911 | printk(KERN_INFO "[EXT4 FS bs=%lu, gc=%u, " |
1898 | "bpg=%lu, ipg=%lu, mo=%04x]\n", | 1912 | "bpg=%lu, ipg=%lu, mo=%04x, mo2=%04x]\n", |
1899 | sb->s_blocksize, | 1913 | sb->s_blocksize, |
1900 | sbi->s_groups_count, | 1914 | sbi->s_groups_count, |
1901 | EXT4_BLOCKS_PER_GROUP(sb), | 1915 | EXT4_BLOCKS_PER_GROUP(sb), |
1902 | EXT4_INODES_PER_GROUP(sb), | 1916 | EXT4_INODES_PER_GROUP(sb), |
1903 | sbi->s_mount_opt); | 1917 | sbi->s_mount_opt, sbi->s_mount_opt2); |
1904 | 1918 | ||
1905 | return res; | 1919 | return res; |
1906 | } | 1920 | } |
@@ -1930,14 +1944,13 @@ static int ext4_fill_flex_info(struct super_block *sb) | |||
1930 | size = flex_group_count * sizeof(struct flex_groups); | 1944 | size = flex_group_count * sizeof(struct flex_groups); |
1931 | sbi->s_flex_groups = kzalloc(size, GFP_KERNEL); | 1945 | sbi->s_flex_groups = kzalloc(size, GFP_KERNEL); |
1932 | if (sbi->s_flex_groups == NULL) { | 1946 | if (sbi->s_flex_groups == NULL) { |
1933 | sbi->s_flex_groups = vmalloc(size); | 1947 | sbi->s_flex_groups = vzalloc(size); |
1934 | if (sbi->s_flex_groups) | 1948 | if (sbi->s_flex_groups == NULL) { |
1935 | memset(sbi->s_flex_groups, 0, size); | 1949 | ext4_msg(sb, KERN_ERR, |
1936 | } | 1950 | "not enough memory for %u flex groups", |
1937 | if (sbi->s_flex_groups == NULL) { | 1951 | flex_group_count); |
1938 | ext4_msg(sb, KERN_ERR, "not enough memory for " | 1952 | goto failed; |
1939 | "%u flex groups", flex_group_count); | 1953 | } |
1940 | goto failed; | ||
1941 | } | 1954 | } |
1942 | 1955 | ||
1943 | for (i = 0; i < sbi->s_groups_count; i++) { | 1956 | for (i = 0; i < sbi->s_groups_count; i++) { |
@@ -2916,7 +2929,7 @@ static int ext4_register_li_request(struct super_block *sb, | |||
2916 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 2929 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
2917 | struct ext4_li_request *elr; | 2930 | struct ext4_li_request *elr; |
2918 | ext4_group_t ngroups = EXT4_SB(sb)->s_groups_count; | 2931 | ext4_group_t ngroups = EXT4_SB(sb)->s_groups_count; |
2919 | int ret; | 2932 | int ret = 0; |
2920 | 2933 | ||
2921 | if (sbi->s_li_request != NULL) | 2934 | if (sbi->s_li_request != NULL) |
2922 | return 0; | 2935 | return 0; |
@@ -3071,41 +3084,41 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3071 | 3084 | ||
3072 | /* Set defaults before we parse the mount options */ | 3085 | /* Set defaults before we parse the mount options */ |
3073 | def_mount_opts = le32_to_cpu(es->s_default_mount_opts); | 3086 | def_mount_opts = le32_to_cpu(es->s_default_mount_opts); |
3074 | set_opt(sbi->s_mount_opt, INIT_INODE_TABLE); | 3087 | set_opt(sb, INIT_INODE_TABLE); |
3075 | if (def_mount_opts & EXT4_DEFM_DEBUG) | 3088 | if (def_mount_opts & EXT4_DEFM_DEBUG) |
3076 | set_opt(sbi->s_mount_opt, DEBUG); | 3089 | set_opt(sb, DEBUG); |
3077 | if (def_mount_opts & EXT4_DEFM_BSDGROUPS) { | 3090 | if (def_mount_opts & EXT4_DEFM_BSDGROUPS) { |
3078 | ext4_msg(sb, KERN_WARNING, deprecated_msg, "bsdgroups", | 3091 | ext4_msg(sb, KERN_WARNING, deprecated_msg, "bsdgroups", |
3079 | "2.6.38"); | 3092 | "2.6.38"); |
3080 | set_opt(sbi->s_mount_opt, GRPID); | 3093 | set_opt(sb, GRPID); |
3081 | } | 3094 | } |
3082 | if (def_mount_opts & EXT4_DEFM_UID16) | 3095 | if (def_mount_opts & EXT4_DEFM_UID16) |
3083 | set_opt(sbi->s_mount_opt, NO_UID32); | 3096 | set_opt(sb, NO_UID32); |
3084 | #ifdef CONFIG_EXT4_FS_XATTR | 3097 | #ifdef CONFIG_EXT4_FS_XATTR |
3085 | if (def_mount_opts & EXT4_DEFM_XATTR_USER) | 3098 | if (def_mount_opts & EXT4_DEFM_XATTR_USER) |
3086 | set_opt(sbi->s_mount_opt, XATTR_USER); | 3099 | set_opt(sb, XATTR_USER); |
3087 | #endif | 3100 | #endif |
3088 | #ifdef CONFIG_EXT4_FS_POSIX_ACL | 3101 | #ifdef CONFIG_EXT4_FS_POSIX_ACL |
3089 | if (def_mount_opts & EXT4_DEFM_ACL) | 3102 | if (def_mount_opts & EXT4_DEFM_ACL) |
3090 | set_opt(sbi->s_mount_opt, POSIX_ACL); | 3103 | set_opt(sb, POSIX_ACL); |
3091 | #endif | 3104 | #endif |
3092 | if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA) | 3105 | if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA) |
3093 | set_opt(sbi->s_mount_opt, JOURNAL_DATA); | 3106 | set_opt(sb, JOURNAL_DATA); |
3094 | else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_ORDERED) | 3107 | else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_ORDERED) |
3095 | set_opt(sbi->s_mount_opt, ORDERED_DATA); | 3108 | set_opt(sb, ORDERED_DATA); |
3096 | else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_WBACK) | 3109 | else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_WBACK) |
3097 | set_opt(sbi->s_mount_opt, WRITEBACK_DATA); | 3110 | set_opt(sb, WRITEBACK_DATA); |
3098 | 3111 | ||
3099 | if (le16_to_cpu(sbi->s_es->s_errors) == EXT4_ERRORS_PANIC) | 3112 | if (le16_to_cpu(sbi->s_es->s_errors) == EXT4_ERRORS_PANIC) |
3100 | set_opt(sbi->s_mount_opt, ERRORS_PANIC); | 3113 | set_opt(sb, ERRORS_PANIC); |
3101 | else if (le16_to_cpu(sbi->s_es->s_errors) == EXT4_ERRORS_CONTINUE) | 3114 | else if (le16_to_cpu(sbi->s_es->s_errors) == EXT4_ERRORS_CONTINUE) |
3102 | set_opt(sbi->s_mount_opt, ERRORS_CONT); | 3115 | set_opt(sb, ERRORS_CONT); |
3103 | else | 3116 | else |
3104 | set_opt(sbi->s_mount_opt, ERRORS_RO); | 3117 | set_opt(sb, ERRORS_RO); |
3105 | if (def_mount_opts & EXT4_DEFM_BLOCK_VALIDITY) | 3118 | if (def_mount_opts & EXT4_DEFM_BLOCK_VALIDITY) |
3106 | set_opt(sbi->s_mount_opt, BLOCK_VALIDITY); | 3119 | set_opt(sb, BLOCK_VALIDITY); |
3107 | if (def_mount_opts & EXT4_DEFM_DISCARD) | 3120 | if (def_mount_opts & EXT4_DEFM_DISCARD) |
3108 | set_opt(sbi->s_mount_opt, DISCARD); | 3121 | set_opt(sb, DISCARD); |
3109 | 3122 | ||
3110 | sbi->s_resuid = le16_to_cpu(es->s_def_resuid); | 3123 | sbi->s_resuid = le16_to_cpu(es->s_def_resuid); |
3111 | sbi->s_resgid = le16_to_cpu(es->s_def_resgid); | 3124 | sbi->s_resgid = le16_to_cpu(es->s_def_resgid); |
@@ -3114,7 +3127,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3114 | sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME; | 3127 | sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME; |
3115 | 3128 | ||
3116 | if ((def_mount_opts & EXT4_DEFM_NOBARRIER) == 0) | 3129 | if ((def_mount_opts & EXT4_DEFM_NOBARRIER) == 0) |
3117 | set_opt(sbi->s_mount_opt, BARRIER); | 3130 | set_opt(sb, BARRIER); |
3118 | 3131 | ||
3119 | /* | 3132 | /* |
3120 | * enable delayed allocation by default | 3133 | * enable delayed allocation by default |
@@ -3122,7 +3135,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3122 | */ | 3135 | */ |
3123 | if (!IS_EXT3_SB(sb) && | 3136 | if (!IS_EXT3_SB(sb) && |
3124 | ((def_mount_opts & EXT4_DEFM_NODELALLOC) == 0)) | 3137 | ((def_mount_opts & EXT4_DEFM_NODELALLOC) == 0)) |
3125 | set_opt(sbi->s_mount_opt, DELALLOC); | 3138 | set_opt(sb, DELALLOC); |
3126 | 3139 | ||
3127 | if (!parse_options((char *) sbi->s_es->s_mount_opts, sb, | 3140 | if (!parse_options((char *) sbi->s_es->s_mount_opts, sb, |
3128 | &journal_devnum, &journal_ioprio, NULL, 0)) { | 3141 | &journal_devnum, &journal_ioprio, NULL, 0)) { |
@@ -3425,8 +3438,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3425 | "suppressed and not mounted read-only"); | 3438 | "suppressed and not mounted read-only"); |
3426 | goto failed_mount_wq; | 3439 | goto failed_mount_wq; |
3427 | } else { | 3440 | } else { |
3428 | clear_opt(sbi->s_mount_opt, DATA_FLAGS); | 3441 | clear_opt(sb, DATA_FLAGS); |
3429 | set_opt(sbi->s_mount_opt, WRITEBACK_DATA); | 3442 | set_opt(sb, WRITEBACK_DATA); |
3430 | sbi->s_journal = NULL; | 3443 | sbi->s_journal = NULL; |
3431 | needs_recovery = 0; | 3444 | needs_recovery = 0; |
3432 | goto no_journal; | 3445 | goto no_journal; |
@@ -3464,9 +3477,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3464 | */ | 3477 | */ |
3465 | if (jbd2_journal_check_available_features | 3478 | if (jbd2_journal_check_available_features |
3466 | (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE)) | 3479 | (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE)) |
3467 | set_opt(sbi->s_mount_opt, ORDERED_DATA); | 3480 | set_opt(sb, ORDERED_DATA); |
3468 | else | 3481 | else |
3469 | set_opt(sbi->s_mount_opt, JOURNAL_DATA); | 3482 | set_opt(sb, JOURNAL_DATA); |
3470 | break; | 3483 | break; |
3471 | 3484 | ||
3472 | case EXT4_MOUNT_ORDERED_DATA: | 3485 | case EXT4_MOUNT_ORDERED_DATA: |
@@ -3556,18 +3569,18 @@ no_journal: | |||
3556 | (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)) { | 3569 | (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)) { |
3557 | ext4_msg(sb, KERN_WARNING, "Ignoring delalloc option - " | 3570 | ext4_msg(sb, KERN_WARNING, "Ignoring delalloc option - " |
3558 | "requested data journaling mode"); | 3571 | "requested data journaling mode"); |
3559 | clear_opt(sbi->s_mount_opt, DELALLOC); | 3572 | clear_opt(sb, DELALLOC); |
3560 | } | 3573 | } |
3561 | if (test_opt(sb, DIOREAD_NOLOCK)) { | 3574 | if (test_opt(sb, DIOREAD_NOLOCK)) { |
3562 | if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { | 3575 | if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { |
3563 | ext4_msg(sb, KERN_WARNING, "Ignoring dioread_nolock " | 3576 | ext4_msg(sb, KERN_WARNING, "Ignoring dioread_nolock " |
3564 | "option - requested data journaling mode"); | 3577 | "option - requested data journaling mode"); |
3565 | clear_opt(sbi->s_mount_opt, DIOREAD_NOLOCK); | 3578 | clear_opt(sb, DIOREAD_NOLOCK); |
3566 | } | 3579 | } |
3567 | if (sb->s_blocksize < PAGE_SIZE) { | 3580 | if (sb->s_blocksize < PAGE_SIZE) { |
3568 | ext4_msg(sb, KERN_WARNING, "Ignoring dioread_nolock " | 3581 | ext4_msg(sb, KERN_WARNING, "Ignoring dioread_nolock " |
3569 | "option - block size is too small"); | 3582 | "option - block size is too small"); |
3570 | clear_opt(sbi->s_mount_opt, DIOREAD_NOLOCK); | 3583 | clear_opt(sb, DIOREAD_NOLOCK); |
3571 | } | 3584 | } |
3572 | } | 3585 | } |
3573 | 3586 | ||
@@ -4166,6 +4179,22 @@ static int ext4_unfreeze(struct super_block *sb) | |||
4166 | return 0; | 4179 | return 0; |
4167 | } | 4180 | } |
4168 | 4181 | ||
4182 | /* | ||
4183 | * Structure to save mount options for ext4_remount's benefit | ||
4184 | */ | ||
4185 | struct ext4_mount_options { | ||
4186 | unsigned long s_mount_opt; | ||
4187 | unsigned long s_mount_opt2; | ||
4188 | uid_t s_resuid; | ||
4189 | gid_t s_resgid; | ||
4190 | unsigned long s_commit_interval; | ||
4191 | u32 s_min_batch_time, s_max_batch_time; | ||
4192 | #ifdef CONFIG_QUOTA | ||
4193 | int s_jquota_fmt; | ||
4194 | char *s_qf_names[MAXQUOTAS]; | ||
4195 | #endif | ||
4196 | }; | ||
4197 | |||
4169 | static int ext4_remount(struct super_block *sb, int *flags, char *data) | 4198 | static int ext4_remount(struct super_block *sb, int *flags, char *data) |
4170 | { | 4199 | { |
4171 | struct ext4_super_block *es; | 4200 | struct ext4_super_block *es; |
@@ -4186,6 +4215,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
4186 | lock_super(sb); | 4215 | lock_super(sb); |
4187 | old_sb_flags = sb->s_flags; | 4216 | old_sb_flags = sb->s_flags; |
4188 | old_opts.s_mount_opt = sbi->s_mount_opt; | 4217 | old_opts.s_mount_opt = sbi->s_mount_opt; |
4218 | old_opts.s_mount_opt2 = sbi->s_mount_opt2; | ||
4189 | old_opts.s_resuid = sbi->s_resuid; | 4219 | old_opts.s_resuid = sbi->s_resuid; |
4190 | old_opts.s_resgid = sbi->s_resgid; | 4220 | old_opts.s_resgid = sbi->s_resgid; |
4191 | old_opts.s_commit_interval = sbi->s_commit_interval; | 4221 | old_opts.s_commit_interval = sbi->s_commit_interval; |
@@ -4339,6 +4369,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
4339 | restore_opts: | 4369 | restore_opts: |
4340 | sb->s_flags = old_sb_flags; | 4370 | sb->s_flags = old_sb_flags; |
4341 | sbi->s_mount_opt = old_opts.s_mount_opt; | 4371 | sbi->s_mount_opt = old_opts.s_mount_opt; |
4372 | sbi->s_mount_opt2 = old_opts.s_mount_opt2; | ||
4342 | sbi->s_resuid = old_opts.s_resuid; | 4373 | sbi->s_resuid = old_opts.s_resuid; |
4343 | sbi->s_resgid = old_opts.s_resgid; | 4374 | sbi->s_resgid = old_opts.s_resgid; |
4344 | sbi->s_commit_interval = old_opts.s_commit_interval; | 4375 | sbi->s_commit_interval = old_opts.s_commit_interval; |
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index fa4b899da4b3..fc32176eee39 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c | |||
@@ -427,23 +427,23 @@ cleanup: | |||
427 | static int | 427 | static int |
428 | ext4_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) | 428 | ext4_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
429 | { | 429 | { |
430 | int i_error, b_error; | 430 | int ret, ret2; |
431 | 431 | ||
432 | down_read(&EXT4_I(dentry->d_inode)->xattr_sem); | 432 | down_read(&EXT4_I(dentry->d_inode)->xattr_sem); |
433 | i_error = ext4_xattr_ibody_list(dentry, buffer, buffer_size); | 433 | ret = ret2 = ext4_xattr_ibody_list(dentry, buffer, buffer_size); |
434 | if (i_error < 0) { | 434 | if (ret < 0) |
435 | b_error = 0; | 435 | goto errout; |
436 | } else { | 436 | if (buffer) { |
437 | if (buffer) { | 437 | buffer += ret; |
438 | buffer += i_error; | 438 | buffer_size -= ret; |
439 | buffer_size -= i_error; | ||
440 | } | ||
441 | b_error = ext4_xattr_block_list(dentry, buffer, buffer_size); | ||
442 | if (b_error < 0) | ||
443 | i_error = 0; | ||
444 | } | 439 | } |
440 | ret = ext4_xattr_block_list(dentry, buffer, buffer_size); | ||
441 | if (ret < 0) | ||
442 | goto errout; | ||
443 | ret += ret2; | ||
444 | errout: | ||
445 | up_read(&EXT4_I(dentry->d_inode)->xattr_sem); | 445 | up_read(&EXT4_I(dentry->d_inode)->xattr_sem); |
446 | return i_error + b_error; | 446 | return ret; |
447 | } | 447 | } |
448 | 448 | ||
449 | /* | 449 | /* |
@@ -947,7 +947,7 @@ ext4_xattr_ibody_set(handle_t *handle, struct inode *inode, | |||
947 | /* | 947 | /* |
948 | * ext4_xattr_set_handle() | 948 | * ext4_xattr_set_handle() |
949 | * | 949 | * |
950 | * Create, replace or remove an extended attribute for this inode. Buffer | 950 | * Create, replace or remove an extended attribute for this inode. Value |
951 | * is NULL to remove an existing extended attribute, and non-NULL to | 951 | * is NULL to remove an existing extended attribute, and non-NULL to |
952 | * either replace an existing extended attribute, or create a new extended | 952 | * either replace an existing extended attribute, or create a new extended |
953 | * attribute. The flags XATTR_REPLACE and XATTR_CREATE | 953 | * attribute. The flags XATTR_REPLACE and XATTR_CREATE |