exofs: clean up the correct page collection on write error
authorIdan Kedar <idank@tonian.com>
Fri, 30 Nov 2012 14:03:31 +0000 (16:03 +0200)
committerBoaz Harrosh <bharrosh@panasas.com>
Tue, 11 Dec 2012 16:56:18 +0000 (18:56 +0200)
if ore_write() fails, we would unlock the pages of pcol, which is now
empty, rather than pcol_copy which owns the pages when ore_write() is
called. this means that no pages will actually be unlocked
(pcol.nr_pages == 0) and the writing process (more accurately, the
syncing process) will hang waiting for a writeback notification that
never comes.

moreover, if ore_write() fails, pcol_free() is called for pcol, whereas
pcol_copy is the object owning the ore_io_state, thus leaking the
ore_io_state.

[Boaz]
I have simplified Idan's original patch a bit, everything else still
holds

Signed-off-by: Idan Kedar <idank@tonian.com>
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
fs/exofs/inode.c

index b5618104775187787415b67c1d99658f45f8b3d7..1634b946565ff150d93ee65d1893a12a63bd6ac0 100644 (file)
@@ -676,8 +676,10 @@ static int write_exec(struct page_collect *pcol)
        return 0;
 
 err:
-       _unlock_pcol_pages(pcol, ret, WRITE);
-       pcol_free(pcol);
+       if (!pcol_copy) /* Failed before ownership transfer */
+               pcol_copy = pcol;
+       _unlock_pcol_pages(pcol_copy, ret, WRITE);
+       pcol_free(pcol_copy);
        kfree(pcol_copy);
 
        return ret;
This page took 0.026423 seconds and 5 git commands to generate.