From patchwork Thu Jan 8 18:31:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 5594851 Return-Path: X-Original-To: patchwork-fstests@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D192AC058D for ; Thu, 8 Jan 2015 18:31:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1B32D2043C for ; Thu, 8 Jan 2015 18:31:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3BB542042B for ; Thu, 8 Jan 2015 18:31:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756863AbbAHSbo (ORCPT ); Thu, 8 Jan 2015 13:31:44 -0500 Received: from mail.kernel.org ([198.145.29.136]:59827 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752008AbbAHSbo (ORCPT ); Thu, 8 Jan 2015 13:31:44 -0500 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2B1A020439; Thu, 8 Jan 2015 18:31:43 +0000 (UTC) Received: from localhost (unknown [166.170.43.56]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2E4BB2042B; Thu, 8 Jan 2015 18:31:42 +0000 (UTC) From: Jaegeuk Kim To: Dave Chinner Cc: fstests@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Jaegeuk Kim Subject: [PATCH 1/2] src/godown: support f2fs triggering specific ioctl Date: Thu, 8 Jan 2015 10:31:18 -0800 Message-Id: <1420741879-73691-1-git-send-email-jaegeuk@kernel.org> X-Mailer: git-send-email 2.1.1 X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch triggers the F2FS-related ioctl for godown. Signed-off-by: Jaegeuk Kim --- src/godown.c | 88 ++++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 65 insertions(+), 23 deletions(-) diff --git a/src/godown.c b/src/godown.c index b140a41..b44790b 100644 --- a/src/godown.c +++ b/src/godown.c @@ -19,33 +19,82 @@ #include #include "global.h" +#define F2FS_IOCTL_MAGIC 0xf5 +#define F2FS_IOC_GOINGDOWN _IO(F2FS_IOCTL_MAGIC, 6) + +enum ftypes { + XFS_FS, + F2FS_FS, +}; + static char *xprogname; +static char *mnt_dir; +static int verbose_opt = 0; +static int flushlog_opt = 0; +static enum ftypes fs = XFS_FS; static void usage(void) { - fprintf(stderr, "usage: %s [-f] [-v] mnt-dir\n", xprogname); + fprintf(stderr, "usage: %s [-f] [-v] [-s 0/1] mnt-dir\n", xprogname); +} + +static int +xfs_goingdown(int fd) +{ + int flag; + + flag = (flushlog_opt ? XFS_FSOP_GOING_FLAGS_LOGFLUSH + : XFS_FSOP_GOING_FLAGS_NOLOGFLUSH); + if (verbose_opt) { + printf("Calling XFS_IOC_GOINGDOWN\n"); + } + + syslog(LOG_WARNING, "xfstests-induced forced shutdown of %s:\n", + mnt_dir); + if ((xfsctl(mnt_dir, fd, XFS_IOC_GOINGDOWN, &flag)) == -1) { + fprintf(stderr, "%s: error on xfsctl(GOINGDOWN) of \"%s\": %s\n", + xprogname, mnt_dir, strerror(errno)); + return 1; + } + return 0; +} + +static int +f2fs_goingdown(int fd) +{ + if (verbose_opt) { + printf("Calling F2FS_IOC_GOINGDOWN\n"); + } + syslog(LOG_WARNING, "xfstests-induced forced shutdown of %s:\n", + mnt_dir); + if ((ioctl(fd, F2FS_IOC_GOINGDOWN)) == -1) { + fprintf(stderr, "%s: error on ioctl(GOINGDOWN) of \"%s\": %s\n", + xprogname, mnt_dir, strerror(errno)); + return 1; + } + return 0; + } int main(int argc, char *argv[]) { - int c; - int flag; - int flushlog_opt = 0; - int verbose_opt = 0; + int c, fd; struct stat st; - char *mnt_dir; - int fd; + int ret = 0; xprogname = argv[0]; - while ((c = getopt(argc, argv, "fv")) != -1) { + while ((c = getopt(argc, argv, "fs:v")) != -1) { switch (c) { case 'f': flushlog_opt = 1; break; + case 's': + fs = atoi(optarg); + break; case 'v': verbose_opt = 1; break; @@ -94,10 +143,6 @@ main(int argc, char *argv[]) } #endif - - flag = (flushlog_opt ? XFS_FSOP_GOING_FLAGS_LOGFLUSH - : XFS_FSOP_GOING_FLAGS_NOLOGFLUSH); - if (verbose_opt) { printf("Opening \"%s\"\n", mnt_dir); } @@ -107,18 +152,15 @@ main(int argc, char *argv[]) return 1; } - if (verbose_opt) { - printf("Calling XFS_IOC_GOINGDOWN\n"); + switch (fs) { + case XFS_FS: + ret = xfs_goingdown(fd); + break; + case F2FS_FS: + ret = f2fs_goingdown(fd); + break; } - syslog(LOG_WARNING, "xfstests-induced forced shutdown of %s:\n", - mnt_dir); - if ((xfsctl(mnt_dir, fd, XFS_IOC_GOINGDOWN, &flag)) == -1) { - fprintf(stderr, "%s: error on xfsctl(GOINGDOWN) of \"%s\": %s\n", - xprogname, mnt_dir, strerror(errno)); - return 1; - } - close(fd); - return 0; + return ret; }