Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp978851yba; Sat, 6 Apr 2019 00:10:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqwAnOVR6yRmq2pHYypw03WwmQB6IOCVLDwOjuFqavIE/l4MIOQENDu6qgXX+BhI3jwDDRc2 X-Received: by 2002:a17:902:e48f:: with SMTP id cj15mr17479799plb.256.1554534618096; Sat, 06 Apr 2019 00:10:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554534618; cv=none; d=google.com; s=arc-20160816; b=slnIDo/NPN3lb0Hohrsk5S/qBP+0VmPg0zSni2cwhleVWxbqTUYvbER45Ngtw7yb0c XgEy++rP46X5Ms1d7C37/GucobICL5tSl54qQfT5jBFsij5eGGDjkkECyU1GBcQLleM2 km+nhwrANn4lYk/ilM2MWNk7QmitRLPbgR/VXD2UsvK9Ngyh7pebFZlYKIUP3hQnUsD9 n4v6x7EveQRQlXOanc3OsVb2PldECHE5bxvTBlnli40gPcr8Fs34kWHXxweRNiqwWURv yooVoGXzxPImstWZ5w0RNPjfyI3dHMcIF8DiRY4VY5LC23i/EXg+iWHOBp+l5/qM1I1i rGxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=NWhBlbJCTgtbwxXoiLSOsbKbof9Pb6hvpXtH1RwkyCQ=; b=cC9bilP/WfrPz0Ex6ajggD05qd3ugSuyJ6xTXZt9jDmzxcezwUM8lFn7N3w6K1w/aw rJvzoCi33DJy2Mz+RLq1AvcvGUGrNgs+O8mehwCGcRqLU4iwvLOYRVjMfLW0l6P4YaHn T3SdIiNWWy//HO6wakfyU0UiVZhS8VxMC5nHrjuL9RpEQVeNU0X/h7OjIgJbZ/ar1XBc 9ZbyyikSlrce9R1C/lkAElXu4iBaOwzRe6ajyY8jiDSbewAjjpmUQDlVoePlJ4Ei3L+c h36Ax0I+1tcLmnLaFe8C6A81lkY0ppyUhfYhU+eT1NUl6w0oJ4Wl0lxO8SNgmv7CBqSW ePqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t12si5284842pgv.415.2019.04.06.00.10.02; Sat, 06 Apr 2019 00:10:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726494AbfDFHJH (ORCPT + 99 others); Sat, 6 Apr 2019 03:09:07 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:35830 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725934AbfDFHJG (ORCPT ); Sat, 6 Apr 2019 03:09:06 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 67E9DF9E5D7211D795D6; Sat, 6 Apr 2019 15:09:03 +0800 (CST) Received: from RH5885H-V3.huawei.com (10.90.53.225) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.408.0; Sat, 6 Apr 2019 15:08:55 +0800 From: ZhangXiaoxu To: , , , , , , CC: Subject: [PATCH] fs/buffer.c: Fix data corruption when buffer write with IO error Date: Sat, 6 Apr 2019 15:13:13 +0800 Message-ID: <1554534793-31444-1-git-send-email-zhangxiaoxu5@huawei.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the buffer write failed, 'end_buffer_write_sync' and 'end_buffer_async_write' will clear the uptodate flag. But the data in the buffer maybe newer than disk. In some case, this will lead data corruption. For example: ext4 flush metadata to disk failed, it will clear the uptodate flag. when a new coming call want the buffer, it will read it from the disk(because the buffer no uptodate flag). But the journal not checkpoint now, it will read old data from disk. If read successfully, ext4 will write the old data to the new journal, the data will corruption. So, don't clear the uptodate flag when write the buffer failed. Signed-off-by: ZhangXiaoxu --- fs/buffer.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index ce35760..9fe1827 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -172,7 +172,6 @@ void end_buffer_write_sync(struct buffer_head *bh, int uptodate) } else { buffer_io_error(bh, ", lost sync page write"); mark_buffer_write_io_error(bh); - clear_buffer_uptodate(bh); } unlock_buffer(bh); put_bh(bh); @@ -325,7 +324,6 @@ void end_buffer_async_write(struct buffer_head *bh, int uptodate) } else { buffer_io_error(bh, ", lost async page write"); mark_buffer_write_io_error(bh); - clear_buffer_uptodate(bh); SetPageError(page); } -- 2.7.4