From patchwork Fri Feb 23 16:22:24 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: 10238271 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 0170960225 for ; Fri, 23 Feb 2018 16:22:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF6DA297E1 for ; Fri, 23 Feb 2018 16:22:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDA82297F6; Fri, 23 Feb 2018 16:22:47 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, 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 7EA10297E1 for ; Fri, 23 Feb 2018 16:22:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751402AbeBWQWc (ORCPT ); Fri, 23 Feb 2018 11:22:32 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:53300 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751381AbeBWQWb (ORCPT ); Fri, 23 Feb 2018 11:22:31 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w1NGM48B171999; Fri, 23 Feb 2018 16:22:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2017-10-26; bh=ySpWVjaY6Yb5iWdt30VqRtySDfEN3RXdTwkBwjnpjk0=; b=Lz/njnXzeCqhphg115br449hRpehn/r6iycbwtfJFhVdat5dVpjD+PemBy+FYCpLRo3F ecg18RuZxoVUCGQGNksPNFkcIp5y0yq7aNBlgR+sXyHTHuMwEhGLLVpJNXLYwjfTAuhr 4m2LkZl12G94WL6xnRxgFpVxURvkrtrvHOKk7/NTyAhMdhMZY+w7kE1nLxgFG7TXtHRx qVMYlmGx+1Vt9jLQgnkgpOoM1Quv9v1rwXYIJp8niFj7TShSW/inYkgpzzfd9VfgkR/x wMhaoPmGX1oQte/rI82Rb0aH9zUOU8xr4YBqUVp21yDR0vt+l78JZgLKgUirA9ryEVeJ RA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2gammt0nck-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Feb 2018 16:22:26 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w1NGMPG4022780 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 23 Feb 2018 16:22:25 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w1NGMOMa031525; Fri, 23 Feb 2018 16:22:24 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 23 Feb 2018 08:22:24 -0800 Date: Fri, 23 Feb 2018 08:22:24 -0800 From: "Darrick J. Wong" To: eguan@redhat.com Cc: Luis Henriques , linux-xfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH] fsstress: avoid infinite loops in clonerange_f Message-ID: <20180223162224.GD14582@magnolia> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8813 signatures=668678 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=504 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802230202 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 Evidently ceph will report a 4M blocksize, which trips clonerange_f's clumsy attempt to avoid reflinking an extent on top of itself. The original code assumed that "pick a random destination up to 1MB past the end of the file" would suffice, but that clearly won't with a 4M blocksize. Instead, we'll change it to 1024*blksize. Signed-off-by: Darrick J. Wong Tested-by: Luis Henriques --- ltp/fsstress.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 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/ltp/fsstress.c b/ltp/fsstress.c index 935f5de..e107099 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -2222,6 +2222,7 @@ clonerange_f( off64_t lr; off64_t off1; off64_t off2; + off64_t max_off2; size_t len; int v1; int v2; @@ -2305,9 +2306,10 @@ clonerange_f( * If srcfile == destfile, randomly generate destination ranges * until we find one that doesn't overlap the source range. */ + max_off2 = MIN(stat2.st_size + (1024ULL * stat2.st_blksize), MAXFSIZE); do { lr = ((int64_t)random() << 32) + random(); - off2 = (off64_t)(lr % MIN(stat2.st_size + (1024 * 1024), MAXFSIZE)); + off2 = (off64_t)(lr % max_off2); off2 %= maxfsize; off2 &= ~(stat2.st_blksize - 1); } while (stat1.st_ino == stat2.st_ino && llabs(off2 - off1) < len);