Whamcloud - gitweb
LU-1842 quota: new quota RPC format
authorNiu Yawei <niu@whamcloud.com>
Thu, 13 Sep 2012 10:25:11 +0000 (06:25 -0400)
committerOleg Drokin <green@whamcloud.com>
Tue, 18 Sep 2012 04:33:34 +0000 (00:33 -0400)
Define RPC formats for quota acquire/release:
- non-intent DQACQ;
- intent DQACQ (per-ID intent lock);
- intent CONNECT (global intent lock);

Signed-off-by: Niu Yawei <niu@whamcloud.com>
Change-Id: Ia6ec34326cd94274f2f0f42b89f11e52d0dc8317
Reviewed-on: http://review.whamcloud.com/3977
Tested-by: Hudson
Reviewed-by: Johann Lombardi <johann@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Fan Yong <yong.fan@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/include/lustre/lustre_idl.h
lustre/include/lustre_req_layout.h
lustre/include/obd.h
lustre/ptlrpc/layout.c
lustre/ptlrpc/pack_generic.c
lustre/ptlrpc/wiretest.c
lustre/utils/req-layout.c
lustre/utils/wirecheck.c
lustre/utils/wiretest.c

index cd4ed5f..69ffac6 100644 (file)
@@ -1817,6 +1817,35 @@ struct obd_quotactl {
 
 extern void lustre_swab_obd_quotactl(struct obd_quotactl *q);
 
+#define QUOTA_DQACQ_FL_ACQ      0x1  /* acquire quota */
+#define QUOTA_DQACQ_FL_PREACQ   0x2  /* pre-acquire */
+#define QUOTA_DQACQ_FL_REL      0x4  /* release quota */
+#define QUOTA_DQACQ_FL_REPORT   0x8  /* report usage */
+
+struct quota_body {
+       struct lu_fid    qb_fid;     /* FID of global index packing the pool ID
+                                     * and type (data or metadata) as well as
+                                     * the quota type (user or group). */
+       union lquota_id  qb_id;      /* uid or gid or directory FID */
+       __u32            qb_flags;   /* see above */
+       __u32            qb_padding;
+       __u64            qb_count;   /* acquire/release count (kbytes/inodes) */
+       __u64            qb_usage;   /* current slave usage (kbytes/inodes) */
+       __u64            qb_slv_ver; /* slave index file version */
+       struct lustre_handle qb_lockh;     /* per-ID lock handle */
+       struct lustre_handle qb_glb_lockh; /* global lock handle */
+       __u64            qb_padding1[4];
+};
+
+/* When the quota_body is used in the reply of quota global intent
+ * lock (IT_QUOTA_CONN) reply, qb_fid contains slave index file FID. */
+#define qb_slv_fid       qb_fid
+/* qb_usage is the current qunit (in kbytes/inodes) when quota_body is used in
+ * acquire reply */
+#define qb_qunit         qb_usage
+
+extern void lustre_swab_quota_body(struct quota_body *b);
+
 struct quota_adjust_qunit {
         __u32 qaq_flags;
         __u32 qaq_id;
index ef94738..f2ec5dd 100644 (file)
@@ -182,6 +182,7 @@ extern struct req_format RQF_MDS_QUOTACHECK;
 extern struct req_format RQF_MDS_QUOTACTL;
 extern struct req_format RQF_MDS_QUOTA_DQACQ;
 extern struct req_format RQF_QC_CALLBACK;
+extern struct req_format RQF_QUOTA_DQACQ;
 /* OST req_format */
 extern struct req_format RQF_OST_CONNECT;
 extern struct req_format RQF_OST_DISCONNECT;
@@ -211,6 +212,7 @@ extern struct req_format RQF_LDLM_INTENT_GETATTR;
 extern struct req_format RQF_LDLM_INTENT_OPEN;
 extern struct req_format RQF_LDLM_INTENT_CREATE;
 extern struct req_format RQF_LDLM_INTENT_UNLINK;
+extern struct req_format RQF_LDLM_INTENT_QUOTA;
 extern struct req_format RQF_LDLM_CANCEL;
 extern struct req_format RQF_LDLM_CALLBACK;
 extern struct req_format RQF_LDLM_CP_CALLBACK;
@@ -260,6 +262,7 @@ extern struct req_msg_field RMF_OBD_QUOTACHECK;
 extern struct req_msg_field RMF_OBD_QUOTACTL;
 extern struct req_msg_field RMF_QUOTA_ADJUST_QUNIT;
 extern struct req_msg_field RMF_QUNIT_DATA;
+extern struct req_msg_field RMF_QUOTA_BODY;
 extern struct req_msg_field RMF_STRING;
 
 /* seq-mgr fields */
index afc7a8e..12cea5a 100644 (file)
@@ -1250,6 +1250,8 @@ struct lu_context;
 #define IT_EXEC     (1 << 8)
 #define IT_PIN      (1 << 9)
 #define IT_LAYOUT   (1 << 10)
+#define IT_QUOTA_DQACQ (1 << 11)
+#define IT_QUOTA_CONN  (1 << 12)
 
 static inline int it_to_lock_mode(struct lookup_intent *it)
 {
index 9240384..78f8751 100644 (file)
@@ -131,6 +131,25 @@ static const struct req_msg_field *qunit_data_only[] = {
         &RMF_QUNIT_DATA
 };
 
+static const struct req_msg_field *quota_body_only[] = {
+       &RMF_PTLRPC_BODY,
+       &RMF_QUOTA_BODY
+};
+
+static const struct req_msg_field *ldlm_intent_quota_client[] = {
+       &RMF_PTLRPC_BODY,
+       &RMF_DLM_REQ,
+       &RMF_LDLM_INTENT,
+       &RMF_QUOTA_BODY
+};
+
+static const struct req_msg_field *ldlm_intent_quota_server[] = {
+       &RMF_PTLRPC_BODY,
+       &RMF_DLM_REP,
+       &RMF_DLM_LVB,
+       &RMF_QUOTA_BODY
+};
+
 static const struct req_msg_field *mdt_close_client[] = {
         &RMF_PTLRPC_BODY,
         &RMF_MDT_EPOCH,
@@ -613,6 +632,8 @@ static struct req_format *req_formats[] = {
         &RQF_LDLM_INTENT_OPEN,
         &RQF_LDLM_INTENT_CREATE,
         &RQF_LDLM_INTENT_UNLINK,
+       &RQF_LDLM_INTENT_QUOTA,
+       &RQF_QUOTA_DQACQ,
         &RQF_LOG_CANCEL,
         &RQF_LLOG_ORIGIN_HANDLE_CREATE,
         &RQF_LLOG_ORIGIN_HANDLE_DESTROY,
@@ -761,6 +782,11 @@ struct req_msg_field RMF_QUNIT_DATA =
                     sizeof(struct qunit_data), lustre_swab_qdata, NULL);
 EXPORT_SYMBOL(RMF_QUNIT_DATA);
 
+struct req_msg_field RMF_QUOTA_BODY =
+       DEFINE_MSGF("quota_body", 0,
+                   sizeof(struct quota_body), lustre_swab_quota_body, NULL);
+EXPORT_SYMBOL(RMF_QUOTA_BODY);
+
 struct req_msg_field RMF_MDT_EPOCH =
         DEFINE_MSGF("mdt_ioepoch", 0,
                     sizeof(struct mdt_ioepoch), lustre_swab_mdt_ioepoch, NULL);
@@ -1038,6 +1064,16 @@ struct req_format RQF_MDS_QUOTA_DQACQ =
         DEFINE_REQ_FMT0("MDS_QUOTA_DQACQ", qunit_data_only, qunit_data_only);
 EXPORT_SYMBOL(RQF_MDS_QUOTA_DQACQ);
 
+struct req_format RQF_QUOTA_DQACQ =
+       DEFINE_REQ_FMT0("QUOTA_DQACQ", quota_body_only, quota_body_only);
+EXPORT_SYMBOL(RQF_QUOTA_DQACQ);
+
+struct req_format RQF_LDLM_INTENT_QUOTA =
+       DEFINE_REQ_FMT0("LDLM_INTENT_QUOTA",
+                       ldlm_intent_quota_client,
+                       ldlm_intent_quota_server);
+EXPORT_SYMBOL(RQF_LDLM_INTENT_QUOTA);
+
 struct req_format RQF_MDS_GETSTATUS =
         DEFINE_REQ_FMT0("MDS_GETSTATUS", mdt_body_only, mdt_body_capa);
 EXPORT_SYMBOL(RQF_MDS_GETSTATUS);
index f1d8621..98c53d9 100644 (file)
@@ -2246,6 +2246,16 @@ void lustre_swab_qdata(struct qunit_data *d)
 }
 EXPORT_SYMBOL(lustre_swab_qdata);
 
+void lustre_swab_quota_body(struct quota_body *b)
+{
+       lustre_swab_lu_fid(&b->qb_fid);
+       lustre_swab_lu_fid((struct lu_fid *)&b->qb_id);
+       __swab32s(&b->qb_flags);
+       __swab64s(&b->qb_count);
+       __swab64s(&b->qb_usage);
+       __swab64s(&b->qb_slv_ver);
+}
+
 /* Dump functions */
 void dump_ioo(struct obd_ioobj *ioo)
 {
index c39eea5..665e986 100644 (file)
@@ -54,8 +54,8 @@ void lustre_assert_wire_constants(void)
 {
         /* Wire protocol assertions generated by 'wirecheck'
          * (make -C lustre/utils newwiretest)
-         * running on Linux node7 2.6.32 #4 SMP Tue Aug 7 13:09:55 MSK 2012 x86_64 x86_64 x86_64 GNU/
-         * with gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC)  */
+         * running on Linux rhel6 2.6.32 #1 SMP Mon Aug 20 00:36:28 EDT 2012 x86_64 x86_64 x86_64 GNU
+         * with gcc version 4.4.4 20100726 (Red Hat 4.4.4-13) (GCC)  */
 
 
         /* Constants... */
@@ -1524,9 +1524,9 @@ void lustre_assert_wire_constants(void)
         LASSERTF((int)sizeof(((struct obd_ioobj *)0)->ioo_bufcnt) == 4, "found %lld\n",
                  (long long)(int)sizeof(((struct obd_ioobj *)0)->ioo_bufcnt));
 
-       /* Checks for union lquota_id */
-       LASSERTF((int)sizeof(union lquota_id) == 16, "found %lld\n",
-                (long long)(int)sizeof(union lquota_id));
+        /* Checks for union lquota_id */
+        LASSERTF((int)sizeof(union lquota_id) == 16, "found %lld\n",
+                 (long long)(int)sizeof(union lquota_id));
 
         /* Checks for struct obd_quotactl */
         LASSERTF((int)sizeof(struct obd_quotactl) == 112, "found %lld\n",
@@ -3584,6 +3584,50 @@ void lustre_assert_wire_constants(void)
         LASSERTF((int)sizeof(((struct qunit_data *)0)->padding) == 8, "found %lld\n",
                  (long long)(int)sizeof(((struct qunit_data *)0)->padding));
 
+        /* Checks for struct quota_body */
+        LASSERTF((int)sizeof(struct quota_body) == 112, "found %lld\n",
+                 (long long)(int)sizeof(struct quota_body));
+        LASSERTF((int)offsetof(struct quota_body, qb_fid) == 0, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_fid));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_fid) == 16, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_fid));
+        LASSERTF((int)offsetof(struct quota_body, qb_id) == 16, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_id));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_id) == 16, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_id));
+        LASSERTF((int)offsetof(struct quota_body, qb_flags) == 32, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_flags));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_flags) == 4, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_flags));
+        LASSERTF((int)offsetof(struct quota_body, qb_padding) == 36, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_padding));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_padding) == 4, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_padding));
+        LASSERTF((int)offsetof(struct quota_body, qb_count) == 40, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_count));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_count) == 8, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_count));
+        LASSERTF((int)offsetof(struct quota_body, qb_usage) == 48, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_usage));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_usage) == 8, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_usage));
+        LASSERTF((int)offsetof(struct quota_body, qb_slv_ver) == 56, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_slv_ver));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_slv_ver) == 8, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_slv_ver));
+        LASSERTF((int)offsetof(struct quota_body, qb_lockh) == 64, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_lockh));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_lockh) == 8, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_lockh));
+        LASSERTF((int)offsetof(struct quota_body, qb_glb_lockh) == 72, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_glb_lockh));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_glb_lockh) == 8, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_glb_lockh));
+        LASSERTF((int)offsetof(struct quota_body, qb_padding1[4]) == 112, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_padding1[4]));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_padding1[4]) == 8, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_padding1[4]));
+
         /* Checks for struct quota_adjust_qunit */
         LASSERTF((int)sizeof(struct quota_adjust_qunit) == 32, "found %lld\n",
                  (long long)(int)sizeof(struct quota_adjust_qunit));
index d21cc41..914253f 100644 (file)
@@ -75,6 +75,7 @@
 #define lustre_swab_ost_last_id NULL
 #define lustre_swab_fiemap NULL
 #define lustre_swab_qdata NULL
+#define lustre_swab_quota_body NULL
 #define lustre_swab_lvb NULL
 #define lustre_swab_mgs_config_body NULL
 #define lustre_swab_mgs_config_res NULL
index 5ce41b2..409a8ff 100644 (file)
@@ -1589,6 +1589,23 @@ check_qunit_data(void)
 }
 
 static void
+check_quota_body(void)
+{
+       BLANK_LINE();
+       CHECK_STRUCT(quota_body);
+       CHECK_MEMBER(quota_body, qb_fid);
+       CHECK_MEMBER(quota_body, qb_id);
+       CHECK_MEMBER(quota_body, qb_flags);
+       CHECK_MEMBER(quota_body, qb_padding);
+       CHECK_MEMBER(quota_body, qb_count);
+       CHECK_MEMBER(quota_body, qb_usage);
+       CHECK_MEMBER(quota_body, qb_slv_ver);
+       CHECK_MEMBER(quota_body, qb_lockh);
+       CHECK_MEMBER(quota_body, qb_glb_lockh);
+       CHECK_MEMBER(quota_body, qb_padding1[4]);
+}
+
+static void
 check_mgs_target_info(void)
 {
         BLANK_LINE();
@@ -2108,6 +2125,7 @@ main(int argc, char **argv)
         check_llogd_conn_body();
         check_ll_fiemap_info_key();
         check_qunit_data();
+       check_quota_body();
         check_quota_adjust_qunit();
         check_mgs_target_info();
         check_lustre_capa();
index 16de235..4e6f36a 100644 (file)
@@ -62,8 +62,8 @@ void lustre_assert_wire_constants(void)
 {
         /* Wire protocol assertions generated by 'wirecheck'
          * (make -C lustre/utils newwiretest)
-         * running on Linux node7 2.6.32 #4 SMP Tue Aug 7 13:09:55 MSK 2012 x86_64 x86_64 x86_64 GNU/
-         * with gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC)  */
+         * running on Linux rhel6 2.6.32 #1 SMP Mon Aug 20 00:36:28 EDT 2012 x86_64 x86_64 x86_64 GNU
+         * with gcc version 4.4.4 20100726 (Red Hat 4.4.4-13) (GCC)  */
 
 
         /* Constants... */
@@ -1532,9 +1532,9 @@ void lustre_assert_wire_constants(void)
         LASSERTF((int)sizeof(((struct obd_ioobj *)0)->ioo_bufcnt) == 4, "found %lld\n",
                  (long long)(int)sizeof(((struct obd_ioobj *)0)->ioo_bufcnt));
 
-       /* Checks for union lquota_id */
-       LASSERTF((int)sizeof(union lquota_id) == 16, "found %lld\n",
-                (long long)(int)sizeof(union lquota_id));
+        /* Checks for union lquota_id */
+        LASSERTF((int)sizeof(union lquota_id) == 16, "found %lld\n",
+                 (long long)(int)sizeof(union lquota_id));
 
         /* Checks for struct obd_quotactl */
         LASSERTF((int)sizeof(struct obd_quotactl) == 112, "found %lld\n",
@@ -3592,6 +3592,50 @@ void lustre_assert_wire_constants(void)
         LASSERTF((int)sizeof(((struct qunit_data *)0)->padding) == 8, "found %lld\n",
                  (long long)(int)sizeof(((struct qunit_data *)0)->padding));
 
+        /* Checks for struct quota_body */
+        LASSERTF((int)sizeof(struct quota_body) == 112, "found %lld\n",
+                 (long long)(int)sizeof(struct quota_body));
+        LASSERTF((int)offsetof(struct quota_body, qb_fid) == 0, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_fid));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_fid) == 16, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_fid));
+        LASSERTF((int)offsetof(struct quota_body, qb_id) == 16, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_id));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_id) == 16, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_id));
+        LASSERTF((int)offsetof(struct quota_body, qb_flags) == 32, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_flags));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_flags) == 4, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_flags));
+        LASSERTF((int)offsetof(struct quota_body, qb_padding) == 36, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_padding));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_padding) == 4, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_padding));
+        LASSERTF((int)offsetof(struct quota_body, qb_count) == 40, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_count));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_count) == 8, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_count));
+        LASSERTF((int)offsetof(struct quota_body, qb_usage) == 48, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_usage));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_usage) == 8, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_usage));
+        LASSERTF((int)offsetof(struct quota_body, qb_slv_ver) == 56, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_slv_ver));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_slv_ver) == 8, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_slv_ver));
+        LASSERTF((int)offsetof(struct quota_body, qb_lockh) == 64, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_lockh));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_lockh) == 8, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_lockh));
+        LASSERTF((int)offsetof(struct quota_body, qb_glb_lockh) == 72, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_glb_lockh));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_glb_lockh) == 8, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_glb_lockh));
+        LASSERTF((int)offsetof(struct quota_body, qb_padding1[4]) == 112, "found %lld\n",
+                 (long long)(int)offsetof(struct quota_body, qb_padding1[4]));
+        LASSERTF((int)sizeof(((struct quota_body *)0)->qb_padding1[4]) == 8, "found %lld\n",
+                 (long long)(int)sizeof(((struct quota_body *)0)->qb_padding1[4]));
+
         /* Checks for struct quota_adjust_qunit */
         LASSERTF((int)sizeof(struct quota_adjust_qunit) == 32, "found %lld\n",
                  (long long)(int)sizeof(struct quota_adjust_qunit));