Whamcloud - gitweb
LU-1347 style: removes obsolete EXPORT_SYMTAB macros
[fs/lustre-release.git] / lustre / quota / lproc_quota.c
index 6f0114a..d2319e0 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -44,8 +44,6 @@
 
 #include "quota_internal.h"
 
-#ifdef HAVE_QUOTA_SUPPORT
-
 #ifdef LPROCFS
 int lprocfs_quota_rd_bunit(char *page, char **start, off_t off, int count,
                            int *eof, void *data)
@@ -181,12 +179,9 @@ int lprocfs_quota_rd_type(char *page, char **start, off_t off, int count,
         struct obd_device *obd = (struct obd_device *)data;
         char stype[MAX_STYPE_SIZE + 1] = "";
         int oq_type;
-        struct obd_device_target *obt;
 
         LASSERT(obd != NULL);
 
-        obt = &obd->u.obt;
-
         /* Collect the needed information */
         oq_type = obd->u.obt.obt_qctxt.lqc_flags;
 
@@ -215,6 +210,7 @@ int generic_quota_on(struct obd_device *obd, struct obd_quotactl *oqctl, int glo
         int id, is_master, rc = 0, local; /* means we need a local quotaon */
 
         cfs_down(&obt->obt_quotachecking);
+        push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         id = UGQUOTA2LQC(oqctl->qc_type);
         local = (obt->obt_qctxt.lqc_flags & id) != id;
 
@@ -223,12 +219,10 @@ int generic_quota_on(struct obd_device *obd, struct obd_quotactl *oqctl, int glo
 
         is_master = !strcmp(obd->obd_type->typ_name, LUSTRE_MDS_NAME);
         if (is_master) {
-                cfs_down(&obd->u.mds.mds_qonoff_sem);
+                cfs_down_write(&obd->u.mds.mds_qonoff_sem);
                 if (local) {
-                        push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
                         /* turn on cluster wide quota */
                         rc = mds_admin_quota_on(obd, oqctl);
-                        pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
                         if (rc && rc != -ENOENT)
                                 CERROR("%s: %s admin quotaon failed. rc=%d\n",
                                        obd->obd_name, global ? "global":"local",
@@ -238,7 +232,6 @@ int generic_quota_on(struct obd_device *obd, struct obd_quotactl *oqctl, int glo
 
         if (rc == 0) {
                 if (local) {
-                        push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
                         rc = fsfilt_quotactl(obd, obt->obt_sb, oqctl);
                         if (rc) {
                                 if (rc != -ENOENT)
@@ -249,18 +242,23 @@ int generic_quota_on(struct obd_device *obd, struct obd_quotactl *oqctl, int glo
                                 obt->obt_qctxt.lqc_flags |= UGQUOTA2LQC(oqctl->qc_type);
                                 build_lqs(obd);
                         }
-                        pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
                 }
 
                 if (rc == 0 && global && is_master)
-                        rc = obd_quotactl(obd->u.mds.mds_osc_exp, oqctl);
+                        rc = obd_quotactl(obd->u.mds.mds_lov_exp, oqctl);
         }
 
         if (is_master)
-                cfs_up(&obd->u.mds.mds_qonoff_sem);
+                cfs_up_write(&obd->u.mds.mds_qonoff_sem);
 
+        pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         cfs_up(&obt->obt_quotachecking);
 
+        CDEBUG(D_QUOTA, "%s: quotaon type:master:global:local:flags:rc "
+               "%u:%d:%d:%d:%lu:%d\n",
+               obd->obd_name, oqctl->qc_type, is_master, global, local,
+               obt->obt_qctxt.lqc_flags, rc);
+
         return rc;
 }
 
@@ -288,17 +286,12 @@ int lprocfs_quota_wr_type(struct file *file, const char *buffer,
                           unsigned long count, void *data)
 {
         struct obd_device *obd = (struct obd_device *)data;
-        struct obd_device_target *obt;
-        int type = 0, is_mds;
+        int type = 0;
         unsigned long i;
         char stype[MAX_STYPE_SIZE + 1] = "";
 
         LASSERT(obd != NULL);
 
-        obt = &obd->u.obt;
-
-        is_mds = !strcmp(obd->obd_type->typ_name, LUSTRE_MDS_NAME);
-
         if (count > MAX_STYPE_SIZE)
                 return -EINVAL;
 
@@ -686,4 +679,3 @@ int lquota_proc_cleanup(struct lustre_quota_ctxt *qctxt)
 }
 
 #endif  /* LPROCFS */
-#endif