Whamcloud - gitweb
Land b_head_quota onto HEAD (20081116_0105)
[fs/lustre-release.git] / lustre / mdc / mdc_request.c
index 4789295..0ca79b9 100644 (file)
 #include <lustre_param.h>
 #include "mdc_internal.h"
 
-quota_interface_t *quota_interface;
-
 #define REQUEST_MINOR 244
 
+static quota_interface_t *quota_interface;
 extern quota_interface_t mdc_quota_interface;
 
 static int mdc_cleanup(struct obd_device *obd);
 
-static struct obd_capa *mdc_unpack_capa(struct ptlrpc_request *req,
-                                        const struct req_msg_field *field)
+int mdc_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req,
+                    const struct req_msg_field *field, struct obd_capa **oc)
 {
         struct lustre_capa *capa;
-        struct obd_capa *oc;
+        struct obd_capa *c;
+        ENTRY;
 
         /* swabbed already in mdc_enqueue */
         capa = req_capsule_server_get(&req->rq_pill, field);
         if (capa == NULL)
-                return ERR_PTR(-EPROTO);
+                RETURN(-EPROTO);
 
-        oc = alloc_capa(CAPA_SITE_CLIENT);
-        if (!oc) {
+        c = alloc_capa(CAPA_SITE_CLIENT);
+        if (IS_ERR(c)) {
                 CDEBUG(D_INFO, "alloc capa failed!\n");
-                return ERR_PTR(-ENOMEM);
+                RETURN(PTR_ERR(c));
+        } else {
+                c->c_capa = *capa;
+                *oc = c;
+                RETURN(0);
         }
-        oc->c_capa = *capa;
-
-        return oc;
 }
 
 /* Helper that implements most of mdc_getstatus and signal_completed_replay. */
@@ -116,12 +117,9 @@ static int send_getstatus(struct obd_import *imp, struct lu_fid *rootfid,
                 GOTO(out, rc = -EPROTO);
 
         if (body->valid & OBD_MD_FLMDSCAPA) {
-                struct obd_capa *oc;
-
-                oc = mdc_unpack_capa(req, &RMF_CAPA1);
-                if (IS_ERR(oc))
-                        GOTO(out, rc = PTR_ERR(oc));
-                *pc = oc;
+                rc = mdc_unpack_capa(NULL, req, &RMF_CAPA1, pc);
+                if (rc)
+                        GOTO(out, rc);
         }
 
         *rootfid = body->fid1;
@@ -584,28 +582,34 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req,
                 }
         }
         if (md->body->valid & OBD_MD_FLMDSCAPA) {
-                struct obd_capa *oc = mdc_unpack_capa(req, &RMF_CAPA1);
+                struct obd_capa *oc = NULL;
 
-                if (IS_ERR(oc))
-                        GOTO(out, rc = PTR_ERR(oc));
+                rc = mdc_unpack_capa(NULL, req, &RMF_CAPA1, &oc);
+                if (rc)
+                        GOTO(out, rc);
                 md->mds_capa = oc;
         }
 
         if (md->body->valid & OBD_MD_FLOSSCAPA) {
-                struct obd_capa *oc = mdc_unpack_capa(req, &RMF_CAPA2);
+                struct obd_capa *oc = NULL;
 
-                if (IS_ERR(oc))
-                        GOTO(out, rc = PTR_ERR(oc));
+                rc = mdc_unpack_capa(NULL, req, &RMF_CAPA2, &oc);
+                if (rc)
+                        GOTO(out, rc);
                 md->oss_capa = oc;
         }
 
         EXIT;
 out:
         if (rc) {
-                if (md->oss_capa)
-                        free_capa(md->oss_capa);
-                if (md->mds_capa)
-                        free_capa(md->mds_capa);
+                if (md->oss_capa) {
+                        capa_put(md->oss_capa);
+                        md->oss_capa = NULL;
+                }
+                if (md->mds_capa) {
+                        capa_put(md->mds_capa);
+                        md->mds_capa = NULL;
+                }
 #ifdef CONFIG_FS_POSIX_ACL
                 posix_acl_release(md->posix_acl);
 #endif
@@ -1689,6 +1693,8 @@ static int mdc_process_config(struct obd_device *obd, obd_count len, void *buf)
         default:
                 rc = class_process_proc_param(PARAM_MDC, lvars.obd_vars,
                                               lcfg, obd);
+               if (rc > 0)
+                       rc = 0;
                 break;
         }
         return(rc);
@@ -1862,13 +1868,12 @@ struct md_ops mdc_md_ops = {
         .m_set_open_replay_data = mdc_set_open_replay_data,
         .m_clear_open_replay_data = mdc_clear_open_replay_data,
         .m_renew_capa       = mdc_renew_capa,
+        .m_unpack_capa      = mdc_unpack_capa,
         .m_get_remote_perm  = mdc_get_remote_perm,
         .m_intent_getattr_async = mdc_intent_getattr_async,
         .m_revalidate_lock      = mdc_revalidate_lock
 };
 
-extern quota_interface_t mdc_quota_interface;
-
 int __init mdc_init(void)
 {
         int rc;