From: "HUANG Weller (CM/ESW12-CN)" Subject: RE: ext4 out of order when use cfq scheduler Date: Mon, 11 Jan 2016 09:05:20 +0000 Message-ID: <97be88d3acae4317ba1b6443f859ada0@SGPMBX1004.APAC.bosch.com> References: <697280a570654ae0aa1723fb7d11f51e@SGPMBX1004.APAC.bosch.com> <20151222150037.GB18178@quack.suse.cz> <20160105153050.GF14464@quack.suse.cz> <20160106100621.GA24046@quack.suse.cz> <3ab48fa47e434455b101251730e69bd2@SGPMBX1004.APAC.bosch.com> <20160107102420.GB8380@quack.suse.cz> <20160107114736.GC8380@quack.suse.cz> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="_002_97be88d3acae4317ba1b6443f859ada0SGPMBX1004APACboschcom_" Cc: "linux-ext4@vger.kernel.org" , "Li, Michael" To: Jan Kara Return-path: Received: from smtp6-v.fe.bosch.de ([139.15.237.11]:63013 "EHLO smtp6-v.fe.bosch.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759084AbcAKJFb (ORCPT ); Mon, 11 Jan 2016 04:05:31 -0500 Content-Language: en-US Sender: linux-ext4-owner@vger.kernel.org List-ID: --_002_97be88d3acae4317ba1b6443f859ada0SGPMBX1004APACboschcom_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: HUANG Weller (CM/ESW12-CN) > Sent: Friday, January 08, 2016 8:47 AM > To: 'Jan Kara' > Cc: linux-ext4@vger.kernel.org; Li, Michael > Subject: RE: ext4 out of order when use cfq scheduler >=20 > > > > > > > > > > > OK, so I was looking into the code and indeed, reality is correct > > > > and my mental model was wrong! ;) I thought that inode gets added > > > > to the list of inodes for which we need to wait for data IO > > > > completion during transaction commit during block allocation. And I= was > wrong. > > > > It used to happen in > > > > mpage_da_map_and_submit() until commit f3b59291a69d (ext4: remove > > > > calls to > > > > ext4_jbd2_file_inode() from delalloc write path) where it got > > > > removed. And that was wrong because although we submit data writes > > > > before dropping handle for allocating transaction and updating > > > > i_size, nobody guarantees that data IO is not delayed in the block > > > > layer until > > transaction commit. > > > > Which seems to happen in your case. I'll send a fix. Thanks for > > > > your report and persistence! > > > > > > > > > > Thanks a lot for your feedback :-) > > > Because I am not familiar with the detail of the ext4 internal code. > > > I will try to > > understand your explanation which you describe above. And have a look > > on related funcations. > > > Could you send the fix in this mail ? > > > And whether the kernel 3.14 also have such issue, right ? > > > > The problem is in all kernels starting with 3.8. Attached is a patch > > which should fix the issue. Can you test whether it fixes the problem f= or you? > > > > Honza > > -- >=20 > Yes, of course I will redo the test with the patch. And also give you fee= dback. Test result: Test on 2 targets with the kernel applied your patch. Both of them are OK a= fter 5000 power failure tests. Our target test cycle is 10,000. By the way, since your original patch can't be applied on 3.x kernel, The a= ttached one is based on yours and can applied on old kernel(mine is 3.10) = directly. >=20 > > Jan Kara > > SUSE Labs, CR --_002_97be88d3acae4317ba1b6443f859ada0SGPMBX1004APACboschcom_ Content-Type: application/octet-stream; name="0001-ext4-Fix-data-exposure-after-a-crash.patch" Content-Description: 0001-ext4-Fix-data-exposure-after-a-crash.patch Content-Disposition: attachment; filename="0001-ext4-Fix-data-exposure-after-a-crash.patch"; size=3185; creation-date="Mon, 11 Jan 2016 09:05:11 GMT"; modification-date="Mon, 11 Jan 2016 09:04:50 GMT" Content-Transfer-Encoding: base64 RnJvbSA5OGNmODIxZTI3MDc0ODQ4NjEzMjA3OWFjOGQxYzk1NTdjOWFkZmI5IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBKYW4gS2FyYSA8amFja0BzdXNlLmN6PgpEYXRlOiBUaHUsIDcg SmFuIDIwMTYgMTI6MjE6MjUgKzAxMDAKU3ViamVjdDogW1BBVENIXSBleHQ0OiBGaXggZGF0YSBl eHBvc3VyZSBhZnRlciBhIGNyYXNoCgpIdWFuZyBoYXMgcmVwb3J0ZWQgdGhhdCBpbiBoaXMgcG93 ZXJmYWlsIHRlc3RpbmcgaGUgaXMgc2VlaW5nIHN0YWxlCmJsb2N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