Message ID | 1455618965-26699-2-git-send-email-dmonakhov@openvz.org |
---|---|
State | New, archived |
Headers | show |
On Tue, Feb 16, 2016 at 02:36:05PM +0400, Dmitry Monakhov wrote: > diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c > index 81e6226..f2760c8 100644 > --- a/fs/jbd2/journal.c > +++ b/fs/jbd2/journal.c > @@ -1333,6 +1333,18 @@ static int jbd2_write_superblock(journal_t *journal, int write_op) > if (!(journal->j_flags & JBD2_BARRIER)) > write_op &= ~(REQ_FUA | REQ_FLUSH); > lock_buffer(bh); > + /* > + * Some disk drives may invalidate its page cache on failure > + * so sbh becomes unmapped. > + */ > + if (!buffer_mapped(bh)) { I think checking bh->bdev == NULL is a better check for this condition. > + /* Disk dissapeared under us, there is nothing we can Spelling nit: "disappeared" > + do but complain */ > + printk(KERN_ERR "JBD2: journal superblock was invalidated " > + "for %s.\n", journal->j_devname); > + return -EIO; > + } > + This is missing a an "unlock_buffer(bh)" before we return. > if (buffer_write_io_error(bh)) { > /* > * Oh, dear. A previous attempt to write the journal - Ted -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 81e6226..f2760c8 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -1333,6 +1333,18 @@ static int jbd2_write_superblock(journal_t *journal, int write_op) if (!(journal->j_flags & JBD2_BARRIER)) write_op &= ~(REQ_FUA | REQ_FLUSH); lock_buffer(bh); + /* + * Some disk drives may invalidate its page cache on failure + * so sbh becomes unmapped. + */ + if (!buffer_mapped(bh)) { + /* Disk dissapeared under us, there is nothing we can + do but complain */ + printk(KERN_ERR "JBD2: journal superblock was invalidated " + "for %s.\n", journal->j_devname); + return -EIO; + } + if (buffer_write_io_error(bh)) { /* * Oh, dear. A previous attempt to write the journal
Some devices(nbd) can becomes unoperatable via kill_bdev so its pagecache will be invalidated and all buffers becomes unmapped. In that situation we will trigger BUGON on submit_bh. #Testcase mkdir -p a/mnt cd a truncate -s 1G img mkfs.ext4 -F img qemu-nbd -c /dev/nbd0 img mount /dev/nbd0 /mnt cp -r /bin/ /mnt& # Disconnect nbd while cp is active qemu-nbd -d /dev/nbd0 Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> --- fs/jbd2/journal.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)