]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ext4: fix the deadlock in mpage_da_map_and_submit()
authorKazuya Mio <k-mio@sx.jp.nec.com>
Thu, 20 Oct 2011 23:23:08 +0000 (19:23 -0400)
committerGuangyu Sun <guangyu.sun@oracle.com>
Thu, 15 Mar 2012 19:08:37 +0000 (12:08 -0700)
If ext4_jbd2_file_inode() in mpage_da_map_and_submit() fails due to
journal abort, this function returns to caller without unlocking the
page.  It leads to the deadlock, and the patch fixes this issue by
calling mpage_da_submit_io().

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Conflicts:

fs/ext4/inode.c

fs/ext4/inode.c

index fa805e7527e6be60d464e48381cc21125e831d68..00523341b77a9dc6713b66fef8382bf350827d16 100644 (file)
@@ -2339,13 +2339,15 @@ static void mpage_da_map_and_submit(struct mpage_da_data *mpd)
 
                for (i = 0; i < map.m_len; i++)
                        unmap_underlying_metadata(bdev, map.m_pblk + i);
-       }
 
-       if (ext4_should_order_data(mpd->inode)) {
-               err = ext4_jbd2_file_inode(handle, mpd->inode);
-               if (err)
-                       /* This only happens if the journal is aborted */
-                       return;
+               if (ext4_should_order_data(mpd->inode)) {
+                       err = ext4_jbd2_file_inode(handle, mpd->inode);
+                       if (err) {
+                               /* Only if the journal is aborted */
+                               mpd->retval = err;
+                               goto submit_io;
+                       }
+               }
        }
 
        /*
@@ -3041,11 +3043,12 @@ retry:
                        ret = 0;
                } else if (ret == MPAGE_DA_EXTENT_TAIL) {
                        /*
-                        * got one extent now try with
-                        * rest of the pages
+                        * Got one extent now try with rest of the pages.
+                        * If mpd.retval is set -EIO, journal is aborted.
+                        * So we don't need to write any more.
                         */
                        pages_written += mpd.pages_written;
-                       ret = 0;
+                       ret = mpd.retval;
                        io_done = 1;
                } else if (wbc->nr_to_write)
                        /*