Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp446425imm; Wed, 17 Oct 2018 02:52:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV623BW0g/ZNYn69whB9Or0ZZR/fLh25c5ccBWv6nZGqlFXgEmOz9WB8Gzwu31sXUSozywK/M X-Received: by 2002:a17:902:54d:: with SMTP id 71-v6mr17610379plf.80.1539769943208; Wed, 17 Oct 2018 02:52:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539769943; cv=none; d=google.com; s=arc-20160816; b=Xv4Hgm8WcNF//IYrQ2Qfe5Ihy+P2dtClOQoznucTTwPaKkW3oxebHg/frhrQemPkD6 D0ch+Pq0Hkz45Juh3P2bRXBqkOHmtcakqaj8jgw44myz13eLpIPm8UmvKf2mwGX5QiM5 kc6dKJ+ovbeTCUqu3go1aIPFU7OELB0q+YFb9WW7GYSctRFsKyhAsDl85V/6vwW5bOMi I6YtjuTl+MFKFOpCYVQpx2+Tdx+y0uGvN0wf/zgMJYIYj3x51WJxcD7Gh10y9PsGjLau 6CTUnMaZJC+wgZ5of1Fm+hoKeEkxljBa5EDivVqGodYOSTGLBvMqcxwo5gkWvIqnh6Yb q8dg== 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=BGLH7vz4ezZJWfo7VViZm9qP//Q/Rhlx7Ad3tXeHBaI=; b=0SBiGqxB/xsCD8AtyYsx9QUtd7rxyfTdViEFqZu1ihs5yJkwgTGVV8AZFsr3KEOSwr kNRB19INSc2WHLHkGN12aE48y2BiqSvsbLFYlvXUOzEXG9fGyTY/SBNLsk+sHlHlgups khdOJqlBFue4Rtmfzl8l2DCG3ie1Wq59G/Od9bfowHG5bECKaPLv+I2DHZ4tG3ihwXcV ulpxjZiwd/mb4v6PC9EbeXQ1Bgp3DRAhTrYXr5zNUwxD+qC5DtLcu7ih9CO84DCG5n4U Zsc0HQDC2QO1Su5pEBRllhTJVDWkOyA2cmf9VlQMWDowaJVS/EQY0tonsD6I02b0HkHI AuMg== 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 l9-v6si17119995pfi.179.2018.10.17.02.52.07; Wed, 17 Oct 2018 02:52:23 -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 S1727049AbeJQRpK (ORCPT + 99 others); Wed, 17 Oct 2018 13:45:10 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:44787 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726691AbeJQRpK (ORCPT ); Wed, 17 Oct 2018 13:45:10 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 99216DC2246DD; Wed, 17 Oct 2018 17:50:13 +0800 (CST) Received: from szvp000201624.huawei.com (10.120.216.130) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.399.0; Wed, 17 Oct 2018 17:50:07 +0800 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH] f2fs: fix to account IO correctly Date: Wed, 17 Oct 2018 17:49:54 +0800 Message-ID: <20181017094954.67547-1-yuchao0@huawei.com> X-Mailer: git-send-email 2.18.0.rc1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.120.216.130] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Below race can cause reversed reference on F2FS_RD_DATA, there is the same issue in f2fs_submit_page_bio(), fix them by relocate __submit_bio() and inc_page_count. Thread A Thread B - f2fs_write_begin - f2fs_submit_page_read - __submit_bio - f2fs_read_end_io - __read_end_io - dec_page_count(, F2FS_RD_DATA) - inc_page_count(, F2FS_RD_DATA) Signed-off-by: Chao Yu --- fs/f2fs/data.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index c03bd0c2ed22..8b9240762156 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -480,10 +480,10 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio) } bio_set_op_attrs(bio, fio->op, fio->op_flags); - __submit_bio(fio->sbi, bio, fio->type); - inc_page_count(fio->sbi, is_read_io(fio->op) ? __read_io_type(page): WB_DATA_TYPE(fio->page)); + + __submit_bio(fio->sbi, bio, fio->type); return 0; } @@ -612,8 +612,8 @@ static int f2fs_submit_page_read(struct inode *inode, struct page *page, return -EFAULT; } ClearPageError(page); - __submit_bio(F2FS_I_SB(inode), bio, DATA); inc_page_count(F2FS_I_SB(inode), F2FS_RD_DATA); + __submit_bio(F2FS_I_SB(inode), bio, DATA); return 0; } -- 2.18.0.rc1