From patchwork Fri Sep 6 03:29:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 2854361 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 70919C0AB5 for ; Fri, 6 Sep 2013 03:33:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 79DE720292 for ; Fri, 6 Sep 2013 03:33:04 +0000 (UTC) Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 78A202028F for ; Fri, 6 Sep 2013 03:33:03 +0000 (UTC) Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r863Wu4L019351 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 6 Sep 2013 03:32:57 GMT Received: from oss.oracle.com (oss-external.oracle.com [137.254.96.51]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r863WtwI027902 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 6 Sep 2013 03:32:56 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1VHmjy-00061G-Rl; Thu, 05 Sep 2013 20:29:46 -0700 Received: from acsinet21.oracle.com ([141.146.126.237]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1VHmjr-000615-LD for ocfs2-devel@oss.oracle.com; Thu, 05 Sep 2013 20:29:39 -0700 Received: from aserp1020.oracle.com (aserp1020.oracle.com [141.146.126.67]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r863TdMv023168 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 6 Sep 2013 03:29:39 GMT Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by aserp1020.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r863TcrG021441 for ; Fri, 6 Sep 2013 03:29:38 GMT Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 2C9E2A398F; Fri, 6 Sep 2013 05:29:38 +0200 (CEST) Date: Thu, 5 Sep 2013 22:29:37 -0500 From: Goldwyn Rodrigues To: ocfs2-devel@oss.oracle.com Message-ID: <20130906032932.GA4192@shrek.lan> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Flow-Control-Info: class=Pass-to-MM reputation=ipRisk-All ip=195.135.220.15 ct-class=T2 ct-vol1=0 ct-vol2=4 ct-vol3=4 ct-risk=66 ct-spam1=82 ct-spam2=47 ct-bulk=27 rcpts=1 size=2741 X-SPF-Info: NONE::cantor2.suse.de X-Sendmail-CM-Score: 0.00% X-Sendmail-CM-Analysis: v=2.1 cv=LdkFtFvi c=1 sm=1 tr=0 a=uEuDQZVrWKuLCe7byFjfVg==:117 a=uEuDQZVrWKuLCe7byFjfVg==:17 a=LcaDllckn3IA:10 a=pfVMGnSxuvwA:10 a=7SFtLa4N3QQA:10 a=kj9zAlcOel0A:10 a=97xfeiHKBjcA:10 a=iox4zFpeAAAA:8 a=SPJOJOn701KtVWfYSHcA:9 a=CjuIK1q_8u gA:10 a=n9GBPR9yFnkA:10 X-Sendmail-CT-Classification: not spam X-Sendmail-CT-RefID: str=0001.0A090207.52294C23.0015:SCFSTAT13898897, ss=1, re=-4.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 Cc: mfasheh@suse.com Subject: [Ocfs2-devel] [PATCH 6/6] Disallow cluster_stack changes if fs are mounted 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: acsinet21.oracle.com [141.146.126.237] X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Signed-off-by: Goldwyn Rodrigues --- fs/ocfs2/stackglue.c | 18 ++++++++++++++++++ fs/ocfs2/stackglue.h | 3 +++ fs/ocfs2/super.c | 2 ++ 3 files changed, 23 insertions(+) diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c index 4dd732b..e352a2e 100644 --- a/fs/ocfs2/stackglue.c +++ b/fs/ocfs2/stackglue.c @@ -41,6 +41,7 @@ static DEFINE_SPINLOCK(ocfs2_stack_lock); static LIST_HEAD(ocfs2_stack_list); static char cluster_stack_name[OCFS2_STACK_LABEL_LEN + 1]; static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl"; +static atomic_t mount_count = ATOMIC_INIT(0); /* * The stack currently in use. If not null, active_stack->sp_count > 0, @@ -417,6 +418,18 @@ int ocfs2_cluster_disconnect(struct ocfs2_cluster_connection *conn, } EXPORT_SYMBOL_GPL(ocfs2_cluster_disconnect); +void ocfs2_inc_mount_count() +{ + atomic_inc(&mount_count); +} +EXPORT_SYMBOL_GPL(ocfs2_inc_mount_count); + +void ocfs2_dec_mount_count() +{ + atomic_dec(&mount_count); +} +EXPORT_SYMBOL_GPL(ocfs2_dec_mount_count); + /* * Leave the group for this filesystem. This is executed by a userspace * program (stored in ocfs2_hb_ctl_path). @@ -569,6 +582,11 @@ static ssize_t ocfs2_cluster_stack_store(struct kobject *kobj, size_t len = count; ssize_t ret; + if (atomic_read(&mount_count) > 0) { + printk(KERN_NOTICE "ocfs2_stackglue: Cannot set cluster_stack when filesystems are mounted.\n"); + return -EINVAL; + } + if (len == 0) return len; diff --git a/fs/ocfs2/stackglue.h b/fs/ocfs2/stackglue.h index c953290..9eeeff03 100644 --- a/fs/ocfs2/stackglue.h +++ b/fs/ocfs2/stackglue.h @@ -291,6 +291,9 @@ int ocfs2_plock(struct ocfs2_cluster_connection *conn, u64 ino, void ocfs2_stack_glue_set_max_proto_version(struct ocfs2_protocol_version *max_proto); +void ocfs2_inc_mount_count(void); +void ocfs2_dec_mount_count(void); + /* Used by stack plugins */ int ocfs2_stack_glue_register(struct ocfs2_stack_plugin *plugin); diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 60f3d8e..c91087c 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -1214,6 +1214,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) /* Start this when the mount is almost sure of being successful */ ocfs2_orphan_scan_start(osb); + ocfs2_inc_mount_count(); return status; @@ -1253,6 +1254,7 @@ static void ocfs2_kill_sb(struct super_block *sb) spin_unlock(&dentry_list_lock); /* Wait for work to finish and/or remove it */ cancel_work_sync(&osb->dentry_lock_work); + ocfs2_dec_mount_count(); out: kill_block_super(sb); }