Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2346001ybz; Thu, 23 Apr 2020 16:27:16 -0700 (PDT) X-Google-Smtp-Source: APiQypKzlAJbTGm+H9eASjF/4gbheMNFme3q2Rx7cWq3/I4tVy02QUYE1eBctxU5KiOmlE3Xnmcu X-Received: by 2002:a17:906:1584:: with SMTP id k4mr4932716ejd.355.1587684436191; Thu, 23 Apr 2020 16:27:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587684436; cv=none; d=google.com; s=arc-20160816; b=UwsVzE9OF14EAE7GHQ33BQ1ihhXEnbFw4U1dOnnHTdZiI3BdfpkJHOFbqHNCjMvd3M 88ctVrAUgqaQUtvSdEsrADeYMFaxzonB4CMTgjvF6IIsT5MTm4WPxpaKcI5k0eJfjmvx RaiiKJZlSAzyl1KkD1UXh6xLpSgSRFfI8MCRFF3aA24yNfi27Q9LcxANw2qrTu1VEO/S C/L1p+cLN0qyYogXrfq0IC3GsTIesGiLFwmxuihG5/0fWCv+HUsEyoRk4H00Vr6rkTqO HtlIU/ZZlQdL1R/aTDZ0R5Rwd0BpEolQCte2MQCUan2WASt6Q4O448xaVXrFbq1gEHYt xetg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=gvXwJE+ACumQ/rN3pGCqaFo4Si+ZDHHf0fknHFrbe7M=; b=hXbITfAJMqxC0FzLhCMhQ6oeWDimH9hYzCdqF29HJHqxx2pSSC5BGlogpzIVQUkOoS Qf1++LZR1vpJzjrHgLFkUZPGAX4TO19aNWdIIcXwGZq2Pi4akq+9id35fSrooM1Al54h nM/PlfW/aZmAwkjVwBwANRE8A1QByevOTtYS48cUrTnhHGQ4tnWGOsBwaYL0wJMirVke JDOTk4J1/fv2+fXZHI6y1fx20rvkiJpYneetFC6OoCOGkwuay1nG1Eer24opxZjmOewc zQMzmurdsCsqQk4mmxbsbcEo9nLqBUb9OJefazeMvC6tZWPnOmqpMB25m5vXwlj4Tics rxHQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n23si1987076edt.420.2020.04.23.16.26.53; Thu, 23 Apr 2020 16:27:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729436AbgDWXXd (ORCPT + 99 others); Thu, 23 Apr 2020 19:23:33 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:48410 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728165AbgDWXGa (ORCPT ); Thu, 23 Apr 2020 19:06:30 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1jRkvK-0004b6-L3; Fri, 24 Apr 2020 00:06:26 +0100 Received: from ben by deadeye with local (Exim 4.93) (envelope-from ) id 1jRkvJ-00E6hu-Ee; Fri, 24 Apr 2020 00:06:25 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "David Sterba" , "Greg Kroah-Hartman" , "Ben Hutchings" , "Josef Bacik" , "Qu Wenruo" Date: Fri, 24 Apr 2020 00:04:34 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 047/245] btrfs: tree-check: reduce stack consumption in check_dir_item In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.83-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: David Sterba commit e2683fc9d219430f5b78889b50cde7f40efeba7b upstream. I've noticed that the updated item checker stack consumption increased dramatically in 542f5385e20cf97447 ("btrfs: tree-checker: Add checker for dir item") tree-checker.c:check_leaf +552 (176 -> 728) The array is 255 bytes long, dynamic allocation would slow down the sanity checks so it's more reasonable to keep it on-stack. Moving the variable to the scope of use reduces the stack usage again tree-checker.c:check_leaf -264 (728 -> 464) Reviewed-by: Josef Bacik Reviewed-by: Qu Wenruo Signed-off-by: David Sterba Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman Signed-off-by: Ben Hutchings --- fs/btrfs/tree-checker.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/btrfs/tree-checker.c +++ b/fs/btrfs/tree-checker.c @@ -212,7 +212,6 @@ static int check_dir_item(struct btrfs_r di = btrfs_item_ptr(leaf, slot, struct btrfs_dir_item); while (cur < item_size) { - char namebuf[max(BTRFS_NAME_LEN, XATTR_NAME_MAX)]; u32 name_len; u32 data_len; u32 max_name_len; @@ -295,6 +294,8 @@ static int check_dir_item(struct btrfs_r */ if (key->type == BTRFS_DIR_ITEM_KEY || key->type == BTRFS_XATTR_ITEM_KEY) { + char namebuf[max(BTRFS_NAME_LEN, XATTR_NAME_MAX)]; + read_extent_buffer(leaf, namebuf, (unsigned long)(di + 1), name_len); name_hash = btrfs_name_hash(namebuf, name_len);