Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ext4: fix double unlock buffer mess during fs-resize

bh_submit_read() is responsible for unlock bh on endio. In addition,
we need to use bh_uptodate_or_lock() to avoid races.

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

authored by

Dmitry Monakhov and committed by
Theodore Ts'o
7f1468d1 f2a09af6

+5 -10
+5 -10
fs/ext4/resize.c
··· 1181 1181 struct buffer_head *bh = sb_getblk(sb, block); 1182 1182 if (!bh) 1183 1183 return NULL; 1184 - 1185 - if (bitmap_uptodate(bh)) 1186 - return bh; 1187 - 1188 - lock_buffer(bh); 1189 - if (bh_submit_read(bh) < 0) { 1190 - unlock_buffer(bh); 1191 - brelse(bh); 1192 - return NULL; 1184 + if (!bh_uptodate_or_lock(bh)) { 1185 + if (bh_submit_read(bh) < 0) { 1186 + brelse(bh); 1187 + return NULL; 1188 + } 1193 1189 } 1194 - unlock_buffer(bh); 1195 1190 1196 1191 return bh; 1197 1192 }