From patchwork Mon Feb 2 02:59:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Qi X-Patchwork-Id: 5758891 Return-Path: X-Original-To: patchwork-ocfs2-devel@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 937CCBF440 for ; Mon, 2 Feb 2015 03:00:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A61E720218 for ; Mon, 2 Feb 2015 03:00:07 +0000 (UTC) Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 777112012E for ; Mon, 2 Feb 2015 03:00:06 +0000 (UTC) Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t122xUwG010165 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 2 Feb 2015 02:59:31 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id t122xTTi010101 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 2 Feb 2015 02:59:30 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1YI7EX-0008JJ-HY; Sun, 01 Feb 2015 18:59:29 -0800 Received: from acsinet22.oracle.com ([141.146.126.238]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1YI7EV-0008J6-D9; Sun, 01 Feb 2015 18:59:27 -0800 Received: from aserp1060.oracle.com (aserp1060.oracle.com [141.146.126.71]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t122xQtw027806 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 2 Feb 2015 02:59:27 GMT Received: from userp2030.oracle.com (userp2030.oracle.com [156.151.31.89]) by aserp1060.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t122xQOo003021 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 2 Feb 2015 02:59:26 GMT Received: from pps.filterd (userp2030.oracle.com [127.0.0.1]) by userp2030.oracle.com (8.14.7/8.14.7) with SMTP id t122xEX3013300; Mon, 2 Feb 2015 02:59:26 GMT Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [119.145.14.65]) by userp2030.oracle.com with ESMTP id 1s9uatuuyu-1 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT); Mon, 02 Feb 2015 02:59:25 +0000 Received: from 172.24.2.119 (EHLO szxeml426-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CGR50032; Mon, 02 Feb 2015 10:59:21 +0800 (CST) Received: from [127.0.0.1] (10.177.24.125) by szxeml426-hub.china.huawei.com (10.82.67.181) with Microsoft SMTP Server id 14.3.158.1; Mon, 2 Feb 2015 10:59:18 +0800 Message-ID: <54CEE804.7020305@huawei.com> Date: Mon, 2 Feb 2015 10:59:16 +0800 From: Joseph Qi User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: "ocfs2-devel@oss.oracle.com" , X-Originating-IP: [10.177.24.125] X-CFilter-Loop: Reflected X-ServerName: szxga02-in.huawei.com X-Proofpoint-Virus-Version: vendor=nai engine=5600 definitions=7699 signatures=670623 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=2 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1402240000 definitions=main-1502020032 Subject: [Ocfs2-devel] [PATCH 2/3] tunefs.ocfs2: support append direct io ro compat feature X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Source-IP: ucsinet22.oracle.com [156.151.31.94] X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Support turn on/off the feature. This is mostly for the existing ocfs2 volume upgrade. Signed-off-by: Joseph Qi --- tunefs.ocfs2/Makefile | 3 +- tunefs.ocfs2/feature_append_dio.c | 123 ++++++++++++++++++++++++++++++++++++++ tunefs.ocfs2/op_features.c | 2 + 3 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 tunefs.ocfs2/feature_append_dio.c diff --git a/tunefs.ocfs2/Makefile b/tunefs.ocfs2/Makefile index 585a68c..62a5e8e 100644 --- a/tunefs.ocfs2/Makefile +++ b/tunefs.ocfs2/Makefile @@ -29,7 +29,8 @@ OCFS2NE_FEATURES = \ feature_xattr \ feature_indexed_dirs \ feature_quota \ - feature_clusterinfo + feature_clusterinfo \ + feature_append_dio OCFS2NE_OPERATIONS = \ op_cloned_volume \ diff --git a/tunefs.ocfs2/feature_append_dio.c b/tunefs.ocfs2/feature_append_dio.c new file mode 100644 index 0000000..791dd64 --- /dev/null +++ b/tunefs.ocfs2/feature_append_dio.c @@ -0,0 +1,123 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * feature_append_dio.c + * + * ocfs2 tune utility for enabling and disabling the append direct + * io feature. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "ocfs2/ocfs2.h" + +#include "libocfs2ne.h" + + +static int enable_append_dio(ocfs2_filesys *fs, int flags) +{ + errcode_t ret = 0; + struct ocfs2_super_block *super = OCFS2_RAW_SB(fs->fs_super); + struct tools_progress *prog; + + if (ocfs2_supports_append_dio(super)) { + verbosef(VL_APP, + "Append direct io feature is already enabled; " + "nothing to enable\n"); + goto out; + } + + if (!tools_interact("Enable the append direct io feature on " + "device \"%s\"? ", + fs->fs_devname)) + goto out; + + prog = tools_progress_start("Enable append direct io", "append-dio", 1); + if (!prog) { + ret = TUNEFS_ET_NO_MEMORY; + tcom_err(ret, "while initializing the progress display"); + goto out; + } + + OCFS2_SET_RO_COMPAT_FEATURE(super, + OCFS2_FEATURE_RO_COMPAT_APPEND_DIO); + tunefs_block_signals(); + ret = ocfs2_write_super(fs); + tunefs_unblock_signals(); + if (ret) + tcom_err(ret, "while writing out the superblock"); + + tools_progress_step(prog, 1); + tools_progress_stop(prog); +out: + return ret; +} + +static int disable_append_dio(ocfs2_filesys *fs, int flags) +{ + errcode_t ret = 0; + struct ocfs2_super_block *super = OCFS2_RAW_SB(fs->fs_super); + struct tools_progress *prog = NULL; + + if (!ocfs2_supports_append_dio(super)) { + verbosef(VL_APP, + "Append direct io feature is not enabled; " + "nothing to disable\n"); + goto out; + } + + if (!tools_interact("Disable the append direct io feature on " + "device \"%s\"? ", + fs->fs_devname)) + goto out; + + prog = tools_progress_start("Disabling append direct io", "noappend-dio", 0); + if (!prog) { + ret = TUNEFS_ET_NO_MEMORY; + tcom_err(ret, "while initializing the progress display"); + goto out; + } + + OCFS2_CLEAR_RO_COMPAT_FEATURE(super, + OCFS2_FEATURE_RO_COMPAT_APPEND_DIO); + tunefs_block_signals(); + ret = ocfs2_write_super(fs); + tunefs_unblock_signals(); + if (ret) + tcom_err(ret, "while writing out the superblock"); + + tools_progress_step(prog, 1); + +out: + if (prog) + tools_progress_stop(prog); + return ret; +} + +DEFINE_TUNEFS_FEATURE_RO_COMPAT(append_dio, + OCFS2_FEATURE_RO_COMPAT_APPEND_DIO, + TUNEFS_FLAG_RW | TUNEFS_FLAG_ONLINE, + enable_append_dio, + disable_append_dio); + +#ifdef DEBUG_EXE +int main(int argc, char *argv[]) +{ + return tunefs_feature_main(argc, argv, &append_dio_feature); +} +#endif diff --git a/tunefs.ocfs2/op_features.c b/tunefs.ocfs2/op_features.c index 20b65a5..b6235aa 100644 --- a/tunefs.ocfs2/op_features.c +++ b/tunefs.ocfs2/op_features.c @@ -47,6 +47,7 @@ extern struct tunefs_feature refcount_feature; extern struct tunefs_feature indexed_dirs_feature; extern struct tunefs_feature discontig_bg_feature; extern struct tunefs_feature clusterinfo_feature; +extern struct tunefs_feature append_dio_feature; /* List of features supported by ocfs2ne */ static struct tunefs_feature *features[] = { @@ -64,6 +65,7 @@ static struct tunefs_feature *features[] = { &indexed_dirs_feature, &discontig_bg_feature, &clusterinfo_feature, + &append_dio_feature, NULL, };