Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp237224imm; Wed, 29 Aug 2018 19:43:02 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZF81LFfEj5lG8fGf0IFwR+YXipI2Sxw8bJGDYABAvy3ezvzaK7xakmdnqFagjqU5eJVh0W X-Received: by 2002:a63:ef10:: with SMTP id u16-v6mr7909648pgh.269.1535596982476; Wed, 29 Aug 2018 19:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535596982; cv=none; d=google.com; s=arc-20160816; b=RRs3dSo1mx+3gRu/0JmqgEINJ3+Hjiq5KIf0cauYN7LG5cG50kvRfB4Yry1D4dNROU EfYpqZaT4ihXq+d545sIvj6XGcvvVQYlSFBlvlYZMKLQnYWeB3O2a43ySlPqsD6VQK0U 3MTR2fOTIOA1vXymF12TEWXj4jwy17k/OVxcBlWB+DTXaOhpO5R/ZKfyx8LZ+hVH4Fsv EGcv7C6ai21mritFLkCyqosEmC5myfAtO4O+ptnIVZKc62gc8dHP7xBzLGYeMd4L1R5K wADXozyNkoQUKZ6t/KQEJh0+jZPSI4Hqq9rsCKwoio/9KwiUTdjQXwFZ7zXjUk0iz8uS qypQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=LNqMqcu8uPTvgC5S7kdHHgjUgKUcrfFH0y1lNdg4a5U=; b=DkTtr+HeLMIs1CYyq/gYnRKhEPpmLzWLUuaesUooS3a3deinjWaqE2DH8gJ79JV7Zx ShrMUl6fX26XegAdye4F9ddzUHqOXamlDydvqXArtqIZwjflq70vibPu47r9xigewIZb NNXHkTBM0Tez2JA6LwV/3XtgEbhc969PF7Rm0bKXyzqNy0g5TPzuoOQXh7s8xGd5xJwi j1UHgt5MEUPoYa89S/gPtOMrDoYpelTn9QwUPbi6wPIEkh670s+YWDmwyBqVq71/WIeh cmi/zM3Exv4bk/RVF6WB2eqPbzTkxAxOl4xG0In3aaj16XPprKQLW/waVrrPmpF2c80n nP7Q== 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 k1-v6si5292770pgh.65.2018.08.29.19.42.47; Wed, 29 Aug 2018 19:43:02 -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 S1727266AbeH3GlE (ORCPT + 99 others); Thu, 30 Aug 2018 02:41:04 -0400 Received: from smtp2.provo.novell.com ([137.65.250.81]:35890 "EHLO smtp2.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725788AbeH3GlE (ORCPT ); Thu, 30 Aug 2018 02:41:04 -0400 Received: from [10.67.19.114] (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Wed, 29 Aug 2018 20:41:03 -0600 Subject: Re: [Ocfs2-devel] [PATCH] fix crash on ocfs2_duplicate_clusters_by_page To: Changwei Ge , Andrew Morton Cc: "ocfs2-devel@oss.oracle.com" , "linux-kernel@vger.kernel.org" References: <20180829074740.9438-1-lchen@suse.com> <20180829152533.431fd4972ae046943cabc2e3@linux-foundation.org> From: Larry Chen Message-ID: <28aec268-2b1d-9763-1909-4f9db2e46f4e@suse.com> Date: Thu, 30 Aug 2018 10:40:51 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andrew and Changwei, Thanks for your review, I'll propose a new version with comments corrected. Thanks, Larry On 08/30/2018 10:29 AM, Changwei Ge wrote: > Hi Larry, > > Besides Andrew's comments, other parts of this patch look good to me. > > Thanks, > > Changwei > > > On 2018/8/30 6:25, Andrew Morton wrote: >> On Wed, 29 Aug 2018 15:47:40 +0800 Larry Chen wrote: >> >>> ocfs2_duplicate_clusters_by_page may crash if one of extent's pages is dirty. >>> When a page has not been written back, it is still in dirty state. If >>> ocfs2_duplicate_clusters_by_page is called against the >>> dirty page, the crash happens. >>> >>> To fix this bug, we can just unlock the page and wait the page until >>> it's not dirty. >>> >>> The following is the buck trace dump: >>> >>> kernel BUG at /root/code/ocfs2/refcounttree.c:2961! >>> [exception RIP: ocfs2_duplicate_clusters_by_page+822] >>> __ocfs2_move_extent+0x80/0x450 [ocfs2] >>> ? __ocfs2_claim_clusters+0x130/0x250 [ocfs2] >>> ocfs2_defrag_extent+0x5b8/0x5e0 [ocfs2] >>> __ocfs2_move_extents_range+0x2a4/0x470 [ocfs2] >>> ocfs2_move_extents+0x180/0x3b0 [ocfs2] >>> ? ocfs2_wait_for_recovery+0x13/0x70 [ocfs2] >>> ocfs2_ioctl_move_extents+0x133/0x2d0 [ocfs2] >>> ocfs2_ioctl+0x253/0x640 [ocfs2] >>> do_vfs_ioctl+0x90/0x5f0 >>> SyS_ioctl+0x74/0x80 >>> do_syscall_64+0x74/0x140 >>> entry_SYSCALL_64_after_hwframe+0x3d/0xa2 >>> >>> --- a/fs/ocfs2/refcounttree.c >>> +++ b/fs/ocfs2/refcounttree.c >>> @@ -2946,6 +2946,7 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle, >>> if (map_end & (PAGE_SIZE - 1)) >>> to = map_end & (PAGE_SIZE - 1); >>> >>> +retry: >>> page = find_or_create_page(mapping, page_index, GFP_NOFS); >>> if (!page) { >>> ret = -ENOMEM; >>> @@ -2957,8 +2958,15 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle, >>> * In case PAGE_SIZE <= CLUSTER_SIZE, This page >>> * can't be dirtied before we CoW it out. >>> */ >> Looks sane, but the below change shows that the above comment is >> untrue. Can we please update the comment as well? >> >> >>> - if (PAGE_SIZE <= OCFS2_SB(sb)->s_clustersize) >>> - BUG_ON(PageDirty(page)); >>> + if (PAGE_SIZE <= OCFS2_SB(sb)->s_clustersize) { >>> + if (PageDirty(page)) { >>> + /* >>> + * write_on_page will unlock the page on return >>> + */ >>> + ret = write_one_page(page); >>> + goto retry; >>> + } >>> + } >>> >>> if (!PageUptodate(page)) { >>> ret = block_read_full_page(page, ocfs2_get_block); >> >> _______________________________________________ >> Ocfs2-devel mailing list >> Ocfs2-devel@oss.oracle.com >> https://oss.oracle.com/mailman/listinfo/ocfs2-devel >