ocfs2: fix regression in ocfs2_read_blocks_sync()

We're panicing in ocfs2_read_blocks_sync() if a jbd-managed buffer is seen.
At first glance, this seems ok but in reality it can happen. My test case
was to just run 'exorcist'. A struct inode is being pushed out of memory but
is then re-read at a later time, before the buffer has been checkpointed by
jbd. This causes a BUG to be hit in ocfs2_read_blocks_sync().

Reviewed-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>

+4 -11
+4 -11
fs/ocfs2/buffer_head_io.c
··· 112 112 bh = bhs[i]; 113 113 114 114 if (buffer_jbd(bh)) { 115 - mlog(ML_ERROR, 115 + mlog(ML_BH_IO, 116 116 "trying to sync read a jbd " 117 117 "managed bh (blocknr = %llu), skipping\n", 118 118 (unsigned long long)bh->b_blocknr); ··· 147 147 for (i = nr; i > 0; i--) { 148 148 bh = bhs[i - 1]; 149 149 150 - if (buffer_jbd(bh)) { 151 - mlog(ML_ERROR, 152 - "the journal got the buffer while it was " 153 - "locked for io! (blocknr = %llu)\n", 154 - (unsigned long long)bh->b_blocknr); 155 - BUG(); 156 - } 150 + /* No need to wait on the buffer if it's managed by JBD. */ 151 + if (!buffer_jbd(bh)) 152 + wait_on_buffer(bh); 157 153 158 - wait_on_buffer(bh); 159 154 if (!buffer_uptodate(bh)) { 160 155 /* Status won't be cleared from here on out, 161 156 * so we can safely record this and loop back ··· 246 251 ignore_cache = 1; 247 252 } 248 253 249 - /* XXX: Can we ever get this and *not* have the cached 250 - * flag set? */ 251 254 if (buffer_jbd(bh)) { 252 255 if (ignore_cache) 253 256 mlog(ML_BH_IO, "trying to sync read a jbd "