1 jbd2: fix compile warning when using JBUFFER_TRACE
3 From: "zhangyi (F)" <yi.zhang@huawei.com>
5 The jh pointer may be used uninitialized in the two cases below and the
6 compiler complain about it when enabling JBUFFER_TRACE macro, fix them.
8 In file included from fs/jbd2/transaction.c:19:0:
9 fs/jbd2/transaction.c: In function ‘jbd2_journal_get_undo_access’:
10 ./include/linux/jbd2.h:1637:38: warning: ‘jh’ is used uninitialized in this function [-Wuninitialized]
11 #define JBUFFER_TRACE(jh, info) do { printk("%s: %d\n", __func__, jh->b_jcount);} while (0)
13 fs/jbd2/transaction.c:1219:23: note: ‘jh’ was declared here
14 struct journal_head *jh;
16 In file included from fs/jbd2/transaction.c:19:0:
17 fs/jbd2/transaction.c: In function ‘jbd2_journal_dirty_metadata’:
18 ./include/linux/jbd2.h:1637:38: warning: ‘jh’ may be used uninitialized in this function [-Wmaybe-uninitialized]
19 #define JBUFFER_TRACE(jh, info) do { printk("%s: %d\n", __func__, jh->b_jcount);} while (0)
21 fs/jbd2/transaction.c:1332:23: note: ‘jh’ was declared here
22 struct journal_head *jh;
25 Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
26 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
27 Cc: stable@vger.kernel.org
28 Reviewed-by: Jan Kara <jack@suse.cz>
30 fs/jbd2/transaction.c | 16 ++++++++--------
31 1 file changed, 8 insertions(+), 8 deletions(-)
33 diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
34 index c0b66a7..4b51177 100644
35 --- a/fs/jbd2/transaction.c
36 +++ b/fs/jbd2/transaction.c
37 @@ -1219,11 +1219,12 @@ int jbd2_journal_get_undo_access(handle_t *handle, struct buffer_head *bh)
38 struct journal_head *jh;
39 char *committed_data = NULL;
41 - JBUFFER_TRACE(jh, "entry");
42 if (jbd2_write_access_granted(handle, bh, true))
45 jh = jbd2_journal_add_journal_head(bh);
46 + JBUFFER_TRACE(jh, "entry");
49 * Do this first --- it can drop the journal lock, so we want to
50 * make sure that obtaining the committed_data is done
51 @@ -1334,15 +1335,17 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)
53 if (is_handle_aborted(handle))
55 - if (!buffer_jbd(bh)) {
59 + if (!buffer_jbd(bh))
63 * We don't grab jh reference here since the buffer must be part
64 * of the running transaction.
67 + jbd_debug(5, "journal_head %p\n", jh);
68 + JBUFFER_TRACE(jh, "entry");
71 * This and the following assertions are unreliable since we may see jh
72 * in inconsistent state unless we grab bh_state lock. But this is
73 @@ -1376,9 +1379,6 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)
76 journal = transaction->t_journal;
77 - jbd_debug(5, "journal_head %p\n", jh);
78 - JBUFFER_TRACE(jh, "entry");
80 jbd_lock_bh_state(bh);
82 if (jh->b_modified == 0) {