Add missing patches (centralize-proc-functions and make-proc-generic)
[ext4-patch-queue.git] / ext4-Add-inode-to-journal-handle-after-block-alloca.patch
blob6ca1b96cf196ff12dcb68db132c129ceea75c957
1 From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
3 ext4: Don't add the inode to journal handle until after the block is allocated
5 Make sure we don't add the inode to the journal handle until after the
6 block allocation, so that a journal commit will not include the inode in
7 case of block allocation failure.
9 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
10 Signed-off-by: Mingming Cao <cmm@us.ibm.com>
11 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 ---
13 fs/ext4/balloc.c | 2 +-
14 fs/ext4/inode.c | 36 +++++++++++++++---------------------
15 2 files changed, 16 insertions(+), 22 deletions(-)
17 Index: linux-2.6.27-rc3/fs/ext4/balloc.c
18 ===================================================================
19 --- linux-2.6.27-rc3.orig/fs/ext4/balloc.c 2008-08-28 14:40:43.000000000 -0700
20 +++ linux-2.6.27-rc3/fs/ext4/balloc.c 2008-08-28 14:52:44.000000000 -0700
21 @@ -2057,7 +2057,7 @@
23 * Account for the allocated meta blocks
25 - if (!(*errp)) {
26 + if (!(*errp) && EXT4_I(inode)->i_delalloc_reserved_flag) {
27 spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
28 EXT4_I(inode)->i_allocated_meta_blocks += *count;
29 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
30 Index: linux-2.6.27-rc3/fs/ext4/inode.c
31 ===================================================================
32 --- linux-2.6.27-rc3.orig/fs/ext4/inode.c 2008-08-28 14:40:17.000000000 -0700
33 +++ linux-2.6.27-rc3/fs/ext4/inode.c 2008-08-28 14:52:44.000000000 -0700
34 @@ -2170,18 +2170,24 @@
35 handle_t *handle = NULL;
37 handle = ext4_journal_current_handle();
38 - if (!handle) {
39 - ret = ext4_get_blocks_wrap(handle, inode, iblock, max_blocks,
40 - bh_result, 0, 0, 0);
41 - BUG_ON(!ret);
42 - } else {
43 - ret = ext4_get_blocks_wrap(handle, inode, iblock, max_blocks,
44 - bh_result, create, 0, EXT4_DELALLOC_RSVED);
45 - }
47 + BUG_ON(!handle);
48 + ret = ext4_get_blocks_wrap(handle, inode, iblock, max_blocks,
49 + bh_result, create, 0, EXT4_DELALLOC_RSVED);
50 if (ret > 0) {
52 bh_result->b_size = (ret << inode->i_blkbits);
54 + if (ext4_should_order_data(inode)) {
55 + int retval;
56 + retval = ext4_jbd2_file_inode(handle, inode);
57 + if (retval)
58 + /*
59 + * Failed to add inode for ordered
60 + * mode. Don't update file size
61 + */
62 + return retval;
63 + }
66 * Update on-disk size along with block allocation
67 * we don't use 'extend_disksize' as size may change
68 @@ -2407,18 +2413,6 @@
69 dump_stack();
70 goto out_writepages;
72 - if (ext4_should_order_data(inode)) {
73 - /*
74 - * With ordered mode we need to add
75 - * the inode to the journal handl
76 - * when we do block allocation.
77 - */
78 - ret = ext4_jbd2_file_inode(handle, inode);
79 - if (ret) {
80 - ext4_journal_stop(handle);
81 - goto out_writepages;
82 - }
83 - }
85 to_write -= wbc->nr_to_write;
86 ret = mpage_da_writepages(mapping, wbc,