Whamcloud - gitweb
LU-1943 tests: async IO is enough for sanity/80
[fs/lustre-release.git] / lustre / include / lustre_quota.h
index 1e12858..545a336 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.
@@ -28,6 +26,8 @@
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -76,8 +76,6 @@ struct client_obd;
 #define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS)
 #endif
 
-#ifdef HAVE_QUOTA_SUPPORT
-
 #ifndef MAX_IQ_TIME
 #define MAX_IQ_TIME  604800     /* (7*24*60*60) 1 week */
 #endif
@@ -177,7 +175,7 @@ struct lustre_dquot {
         /** Hash list in memory, protect by dquot_hash_lock */
         cfs_list_t dq_hash;
         /** Protect the data in lustre_dquot */
-        cfs_semaphore_t dq_sem;
+        cfs_mutex_t dq_mutex;
         /** Use count */
         cfs_atomic_t dq_refcnt;
         /** Pointer of quota info it belongs to */
@@ -226,17 +224,6 @@ int lustre_quota_convert(struct lustre_quota_info *lqi, int type);
 typedef int (*dqacq_handler_t) (struct obd_device * obd, struct qunit_data * qd,
                                 int opc);
 
-/*
-#ifdef HAVE_VFS_DQ_OFF
-#define LL_DQUOT_OFF(sb, remount)    vfs_dq_off(sb, remount)
-#else
-#define LL_DQUOT_OFF(sb, remount)    DQUOT_OFF(sb)
-#endif
-*/
-
-#define LL_DQUOT_OFF(sb)    DQUOT_OFF(sb)
-
-
 /* user quota is turned on on filter */
 #define LQC_USRQUOTA_FLAG (1 << 0)
 /* group quota is turned on on filter */
@@ -397,39 +384,25 @@ struct lustre_qunit_size {
 #define LQS_KEY_ID(key)      (key & 0xffffffff)
 #define LQS_KEY_GRP(key)     (key >> 32)
 
-static inline void __lqs_getref(struct lustre_qunit_size *lqs)
+static inline void lqs_getref(struct lustre_qunit_size *lqs)
 {
         int count = cfs_atomic_inc_return(&lqs->lqs_refcount);
 
-        if (count == 2) /* quota_create_lqs */
-                cfs_atomic_inc(&lqs->lqs_ctxt->lqc_lqs);
         CDEBUG(D_INFO, "lqs=%p refcount %d\n", lqs, count);
 }
 
-static inline void lqs_getref(struct lustre_qunit_size *lqs)
+static inline void lqs_putref(struct lustre_qunit_size *lqs)
 {
-        __lqs_getref(lqs);
-}
+        int count = cfs_atomic_read(&lqs->lqs_refcount);
 
-static inline void __lqs_putref(struct lustre_qunit_size *lqs)
-{
-        LASSERT(cfs_atomic_read(&lqs->lqs_refcount) > 0);
+        LASSERT(count > 0);
+        CDEBUG(D_INFO, "lqs=%p refcount %d\n", lqs, count - 1);
 
-        if (cfs_atomic_dec_return(&lqs->lqs_refcount) == 1)
+        if (cfs_atomic_dec_and_test(&lqs->lqs_refcount)) {
                 if (cfs_atomic_dec_and_test(&lqs->lqs_ctxt->lqc_lqs))
                         cfs_waitq_signal(&lqs->lqs_ctxt->lqc_lqs_waitq);
-        CDEBUG(D_INFO, "lqs=%p refcount %d\n",
-               lqs, cfs_atomic_read(&lqs->lqs_refcount));
-}
-
-static inline void lqs_putref(struct lustre_qunit_size *lqs)
-{
-        __lqs_putref(lqs);
-}
-
-static inline void lqs_initref(struct lustre_qunit_size *lqs)
-{
-        cfs_atomic_set(&lqs->lqs_refcount, 0);
+                OBD_FREE_PTR(lqs);
+        }
 }
 
 #else
@@ -445,18 +418,6 @@ struct lustre_quota_ctxt {
 
 #endif  /* !__KERNEL__ */
 
-#else
-
-#define LL_DQUOT_OFF(sb) do {} while(0)
-
-struct lustre_quota_info {
-};
-
-struct lustre_quota_ctxt {
-};
-
-#endif /* !HAVE_QUOTA_SUPPORT */
-
 /* If the (quota limit < qunit * slave count), the slave which can't
  * acquire qunit should set it's local limit as MIN_QLIMIT */
 #define MIN_QLIMIT      1
@@ -682,41 +643,6 @@ static inline int lquota_adjust(quota_interface_t *interface,
         RETURN(ret);
 }
 
-static inline int lquota_chkdq(quota_interface_t *interface,
-                               struct client_obd *cli, const unsigned int qid[])
-{
-        int rc;
-        ENTRY;
-
-        QUOTA_CHECK_OP(interface, chkdq);
-        rc = QUOTA_OP(interface, chkdq)(cli, qid);
-        RETURN(rc);
-}
-
-static inline int lquota_setdq(quota_interface_t *interface,
-                               struct client_obd *cli, const unsigned int qid[],
-                               obd_flag valid, obd_flag flags)
-{
-        int rc;
-        ENTRY;
-
-        QUOTA_CHECK_OP(interface, setdq);
-        rc = QUOTA_OP(interface, setdq)(cli, qid, valid, flags);
-        RETURN(rc);
-}
-
-static inline int lquota_poll_check(quota_interface_t *interface,
-                                    struct obd_export *exp,
-                                    struct if_quotacheck *qchk)
-{
-        int rc;
-        ENTRY;
-
-        QUOTA_CHECK_OP(interface, poll_check);
-        rc = QUOTA_OP(interface, poll_check)(exp, qchk);
-        RETURN(rc);
-}
-
 static inline int lquota_setinfo(quota_interface_t *interface,
                                  struct obd_device *obd,
                                  void *data)
@@ -798,11 +724,6 @@ static inline int lquota_pending_commit(quota_interface_t *interface,
 #endif
 
 #ifndef __KERNEL__
-extern quota_interface_t osc_quota_interface;
-extern quota_interface_t lov_quota_interface;
-extern quota_interface_t mdc_quota_interface;
-extern quota_interface_t lmv_quota_interface;
-
 #ifndef MAXQUOTAS
 #define MAXQUOTAS 2
 #endif
@@ -822,6 +743,48 @@ extern quota_interface_t lmv_quota_interface;
         "admin_quotafile_v2.grp"        /** group admin quotafile */\
 }
 
+/*
+ * Definitions of structures for vfsv0 quota format
+ * Source linux/fs/quota/quotaio_v2.h
+ *
+ * The following definitions are normally found in private kernel headers.
+ * However, some sites build Lustre against kernel development headers rather
+ * than than full kernel source, so we provide them here for compatibility.
+ */
+#ifdef __KERNEL__
+# if !defined(HAVE_QUOTAIO_H) && !defined(HAVE_FS_QUOTA_QUOTAIO_H) && \
+     !defined(HAVE_FS_QUOTAIO_H)
+
+#include <linux/types.h>
+#include <linux/quota.h>
+
+#define V2_INITQMAGICS {\
+        0xd9c01f11,     /* USRQUOTA */\
+        0xd9c01927      /* GRPQUOTA */\
+}
+
+/* Header with type and version specific information */
+struct v2_disk_dqinfo {
+        __le32 dqi_bgrace;      /* Time before block soft limit becomes hard limit */
+        __le32 dqi_igrace;      /* Time before inode soft limit becomes hard limit */
+        __le32 dqi_flags;       /* Flags for quotafile (DQF_*) */
+        __le32 dqi_blocks;      /* Number of blocks in file */
+        __le32 dqi_free_blk;    /* Number of first free block in the list */
+        __le32 dqi_free_entry;  /* Number of block with at least one free entry */
+};
+
+/* First generic header */
+struct v2_disk_dqheader {
+        __le32 dqh_magic;       /* Magic number identifying file */
+        __le32 dqh_version;     /* File version */
+};
+#define V2_DQINFOOFF    sizeof(struct v2_disk_dqheader) /* Offset of info header in file */
+#define QT_TREEOFF      1                               /* Offset of tree in file in blocks */
+#define V2_DQTREEOFF    QT_TREEOFF
+
+# endif /* !defined(HAVE_QUOTAIO_V1_H) ... */
+#endif  /* __KERNEL__ */
+
 /** @} quota */
 
 #endif /* _LUSTRE_QUOTA_H */