From patchwork Thu Nov 22 17:58:28 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: 10694631 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 292F513BB for ; Thu, 22 Nov 2018 17:58:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 210A42C15F for ; Thu, 22 Nov 2018 17:58:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14B372C17C; Thu, 22 Nov 2018 17:58:45 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 BA5CA2C15F for ; Thu, 22 Nov 2018 17:58:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395544AbeKWEjK (ORCPT ); Thu, 22 Nov 2018 23:39:10 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:36778 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395487AbeKWEjK (ORCPT ); Thu, 22 Nov 2018 23:39:10 -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 wAMHsQeN105063; Thu, 22 Nov 2018 17:58:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=T7foTYRqwU2BC+Gu+GdWGq1l/0aaLUeqgXjDrfnDUvc=; b=1avcOmrir4H5SpvhZ98NJXPVMAChKq2JoTUUJZZoLBj2k4mhLnlB3FacGksCvMXkX69x 4Vnvr9PV+D+VFxLePwaVdndhEzNKBjz+a/+iY30hdZapOOrGi6KX6GtEYKINDZNV0E1z ypjvwz2EdIqm7UaOz5PJwmxxrmqE67SaeRNeFpxQLgYIBaHSLnjRLxfNnpKqRunhB3Jw a1GUGZkg7IqsQsClGWZnaWyPRwsX4uw1zU6DvUQ7THcNOQJo+DyipXRMXXDpr8kQtRJB CMGP8/Be1Qe06CxKCG1WEHs3lsAlKow6ThWvMlE0B3+RrnWqJkAWtGaHBKCwxIJXAPND +Q== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2ntaxqg11a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:58:42 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wAMHwZvF016505 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:58:36 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wAMHwZFC024188; Thu, 22 Nov 2018 17:58:35 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Nov 2018 09:58:35 -0800 Subject: [PATCH 01/12] fsstress: fix compiler warnings From: "Darrick J. Wong" To: guaneryu@gmail.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Thu, 22 Nov 2018 09:58:28 -0800 Message-ID: <154290950874.1218.16162093723366805081.stgit@magnolia> In-Reply-To: <154290950237.1218.9937108728673485814.stgit@magnolia> References: <154290950237.1218.9937108728673485814.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9085 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=754 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811220160 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 Fix all the gcc warnings in fsstress. Signed-off-by: Darrick J. Wong Reviewed-By: Allison Henderson --- ltp/fsstress.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ltp/fsstress.c b/ltp/fsstress.c index edbb3f2f..8d0734fc 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -499,7 +499,7 @@ int main(int argc, char **argv) exit(1); } if (logname) { - char path[PATH_MAX]; + char path[PATH_MAX + NAME_MAX + 1]; snprintf(path, sizeof(path), "%s/%s", rpath, logname); if (freopen(path, "a", stdout) == NULL) { perror("freopen logfile failed"); @@ -583,7 +583,7 @@ int main(int argc, char **argv) return 0; #endif if (logname) { - char path[PATH_MAX]; + char path[PATH_MAX + NAME_MAX + 2 + 11]; snprintf(path, sizeof(path), "%s/%s.%d", rpath, logname, i); if (freopen(path, "a", stdout) == NULL) { From patchwork Thu Nov 22 17:58:40 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: 10694635 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C86355A4 for ; Thu, 22 Nov 2018 17:58:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C04C92C15F for ; Thu, 22 Nov 2018 17:58:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B49F22C17C; Thu, 22 Nov 2018 17:58:46 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 1B63A2C15F for ; Thu, 22 Nov 2018 17:58:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405970AbeKWEjL (ORCPT ); Thu, 22 Nov 2018 23:39:11 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:48810 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395487AbeKWEjL (ORCPT ); Thu, 22 Nov 2018 23:39:11 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wAMHsRIJ139303; Thu, 22 Nov 2018 17:58:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=lCRcdxFfd3LeguaPCbz5Pjm7ke/usZbvV70Ds7CFhEA=; b=pUaclwaPKdTQcv2jAks5RnjtPz5qIHm5P5mAVjV8Ob0sR0dGKAF+NaKXkDG7ZckDEY6g o2GIcaymPJhWeM7vSloogcREFzO6nCCfG23jxV++6DD5C4UrBlXH6b/V13r6Mu6uk42S SpFN/rROEoI5J1WyunCk9z8T2HCeWUIp7EMMjgSz1/0vNkUSc4r3p7wq/ddagX+xiFLQ q8rmJpa/SS0Fr8JwV0hH2s+fuVPHgqv9aGzZmWeDXcepe3X4M9Vq1LsM1fMyCuRs+xrx 7Z4sRZ4EauFH/Bn2/oTYFUEpdooVHdIKToyLT4ZoxrAhEYafAAdKmuEm2Mf3Pg2rwXwz gA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2ntadu82bt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:58:43 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wAMHwg7M014652 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:58:43 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 wAMHwgbf000743; Thu, 22 Nov 2018 17:58:42 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Nov 2018 09:58:41 -0800 Subject: [PATCH 02/12] fsstress: check system call return values From: "Darrick J. Wong" To: guaneryu@gmail.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Thu, 22 Nov 2018 09:58:40 -0800 Message-ID: <154290952081.1218.5326269464784776136.stgit@magnolia> In-Reply-To: <154290950237.1218.9937108728673485814.stgit@magnolia> References: <154290950237.1218.9937108728673485814.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9085 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=680 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811220160 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 Check the return values of various system calls and blow up if something went wrong. Signed-off-by: Darrick J. Wong Reviewed-By: Allison Henderson --- ltp/fsstress.c | 56 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/ltp/fsstress.c b/ltp/fsstress.c index 8d0734fc..af5d125f 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -733,7 +733,7 @@ append_pathname(pathname_t *name, char *str) /* attempting to append to a dir a zero length path */ if (len && *str == '/' && name->len == 0) { fprintf(stderr, "fsstress: append_pathname failure\n"); - chdir(homedir); + assert(chdir(homedir) == 0); abort(); /* NOTREACHED */ } @@ -765,7 +765,7 @@ attr_list_path(pathname_t *name, separate_pathname(name, buf, &newname); if (chdir(buf) == 0) { rval = attr_list_path(&newname, buffer, buffersize, flags, cursor); - chdir(".."); + assert(chdir("..") == 0); } free_pathname(&newname); return rval; @@ -784,7 +784,7 @@ attr_remove_path(pathname_t *name, const char *attrname, int flags) separate_pathname(name, buf, &newname); if (chdir(buf) == 0) { rval = attr_remove_path(&newname, attrname, flags); - chdir(".."); + assert(chdir("..") == 0); } free_pathname(&newname); return rval; @@ -805,7 +805,7 @@ attr_set_path(pathname_t *name, const char *attrname, const char *attrvalue, if (chdir(buf) == 0) { rval = attr_set_path(&newname, attrname, attrvalue, valuelength, flags); - chdir(".."); + assert(chdir("..") == 0); } free_pathname(&newname); return rval; @@ -819,7 +819,7 @@ check_cwd(void) if (stat64(".", &statbuf) == 0 && statbuf.st_ino == top_ino) return; - chdir(homedir); + assert(chdir(homedir) == 0); fprintf(stderr, "fsstress: check_cwd failure\n"); abort(); /* NOTREACHED */ @@ -858,7 +858,7 @@ creat_path(pathname_t *name, mode_t mode) separate_pathname(name, buf, &newname); if (chdir(buf) == 0) { rval = creat_path(&newname, mode); - chdir(".."); + assert(chdir("..") == 0); } free_pathname(&newname); return rval; @@ -996,11 +996,15 @@ doproc(void) } } errout: - chdir(".."); + assert(chdir("..") == 0); free(homedir); if (cleanup) { + int ret; + sprintf(cmd, "rm -rf %s", buf); - system(cmd); + ret = system(cmd); + if (ret != 0) + perror("cleaning up"); cleanup_flist(); } } @@ -1216,7 +1220,7 @@ lchown_path(pathname_t *name, uid_t owner, gid_t group) separate_pathname(name, buf, &newname); if (chdir(buf) == 0) { rval = lchown_path(&newname, owner, group); - chdir(".."); + assert(chdir("..") == 0); } free_pathname(&newname); return rval; @@ -1240,7 +1244,7 @@ link_path(pathname_t *name1, pathname_t *name2) if (strcmp(buf1, buf2) == 0) { if (chdir(buf1) == 0) { rval = link_path(&newname1, &newname2); - chdir(".."); + assert(chdir("..") == 0); } } else { if (strcmp(buf1, "..") == 0) @@ -1260,7 +1264,7 @@ link_path(pathname_t *name1, pathname_t *name2) append_pathname(&newname2, name2->path); if (chdir(buf1) == 0) { rval = link_path(&newname1, &newname2); - chdir(".."); + assert(chdir("..") == 0); } } else { free_pathname(&newname1); @@ -1268,7 +1272,7 @@ link_path(pathname_t *name1, pathname_t *name2) append_pathname(&newname1, name1->path); if (chdir(buf2) == 0) { rval = link_path(&newname1, &newname2); - chdir(".."); + assert(chdir("..") == 0); } } } @@ -1290,7 +1294,7 @@ lstat64_path(pathname_t *name, struct stat64 *sbuf) separate_pathname(name, buf, &newname); if (chdir(buf) == 0) { rval = lstat64_path(&newname, sbuf); - chdir(".."); + assert(chdir("..") == 0); } free_pathname(&newname); return rval; @@ -1326,7 +1330,7 @@ mkdir_path(pathname_t *name, mode_t mode) separate_pathname(name, buf, &newname); if (chdir(buf) == 0) { rval = mkdir_path(&newname, mode); - chdir(".."); + assert(chdir("..") == 0); } free_pathname(&newname); return rval; @@ -1345,7 +1349,7 @@ mknod_path(pathname_t *name, mode_t mode, dev_t dev) separate_pathname(name, buf, &newname); if (chdir(buf) == 0) { rval = mknod_path(&newname, mode, dev); - chdir(".."); + assert(chdir("..") == 0); } free_pathname(&newname); return rval; @@ -1386,7 +1390,7 @@ open_path(pathname_t *name, int oflag) separate_pathname(name, buf, &newname); if (chdir(buf) == 0) { rval = open_path(&newname, oflag); - chdir(".."); + assert(chdir("..") == 0); } free_pathname(&newname); return rval; @@ -1405,7 +1409,7 @@ opendir_path(pathname_t *name) separate_pathname(name, buf, &newname); if (chdir(buf) == 0) { rval = opendir_path(&newname); - chdir(".."); + assert(chdir("..") == 0); } free_pathname(&newname); return rval; @@ -1446,7 +1450,7 @@ readlink_path(pathname_t *name, char *lbuf, size_t lbufsiz) separate_pathname(name, buf, &newname); if (chdir(buf) == 0) { rval = readlink_path(&newname, lbuf, lbufsiz); - chdir(".."); + assert(chdir("..") == 0); } free_pathname(&newname); return rval; @@ -1470,7 +1474,7 @@ rename_path(pathname_t *name1, pathname_t *name2) if (strcmp(buf1, buf2) == 0) { if (chdir(buf1) == 0) { rval = rename_path(&newname1, &newname2); - chdir(".."); + assert(chdir("..") == 0); } } else { if (strcmp(buf1, "..") == 0) @@ -1490,7 +1494,7 @@ rename_path(pathname_t *name1, pathname_t *name2) append_pathname(&newname2, name2->path); if (chdir(buf1) == 0) { rval = rename_path(&newname1, &newname2); - chdir(".."); + assert(chdir("..") == 0); } } else { free_pathname(&newname1); @@ -1498,7 +1502,7 @@ rename_path(pathname_t *name1, pathname_t *name2) append_pathname(&newname1, name1->path); if (chdir(buf2) == 0) { rval = rename_path(&newname1, &newname2); - chdir(".."); + assert(chdir("..") == 0); } } } @@ -1520,7 +1524,7 @@ rmdir_path(pathname_t *name) separate_pathname(name, buf, &newname); if (chdir(buf) == 0) { rval = rmdir_path(&newname); - chdir(".."); + assert(chdir("..") == 0); } free_pathname(&newname); return rval; @@ -1603,7 +1607,7 @@ stat64_path(pathname_t *name, struct stat64 *sbuf) separate_pathname(name, buf, &newname); if (chdir(buf) == 0) { rval = stat64_path(&newname, sbuf); - chdir(".."); + assert(chdir("..") == 0); } free_pathname(&newname); return rval; @@ -1627,7 +1631,7 @@ symlink_path(const char *name1, pathname_t *name) separate_pathname(name, buf, &newname); if (chdir(buf) == 0) { rval = symlink_path(name1, &newname); - chdir(".."); + assert(chdir("..") == 0); } free_pathname(&newname); return rval; @@ -1646,7 +1650,7 @@ truncate64_path(pathname_t *name, off64_t length) separate_pathname(name, buf, &newname); if (chdir(buf) == 0) { rval = truncate64_path(&newname, length); - chdir(".."); + assert(chdir("..") == 0); } free_pathname(&newname); return rval; @@ -1665,7 +1669,7 @@ unlink_path(pathname_t *name) separate_pathname(name, buf, &newname); if (chdir(buf) == 0) { rval = unlink_path(&newname); - chdir(".."); + assert(chdir("..") == 0); } free_pathname(&newname); return rval; From patchwork Thu Nov 22 17:58:47 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: 10694639 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8ADA45A4 for ; Thu, 22 Nov 2018 17:58:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83A9A2C15F for ; Thu, 22 Nov 2018 17:58:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7466C2C17C; Thu, 22 Nov 2018 17:58:52 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 20E4E2C15F for ; Thu, 22 Nov 2018 17:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405989AbeKWEjR (ORCPT ); Thu, 22 Nov 2018 23:39:17 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:36856 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395487AbeKWEjR (ORCPT ); Thu, 22 Nov 2018 23:39:17 -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 wAMHt2An105193; Thu, 22 Nov 2018 17:58:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=gkEbzt0X75mV0RTARNIfHdzBB/jgI6z3YXlukup5mf4=; b=BsrFBKkDNtm93Vb/VqBAAFY77GhaTI5qhVPU5sXFVs7VYm2tJgPET4oiuUphDppcxOg2 AM30Apaz+yYbrTU+oFfaxIFi0vlr8gkl3pubQn7Q6u7S/RDI63CEVHWZ076PiGn8aAiC 3Jo6JAVRhl3JaZs5/86+R3TLo5ArN5Ehl/8/SpcmHIsNIXjU2Yh3XuN3ImxFsvT0xsKU muip8K4iSo3twtSc7slDQPJilrHm5Zlt75VHeLDGCs3nvU7Q2EBjEvT4Diwn/hAorVOP FbeclF8Kno8hLez1OXpqVLHNhKtDG1sCZoYQDJFY+zZOTdgN0zzcmHo/PaO8r3/LMdKq ig== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2ntaxqg11g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:58:48 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wAMHwmpZ014756 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:58:48 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 wAMHwm14024328; Thu, 22 Nov 2018 17:58:48 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Nov 2018 09:58:48 -0800 Subject: [PATCH 03/12] fsx: shut up compiler warnings From: "Darrick J. Wong" To: guaneryu@gmail.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Thu, 22 Nov 2018 09:58:47 -0800 Message-ID: <154290952722.1218.5031880474187869562.stgit@magnolia> In-Reply-To: <154290950237.1218.9937108728673485814.stgit@magnolia> References: <154290950237.1218.9937108728673485814.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9085 signatures=668683 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-1810050000 definitions=main-1811220160 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 Fix unused variables and potential filename overflows in fsx. Signed-off-by: Darrick J. Wong Reviewed-By: Allison Henderson --- ltp/fsx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ltp/fsx.c b/ltp/fsx.c index b0157ba3..5601c70c 100644 --- a/ltp/fsx.c +++ b/ltp/fsx.c @@ -121,7 +121,7 @@ char *bname; /* basename of our test file */ char *logdev; /* -i flag */ char *logid; /* -j flag */ char dname[1024]; /* -P flag */ -char goodfile[1024]; +char goodfile[PATH_MAX]; int dirpath = 0; /* -P flag */ int fd; /* fd for our test file */ @@ -185,7 +185,7 @@ const char *replayops = NULL; const char *recordops = NULL; FILE * fsxlogf = NULL; FILE * replayopsf = NULL; -char opsfile[1024]; +char opsfile[PATH_MAX]; int badoff = -1; int closeopen = 0; @@ -541,13 +541,13 @@ mark_log(void) void dump_fsync_buffer(void) { - char fname_buffer[1024]; + char fname_buffer[PATH_MAX]; int good_fd; if (!good_buf) return; - snprintf(fname_buffer, 1024, "%s%s.mark%d", dname, + snprintf(fname_buffer, sizeof(fname_buffer), "%s%s.mark%d", dname, bname, mark_nr); good_fd = open(fname_buffer, O_WRONLY|O_CREAT|O_TRUNC, 0666); if (good_fd < 0) { @@ -1865,7 +1865,7 @@ main(int argc, char **argv) { int i, style, ch; char *endp, *tmp; - char logfile[1024]; + char logfile[PATH_MAX]; struct stat statbuf; int o_flags = O_RDWR|O_CREAT|O_TRUNC; From patchwork Thu Nov 22 17:58:53 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: 10694643 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7B4713BB for ; Thu, 22 Nov 2018 17:59:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD8962CF9B for ; Thu, 22 Nov 2018 17:59:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C08DB2CFA8; Thu, 22 Nov 2018 17:59:04 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 4CCA32CF9B for ; Thu, 22 Nov 2018 17:59:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406143AbeKWEja (ORCPT ); Thu, 22 Nov 2018 23:39:30 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:37072 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395487AbeKWEj3 (ORCPT ); Thu, 22 Nov 2018 23:39:29 -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 wAMHx1u4107716; Thu, 22 Nov 2018 17:59:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=tJq7aLIXnvkg1A65T0crAZoUgYCVpX2TVBB2ipJyJJQ=; b=0IEyuyhKhU7lJfNA2U6vJppZZfrzt3DN1HeLtg2otkOXmCmm1CWaSEyePHvZ2iyjwLAM KaLFisdNkOMyzIHfHxIJPP9fPS1BXjO31yCR7ObPG5cEtph0x/bFBVOnk51cEHm/6m7a TTAzC7NETUGNZ3E84J0wlvZfcUasWq0F8ZYm+DWj2CRlbEnVe0OwlIr0XXxdpwTYLEPn LVjFEC+VyBvgKJNRFlJ5SICZwO4TnKO3V0l5pWYriO1eo46PFRpuMo8WnpHwWBqi55Mc kicBLnk8rsgaRsaU4RuH1r8M+IJ08OsghWxQhqiCneW1Oah6P+CvIB58/A5BSTgl1dux Tw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2ntaxqg120-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:59:01 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wAMHwsMC016849 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:58:55 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 wAMHwsAN024345; Thu, 22 Nov 2018 17:58:54 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Nov 2018 09:58:54 -0800 Subject: [PATCH 04/12] fsx: always check buffer after each operation From: "Darrick J. Wong" To: guaneryu@gmail.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Thu, 22 Nov 2018 09:58:53 -0800 Message-ID: <154290953356.1218.995241000619100958.stgit@magnolia> In-Reply-To: <154290950237.1218.9937108728673485814.stgit@magnolia> References: <154290950237.1218.9937108728673485814.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9085 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=798 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811220161 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 Add a new option to make fsx read the file after each operation and compare it with the good buffer to try to catch corruptions as soon as they occur. Signed-off-by: Darrick J. Wong --- ltp/fsx.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/ltp/fsx.c b/ltp/fsx.c index 5601c70c..7fb8b3ab 100644 --- a/ltp/fsx.c +++ b/ltp/fsx.c @@ -160,7 +160,8 @@ int punch_hole_calls = 1; /* -H flag disables */ int zero_range_calls = 1; /* -z flag disables */ int collapse_range_calls = 1; /* -C flag disables */ int insert_range_calls = 1; /* -I flag disables */ -int mapped_reads = 1; /* -R flag disables it */ +int mapped_reads = 1; /* -R flag disables it */ +int check_file = 0; /* -X flag enables */ int integrity = 0; /* -i flag */ int fsxgoodfd = 0; int o_direct; /* -Z */ @@ -561,7 +562,7 @@ dump_fsync_buffer(void) } void -check_buffers(unsigned offset, unsigned size) +check_buffers(char *buf, unsigned offset, unsigned size) { unsigned char c, t; unsigned i = 0; @@ -569,19 +570,19 @@ check_buffers(unsigned offset, unsigned size) unsigned op = 0; unsigned bad = 0; - if (memcmp(good_buf + offset, temp_buf, size) != 0) { + if (memcmp(good_buf + offset, buf, size) != 0) { prt("READ BAD DATA: offset = 0x%x, size = 0x%x, fname = %s\n", offset, size, fname); prt("OFFSET\tGOOD\tBAD\tRANGE\n"); while (size > 0) { c = good_buf[offset]; - t = temp_buf[i]; + t = buf[i]; if (c != t) { if (n < 16) { - bad = short_at(&temp_buf[i]); + bad = short_at(&buf[i]); prt("0x%05x\t0x%04x\t0x%04x", offset, short_at(&good_buf[offset]), bad); - op = temp_buf[offset & 1 ? i+1 : i]; + op = buf[offset & 1 ? i+1 : i]; prt("\t0x%05x\n", n); if (op) prt("operation# (mod 256) for " @@ -725,7 +726,46 @@ doread(unsigned offset, unsigned size) iret, size); report_failure(141); } - check_buffers(offset, size); + check_buffers(temp_buf, offset, size); +} + +void +check_contents(void) +{ + static char *check_buf; + unsigned offset = 0; + unsigned size = file_size; + off_t ret; + unsigned iret; + + if (!check_buf) { + check_buf = (char *) malloc(maxfilelen + writebdy); + assert(check_buf != NULL); + check_buf = round_ptr_up(check_buf, writebdy, 0); + memset(check_buf, '\0', maxfilelen); + } + + if (o_direct) + size -= size % readbdy; + if (size == 0) + return; + + ret = lseek(fd, (off_t)offset, SEEK_SET); + if (ret == (off_t)-1) { + prterr("doread: lseek"); + report_failure(140); + } + + iret = fsxread(fd, check_buf, size, offset); + if (iret != size) { + if (iret == -1) + prterr("check_contents: read"); + else + prt("short check read: 0x%x bytes instead of 0x%x\n", + iret, size); + report_failure(141); + } + check_buffers(check_buf, offset, size); } @@ -808,7 +848,7 @@ domapread(unsigned offset, unsigned size) report_failure(191); } - check_buffers(offset, size); + check_buffers(temp_buf, offset, size); } @@ -1624,6 +1664,9 @@ test(void) break; } + if (check_file && testcalls > simulatedopcount) + check_contents(); + out: if (sizechecks && testcalls > simulatedopcount) check_size(); @@ -1684,6 +1727,7 @@ usage(void) -P: save .fsxlog .fsxops and .fsxgood files in dirpath (default ./)\n\ -S seed: for random # generator (default 1) 0 gets timestamp\n\ -W: mapped write operations DISabled\n\ + -X: Read file and compare to good buffer after every operation.\n\ -R: read() system calls only (mapped reads disabled)\n\ -Z: O_DIRECT (use -R, -W, -r and -w too)\n\ --replay-ops opsfile: replay ops from recorded .fsxops file\n\ @@ -1880,7 +1924,7 @@ main(int argc, char **argv) setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */ while ((ch = getopt_long(argc, argv, - "b:c:dfg:i:j:kl:m:no:p:qr:s:t:w:xyAD:FKHzCILN:OP:RS:WZ", + "b:c:dfg:i:j:kl:m:no:p:qr:s:t:w:xyAD:FKHzCILN:OP:RS:WXZ", longopts, NULL)) != EOF) switch (ch) { case 'b': @@ -2044,6 +2088,9 @@ main(int argc, char **argv) if (!quiet) prt("mapped writes DISABLED\n"); break; + case 'X': + check_file = 1; + break; case 'Z': o_direct = O_DIRECT; o_flags |= O_DIRECT; From patchwork Thu Nov 22 17:58:59 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: 10694647 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B42BF13BB for ; Thu, 22 Nov 2018 17:59:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6ACA2CF9B for ; Thu, 22 Nov 2018 17:59:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B7D42CFA8; Thu, 22 Nov 2018 17:59:11 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 46FB22CF9B for ; Thu, 22 Nov 2018 17:59:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406352AbeKWEjg (ORCPT ); Thu, 22 Nov 2018 23:39:36 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:49160 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406364AbeKWEjf (ORCPT ); Thu, 22 Nov 2018 23:39:35 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wAMHwxNO142155; Thu, 22 Nov 2018 17:59:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=MylJZqyKZlb3yekQ8q+cZpZvEnKnKwIdC2VdXDqSTu8=; b=qKnWLZAeu6TFmCydBsguo/tS9ic+ILrRhyVcx1nyrXGY6wKfoweHFu4Bvy7SWXEUTHQ9 49G4PRlcbZdbyM09CI3p1U50DJ/RtCUbuv2GUsSHyutzAUPJR50t6mhmqLVu1S8272J8 qxIZ3kwhKHEusP8gr4lx+V1Hmk/8HFHy8PjqA4UgndgBpPo3sMxeFnNW4vOgiB7nz2DU w1LqnqXjwi5OuoQSYgWkAvtybpbtRUHJ1DFcb3ESBJtZZ9j2GDgp7VIz1lsq4AfPM3VY cvBd6h4VbMEHRqqyetwT2kTE2mZ2RrmOTvLgcAGGXjzpXeezc/Y82WU5+oeAQLXrDhwQ UQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2ntadu82cf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:59:06 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wAMHx1bV016392 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:59:01 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 wAMHx1Jt024362; Thu, 22 Nov 2018 17:59:01 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Nov 2018 09:59:00 -0800 Subject: [PATCH 05/12] fsx: use an enum to define the operation commands From: "Darrick J. Wong" To: guaneryu@gmail.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Thu, 22 Nov 2018 09:58:59 -0800 Message-ID: <154290953980.1218.7605730679708903723.stgit@magnolia> In-Reply-To: <154290950237.1218.9937108728673485814.stgit@magnolia> References: <154290950237.1218.9937108728673485814.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9085 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=823 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811220161 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 Use an enum to define operation codes and the boundaries between operation classes so that we can add new commands without having to change a bunch of unrelated #defines. Signed-off-by: Darrick J. Wong Reviewed-By: Allison Henderson --- ltp/fsx.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/ltp/fsx.c b/ltp/fsx.c index 7fb8b3ab..dabad302 100644 --- a/ltp/fsx.c +++ b/ltp/fsx.c @@ -88,25 +88,27 @@ int logcount = 0; /* total ops */ * mode being run. */ -/* common operations */ -#define OP_READ 0 -#define OP_WRITE 1 -#define OP_MAPREAD 2 -#define OP_MAPWRITE 3 -#define OP_MAX_LITE 4 - -/* !lite operations */ -#define OP_TRUNCATE 4 -#define OP_FALLOCATE 5 -#define OP_PUNCH_HOLE 6 -#define OP_ZERO_RANGE 7 -#define OP_COLLAPSE_RANGE 8 -#define OP_INSERT_RANGE 9 -#define OP_MAX_FULL 10 - -/* integrity operations */ -#define OP_FSYNC 10 -#define OP_MAX_INTEGRITY 11 +enum { + /* common operations */ + OP_READ = 0, + OP_WRITE, + OP_MAPREAD, + OP_MAPWRITE, + OP_MAX_LITE, + + /* !lite operations */ + OP_TRUNCATE = OP_MAX_LITE, + OP_FALLOCATE, + OP_PUNCH_HOLE, + OP_ZERO_RANGE, + OP_COLLAPSE_RANGE, + OP_INSERT_RANGE, + OP_MAX_FULL, + + /* integrity operations */ + OP_FSYNC = OP_MAX_FULL, + OP_MAX_INTEGRITY, +}; #undef PAGE_SIZE #define PAGE_SIZE getpagesize() From patchwork Thu Nov 22 17:59:06 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: 10694651 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8E49A5A4 for ; Thu, 22 Nov 2018 17:59:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8708E2CF9B for ; Thu, 22 Nov 2018 17:59:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B5632CFA5; Thu, 22 Nov 2018 17:59:12 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 20D2F2CF9B for ; Thu, 22 Nov 2018 17:59:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406364AbeKWEjh (ORCPT ); Thu, 22 Nov 2018 23:39:37 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:37878 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406388AbeKWEjh (ORCPT ); Thu, 22 Nov 2018 23:39:37 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wAMHx960100985; Thu, 22 Nov 2018 17:59:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=Zk2X4KrnTofiE1uFF9tE5ZVNGZkNJ/j+1y/v8vRBnuQ=; b=UFKmTid6nWSV4fwVvUR7pzkYO3cGJFHMwc6VWHVWGtth5sxysBK1IZ0T+4dNyrn7ry/w Y38jEvuHe0eDYw+SUNqcG9BCj0MfPtdIyDSP/AL9ZIieAUXQ3nPjqdnVdB9tPfAOXjBw MIq9NI+l8LMD5ekZICxwPcmgqbzQRL2IW9XI53c/Nm8hU7UXe33kYOGnHrlL+sewGp6V N58miiXb7wlZoTWffpfq05ylIHhysdIJC/EHDkJNfTBcfuXNWhPAdi6uJonTKOya6ZWN bl0Kkje3GsUozorQfwEbeJguPlrTd9IsGATVI1wjGxzm3cUM6x/sYQ7iun37zl/Kd+// LA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2ntbmqyx7g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:59:08 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wAMHx7cs015374 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:59:08 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wAMHx7x8025791; Thu, 22 Nov 2018 17:59:07 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Nov 2018 09:59:07 -0800 Subject: [PATCH 06/12] fsx: add five-argument logging function From: "Darrick J. Wong" To: guaneryu@gmail.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Thu, 22 Nov 2018 09:59:06 -0800 Message-ID: <154290954603.1218.7246941650070239499.stgit@magnolia> In-Reply-To: <154290950237.1218.9937108728673485814.stgit@magnolia> References: <154290950237.1218.9937108728673485814.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9085 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=951 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811220161 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 Add a five-argument logging function to support new operations. Signed-off-by: Darrick J. Wong Reviewed-By: Allison Henderson --- ltp/fsx.c | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/ltp/fsx.c b/ltp/fsx.c index dabad302..c525ba13 100644 --- a/ltp/fsx.c +++ b/ltp/fsx.c @@ -51,7 +51,8 @@ enum opflags { FL_NONE = 0, FL_SKIPPED = 1, FL_CLOSE_OPEN = 2, FL_KEEP_SIZE = 4 struct log_entry { int operation; - int args[3]; + int nr_args; + int args[4]; enum opflags flags; }; @@ -278,6 +279,27 @@ static int op_code(const char *name) return -1; } +void +log5(int operation, int arg0, int arg1, int arg2, enum opflags flags) +{ + struct log_entry *le; + + le = &oplog[logptr]; + le->operation = operation; + if (closeopen) + flags |= FL_CLOSE_OPEN; + le->args[0] = arg0; + le->args[1] = arg1; + le->args[2] = arg2; + le->args[3] = file_size; + le->nr_args = 4; + le->flags = flags; + logptr++; + logcount++; + if (logptr >= LOGSIZE) + logptr = 0; +} + void log4(int operation, int arg0, int arg1, enum opflags flags) { @@ -290,6 +312,7 @@ log4(int operation, int arg0, int arg1, enum opflags flags) le->args[0] = arg0; le->args[1] = arg1; le->args[2] = file_size; + le->nr_args = 3; le->flags = flags; logptr++; logcount++; @@ -439,11 +462,13 @@ logdump(void) i = 0; if (logopsf) { + int j; + if (lp->flags & FL_SKIPPED) fprintf(logopsf, "skip "); - fprintf(logopsf, "%s 0x%x 0x%x 0x%x", - op_name(lp->operation), - lp->args[0], lp->args[1], lp->args[2]); + fprintf(logopsf, "%s", op_name(lp->operation)); + for (j = 0; j < lp->nr_args; j++) + fprintf(logopsf, " 0x%x", lp->args[j]); if (lp->flags & FL_KEEP_SIZE) fprintf(logopsf, " keep_size"); if (lp->flags & FL_CLOSE_OPEN) @@ -1413,6 +1438,15 @@ cleanup(int sig) exit(sig); } +static int +op_args_count(int operation) +{ + switch (operation) { + default: + return 3; + } +} + static int read_op(struct log_entry *log_entry) { @@ -1445,7 +1479,8 @@ read_op(struct log_entry *log_entry) log_entry->operation = op_code(str); if (log_entry->operation == -1) goto fail; - for (i = 0; i < 3; i++) { + log_entry->nr_args = op_args_count(log_entry->operation); + for (i = 0; i < log_entry->nr_args; i++) { char *end; str = strtok(NULL, " \t\n"); From patchwork Thu Nov 22 17:59:12 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: 10694655 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AC46C13BB for ; Thu, 22 Nov 2018 17:59:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A52EE2CF9B for ; Thu, 22 Nov 2018 17:59:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 998F82CFA8; Thu, 22 Nov 2018 17:59:22 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 E6CC52CF9B for ; Thu, 22 Nov 2018 17:59:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406432AbeKWEjr (ORCPT ); Thu, 22 Nov 2018 23:39:47 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:49320 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406388AbeKWEjr (ORCPT ); Thu, 22 Nov 2018 23:39:47 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wAMHwxNP142155; Thu, 22 Nov 2018 17:59:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=w6r/SwCkRiKeGqaShc+wy3flCs1FitRgInvX0P+3igU=; b=w13dhovu+e9uqr/UhskyKl3lmyrHh+XwHDD9i+xth6anRFG+vNR0RFIG4gL3Mdqb+4+X wn9MNXO7eT5RelF7vQFuZSHHQWwj+7qR57yzsb7LYsNMnMIa99el6Ndxxx38Zjm3+Pce PQm0aCwiHcBxQ0lUXJmPmPea1zahhlOWpH2pT3M1LU5niVDLRjj6ZbEs82OLwUcHnpxx /qBeXAC5NszKRaN2hNUkOoCE0M+Ki5YyHSlDzE0aFzxFJ5YQ+I1IMM0uXiZdbQcSmh1+ Qn5XJt1dVEqC9jYztZlh0gsreQOa8PzR0RobO5J8FVxJKLavkqQLxhMp/V6xRyEiSJzo OA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2ntadu82cn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:59:19 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wAMHxDAh016766 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:59:13 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wAMHxDTk024563; Thu, 22 Nov 2018 17:59:13 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Nov 2018 09:59:13 -0800 Subject: [PATCH 07/12] fsx: add FICLONERANGE support From: "Darrick J. Wong" To: guaneryu@gmail.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Thu, 22 Nov 2018 09:59:12 -0800 Message-ID: <154290955225.1218.10970759549765550744.stgit@magnolia> In-Reply-To: <154290950237.1218.9937108728673485814.stgit@magnolia> References: <154290950237.1218.9937108728673485814.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9085 signatures=668683 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-1810050000 definitions=main-1811220161 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 Add support for the clone range (i.e. reflink) ioctl to fsx. Signed-off-by: Darrick J. Wong --- ltp/fsx.c | 157 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 152 insertions(+), 5 deletions(-) diff --git a/ltp/fsx.c b/ltp/fsx.c index c525ba13..f51d38cf 100644 --- a/ltp/fsx.c +++ b/ltp/fsx.c @@ -104,6 +104,7 @@ enum { OP_ZERO_RANGE, OP_COLLAPSE_RANGE, OP_INSERT_RANGE, + OP_CLONE_RANGE, OP_MAX_FULL, /* integrity operations */ @@ -165,6 +166,7 @@ int collapse_range_calls = 1; /* -C flag disables */ int insert_range_calls = 1; /* -I flag disables */ int mapped_reads = 1; /* -R flag disables it */ int check_file = 0; /* -X flag enables */ +int clone_range_calls = 1; /* -J flag disables */ int integrity = 0; /* -i flag */ int fsxgoodfd = 0; int o_direct; /* -Z */ @@ -258,6 +260,7 @@ static const char *op_names[] = { [OP_ZERO_RANGE] = "zero_range", [OP_COLLAPSE_RANGE] = "collapse_range", [OP_INSERT_RANGE] = "insert_range", + [OP_CLONE_RANGE] = "clone_range", [OP_FSYNC] = "fsync", }; @@ -320,7 +323,6 @@ log4(int operation, int arg0, int arg1, enum opflags flags) logptr = 0; } - void logdump(void) { @@ -342,7 +344,7 @@ logdump(void) count = LOGSIZE; } for ( ; count > 0; count--) { - bool overlap; + bool overlap, overlap2; int opnum; opnum = i+1 + (logcount/LOGSIZE)*LOGSIZE; @@ -444,6 +446,20 @@ logdump(void) if (overlap) prt("\t******IIII"); break; + case OP_CLONE_RANGE: + prt("CLONE 0x%x thru 0x%x\t(0x%x bytes) to 0x%x thru 0x%x", + lp->args[0], lp->args[0] + lp->args[1] - 1, + lp->args[1], + lp->args[2], lp->args[2] + lp->args[1] - 1); + overlap2 = badoff >= lp->args[2] && + badoff < lp->args[2] + lp->args[1]; + if (overlap && overlap2) + prt("\tJJJJ**JJJJ"); + else if (overlap) + prt("\tJJJJ******"); + else if (overlap2) + prt("\t******JJJJ"); + break; case OP_FSYNC: prt("FSYNC"); break; @@ -1285,6 +1301,96 @@ do_insert_range(unsigned offset, unsigned length) } #endif +#ifdef FICLONERANGE +int +test_clone_range(void) +{ + struct file_clone_range fcr = { + .src_fd = fd, + }; + + if (ioctl(fd, FICLONERANGE, &fcr) && + (errno = EOPNOTSUPP || errno == ENOTTY)) { + if (!quiet) + fprintf(stderr, + "main: filesystem does not support " + "clone range, disabling!\n"); + return 0; + } + + return 1; +} + +void +do_clone_range(unsigned offset, unsigned length, unsigned dest) +{ + struct file_clone_range fcr = { + .src_fd = fd, + .src_offset = offset, + .src_length = length, + .dest_offset = dest, + }; + + if (length == 0) { + if (!quiet && testcalls > simulatedopcount) + prt("skipping zero length clone range\n"); + log5(OP_CLONE_RANGE, offset, length, dest, FL_SKIPPED); + return; + } + + if ((loff_t)offset >= file_size) { + if (!quiet && testcalls > simulatedopcount) + prt("skipping clone range behind EOF\n"); + log5(OP_CLONE_RANGE, offset, length, dest, FL_SKIPPED); + return; + } + + if (dest + length > biggest) { + biggest = dest + length; + if (!quiet && testcalls > simulatedopcount) + prt("cloning to largest ever: 0x%x\n", dest + length); + } + + log5(OP_CLONE_RANGE, offset, length, dest, FL_NONE); + + if (testcalls <= simulatedopcount) + return; + + if ((progressinterval && testcalls % progressinterval == 0) || + (debug && (monitorstart == -1 || monitorend == -1 || + dest <= monitorstart || dest + length <= monitorend))) { + prt("%lu clone\tfrom 0x%x to 0x%x, (0x%x bytes) at 0x%x\n", + testcalls, offset, offset+length, length, dest); + } + + if (ioctl(fd, FICLONERANGE, &fcr) == -1) { + prt("clone range: 0x%x to 0x%x at 0x%x\n", offset, + offset + length, dest); + prterr("do_clone_range: FICLONERANGE"); + report_failure(161); + } + + memcpy(good_buf + dest, good_buf + offset, length); + if (dest > file_size) + memset(good_buf + file_size, '\0', dest - file_size); + if (dest + length > file_size) + file_size = dest + length; +} + +#else +int +test_clone_range(void) +{ + return 0; +} + +void +do_clone_range(unsigned offset, unsigned length, unsigned dest) +{ + return; +} +#endif + #ifdef HAVE_LINUX_FALLOC_H /* fallocate is basically a no-op unless extending, then a lot like a truncate */ void @@ -1442,6 +1548,8 @@ static int op_args_count(int operation) { switch (operation) { + case OP_CLONE_RANGE: + return 4; default: return 3; } @@ -1515,7 +1623,7 @@ read_op(struct log_entry *log_entry) int test(void) { - unsigned long offset; + unsigned long offset, offset2; unsigned long size; unsigned long rv; unsigned long op; @@ -1546,6 +1654,7 @@ test(void) op = log_entry.operation; offset = log_entry.args[0]; size = log_entry.args[1]; + offset2 = log_entry.args[2]; closeopen = !!(log_entry.flags & FL_CLOSE_OPEN); keep_size = !!(log_entry.flags & FL_KEEP_SIZE); goto have_op; @@ -1558,6 +1667,7 @@ test(void) closeopen = (rv >> 3) < (1 << 28) / closeprob; offset = random(); + offset2 = 0; size = maxoplen; if (randomoplen) size = random() % (maxoplen + 1); @@ -1583,6 +1693,17 @@ test(void) if (zero_range_calls && size && keep_size_calls) keep_size = random() % 2; break; + case OP_CLONE_RANGE: + TRIM_OFF_LEN(offset, size, file_size); + offset = offset & ~(block_size - 1); + size = size & ~(block_size - 1); + do { + offset2 = random(); + TRIM_OFF(offset2, maxfilelen); + offset2 = offset2 & ~(block_size - 1); + } while (llabs(offset2 - offset) < size || + offset2 + size > maxfilelen); + break; } have_op: @@ -1626,6 +1747,12 @@ test(void) goto out; } break; + case OP_CLONE_RANGE: + if (!clone_range_calls) { + log5(op, offset, size, offset2, FL_SKIPPED); + goto out; + } + break; } switch (op) { @@ -1692,6 +1819,18 @@ test(void) do_insert_range(offset, size); break; + case OP_CLONE_RANGE: + if (size == 0) { + log5(OP_CLONE_RANGE, offset, size, offset2, FL_SKIPPED); + goto out; + } + if (offset2 + size > maxfilelen) { + log5(OP_CLONE_RANGE, offset, size, offset2, FL_SKIPPED); + goto out; + } + + do_clone_range(offset, size, offset2); + break; case OP_FSYNC: dofsync(); break; @@ -1717,7 +1856,7 @@ void usage(void) { fprintf(stdout, "usage: %s", - "fsx [-dknqxAFLOWZ] [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\ + "fsx [-dknqxAFJLOWZ] [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\ -b opnum: beginning operation number (default 1)\n\ -c P: 1 in P chance of file close+open at each op (default infinity)\n\ -d: debug output for all operations\n\ @@ -1758,6 +1897,9 @@ usage(void) #ifdef FALLOC_FL_INSERT_RANGE " -I: Do not use insert range calls\n" #endif +#ifdef FICLONERANGE +" -J: Do not use clone range calls\n" +#endif " -L: fsxLite - no file creations & no file size changes\n\ -N numops: total # operations to do (default infinity)\n\ -O: use oplen (see -o flag) for every op (default random)\n\ @@ -1961,7 +2103,7 @@ main(int argc, char **argv) setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */ while ((ch = getopt_long(argc, argv, - "b:c:dfg:i:j:kl:m:no:p:qr:s:t:w:xyAD:FKHzCILN:OP:RS:WXZ", + "b:c:dfg:i:j:kl:m:no:p:qr:s:t:w:xyAD:FJKHzCILN:OP:RS:WXZ", longopts, NULL)) != EOF) switch (ch) { case 'b': @@ -2091,6 +2233,9 @@ main(int argc, char **argv) case 'I': insert_range_calls = 0; break; + case 'J': + clone_range_calls = 0; + break; case 'L': lite = 1; o_flags &= ~(O_CREAT|O_TRUNC); @@ -2309,6 +2454,8 @@ main(int argc, char **argv) collapse_range_calls = test_fallocate(FALLOC_FL_COLLAPSE_RANGE); if (insert_range_calls) insert_range_calls = test_fallocate(FALLOC_FL_INSERT_RANGE); + if (clone_range_calls) + clone_range_calls = test_clone_range(); while (numops == -1 || numops--) if (!test()) From patchwork Thu Nov 22 17:59:18 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: 10694659 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E0F575A4 for ; Thu, 22 Nov 2018 17:59:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D74182CFA1 for ; Thu, 22 Nov 2018 17:59:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB7482CFAE; Thu, 22 Nov 2018 17:59:24 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 216F42CFA5 for ; Thu, 22 Nov 2018 17:59:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406518AbeKWEju (ORCPT ); Thu, 22 Nov 2018 23:39:50 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:37350 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406517AbeKWEjt (ORCPT ); Thu, 22 Nov 2018 23:39:49 -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 wAMHwvnw107685; Thu, 22 Nov 2018 17:59:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=tDI6tdJY+YzLiAmKd6EDfIwLt4eFdrCIio2ZMvyZy3g=; b=D7iO/lQX7jL5rFZ7WaRsCioFDhkEg2ylHx/BgRfx2gz1SepRY7Nu8+MYvQ7jUe5ge8+7 bSPqzzDvLpuKDwUE/iZrt8rGVnHPP4trJQ2vmvVsokR/oJ+tpLtYdkkFsCHrGGZ6n5vn soPp/qyAr2jfV00uob/+QFg7mO5Ne5xFCHULXLS/qnF9MoCkxRR6of+WzI7EgNiZcOZ7 WIt1548wc5fO6zt85/crPufaZxjdzquoP22V9o9gMzEfFqU2Zo9xjOzmmyedmrMut+4M wS+4K6fDTLV4GGO6nzNvf2SEmN+9DL8Foqp/mklryfNUrJKUW1rYgjRjrku6URZEo58M bQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2ntaxqg12s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:59:21 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wAMHxKl4012492 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:59:20 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 wAMHxKP0000911; Thu, 22 Nov 2018 17:59:20 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Nov 2018 09:59:19 -0800 Subject: [PATCH 08/12] fsx: add FIDEDUPERANGE support From: "Darrick J. Wong" To: guaneryu@gmail.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Thu, 22 Nov 2018 09:59:18 -0800 Message-ID: <154290955866.1218.2027396664240023006.stgit@magnolia> In-Reply-To: <154290950237.1218.9937108728673485814.stgit@magnolia> References: <154290950237.1218.9937108728673485814.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9085 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 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-1810050000 definitions=main-1811220161 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 Add support for the dedupe range ioctl to fsx. Signed-off-by: Darrick J. Wong --- ltp/fsx.c | 198 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 196 insertions(+), 2 deletions(-) diff --git a/ltp/fsx.c b/ltp/fsx.c index f51d38cf..577c7309 100644 --- a/ltp/fsx.c +++ b/ltp/fsx.c @@ -105,6 +105,7 @@ enum { OP_COLLAPSE_RANGE, OP_INSERT_RANGE, OP_CLONE_RANGE, + OP_DEDUPE_RANGE, OP_MAX_FULL, /* integrity operations */ @@ -167,6 +168,7 @@ int insert_range_calls = 1; /* -I flag disables */ int mapped_reads = 1; /* -R flag disables it */ int check_file = 0; /* -X flag enables */ int clone_range_calls = 1; /* -J flag disables */ +int dedupe_range_calls = 1; /* -B flag disables */ int integrity = 0; /* -i flag */ int fsxgoodfd = 0; int o_direct; /* -Z */ @@ -261,6 +263,7 @@ static const char *op_names[] = { [OP_COLLAPSE_RANGE] = "collapse_range", [OP_INSERT_RANGE] = "insert_range", [OP_CLONE_RANGE] = "clone_range", + [OP_DEDUPE_RANGE] = "dedupe_range", [OP_FSYNC] = "fsync", }; @@ -460,6 +463,20 @@ logdump(void) else if (overlap2) prt("\t******JJJJ"); break; + case OP_DEDUPE_RANGE: + prt("DEDUPE 0x%x thru 0x%x\t(0x%x bytes) to 0x%x thru 0x%x", + lp->args[0], lp->args[0] + lp->args[1] - 1, + lp->args[1], + lp->args[2], lp->args[2] + lp->args[1] - 1); + overlap2 = badoff >= lp->args[2] && + badoff < lp->args[2] + lp->args[1]; + if (overlap && overlap2) + prt("\tBBBB**BBBB"); + else if (overlap) + prt("\tBBBB******"); + else if (overlap2) + prt("\t******BBBB"); + break; case OP_FSYNC: prt("FSYNC"); break; @@ -1391,6 +1408,137 @@ do_clone_range(unsigned offset, unsigned length, unsigned dest) } #endif +#ifdef FIDEDUPERANGE +int +test_dedupe_range(void) +{ + struct file_dedupe_range *fdr; + off_t new_len; + int error; + int ret = 1; + + /* Alloc memory */ + fdr = calloc(sizeof(struct file_dedupe_range_info) + + sizeof(struct file_dedupe_range), 1); + if (!fdr) { + prterr("do_dedupe_range: malloc"); + report_failure(161); + } + + /* Make sure we have at least two blocks */ + new_len = block_size * 2; + if (file_size < new_len && ftruncate(fd, new_len)) { + warn("main: ftruncate"); + exit(132); + } + + /* Try to dedupe them */ + fdr->src_length = block_size; + fdr->dest_count = 1; + fdr->info[0].dest_fd = fd; + fdr->info[0].dest_offset = block_size; + + if (ioctl(fd, FIDEDUPERANGE, fdr)) + error = errno; + else if (fdr->info[0].status < 0) + error = -fdr->info[0].status; + else + error = 0; + + if (error == EOPNOTSUPP || error == ENOTTY) { + if (!quiet) + fprintf(stderr, + "main: filesystem does not support " + "dedupe range, disabling!\n"); + ret = 0; + } + + /* Put the file back the way it was. */ + if (file_size < new_len && ftruncate(fd, file_size)) { + warn("main: ftruncate"); + exit(132); + } + + free(fdr); + return ret; +} + +void +do_dedupe_range(unsigned offset, unsigned length, unsigned dest) +{ + struct file_dedupe_range *fdr; + + if (length == 0) { + if (!quiet && testcalls > simulatedopcount) + prt("skipping zero length dedupe range\n"); + log5(OP_DEDUPE_RANGE, offset, length, dest, FL_SKIPPED); + return; + } + + if ((loff_t)offset >= file_size) { + if (!quiet && testcalls > simulatedopcount) + prt("skipping dedupe range behind EOF\n"); + log5(OP_DEDUPE_RANGE, offset, length, dest, FL_SKIPPED); + return; + } + + log5(OP_DEDUPE_RANGE, offset, length, dest, FL_NONE); + + if (testcalls <= simulatedopcount) + return; + + if ((progressinterval && testcalls % progressinterval == 0) || + (debug && (monitorstart == -1 || monitorend == -1 || + dest <= monitorstart || dest + length <= monitorend))) { + prt("%lu dedupe\tfrom 0x%x to 0x%x, (0x%x bytes) at 0x%x\n", + testcalls, offset, offset+length, length, dest); + } + + /* Alloc memory */ + fdr = calloc(sizeof(struct file_dedupe_range_info) + + sizeof(struct file_dedupe_range), 1); + if (!fdr) { + prterr("do_dedupe_range: malloc"); + report_failure(161); + } + + /* Dedupe data blocks */ + fdr->src_offset = offset; + fdr->src_length = length; + fdr->dest_count = 1; + fdr->info[0].dest_fd = fd; + fdr->info[0].dest_offset = dest; + + if (ioctl(fd, FIDEDUPERANGE, fdr) == -1) { + prt("dedupe range: 0x%x to 0x%x at 0x%x\n", offset, + offset + length, dest); + prterr("do_dedupe_range(0): FIDEDUPERANGE"); + report_failure(161); + } else if (fdr->info[0].status < 0) { + errno = -fdr->info[0].status; + prt("dedupe range: 0x%x to 0x%x at 0x%x\n", offset, + offset + length, dest); + prterr("do_dedupe_range(1): FIDEDUPERANGE"); + report_failure(161); + } + + free(fdr); +} + +#else +int +test_dedupe_range(void) +{ + return 0; +} + +void +do_dedupe_range(unsigned offset, unsigned length, unsigned dest) +{ + return; +} +#endif + #ifdef HAVE_LINUX_FALLOC_H /* fallocate is basically a no-op unless extending, then a lot like a truncate */ void @@ -1549,6 +1697,7 @@ op_args_count(int operation) { switch (operation) { case OP_CLONE_RANGE: + case OP_DEDUPE_RANGE: return 4; default: return 3; @@ -1704,6 +1853,25 @@ test(void) } while (llabs(offset2 - offset) < size || offset2 + size > maxfilelen); break; + case OP_DEDUPE_RANGE: + { + int tries = 0; + + TRIM_OFF_LEN(offset, size, file_size); + offset = offset & ~(block_size - 1); + size = size & ~(block_size - 1); + do { + if (tries++ >= 30) { + size = 0; + break; + } + offset2 = random(); + TRIM_OFF(offset2, file_size); + offset2 = offset2 & ~(block_size - 1); + } while (llabs(offset2 - offset) < size || + offset2 + size > file_size); + break; + } } have_op: @@ -1753,6 +1921,12 @@ test(void) goto out; } break; + case OP_DEDUPE_RANGE: + if (!dedupe_range_calls) { + log5(op, offset, size, offset2, FL_SKIPPED); + goto out; + } + break; } switch (op) { @@ -1831,6 +2005,18 @@ test(void) do_clone_range(offset, size, offset2); break; + case OP_DEDUPE_RANGE: + if (size == 0) { + log5(OP_DEDUPE_RANGE, offset, size, offset2, FL_SKIPPED); + goto out; + } + if (offset2 + size > maxfilelen) { + log5(OP_DEDUPE_RANGE, offset, size, offset2, FL_SKIPPED); + goto out; + } + + do_dedupe_range(offset, size, offset2); + break; case OP_FSYNC: dofsync(); break; @@ -1856,7 +2042,7 @@ void usage(void) { fprintf(stdout, "usage: %s", - "fsx [-dknqxAFJLOWZ] [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\ + "fsx [-dknqxABFJLOWZ] [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\ -b opnum: beginning operation number (default 1)\n\ -c P: 1 in P chance of file close+open at each op (default infinity)\n\ -d: debug output for all operations\n\ @@ -1900,6 +2086,9 @@ usage(void) #ifdef FICLONERANGE " -J: Do not use clone range calls\n" #endif +#ifdef FIDEDUPERANGE +" -B: Do not use dedupe range calls\n" +#endif " -L: fsxLite - no file creations & no file size changes\n\ -N numops: total # operations to do (default infinity)\n\ -O: use oplen (see -o flag) for every op (default random)\n\ @@ -2103,7 +2292,7 @@ main(int argc, char **argv) setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */ while ((ch = getopt_long(argc, argv, - "b:c:dfg:i:j:kl:m:no:p:qr:s:t:w:xyAD:FJKHzCILN:OP:RS:WXZ", + "b:c:dfg:i:j:kl:m:no:p:qr:s:t:w:xyABD:FJKHzCILN:OP:RS:WXZ", longopts, NULL)) != EOF) switch (ch) { case 'b': @@ -2236,6 +2425,9 @@ main(int argc, char **argv) case 'J': clone_range_calls = 0; break; + case 'B': + dedupe_range_calls = 0; + break; case 'L': lite = 1; o_flags &= ~(O_CREAT|O_TRUNC); @@ -2456,6 +2648,8 @@ main(int argc, char **argv) insert_range_calls = test_fallocate(FALLOC_FL_INSERT_RANGE); if (clone_range_calls) clone_range_calls = test_clone_range(); + if (dedupe_range_calls) + dedupe_range_calls = test_dedupe_range(); while (numops == -1 || numops--) if (!test()) From patchwork Thu Nov 22 17:59:25 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: 10694663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92CD65A4 for ; Thu, 22 Nov 2018 17:59:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AB072CFA1 for ; Thu, 22 Nov 2018 17:59:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7EFF72CFB2; Thu, 22 Nov 2018 17:59:33 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 9B1392CFA1 for ; Thu, 22 Nov 2018 17:59:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406521AbeKWEj5 (ORCPT ); Thu, 22 Nov 2018 23:39:57 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:37436 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406519AbeKWEj4 (ORCPT ); Thu, 22 Nov 2018 23:39:56 -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 wAMHww86107697; Thu, 22 Nov 2018 17:59:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=wR8s0vz4AYZMYd/LOt8F3ZZHj/2UAqaj294dEzK5pJ4=; b=cx5o9fpjtOghHY35gd3ZqjMO6iKkW6DizASx7g/N1ZqC5I/PFkEKgt7rUaufzVCh3TZI hhQSd38IDnfLDl6t+wMcQHeUjIUJ4VHfwjOKJZvFQv7XfKdpwqyOJNiNKVdfcJA9Qvlm vKDQg9EWPCxu/mPmJqtDj5EiwrehuepfAhut/kbRGUKpC39UddLgjnZJ6gvs0ZB7QFm6 8M4vgbP7GG40rAcme5o9xbwyQpkRPdW7JF3V1ke5OtOpvg9S23M6FmFiKQVAoKUAdzx2 yGJ7l/9aPSQkXC/cnG5oW1BUnkd8YGUO6oLb2dgSuULCOfrDI2lO8CaMKc5U+C2uOvvL Aw== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2ntaxqg12w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:59:27 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wAMHxQrW015908 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:59:27 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wAMHxQHm002077; Thu, 22 Nov 2018 17:59:26 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Nov 2018 09:59:26 -0800 Subject: [PATCH 09/12] fsstress: add copy_file_range support From: "Darrick J. Wong" To: guaneryu@gmail.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Thu, 22 Nov 2018 09:59:25 -0800 Message-ID: <154290956504.1218.10573532271207817360.stgit@magnolia> In-Reply-To: <154290950237.1218.9937108728673485814.stgit@magnolia> References: <154290950237.1218.9937108728673485814.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9085 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=29 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-1810050000 definitions=main-1811220161 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 Support the copy_file_range syscall in fsstress. Signed-off-by: Darrick J. Wong --- configure.ac | 2 + include/builddefs.in | 1 ltp/Makefile | 4 + ltp/fsstress.c | 133 +++++++++++++++++++++++++++++++++++++++++++++++++ m4/package_libcdev.m4 | 19 +++++++ 5 files changed, 159 insertions(+) diff --git a/configure.ac b/configure.ac index aede4f59..19798824 100644 --- a/configure.ac +++ b/configure.ac @@ -68,6 +68,8 @@ AC_PACKAGE_WANT_OPEN_BY_HANDLE_AT AC_PACKAGE_WANT_LINUX_PRCTL_H AC_PACKAGE_WANT_LINUX_FS_H +AC_HAVE_COPY_FILE_RANGE + AC_CHECK_FUNCS([renameat2]) AC_CONFIG_HEADER(include/config.h) diff --git a/include/builddefs.in b/include/builddefs.in index fb8e912b..2605e42d 100644 --- a/include/builddefs.in +++ b/include/builddefs.in @@ -67,6 +67,7 @@ HAVE_DMAPI = @have_dmapi@ HAVE_ATTR_LIST = @have_attr_list@ HAVE_FIEMAP = @have_fiemap@ HAVE_FALLOCATE = @have_fallocate@ +HAVE_COPY_FILE_RANGE = @have_copy_file_range@ GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall diff --git a/ltp/Makefile b/ltp/Makefile index 5f784ecf..e4ca45f4 100644 --- a/ltp/Makefile +++ b/ltp/Makefile @@ -28,6 +28,10 @@ ifeq ($(HAVE_FALLOCATE), true) LCFLAGS += -DFALLOCATE endif +ifeq ($(HAVE_COPY_FILE_RANGE),yes) +LCFLAGS += -DHAVE_COPY_FILE_RANGE +endif + default: depend $(TARGETS) depend: .dep diff --git a/ltp/fsstress.c b/ltp/fsstress.c index af5d125f..e0330c95 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -26,6 +26,7 @@ #include io_context_t io_ctx; #endif +#include #ifndef FS_IOC_GETFLAGS #define FS_IOC_GETFLAGS _IOR('f', 1, long) @@ -55,6 +56,7 @@ typedef enum { OP_BULKSTAT1, OP_CHOWN, OP_CLONERANGE, + OP_COPYRANGE, OP_CREAT, OP_DEDUPERANGE, OP_DREAD, @@ -163,6 +165,7 @@ void bulkstat_f(int, long); void bulkstat1_f(int, long); void chown_f(int, long); void clonerange_f(int, long); +void copyrange_f(int, long); void creat_f(int, long); void deduperange_f(int, long); void dread_f(int, long); @@ -212,6 +215,7 @@ opdesc_t ops[] = { { OP_BULKSTAT1, "bulkstat1", bulkstat1_f, 1, 0 }, { OP_CHOWN, "chown", chown_f, 3, 1 }, { OP_CLONERANGE, "clonerange", clonerange_f, 4, 1 }, + { OP_COPYRANGE, "copyrange", copyrange_f, 4, 1 }, { OP_CREAT, "creat", creat_f, 4, 1 }, { OP_DEDUPERANGE, "deduperange", deduperange_f, 4, 1}, { OP_DREAD, "dread", dread_f, 4, 0 }, @@ -2333,6 +2337,135 @@ clonerange_f( #endif } +/* copy some arbitrary range of f1 to f2. */ +void +copyrange_f( + int opno, + long r) +{ +#ifdef HAVE_COPY_FILE_RANGE + struct pathname fpath1; + struct pathname fpath2; + struct stat64 stat1; + struct stat64 stat2; + char inoinfo1[1024]; + char inoinfo2[1024]; + loff_t lr; + loff_t off1; + loff_t off2; + loff_t max_off2; + size_t len; + int v1; + int v2; + int fd1; + int fd2; + int ret; + int e; + + /* Load paths */ + init_pathname(&fpath1); + if (!get_fname(FT_REGm, r, &fpath1, NULL, NULL, &v1)) { + if (v1) + printf("%d/%d: copyrange read - no filename\n", + procid, opno); + goto out_fpath1; + } + + init_pathname(&fpath2); + if (!get_fname(FT_REGm, random(), &fpath2, NULL, NULL, &v2)) { + if (v2) + printf("%d/%d: copyrange write - no filename\n", + procid, opno); + goto out_fpath2; + } + + /* Open files */ + fd1 = open_path(&fpath1, O_RDONLY); + e = fd1 < 0 ? errno : 0; + check_cwd(); + if (fd1 < 0) { + if (v1) + printf("%d/%d: copyrange read - open %s failed %d\n", + procid, opno, fpath1.path, e); + goto out_fpath2; + } + + fd2 = open_path(&fpath2, O_WRONLY); + e = fd2 < 0 ? errno : 0; + check_cwd(); + if (fd2 < 0) { + if (v2) + printf("%d/%d: copyrange write - open %s failed %d\n", + procid, opno, fpath2.path, e); + goto out_fd1; + } + + /* Get file stats */ + if (fstat64(fd1, &stat1) < 0) { + if (v1) + printf("%d/%d: copyrange read - fstat64 %s failed %d\n", + procid, opno, fpath1.path, errno); + goto out_fd2; + } + inode_info(inoinfo1, sizeof(inoinfo1), &stat1, v1); + + if (fstat64(fd2, &stat2) < 0) { + if (v2) + printf("%d/%d: copyrange write - fstat64 %s failed %d\n", + procid, opno, fpath2.path, errno); + goto out_fd2; + } + inode_info(inoinfo2, sizeof(inoinfo2), &stat2, v2); + + /* Calculate offsets */ + len = (random() % FILELEN_MAX) + 1; + if (len == 0) + len = stat1.st_blksize; + if (len > stat1.st_size) + len = stat1.st_size; + + lr = ((int64_t)random() << 32) + random(); + if (stat1.st_size == len) + off1 = 0; + else + off1 = (off64_t)(lr % MIN(stat1.st_size - len, MAXFSIZE)); + off1 %= maxfsize; + + /* + * 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 % max_off2); + off2 %= maxfsize; + } while (stat1.st_ino == stat2.st_ino && llabs(off2 - off1) < len); + + ret = copy_file_range(fd1, &off1, fd2, &off2, len, 0); + e = ret < 0 ? errno : 0; + if (v1 || v2) { + printf("%d/%d: copyrange %s%s [%lld,%lld] -> %s%s [%lld,%lld]", + procid, opno, + fpath1.path, inoinfo1, (long long)off1, (long long)len, + fpath2.path, inoinfo2, (long long)off2, (long long)len); + + if (ret < 0) + printf(" error %d", e); + printf("\n"); + } + +out_fd2: + close(fd2); +out_fd1: + close(fd1); +out_fpath2: + free_pathname(&fpath2); +out_fpath1: + free_pathname(&fpath1); +#endif +} + /* dedupe some arbitrary range of f1 to f2...fn. */ void deduperange_f( diff --git a/m4/package_libcdev.m4 b/m4/package_libcdev.m4 index fb123f33..14e67e18 100644 --- a/m4/package_libcdev.m4 +++ b/m4/package_libcdev.m4 @@ -98,3 +98,22 @@ AC_DEFUN([AC_HAVE_GETMNTINFO], AC_MSG_RESULT(no)) AC_SUBST(have_getmntinfo) ]) + +# +# +# Check if we have a copy_file_range system call (Linux) +# +AC_DEFUN([AC_HAVE_COPY_FILE_RANGE], + [ AC_MSG_CHECKING([for copy_file_range]) + AC_TRY_LINK([ +#define _GNU_SOURCE +#include +#include + ], [ + syscall(__NR_copy_file_range, 0, 0, 0, 0, 0, 0); + ], have_copy_file_range=yes + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no)) + AC_SUBST(have_copy_file_range) + ]) + From patchwork Thu Nov 22 17:59:31 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: 10694667 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A3D8C13BB for ; Thu, 22 Nov 2018 17:59:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A7AF2CFA1 for ; Thu, 22 Nov 2018 17:59:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F1172CFAE; Thu, 22 Nov 2018 17:59:38 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 E49262CFA1 for ; Thu, 22 Nov 2018 17:59:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406522AbeKWEkE (ORCPT ); Thu, 22 Nov 2018 23:40:04 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:38308 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406520AbeKWEkD (ORCPT ); Thu, 22 Nov 2018 23:40:03 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wAMHxEBH101266; Thu, 22 Nov 2018 17:59:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=5nIgeLdEIpcE7P/PHtlDArOzLkTt0AC93bfHhFgtel4=; b=x9XMIIzZvkOuTj9KzQk7qZia1iq1I2TWt5I6M48nIyn/mLXEHkokKWjZ6I2rdtI6PQHa LRrbH374BLkhonfndLTQehPl1hd4MZ+qy08PiA4ifa2xLcmYtkxB462o3X5BK+L+Z6fX 6cAMWkOhFpNqJef6G4AIMRwU9HwmDgshK8iESQ7HjOOWzc9v4Tr6rksXuysfJJL+IyBK uHXLRa377W3zxRtrnehzWxwvye/+6x5ktY3XCPmc8rGQzTIJ+EsiVpkeJzhjjArf76UI ppDk9gCFugFyLFuL3Gl1qoYCdmn4rtQtMCfGEWxMEkAQabCiVzFz+mCi1zHuTOMKtqQe /w== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2ntbmqyx8e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:59:33 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wAMHxX6M017085 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:59:33 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wAMHxWZC026002; Thu, 22 Nov 2018 17:59:32 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Nov 2018 09:59:32 -0800 Subject: [PATCH 10/12] fsx: add copy_file_range support From: "Darrick J. Wong" To: guaneryu@gmail.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, Dave Chinner Date: Thu, 22 Nov 2018 09:59:31 -0800 Message-ID: <154290957142.1218.8388379045411939584.stgit@magnolia> In-Reply-To: <154290950237.1218.9937108728673485814.stgit@magnolia> References: <154290950237.1218.9937108728673485814.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9085 signatures=668683 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-1810050000 definitions=main-1811220161 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 Add support for the copy_file_range system call to fsx. Signed-off-by: Darrick J. Wong [dchinner: copy_file_range() needs to obey read/write constraints otherwise is blows up when direct IO is used] Signed-off-by: Dave Chinner --- ltp/fsx.c | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 148 insertions(+), 2 deletions(-) diff --git a/ltp/fsx.c b/ltp/fsx.c index 577c7309..92e4c30f 100644 --- a/ltp/fsx.c +++ b/ltp/fsx.c @@ -34,6 +34,7 @@ #ifdef AIO #include #endif +#include #ifndef MAP_FILE # define MAP_FILE 0 @@ -106,6 +107,7 @@ enum { OP_INSERT_RANGE, OP_CLONE_RANGE, OP_DEDUPE_RANGE, + OP_COPY_RANGE, OP_MAX_FULL, /* integrity operations */ @@ -169,6 +171,7 @@ int mapped_reads = 1; /* -R flag disables it */ int check_file = 0; /* -X flag enables */ int clone_range_calls = 1; /* -J flag disables */ int dedupe_range_calls = 1; /* -B flag disables */ +int copy_range_calls = 1; /* -E flag disables */ int integrity = 0; /* -i flag */ int fsxgoodfd = 0; int o_direct; /* -Z */ @@ -264,6 +267,7 @@ static const char *op_names[] = { [OP_INSERT_RANGE] = "insert_range", [OP_CLONE_RANGE] = "clone_range", [OP_DEDUPE_RANGE] = "dedupe_range", + [OP_COPY_RANGE] = "copy_range", [OP_FSYNC] = "fsync", }; @@ -477,6 +481,20 @@ logdump(void) else if (overlap2) prt("\t******BBBB"); break; + case OP_COPY_RANGE: + prt("COPY 0x%x thru 0x%x\t(0x%x bytes) to 0x%x thru 0x%x", + lp->args[0], lp->args[0] + lp->args[1] - 1, + lp->args[1], + lp->args[2], lp->args[2] + lp->args[1] - 1); + overlap2 = badoff >= lp->args[2] && + badoff < lp->args[2] + lp->args[1]; + if (overlap && overlap2) + prt("\tEEEE**EEEE"); + else if (overlap) + prt("\tEEEE******"); + else if (overlap2) + prt("\t******EEEE"); + break; case OP_FSYNC: prt("FSYNC"); break; @@ -1539,6 +1557,99 @@ do_dedupe_range(unsigned offset, unsigned length, unsigned dest) } #endif +#ifdef HAVE_COPY_FILE_RANGE +int +test_copy_range(void) +{ + loff_t o1 = 0, o2 = 0; + + if (copy_file_range(fd, &o1, fd, &o2, 0, 0) == -1 && + (errno == EOPNOTSUPP || errno == ENOTTY)) { + if (!quiet) + fprintf(stderr, + "main: filesystem does not support " + "copy range, disabling!\n"); + return 0; + } + + return 1; +} + +void +do_copy_range(unsigned offset, unsigned length, unsigned dest) +{ + loff_t o1, o2; + ssize_t nr; + + offset -= offset % readbdy; + dest -= dest % writebdy; + if (o_direct) + length -= length % readbdy; + + if (length == 0) { + if (!quiet && testcalls > simulatedopcount) + prt("skipping zero length copy range\n"); + log5(OP_COPY_RANGE, offset, length, dest, FL_SKIPPED); + return; + } + + if ((loff_t)offset >= file_size) { + if (!quiet && testcalls > simulatedopcount) + prt("skipping copy range behind EOF\n"); + log5(OP_COPY_RANGE, offset, length, dest, FL_SKIPPED); + return; + } + + if (dest + length > biggest) { + biggest = dest + length; + if (!quiet && testcalls > simulatedopcount) + prt("copying to largest ever: 0x%x\n", dest + length); + } + + log5(OP_COPY_RANGE, offset, length, dest, FL_NONE); + + if (testcalls <= simulatedopcount) + return; + + if ((progressinterval && testcalls % progressinterval == 0) || + (debug && (monitorstart == -1 || monitorend == -1 || + dest <= monitorstart || dest + length <= monitorend))) { + prt("%lu copy\tfrom 0x%x to 0x%x, (0x%x bytes) at 0x%x\n", + testcalls, offset, offset+length, length, dest); + } + + o1 = offset; + o2 = dest; + + nr = copy_file_range(fd, &o1, fd, &o2, length, 0); + if (nr == -1) { + prt("copy range: 0x%x to 0x%x at 0x%x\n", offset, + offset + length, dest); + prterr("do_copy_range:"); + report_failure(161); + } + + memcpy(good_buf + dest, good_buf + offset, nr); + if (dest > file_size) + memset(good_buf + file_size, '\0', dest - file_size); + if (dest + nr > file_size) + file_size = dest + nr; +} + +#else +int +test_copy_range(void) +{ + return 0; +} + +void +do_copy_range(unsigned offset, unsigned length, unsigned dest) +{ + return; +} +#endif + #ifdef HAVE_LINUX_FALLOC_H /* fallocate is basically a no-op unless extending, then a lot like a truncate */ void @@ -1698,6 +1809,7 @@ op_args_count(int operation) switch (operation) { case OP_CLONE_RANGE: case OP_DEDUPE_RANGE: + case OP_COPY_RANGE: return 4; default: return 3; @@ -1872,6 +1984,14 @@ test(void) offset2 + size > file_size); break; } + case OP_COPY_RANGE: + TRIM_OFF_LEN(offset, size, file_size); + do { + offset2 = random(); + TRIM_OFF(offset2, maxfilelen); + } while (llabs(offset2 - offset) < size || + offset2 + size > maxfilelen); + break; } have_op: @@ -1927,6 +2047,12 @@ test(void) goto out; } break; + case OP_COPY_RANGE: + if (!copy_range_calls) { + log5(op, offset, size, offset2, FL_SKIPPED); + goto out; + } + break; } switch (op) { @@ -2017,6 +2143,18 @@ test(void) do_dedupe_range(offset, size, offset2); break; + case OP_COPY_RANGE: + if (size == 0) { + log5(OP_COPY_RANGE, offset, size, offset2, FL_SKIPPED); + goto out; + } + if (offset2 + size > maxfilelen) { + log5(OP_COPY_RANGE, offset, size, offset2, FL_SKIPPED); + goto out; + } + + do_copy_range(offset, size, offset2); + break; case OP_FSYNC: dofsync(); break; @@ -2042,7 +2180,7 @@ void usage(void) { fprintf(stdout, "usage: %s", - "fsx [-dknqxABFJLOWZ] [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\ + "fsx [-dknqxABEFJLOWZ] [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\ -b opnum: beginning operation number (default 1)\n\ -c P: 1 in P chance of file close+open at each op (default infinity)\n\ -d: debug output for all operations\n\ @@ -2089,6 +2227,9 @@ usage(void) #ifdef FIDEDUPERANGE " -B: Do not use dedupe range calls\n" #endif +#ifdef HAVE_COPY_FILE_RANGE +" -E: Do not use copy range calls\n" +#endif " -L: fsxLite - no file creations & no file size changes\n\ -N numops: total # operations to do (default infinity)\n\ -O: use oplen (see -o flag) for every op (default random)\n\ @@ -2292,7 +2433,7 @@ main(int argc, char **argv) setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */ while ((ch = getopt_long(argc, argv, - "b:c:dfg:i:j:kl:m:no:p:qr:s:t:w:xyABD:FJKHzCILN:OP:RS:WXZ", + "b:c:dfg:i:j:kl:m:no:p:qr:s:t:w:xyABD:EFJKHzCILN:OP:RS:WXZ", longopts, NULL)) != EOF) switch (ch) { case 'b': @@ -2428,6 +2569,9 @@ main(int argc, char **argv) case 'B': dedupe_range_calls = 0; break; + case 'E': + copy_range_calls = 0; + break; case 'L': lite = 1; o_flags &= ~(O_CREAT|O_TRUNC); @@ -2650,6 +2794,8 @@ main(int argc, char **argv) clone_range_calls = test_clone_range(); if (dedupe_range_calls) dedupe_range_calls = test_dedupe_range(); + if (copy_range_calls) + copy_range_calls = test_copy_range(); while (numops == -1 || numops--) if (!test()) From patchwork Thu Nov 22 17:59:37 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: 10694671 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4573B5A4 for ; Thu, 22 Nov 2018 17:59:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DCDA2CFA1 for ; Thu, 22 Nov 2018 17:59:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 320EE2CFB2; Thu, 22 Nov 2018 17:59:43 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 248332CFA1 for ; Thu, 22 Nov 2018 17:59:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406526AbeKWEkI (ORCPT ); Thu, 22 Nov 2018 23:40:08 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:49572 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406524AbeKWEkI (ORCPT ); Thu, 22 Nov 2018 23:40:08 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wAMHxeZg142619; Thu, 22 Nov 2018 17:59:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=bYuzvfc2noHHTyDPwU24TDrhIvVN7I8a7JIntOFSYTI=; b=qCQYrWY/JIVaTyskQKWj4p3cDKA2r+5/QxepZ7NUXQbzgoriiDGrDT7MqdwF5XnrMSHV UWXmQZsHc4KLH3StfNyNqU1pO0TVEyniqqm3EHPU87KpVcucDONGcFXcsGnoRgyGiWJH +mXuE3BbNK53WA6bGCelF0mCJP77oCm+socug0esQ5ysmSBVtd79wFT1zuHXhJLdgUwF UDt5M2gKGDmlnBEX0XxjG2KO+Nqes6sxCjP5kJnm2hdDchxMMIuDRRX/29IQwrtYDolj e4B/NP5hzwtvQMAamq4HEvfOJjp/srzPJv2OO81IHflyiusApZ4wC74JvDCcgdLB2r+e Ag== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2ntadu82db-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:59:39 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wAMHxdbv012983 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:59:39 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wAMHxdbH026018; Thu, 22 Nov 2018 17:59:39 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Nov 2018 09:59:38 -0800 Subject: [PATCH 11/12] common/dump: disable copyrange From: "Darrick J. Wong" To: guaneryu@gmail.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Thu, 22 Nov 2018 09:59:37 -0800 Message-ID: <154290957785.1218.10166123029263020778.stgit@magnolia> In-Reply-To: <154290950237.1218.9937108728673485814.stgit@magnolia> References: <154290950237.1218.9937108728673485814.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9085 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=519 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811220161 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 In _create_dumpdir_stress_num, disable copyrange in fsstress so that we dump exactly the same set of files and directories no matter how the xfs is configured. Signed-off-by: Darrick J. Wong --- common/dump | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/dump b/common/dump index c45b8a5a..4d1a1607 100644 --- a/common/dump +++ b/common/dump @@ -307,6 +307,9 @@ _create_dumpdir_stress_num() if $FSSTRESS_PROG | grep -q deduperange; then FSSTRESS_AVOID="-f deduperange=0 $FSSTRESS_AVOID" fi + if $FSSTRESS_PROG | grep -q copyrange; then + FSSTRESS_AVOID="-f copyrange=0 $FSSTRESS_AVOID" + fi echo "" echo "-----------------------------------------------" From patchwork Thu Nov 22 17:59:44 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: 10694675 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 400F913BB for ; Thu, 22 Nov 2018 17:59:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 391FD2CFA1 for ; Thu, 22 Nov 2018 17:59:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D9572CFAE; Thu, 22 Nov 2018 17:59:49 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 AC4142CFA1 for ; Thu, 22 Nov 2018 17:59:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406519AbeKWEkO (ORCPT ); Thu, 22 Nov 2018 23:40:14 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:38472 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732278AbeKWEkO (ORCPT ); Thu, 22 Nov 2018 23:40:14 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wAMHxkKD101409; Thu, 22 Nov 2018 17:59:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=U+LJq+wOW5AErGH8iByHT7cRFd2IFYtp+v3/DZuxuDs=; b=1bZjQ1NbjMOLyfDzeKvT07OXTlFGfDTZrkgQb+Wp54xvfggyH9R1ezszZYl4iyrCWu+s O5eKTJTFLavn3MhiBmBOekeNx6vIfWt8Gw3KAktwvRzr/VBSqbH3TMHWLeF5NEVPaqM3 pg3i25tXrUb8Ctekk4tBxR4mYLvyCfOApbUmJDuy+iESuhFAepkUHkeLp4q+XdXsS8ME hejVOn3iukqBzeSl22ggMqzVbFtcxJAV2hJV5exy516SXq+NxNt/H+1A3Fkapwd7mCPI STet1hqSe476UsY7lrQEirjXsuWEJ92D5Y0lC8DgAVzAXWSW1qJu3/auhGWDMuOwSDJ9 Rw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2ntbmqyx8y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:59:46 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wAMHxjgI018144 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Nov 2018 17:59:45 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wAMHxjvV002136; Thu, 22 Nov 2018 17:59:45 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Nov 2018 09:59:45 -0800 Subject: [PATCH 12/12] generic: long fsx soak tests From: "Darrick J. Wong" To: guaneryu@gmail.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Thu, 22 Nov 2018 09:59:44 -0800 Message-ID: <154290958406.1218.8922234236895263233.stgit@magnolia> In-Reply-To: <154290950237.1218.9937108728673485814.stgit@magnolia> References: <154290950237.1218.9937108728673485814.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9085 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=974 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811220161 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 Add a few tests to implement long soak tests of fsx. Signed-off-by: Darrick J. Wong --- tests/generic/938 | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/938.out | 2 ++ tests/generic/939 | 60 +++++++++++++++++++++++++++++++++++++++++++++ tests/generic/939.out | 2 ++ tests/generic/group | 2 ++ 5 files changed, 131 insertions(+) create mode 100644 tests/generic/938 create mode 100644 tests/generic/938.out create mode 100644 tests/generic/939 create mode 100644 tests/generic/939.out diff --git a/tests/generic/938 b/tests/generic/938 new file mode 100644 index 00000000..a85a6472 --- /dev/null +++ b/tests/generic/938 @@ -0,0 +1,65 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Oracle. All Rights Reserved. +# +# FS QA Test 938 +# +# Long-soak directio fsx test +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_supported_os Linux +_require_test + +# Run fsx for a million ops or more +nr_ops=$((1000000 * TIME_FACTOR)) +op_sz=$((128000 * LOAD_FACTOR)) +file_sz=$((600000 * LOAD_FACTOR)) +fsx_file=$TEST_DIR/fsx.$seq +min_dio_sz=$(_min_dio_alignment) + +fsx_args=(-q) +fsx_args+=(-N $nr_ops) +fsx_args+=(-p $((nr_ops / 100))) +fsx_args+=(-o $op_sz) +fsx_args+=(-l $file_sz) +fsx_args+=(-r $min_dio_sz) +fsx_args+=(-t $min_dio_sz) +fsx_args+=(-w $min_dio_sz) +fsx_args+=(-Z) +fsx_args+=($fsx_file) + +echo "ltp ${fsx_args[@]} $FSX_ARGS" >> $seqres.full + +if ! ltp/fsx "${fsx_args[@]}" $FSX_ARGS > $tmp.fsx 2>&1; then + cat $tmp.fsx | tee -a $seqres.full +fi + +# success, all done +echo Silence is golden +status=0 +exit diff --git a/tests/generic/938.out b/tests/generic/938.out new file mode 100644 index 00000000..11b565ee --- /dev/null +++ b/tests/generic/938.out @@ -0,0 +1,2 @@ +QA output created by 938 +Silence is golden diff --git a/tests/generic/939 b/tests/generic/939 new file mode 100644 index 00000000..5e341e30 --- /dev/null +++ b/tests/generic/939 @@ -0,0 +1,60 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Oracle. All Rights Reserved. +# +# FS QA Test 938 +# +# Long-soak buffered fsx test +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_supported_os Linux +_require_test + +# Run fsx for a million ops or more +nr_ops=$((1000000 * TIME_FACTOR)) +op_sz=$((128000 * LOAD_FACTOR)) +file_sz=$((600000 * LOAD_FACTOR)) +fsx_file=$TEST_DIR/fsx.$seq + +fsx_args=(-q) +fsx_args+=(-N $nr_ops) +fsx_args+=(-p $((nr_ops / 100))) +fsx_args+=(-o $op_sz) +fsx_args+=(-l $file_sz) +fsx_args+=($fsx_file) + +echo "ltp ${fsx_args[@]} $FSX_ARGS" >> $seqres.full + +if ! ltp/fsx "${fsx_args[@]}" $FSX_ARGS > $tmp.fsx 2>&1; then + cat $tmp.fsx | tee -a $seqres.full +fi + +# success, all done +echo Silence is golden +status=0 +exit diff --git a/tests/generic/939.out b/tests/generic/939.out new file mode 100644 index 00000000..a86e90c5 --- /dev/null +++ b/tests/generic/939.out @@ -0,0 +1,2 @@ +QA output created by 939 +Silence is golden diff --git a/tests/generic/group b/tests/generic/group index 92330b52..16e5cc17 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -522,3 +522,5 @@ 517 auto quick dedupe clone 518 auto quick clone 519 auto quick +938 soak long_rw +939 soak long_rw