From patchwork Wed Apr 18 02:57:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10347297 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 09F4F60244 for ; Wed, 18 Apr 2018 02:58:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFD7928389 for ; Wed, 18 Apr 2018 02:58:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFFE728420; Wed, 18 Apr 2018 02:58:14 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20FF928389 for ; Wed, 18 Apr 2018 02:58:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752841AbeDRC6N (ORCPT ); Tue, 17 Apr 2018 22:58:13 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:56776 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752800AbeDRC6M (ORCPT ); Tue, 17 Apr 2018 22:58:12 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w3I2uaSa179547; Wed, 18 Apr 2018 02:57:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2017-10-26; bh=RhEOPcp9ZvJGu+Lyn5NoWWRwj+3EHpPdRIEk9z6Mku0=; b=G9qpfogr4gJpAiqcNSdu6RrScr7vHJqou1OfcVNvrB4prT2/RWXkVL7lUu6GFC8Mwq8C 8d3EfN15suDFcO/wIwWi3BeiDJbxGs9tSqHR9ZHGGnbD7c+fZCf32nQYKmEdt4qRPoNy 3kEwiF2zaDjYZzkDQzgMnXpDGHO4b6enYC4+3i2XeRS4jA7vtZ/oh7/rYblJjv/j6yBf Y+DZZi2wmEAiAi5eIyMD79XO6gApYntLBjzORQlhmH9VVxHAqgbLMERkqw7RYysu8Zhr heUEsWXjg+nELeYAp5KX7Gmz9UCmdBBet4OLDRX99qAL/XIWIUM3aCqhdBIEUqkA8kqt Zg== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2hdrxn8kgn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Apr 2018 02:57:58 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w3I2vvNI023182 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Apr 2018 02:57:57 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w3I2vvTv000708; Wed, 18 Apr 2018 02:57:57 GMT Received: from localhost (/10.159.132.124) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 17 Apr 2018 19:57:56 -0700 Date: Tue, 17 Apr 2018 19:57:55 -0700 From: "Darrick J. Wong" To: xfs Cc: fstests , Christoph Hellwig Subject: [PATCH v2] xfs: cap the length of deduplication requests Message-ID: <20180418025755.GN24738@magnolia> References: <20180417051918.GD5203@magnolia> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180417051918.GD5203@magnolia> User-Agent: Mutt/1.5.24 (2015-08-30) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8866 signatures=668698 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-1804180026 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Since deduplication potentially has to read in all the pages in both files in order to compare the contents, cap the deduplication request length at MAX_RW_COUNT/2 (roughly 1GB) so that we have /some/ upper bound on the request length and can't just lock up the kernel forever. Found by running generic/304 after commit 1ddae54555b62a ("common/rc: add missing 'local' keywords"). Signed-off-by: Darrick J. Wong Reviewed-by: Carlos Maiolino --- v2: halve the amount so that we do MAX_RW_COUNT IO max --- fs/xfs/xfs_file.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe fstests" 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_file.c b/fs/xfs/xfs_file.c index 299aee4..9cafad4 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -876,8 +876,18 @@ xfs_file_dedupe_range( struct file *dst_file, u64 dst_loff) { + struct inode *srci = file_inode(src_file); + u64 max_dedupe; int error; + /* + * Since we have to read all these pages in to compare them, cut + * it off at MAX_RW_COUNT/2 rounded down to the nearest block. + * That means we won't do more than MAX_RW_COUNT IO per request. + */ + max_dedupe = (MAX_RW_COUNT >> 1) & ~(i_blocksize(srci) - 1); + if (len > max_dedupe) + len = max_dedupe; error = xfs_reflink_remap_range(src_file, loff, dst_file, dst_loff, len, true); if (error)