[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202010091437.T53myZsm-lkp@intel.com>
Date: Fri, 9 Oct 2020 14:43:51 +0800
From: kernel test robot <lkp@...el.com>
To: Harshad Shirwadkar <harshadshirwadkar@...il.com>
Cc: kbuild-all@...ts.01.org, clang-built-linux@...glegroups.com,
linux-ext4@...r.kernel.org, Theodore Ts'o <tytso@....edu>
Subject: [ext4:dev 9/44] fs/ext4/fast_commit.c:1079:6: warning: variable
'start_time' is used uninitialized whenever 'if' condition is true
tree: https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
head: ab7b179af3f98772f2433ddc4ace6b7924a4e862
commit: 96df8fb629b26ce3b0b10c9b730965788786bb8c [9/44] ext4: main fast-commit commit path
config: x86_64-randconfig-a004-20201009 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 4cfc4025cc1433ca5ef1c526053fc9c4bfe64109)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git/commit/?id=96df8fb629b26ce3b0b10c9b730965788786bb8c
git remote add ext4 https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git
git fetch --no-tags ext4 dev
git checkout 96df8fb629b26ce3b0b10c9b730965788786bb8c
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
All warnings (new ones prefixed by >>):
>> fs/ext4/fast_commit.c:1079:6: warning: variable 'start_time' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!test_opt2(sb, JOURNAL_FAST_COMMIT) ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/ext4/fast_commit.c:1135:51: note: uninitialized use occurs here
commit_time = ktime_to_ns(ktime_sub(ktime_get(), start_time));
^~~~~~~~~~
include/linux/ktime.h:47:39: note: expanded from macro 'ktime_sub'
#define ktime_sub(lhs, rhs) ((lhs) - (rhs))
^~~
fs/ext4/fast_commit.c:1079:2: note: remove the 'if' if its condition is always false
if (!test_opt2(sb, JOURNAL_FAST_COMMIT) ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> fs/ext4/fast_commit.c:1079:6: warning: variable 'start_time' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
if (!test_opt2(sb, JOURNAL_FAST_COMMIT) ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/ext4/fast_commit.c:1135:51: note: uninitialized use occurs here
commit_time = ktime_to_ns(ktime_sub(ktime_get(), start_time));
^~~~~~~~~~
include/linux/ktime.h:47:39: note: expanded from macro 'ktime_sub'
#define ktime_sub(lhs, rhs) ((lhs) - (rhs))
^~~
fs/ext4/fast_commit.c:1079:6: note: remove the '||' if its condition is always false
if (!test_opt2(sb, JOURNAL_FAST_COMMIT) ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/ext4/fast_commit.c:1075:20: note: initialize the variable 'start_time' to silence this warning
ktime_t start_time, commit_time;
^
= 0
2 warnings generated.
vim +1079 fs/ext4/fast_commit.c
1061
1062 /*
1063 * The main commit entry point. Performs a fast commit for transaction
1064 * commit_tid if needed. If it's not possible to perform a fast commit
1065 * due to various reasons, we fall back to full commit. Returns 0
1066 * on success, error otherwise.
1067 */
1068 int ext4_fc_commit(journal_t *journal, tid_t commit_tid)
1069 {
1070 struct super_block *sb = (struct super_block *)(journal->j_private);
1071 struct ext4_sb_info *sbi = EXT4_SB(sb);
1072 int nblks = 0, ret, bsize = journal->j_blocksize;
1073 int subtid = atomic_read(&sbi->s_fc_subtid);
1074 int reason = EXT4_FC_REASON_OK, fc_bufs_before = 0;
1075 ktime_t start_time, commit_time;
1076
1077 trace_ext4_fc_commit_start(sb);
1078
> 1079 if (!test_opt2(sb, JOURNAL_FAST_COMMIT) ||
1080 (ext4_fc_is_ineligible(sb))) {
1081 reason = EXT4_FC_REASON_INELIGIBLE;
1082 goto out;
1083 }
1084
1085 start_time = ktime_get();
1086 restart_fc:
1087 ret = jbd2_fc_start(journal, commit_tid);
1088 if (ret == -EALREADY) {
1089 /* There was an ongoing commit, check if we need to restart */
1090 if (atomic_read(&sbi->s_fc_subtid) <= subtid &&
1091 commit_tid > journal->j_commit_sequence)
1092 goto restart_fc;
1093 reason = EXT4_FC_REASON_ALREADY_COMMITTED;
1094 goto out;
1095 } else if (ret) {
1096 sbi->s_fc_stats.fc_ineligible_reason_count[EXT4_FC_COMMIT_FAILED]++;
1097 reason = EXT4_FC_REASON_FC_START_FAILED;
1098 goto out;
1099 }
1100
1101 fc_bufs_before = (sbi->s_fc_bytes + bsize - 1) / bsize;
1102 ret = ext4_fc_perform_commit(journal);
1103 if (ret < 0) {
1104 sbi->s_fc_stats.fc_ineligible_reason_count[EXT4_FC_COMMIT_FAILED]++;
1105 reason = EXT4_FC_REASON_FC_FAILED;
1106 goto out;
1107 }
1108 nblks = (sbi->s_fc_bytes + bsize - 1) / bsize - fc_bufs_before;
1109 ret = jbd2_fc_wait_bufs(journal, nblks);
1110 if (ret < 0) {
1111 sbi->s_fc_stats.fc_ineligible_reason_count[EXT4_FC_COMMIT_FAILED]++;
1112 reason = EXT4_FC_REASON_FC_FAILED;
1113 goto out;
1114 }
1115 atomic_inc(&sbi->s_fc_subtid);
1116 jbd2_fc_stop(journal);
1117 out:
1118 /* Has any ineligible update happened since we started? */
1119 if (reason == EXT4_FC_REASON_OK && ext4_fc_is_ineligible(sb)) {
1120 sbi->s_fc_stats.fc_ineligible_reason_count[EXT4_FC_COMMIT_FAILED]++;
1121 reason = EXT4_FC_REASON_INELIGIBLE;
1122 }
1123
1124 spin_lock(&sbi->s_fc_lock);
1125 if (reason != EXT4_FC_REASON_OK &&
1126 reason != EXT4_FC_REASON_ALREADY_COMMITTED) {
1127 sbi->s_fc_stats.fc_ineligible_commits++;
1128 } else {
1129 sbi->s_fc_stats.fc_num_commits++;
1130 sbi->s_fc_stats.fc_numblks += nblks;
1131 }
1132 spin_unlock(&sbi->s_fc_lock);
1133 nblks = (reason == EXT4_FC_REASON_OK) ? nblks : 0;
1134 trace_ext4_fc_commit_stop(sb, nblks, reason);
> 1135 commit_time = ktime_to_ns(ktime_sub(ktime_get(), start_time));
1136 /*
1137 * weight the commit time higher than the average time so we don't
1138 * react too strongly to vast changes in the commit time
1139 */
1140 if (likely(sbi->s_fc_avg_commit_time))
1141 sbi->s_fc_avg_commit_time = (commit_time +
1142 sbi->s_fc_avg_commit_time * 3) / 4;
1143 else
1144 sbi->s_fc_avg_commit_time = commit_time;
1145 jbd_debug(1,
1146 "Fast commit ended with blks = %d, reason = %d, subtid - %d",
1147 nblks, reason, subtid);
1148 if (reason == EXT4_FC_REASON_FC_FAILED)
1149 return jbd2_fc_stop_do_commit(journal, commit_tid);
1150 if (reason == EXT4_FC_REASON_FC_START_FAILED ||
1151 reason == EXT4_FC_REASON_INELIGIBLE)
1152 return jbd2_complete_transaction(journal, commit_tid);
1153 return 0;
1154 }
1155
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Download attachment ".config.gz" of type "application/gzip" (35031 bytes)
Powered by blists - more mailing lists