From patchwork Sun Jan 7 21:07:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Lightsey X-Patchwork-Id: 10148473 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B27E4601BE for ; Sun, 7 Jan 2018 21:15:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A42F825404 for ; Sun, 7 Jan 2018 21:15:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97A5E26224; Sun, 7 Jan 2018 21:15:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) (using TLSv1.2 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C083F25404 for ; Sun, 7 Jan 2018 21:15:55 +0000 (UTC) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.21) with SMTP id w07LBvX4059711; Sun, 7 Jan 2018 21:14:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=message-id : from : to : date : in-reply-to : references : mime-version : cc : subject : list-id : list-unsubscribe : list-archive : list-post : list-help : list-subscribe : content-type : content-transfer-encoding : sender; s=corp-2017-10-26; bh=wr9QAg4O7X/P8PlUxkU4WJeVC4hp3Lm4nTrAOCUTe8Q=; b=rxQ3MeoYnw+lbb+UpFk9qK3CSbJb9OflkLCZnFD0kiwDBxAVk/57yFOx7Yx+yav4H1cS 45h3bVIkHkUT/8E7wsNcZ6m4jTNcyEQ1KCtnfeBHjdLO7v5QtmUcjuECuJeErtVw+KAK vFdWO0tqIkaxMcKbv1PY98U6AGgUpgruEESC+O0Vd6En4uwTewuDdduFkiKFZvsdb+up ukU2uwWigQKWd6LlwVTUJI3/Eq7ukO/OZRJhzTR3VRmd8Z46SDmbDtIYqrMDTMRBmvWT MQK7LRIQk48S9ceH2jxcG/QzYMLvykWw2QWqZoxLlhbAZC2Z17ReayozDlPHhZr2o3YP aA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2fbu58r0gj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Jan 2018 21:14:47 +0000 Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w07L8q4C020373 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 7 Jan 2018 21:08:53 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1eYIBY-0007Dk-Kx; Sun, 07 Jan 2018 13:08:52 -0800 Received: from userv0021.oracle.com ([156.151.31.71]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1eYIB4-0007Ag-LF for ocfs2-devel@oss.oracle.com; Sun, 07 Jan 2018 13:08:24 -0800 Received: from userp2030.oracle.com (userp2030.oracle.com [156.151.31.89]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w07L8Muf019985 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL) for ; Sun, 7 Jan 2018 21:08:22 GMT Received: from pps.filterd (userp2030.oracle.com [127.0.0.1]) by userp2030.oracle.com (8.16.0.22/8.16.0.21) with SMTP id w07L6wcF011576 for ; Sun, 7 Jan 2018 21:08:22 GMT Received: from mail.wazzim.com (mail.wazzim.com [208.74.120.37]) by userp2030.oracle.com with ESMTP id 2fbnvy3dmk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Sun, 07 Jan 2018 21:08:21 +0000 Message-ID: <1515359275.3044.4.camel@nixnuts.net> From: John Lightsey To: Ge Changwei Date: Sun, 07 Jan 2018 15:07:55 -0600 In-Reply-To: References: <63ADC13FD55D6546B7DECE290D39E373F2908FC7@H3CMLB12-EX.srv.huawei-3com.com> <5A448D59.4040603@huawei.com> <63ADC13FD55D6546B7DECE290D39E373F2909D75@H3CMLB12-EX.srv.huawei-3com.com> ,<1514582159.2812.5.camel@nixnuts.net> X-Mailer: Evolution 3.22.6-1+deb9u1 Mime-Version: 1.0 X-Spam_score: -1.5 X-Spam_score_int: -14 X-Spam_bar: - X-Spam_report: Spam detection software, running on the system "nixnuts.net", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On Fri, 2017-12-29 at 22:36 +0000, Ge Changwei wrote: > Hi john, > > Thanks for your test. > I am on a vacation until 3, January. > I will investigate the issue when I am back to work. > From what I can tell, the order of reclaiming blocs vs allocating new ones just needs to be reversed for everything to work correctly. [...] Content analysis details: (-1.5 points, 3.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -0.5 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-CLX-Shades: MLX X-CLX-Response: 1TFkXGRsRCkx6FxoRCllNF2dmchEKWUkXGnEaEBp3BhsYcRsfEBsbdwYbEwY aEQpZXhdobmYRCklGF0VYS0lGT3VaWEVOX0leQ0VEGXVPSxEKQ04XeFxmbn9JbWETGxN4WXVDb0 waT1JTWl1yX35daW5YdXoRClhcFx8EGgQbGBgHHEtIS08eHBoFGxoEGxoaBB4SBBsQGx4aHxoRC l5ZF3hDbm5NEQpNXBcfGhoRCkxaF3tpQk17EQpFWRdvaxEKTF8XegUFBQUFBQUFBW8RCkxGF2xr axEKQ1oXGBoSBB0eBBsYGgQZHREKQl4XGxEKREkXHxEKQkYXYlBQfElAfl9STmIRCkJcFxoRCkJ FF2RufGNlf3x+RFN8EQpCThduZXhYYUEef0gFfREKQkwXY2cTTWFhTAFvc30RCkJsF2JPS0JkTX weQ2RaEQpCQBdiZ2ZMXx99aGBwRREKQlgXYn1veQFPGBlwcHsRCnBoF3oYW2lAT1laSERnEBkaE QpwaBd6QExte2R7TVMTHBAZGhEKcGgXZwEZW3hHGB5Scm4QGRoRCnBoF29gXkVsT3JYE2kSEBka EQpwaBdgG2hbcnldYE15bRAZGhEKcGwXbwF8Zxh7GmcFHUcQGRoRCm1+FxoRClhNF0sRIA== X-PDR: PASS X-Source-IP: 208.74.120.37 X-ServerName: mail.wazzim.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 a mx -all X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8767 signatures=668652 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=0 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=31 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801070316 X-Spam: Clean Cc: Zhangduan , "ocfs2-devel@oss.oracle.com" Subject: Re: [Ocfs2-devel] [PATCH v2] ocfs2: try to reuse extent block in dealloc without meta_alloc X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8767 signatures=668652 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801070317 X-Virus-Scanned: ClamAV using ClamSMTP On Fri, 2017-12-29 at 22:36 +0000, Ge Changwei wrote: > Hi john, > > Thanks for your test. > I am on a vacation until 3, January. > I will investigate the issue when I am back to work. > >From what I can tell, the order of reclaiming blocs vs allocating new ones just needs to be reversed for everything to work correctly. This patch on top of yours works in my testing. I'm not certain my test scenario is hitting ocfs2_add_branch() with new_blocks > 1 and meta_ac != NULL though. >From 317cbd5a7c8ee5f8f6dff3844d23d3169db990a4 Mon Sep 17 00:00:00 2001 From: John Lightsey Date: Sun, 7 Jan 2018 14:43:21 -0600 Subject: [PATCH] Reuse deallocated extents before claiming new extents. By reusing deallocated extents before attempting to claim new extents, this avoids a condition where the extent tree is truncated, and then an allocation requests are made for more extents than were originally reserved. --- fs/ocfs2/alloc.c | 26 +++++++++++++++++++------- fs/ocfs2/aops.c | 3 +-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 89807ea7..dce2eaa7 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c @@ -1166,7 +1166,7 @@ static int ocfs2_add_branch(handle_t *handle, struct buffer_head **last_eb_bh, struct ocfs2_alloc_context *meta_ac) { - int status, new_blocks, i; + int status, new_blocks, reclaimed_blocks, i; u64 next_blkno, new_last_eb_blk; struct buffer_head *bh; struct buffer_head **new_eb_bhs = NULL; @@ -1222,8 +1222,20 @@ static int ocfs2_add_branch(handle_t *handle, } if (meta_ac) { - status = ocfs2_create_new_meta_bhs(handle, et, new_blocks, - meta_ac, new_eb_bhs); + reclaimed_blocks = 0; + while ( reclaimed_blocks < new_blocks && !ocfs2_is_dealloc_empty(et) ) { + status = ocfs2_reuse_blk_from_dealloc(handle, et, + new_eb_bhs + reclaimed_blocks, 1); + if (status < 0) { + mlog_errno(status); + goto bail; + } + reclaimed_blocks++; + } + if (reclaimed_blocks < new_blocks) { + status = ocfs2_create_new_meta_bhs(handle, et, new_blocks - reclaimed_blocks, + meta_ac, new_eb_bhs + reclaimed_blocks); + } } else if (!ocfs2_is_dealloc_empty(et)) { status = ocfs2_reuse_blk_from_dealloc(handle, et, new_eb_bhs, new_blocks); @@ -1362,12 +1374,12 @@ static int ocfs2_shift_tree_depth(handle_t *handle, struct ocfs2_extent_list *root_el; struct ocfs2_extent_list *eb_el; - if (meta_ac) { - status = ocfs2_create_new_meta_bhs(handle, et, 1, meta_ac, - &new_eb_bh); - } else if (!ocfs2_is_dealloc_empty(et)) { + if (!ocfs2_is_dealloc_empty(et)) { status = ocfs2_reuse_blk_from_dealloc(handle, et, &new_eb_bh, 1); + } else if (meta_ac) { + status = ocfs2_create_new_meta_bhs(handle, et, 1, meta_ac, + &new_eb_bh); } else { BUG(); } diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index dcea6d5c..8ad37965 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -1743,8 +1743,7 @@ int ocfs2_write_begin_nolock(struct address_space *mapping, ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), wc->w_di_bh); ret = ocfs2_lock_allocators(inode, &et, - clusters_to_alloc, - 2*extents_to_split, + clusters_to_alloc, extents_to_split, &data_ac, &meta_ac); if (ret) { mlog_errno(ret);