From patchwork Fri Oct 7 23:07:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 9485685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on sandeen.net X-Spam-Level: X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM, RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 X-Spam-HP: BAYES_00=-1.9,HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_HI=-5,RCVD_IN_SORBS_SPAM=0.5,RP_MATCHES_RCVD=-0.1, UNPARSEABLE_RELAY=0.001 X-Original-To: sandeen@sandeen.net Delivered-To: sandeen@sandeen.net Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by sandeen.net (Postfix) with ESMTP id AA8DE1431 for ; Fri, 7 Oct 2016 18:07:08 -0500 (CDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753093AbcJGXHt (ORCPT ); Fri, 7 Oct 2016 19:07:49 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:45519 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755110AbcJGXHq (ORCPT ); Fri, 7 Oct 2016 19:07:46 -0400 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u97N7hON018903 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 7 Oct 2016 23:07:43 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u97N7h9e011912 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 7 Oct 2016 23:07:43 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u97N7dI5027918; Fri, 7 Oct 2016 23:07:42 GMT Received: from localhost (/24.21.211.40) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 07 Oct 2016 16:07:39 -0700 Subject: [PATCH 3/7] xfs: reduce stack usage of _reflink_clear_inode_flag From: "Darrick J. Wong" To: david@fromorbit.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, Brian Foster Date: Fri, 07 Oct 2016 16:07:38 -0700 Message-ID: <147588165809.12127.6624984020251009472.stgit@birch.djwong.org> In-Reply-To: <147588163396.12127.8356851783027062457.stgit@birch.djwong.org> References: <147588163396.12127.8356851783027062457.stgit@birch.djwong.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The loop in _reflink_clear_inode_flag isn't necessary since we jump out if any part of any extent is shared. Remove the loop and we no longer need two maps, so we can save some stack use. Signed-off-by: Darrick J. Wong Reported-by: Brian Foster --- fs/xfs/xfs_reflink.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 9c58b4a..c4e35dc 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1507,7 +1507,7 @@ xfs_reflink_clear_inode_flag( xfs_extlen_t aglen; xfs_agblock_t rbno; xfs_extlen_t rlen; - struct xfs_bmbt_irec map[2]; + struct xfs_bmbt_irec map; int nmaps; int error = 0; @@ -1521,37 +1521,29 @@ xfs_reflink_clear_inode_flag( * Look for extents in the file. Skip holes, delalloc, or * unwritten extents; they can't be reflinked. */ - error = xfs_bmapi_read(ip, fbno, end - fbno, map, &nmaps, 0); + error = xfs_bmapi_read(ip, fbno, end - fbno, &map, &nmaps, 0); if (error) return error; if (nmaps == 0) break; - if (map[0].br_startblock == HOLESTARTBLOCK || - map[0].br_startblock == DELAYSTARTBLOCK || - ISUNWRITTEN(&map[0])) + if (map.br_startblock == HOLESTARTBLOCK || + map.br_startblock == DELAYSTARTBLOCK || + ISUNWRITTEN(&map)) goto next; - map[1] = map[0]; - while (map[1].br_blockcount) { - agno = XFS_FSB_TO_AGNO(mp, map[1].br_startblock); - agbno = XFS_FSB_TO_AGBNO(mp, map[1].br_startblock); - aglen = map[1].br_blockcount; - - error = xfs_reflink_find_shared(mp, agno, agbno, aglen, - &rbno, &rlen, false); - if (error) - return error; - /* Is there still a shared block here? */ - if (rbno != NULLAGBLOCK) - return 0; - - map[1].br_blockcount -= aglen; - map[1].br_startoff += aglen; - map[1].br_startblock += aglen; - } + agno = XFS_FSB_TO_AGNO(mp, map.br_startblock); + agbno = XFS_FSB_TO_AGBNO(mp, map.br_startblock); + aglen = map.br_blockcount; + error = xfs_reflink_find_shared(mp, agno, agbno, aglen, + &rbno, &rlen, false); + if (error) + return error; + /* Is there still a shared block here? */ + if (rbno != NULLAGBLOCK) + return 0; next: - fbno = map[0].br_startoff + map[0].br_blockcount; + fbno = map.br_startoff + map.br_blockcount; } /*