Whamcloud - gitweb
LU-1799 o2iblnd: debug patch for o2iblnd
[fs/lustre-release.git] / lustre / quota / quota_interface.c
index c82e280..53d450c 100644 (file)
@@ -34,9 +34,6 @@
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
 #define DEBUG_SUBSYSTEM S_LQUOTA
 
 #ifdef __KERNEL__
@@ -45,7 +42,6 @@
 # include <linux/init.h>
 # include <linux/fs.h>
 # include <linux/jbd.h>
-# include <linux/smp_lock.h>
 # include <linux/buffer_head.h>
 # include <linux/workqueue.h>
 # include <linux/mount.h>
@@ -66,7 +62,7 @@
 #ifdef __KERNEL__
 
 static cfs_time_t last_print = 0;
-static cfs_spinlock_t last_print_lock = CFS_SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(last_print_lock);
 
 static int filter_quota_setup(struct obd_device *obd)
 {
@@ -198,6 +194,10 @@ static int filter_quota_getflag(struct obd_device *obd, struct obdo *oa)
         for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
                 struct lustre_qunit_size *lqs = NULL;
 
+                /* check if quota is enabled */
+                if (!ll_sb_has_quota_active(obt->obt_sb, cnt))
+                        continue;
+
                 lqs = quota_search_lqs(LQS_KEY(cnt, GET_OA_ID(cnt, oa)),
                                        qctxt, 0);
                 if (IS_ERR(lqs)) {
@@ -292,6 +292,10 @@ static int quota_check_common(struct obd_device *obd, const unsigned int id[],
                         QDATA_SET_BLK(&qdata[i]);
                 qdata[i].qd_count = 0;
 
+                /* check if quota is enabled */
+                if (!ll_sb_has_quota_active(qctxt->lqc_sb, i))
+                        continue;
+
                 /* ignore root user */
                 if (qdata[i].qd_id == 0 && !QDATA_IS_GRP(&qdata[i]))
                         continue;
@@ -399,6 +403,9 @@ int quota_is_set(struct obd_device *obd, const unsigned int id[], int flag)
                 RETURN(0);
 
         for (i = 0; i < MAXQUOTAS; i++) {
+                /* check if quota is enabled */
+                if (!ll_sb_has_quota_active(obd->u.obt.obt_qctxt.lqc_sb, i))
+                        continue;
                 lqs = quota_search_lqs(LQS_KEY(i, id[i]),
                                        &obd->u.obt.obt_qctxt, 0);
                 if (lqs && !IS_ERR(lqs)) {
@@ -444,23 +451,27 @@ static int quota_chk_acq_common(struct obd_device *obd, struct obd_export *exp,
         while ((rc = quota_check_common(obd, id, pending, count, cycle, isblk,
                                         inode, frags)) &
                QUOTA_RET_ACQUOTA) {
-
-                cfs_spin_lock(&qctxt->lqc_lock);
-                if (!qctxt->lqc_import && oti) {
-                        cfs_spin_unlock(&qctxt->lqc_lock);
-                        LASSERT(oti->oti_thread);
-                        /* The recovery thread doesn't have watchdog
-                         * attached. LU-369 */
-                        if (oti->oti_thread->t_watchdog)
-                                lc_watchdog_disable(oti->oti_thread->\
-                                                t_watchdog);
-                        CDEBUG(D_QUOTA, "sleep for quota master\n");
-                        l_wait_event(qctxt->lqc_wait_for_qmaster, check_qm(qctxt),
-                                     &lwi);
-                        CDEBUG(D_QUOTA, "wake up when quota master is back\n");
-                        if (oti->oti_thread->t_watchdog)
-                                lc_watchdog_touch(oti->oti_thread->t_watchdog,
-                                       CFS_GET_TIMEOUT(oti->oti_thread->t_svc));
+               struct ptlrpc_thread *thr = oti != NULL ?
+                                           oti->oti_thread : NULL;
+
+               cfs_spin_lock(&qctxt->lqc_lock);
+               if (!qctxt->lqc_import && oti != NULL) {
+                       cfs_spin_unlock(&qctxt->lqc_lock);
+
+                       LASSERT(thr != NULL);
+                       /* The recovery thread doesn't have watchdog
+                        * attached. LU-369 */
+                       if (thr->t_watchdog != NULL)
+                               lc_watchdog_disable(thr->t_watchdog);
+                       CDEBUG(D_QUOTA, "sleep for quota master\n");
+                       l_wait_event(qctxt->lqc_wait_for_qmaster,
+                                    check_qm(qctxt), &lwi);
+
+                       CDEBUG(D_QUOTA, "wake up when quota master is back\n");
+                       if (thr->t_watchdog != NULL) {
+                               lc_watchdog_touch(thr->t_watchdog,
+                                  ptlrpc_server_get_timeout(thr->t_svcpt));
+                       }
                 } else {
                         cfs_spin_unlock(&qctxt->lqc_lock);
                 }
@@ -502,9 +513,9 @@ static int quota_chk_acq_common(struct obd_device *obd, struct obd_export *exp,
                         cfs_waitq_t        waitq;
                         struct l_wait_info lwi;
 
-                        if (oti && oti->oti_thread && oti->oti_thread->t_watchdog)
-                                lc_watchdog_touch(oti->oti_thread->t_watchdog,
-                                       CFS_GET_TIMEOUT(oti->oti_thread->t_svc));
+                       if (thr != NULL && thr->t_watchdog != NULL)
+                               lc_watchdog_touch(thr->t_watchdog,
+                                  ptlrpc_server_get_timeout(thr->t_svcpt));
                         CDEBUG(D_QUOTA, "rc: %d, count_err: %d\n", rc,
                                count_err++);
 
@@ -759,7 +770,7 @@ quota_interface_t filter_quota_interface = {
 
 cfs_proc_dir_entry_t *lquota_type_proc_dir = NULL;
 
-static int __init init_lustre_quota(void)
+int init_lustre_quota(void)
 {
         int rc = 0;
 
@@ -782,7 +793,7 @@ static int __init init_lustre_quota(void)
         return 0;
 }
 
-static void /*__exit*/ exit_lustre_quota(void)
+void exit_lustre_quota(void)
 {
         PORTAL_SYMBOL_UNREGISTER(filter_quota_interface);
         PORTAL_SYMBOL_UNREGISTER(mds_quota_interface);
@@ -793,12 +804,6 @@ static void /*__exit*/ exit_lustre_quota(void)
                 lprocfs_remove(&lquota_type_proc_dir);
 }
 
-MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
-MODULE_DESCRIPTION("Lustre Quota");
-MODULE_LICENSE("GPL");
-
-cfs_module(lquota, "1.0.0", init_lustre_quota, exit_lustre_quota);
-
 EXPORT_SYMBOL(mds_quota_interface);
 EXPORT_SYMBOL(filter_quota_interface);
 #endif /* __KERNEL */