Commit e4684b3fbb848446683feecb4aee133344c93933
1 parent
d6797d14b1
Exists in
master
and in
7 other branches
ext4: fold ext4_journal_revoke() into ext4_forget()
The only caller of ext4_journal_revoke() is ext4_forget(), so we can fold ext4_journal_revoke() into ext4_forget() to simplify the code and shorten the call stack. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Showing 2 changed files with 12 additions and 30 deletions Side-by-side Diff
fs/ext4/ext4_jbd2.c
... | ... | @@ -50,22 +50,6 @@ |
50 | 50 | return err; |
51 | 51 | } |
52 | 52 | |
53 | -int __ext4_journal_revoke(const char *where, handle_t *handle, | |
54 | - ext4_fsblk_t blocknr, struct buffer_head *bh) | |
55 | -{ | |
56 | - int err = 0; | |
57 | - | |
58 | - if (ext4_handle_valid(handle)) { | |
59 | - err = jbd2_journal_revoke(handle, blocknr, bh); | |
60 | - if (err) | |
61 | - ext4_journal_abort_handle(where, __func__, bh, | |
62 | - handle, err); | |
63 | - } | |
64 | - else | |
65 | - bforget(bh); | |
66 | - return err; | |
67 | -} | |
68 | - | |
69 | 53 | /* |
70 | 54 | * The ext4 forget function must perform a revoke if we are freeing data |
71 | 55 | * which has been journaled. Metadata (eg. indirect blocks) must be |
... | ... | @@ -94,6 +78,12 @@ |
94 | 78 | bh, is_metadata, inode->i_mode, |
95 | 79 | test_opt(inode->i_sb, DATA_FLAGS)); |
96 | 80 | |
81 | + /* In the no journal case, we can just do a bforget and return */ | |
82 | + if (!ext4_handle_valid(handle)) { | |
83 | + bforget(bh); | |
84 | + return 0; | |
85 | + } | |
86 | + | |
97 | 87 | /* Never use the revoke function if we are doing full data |
98 | 88 | * journaling: there is no need to, and a V1 superblock won't |
99 | 89 | * support it. Otherwise, only skip the revoke on un-journaled |
100 | 90 | |
... | ... | @@ -111,11 +101,13 @@ |
111 | 101 | /* |
112 | 102 | * data!=journal && (is_metadata || should_journal_data(inode)) |
113 | 103 | */ |
114 | - BUFFER_TRACE(bh, "call ext4_journal_revoke"); | |
115 | - err = __ext4_journal_revoke(where, handle, blocknr, bh); | |
116 | - if (err) | |
104 | + BUFFER_TRACE(bh, "call jbd2_journal_revoke"); | |
105 | + err = jbd2_journal_revoke(handle, blocknr, bh); | |
106 | + if (err) { | |
107 | + ext4_journal_abort_handle(where, __func__, bh, handle, err); | |
117 | 108 | ext4_abort(inode->i_sb, __func__, |
118 | 109 | "error %d when attempting revoke", err); |
110 | + } | |
119 | 111 | BUFFER_TRACE(bh, "exit"); |
120 | 112 | return err; |
121 | 113 | } |
fs/ext4/ext4_jbd2.h
... | ... | @@ -116,12 +116,8 @@ |
116 | 116 | int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode); |
117 | 117 | |
118 | 118 | /* |
119 | - * Wrapper functions with which ext4 calls into JBD. The intent here is | |
120 | - * to allow these to be turned into appropriate stubs so ext4 can control | |
121 | - * ext2 filesystems, so ext2+ext4 systems only nee one fs. This work hasn't | |
122 | - * been done yet. | |
119 | + * Wrapper functions with which ext4 calls into JBD. | |
123 | 120 | */ |
124 | - | |
125 | 121 | void ext4_journal_abort_handle(const char *caller, const char *err_fn, |
126 | 122 | struct buffer_head *bh, handle_t *handle, int err); |
127 | 123 | |
... | ... | @@ -135,10 +131,6 @@ |
135 | 131 | int __ext4_journal_forget(const char *where, handle_t *handle, |
136 | 132 | struct buffer_head *bh); |
137 | 133 | |
138 | -/* When called with an invalid handle, this will still do a put on the BH */ | |
139 | -int __ext4_journal_revoke(const char *where, handle_t *handle, | |
140 | - ext4_fsblk_t blocknr, struct buffer_head *bh); | |
141 | - | |
142 | 134 | int __ext4_forget(const char *where, handle_t *handle, int is_metadata, |
143 | 135 | struct inode *inode, struct buffer_head *bh, |
144 | 136 | ext4_fsblk_t blocknr); |
... | ... | @@ -153,8 +145,6 @@ |
153 | 145 | __ext4_journal_get_undo_access(__func__, (handle), (bh)) |
154 | 146 | #define ext4_journal_get_write_access(handle, bh) \ |
155 | 147 | __ext4_journal_get_write_access(__func__, (handle), (bh)) |
156 | -#define ext4_journal_revoke(handle, blocknr, bh) \ | |
157 | - __ext4_journal_revoke(__func__, (handle), (blocknr), (bh)) | |
158 | 148 | #define ext4_forget(handle, is_metadata, inode, bh, block_nr) \ |
159 | 149 | __ext4_forget(__func__, (handle), (is_metadata), (inode), (bh),\ |
160 | 150 | (block_nr)) |