2008-02-15 06:36:25

by Hisashi Hifumi

[permalink] [raw]
Subject: [RESEND] [PATCH] fix invalidate_inode_pages2_range not to clear ret

Hi Andrew.

DIO invalidates page cache through invalidate_inode_pages2_range().
invalidate_inode_pages2_range() sets ret=-EIO when invalidate_complete_page2()
fails, but this ret is cleared if do_launder_page() succeed on a page of next index.
In this case, dio is carried out even if invalidate_complete_page2() fails on some pages.
This can cause inconsistency between memory and blocks on HDD because the page
cache still exists.

Following patch fixes this issue.

Thanks.

Signed-off-by :Hisashi Hifumi <[email protected]>

diff -Nrup linux-2.6.25-rc1.org/mm/truncate.c linux-2.6.25-rc1/mm/truncate.c
--- linux-2.6.25-rc1.org/mm/truncate.c 2008-02-12 13:37:41.000000000 +0900
+++ linux-2.6.25-rc1/mm/truncate.c 2008-02-15 11:24:33.000000000 +0900
@@ -392,6 +392,7 @@ int invalidate_inode_pages2_range(struct
pgoff_t next;
int i;
int ret = 0;
+ int ret2 = 0;
int did_range_unmap = 0;
int wrapped = 0;

@@ -439,9 +440,11 @@ int invalidate_inode_pages2_range(struct
}
}
BUG_ON(page_mapped(page));
- ret = do_launder_page(mapping, page);
- if (ret == 0 && !invalidate_complete_page2(mapping, page))
- ret = -EIO;
+ ret2 = do_launder_page(mapping, page);
+ if (ret2 == 0 && !invalidate_complete_page2(mapping, page))
+ ret2 = -EIO;
+ if (ret2 < 0)
+ ret = ret2;
unlock_page(page);
}
pagevec_release(&pvec);


2008-02-20 18:08:29

by Jeff Moyer

[permalink] [raw]
Subject: Re: [RESEND] [PATCH] fix invalidate_inode_pages2_range not to clear ret

Hisashi Hifumi <[email protected]> writes:

> Hi Andrew.
>
> DIO invalidates page cache through invalidate_inode_pages2_range().
> invalidate_inode_pages2_range() sets ret=-EIO when invalidate_complete_page2()
> fails, but this ret is cleared if do_launder_page() succeed on a page of next index.
> In this case, dio is carried out even if invalidate_complete_page2() fails on some pages.
> This can cause inconsistency between memory and blocks on HDD because the page
> cache still exists.
>
> Following patch fixes this issue.

I agree with the patch (and I see Andrew already accepted it). Do you
have a reproducer for this problem?

Cheers,

Jeff

2008-02-21 02:24:26

by Hisashi Hifumi

[permalink] [raw]
Subject: Re: [RESEND] [PATCH] fix invalidate_inode_pages2_range not to clear ret

Hi Jeff.

>
>I agree with the patch (and I see Andrew already accepted it). Do you
>have a reproducer for this problem?

Do you want to know the way of failing invalidate_complete_page2() ?

2008-02-21 13:23:44

by Jeff Moyer

[permalink] [raw]
Subject: Re: [RESEND] [PATCH] fix invalidate_inode_pages2_range not to clear ret

Hisashi Hifumi <[email protected]> writes:

> Hi Jeff.
>
>>
>>I agree with the patch (and I see Andrew already accepted it). Do you
>>have a reproducer for this problem?
>
> Do you want to know the way of failing invalidate_complete_page2() ?

I was hoping for a test program that shows the problem. Looking through
the previous threads on this subject, it seems that Zach may have had a
reproducer. I tried running the aio-dio-regress tests on the 2.6.25-rc2
kernel, but was unable to trigger this problem.

-Jeff