diff options
author | Theodore Ts'o <tytso@mit.edu> | 2009-11-22 21:00:13 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2009-11-22 21:00:13 -0500 |
commit | b7e57e7c2a41826e51fe060fae5158bfc7a04e81 (patch) | |
tree | 2c7331402c731a9c6bb98827a4f6e5926fd90055 /fs/ext4 | |
parent | e4684b3fbb848446683feecb4aee133344c93933 (diff) |
ext4: fold ext4_journal_forget() into ext4_forget()
Convert the last two callers of ext4_journal_forget() to use
ext4_forget() instead, and then fold ext4_journal_forget() into
ext4_forget(). This reduces are code complexity and shortens our call
stack.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/ext4_jbd2.c | 22 | ||||
-rw-r--r-- | fs/ext4/ext4_jbd2.h | 6 | ||||
-rw-r--r-- | fs/ext4/inode.c | 16 |
3 files changed, 19 insertions, 25 deletions
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c index 92c88a8f734d..b57e5c711b6d 100644 --- a/fs/ext4/ext4_jbd2.c +++ b/fs/ext4/ext4_jbd2.c | |||
@@ -34,22 +34,6 @@ int __ext4_journal_get_write_access(const char *where, handle_t *handle, | |||
34 | return err; | 34 | return err; |
35 | } | 35 | } |
36 | 36 | ||
37 | int __ext4_journal_forget(const char *where, handle_t *handle, | ||
38 | struct buffer_head *bh) | ||
39 | { | ||
40 | int err = 0; | ||
41 | |||
42 | if (ext4_handle_valid(handle)) { | ||
43 | err = jbd2_journal_forget(handle, bh); | ||
44 | if (err) | ||
45 | ext4_journal_abort_handle(where, __func__, bh, | ||
46 | handle, err); | ||
47 | } | ||
48 | else | ||
49 | bforget(bh); | ||
50 | return err; | ||
51 | } | ||
52 | |||
53 | /* | 37 | /* |
54 | * The ext4 forget function must perform a revoke if we are freeing data | 38 | * The ext4 forget function must perform a revoke if we are freeing data |
55 | * which has been journaled. Metadata (eg. indirect blocks) must be | 39 | * which has been journaled. Metadata (eg. indirect blocks) must be |
@@ -93,7 +77,11 @@ int __ext4_forget(const char *where, handle_t *handle, int is_metadata, | |||
93 | (!is_metadata && !ext4_should_journal_data(inode))) { | 77 | (!is_metadata && !ext4_should_journal_data(inode))) { |
94 | if (bh) { | 78 | if (bh) { |
95 | BUFFER_TRACE(bh, "call jbd2_journal_forget"); | 79 | BUFFER_TRACE(bh, "call jbd2_journal_forget"); |
96 | return __ext4_journal_forget(where, handle, bh); | 80 | err = jbd2_journal_forget(handle, bh); |
81 | if (err) | ||
82 | ext4_journal_abort_handle(where, __func__, bh, | ||
83 | handle, err); | ||
84 | return err; | ||
97 | } | 85 | } |
98 | return 0; | 86 | return 0; |
99 | } | 87 | } |
diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h index f9fb4bb69577..84bc98ab9f0d 100644 --- a/fs/ext4/ext4_jbd2.h +++ b/fs/ext4/ext4_jbd2.h | |||
@@ -127,10 +127,6 @@ int __ext4_journal_get_undo_access(const char *where, handle_t *handle, | |||
127 | int __ext4_journal_get_write_access(const char *where, handle_t *handle, | 127 | int __ext4_journal_get_write_access(const char *where, handle_t *handle, |
128 | struct buffer_head *bh); | 128 | struct buffer_head *bh); |
129 | 129 | ||
130 | /* When called with an invalid handle, this will still do a put on the BH */ | ||
131 | int __ext4_journal_forget(const char *where, handle_t *handle, | ||
132 | struct buffer_head *bh); | ||
133 | |||
134 | int __ext4_forget(const char *where, handle_t *handle, int is_metadata, | 130 | int __ext4_forget(const char *where, handle_t *handle, int is_metadata, |
135 | struct inode *inode, struct buffer_head *bh, | 131 | struct inode *inode, struct buffer_head *bh, |
136 | ext4_fsblk_t blocknr); | 132 | ext4_fsblk_t blocknr); |
@@ -150,8 +146,6 @@ int __ext4_handle_dirty_metadata(const char *where, handle_t *handle, | |||
150 | (block_nr)) | 146 | (block_nr)) |
151 | #define ext4_journal_get_create_access(handle, bh) \ | 147 | #define ext4_journal_get_create_access(handle, bh) \ |
152 | __ext4_journal_get_create_access(__func__, (handle), (bh)) | 148 | __ext4_journal_get_create_access(__func__, (handle), (bh)) |
153 | #define ext4_journal_forget(handle, bh) \ | ||
154 | __ext4_journal_forget(__func__, (handle), (bh)) | ||
155 | #define ext4_handle_dirty_metadata(handle, inode, bh) \ | 149 | #define ext4_handle_dirty_metadata(handle, inode, bh) \ |
156 | __ext4_handle_dirty_metadata(__func__, (handle), (inode), (bh)) | 150 | __ext4_handle_dirty_metadata(__func__, (handle), (inode), (bh)) |
157 | 151 | ||
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index fa37f9504ece..72c694323492 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -767,7 +767,13 @@ failed: | |||
767 | /* Allocation failed, free what we already allocated */ | 767 | /* Allocation failed, free what we already allocated */ |
768 | for (i = 1; i <= n ; i++) { | 768 | for (i = 1; i <= n ; i++) { |
769 | BUFFER_TRACE(branch[i].bh, "call jbd2_journal_forget"); | 769 | BUFFER_TRACE(branch[i].bh, "call jbd2_journal_forget"); |
770 | ext4_journal_forget(handle, branch[i].bh); | 770 | /* |
771 | * Note: is_metadata is 0 because branch[i].bh is | ||
772 | * newly allocated, so there is no need to revoke the | ||
773 | * block. If we do, it's harmless, but not necessary. | ||
774 | */ | ||
775 | ext4_forget(handle, 0, inode, branch[i].bh, | ||
776 | branch[i].bh->b_blocknr); | ||
771 | } | 777 | } |
772 | for (i = 0; i < indirect_blks; i++) | 778 | for (i = 0; i < indirect_blks; i++) |
773 | ext4_free_blocks(handle, inode, new_blocks[i], 1, 0); | 779 | ext4_free_blocks(handle, inode, new_blocks[i], 1, 0); |
@@ -852,7 +858,13 @@ static int ext4_splice_branch(handle_t *handle, struct inode *inode, | |||
852 | err_out: | 858 | err_out: |
853 | for (i = 1; i <= num; i++) { | 859 | for (i = 1; i <= num; i++) { |
854 | BUFFER_TRACE(where[i].bh, "call jbd2_journal_forget"); | 860 | BUFFER_TRACE(where[i].bh, "call jbd2_journal_forget"); |
855 | ext4_journal_forget(handle, where[i].bh); | 861 | /* |
862 | * Note: is_metadata is 0 because branch[i].bh is | ||
863 | * newly allocated, so there is no need to revoke the | ||
864 | * block. If we do, it's harmless, but not necessary. | ||
865 | */ | ||
866 | ext4_forget(handle, 0, inode, where[i].bh, | ||
867 | where[i].bh->b_blocknr); | ||
856 | ext4_free_blocks(handle, inode, | 868 | ext4_free_blocks(handle, inode, |
857 | le32_to_cpu(where[i-1].key), 1, 0); | 869 | le32_to_cpu(where[i-1].key), 1, 0); |
858 | } | 870 | } |