Whamcloud - gitweb
LU-6142 mdc: minor function cleanups.
[fs/lustre-release.git] / lustre / mdc / mdc_request.c
index 79c127c..2a5b2c7 100644 (file)
@@ -455,7 +455,9 @@ static int mdc_getxattr(struct obd_export *exp, const struct lu_fid *fid,
        LASSERT(obd_md_valid == OBD_MD_FLXATTR ||
                obd_md_valid == OBD_MD_FLXATTRLS);
 
-       /* The below message is checked in sanity-selinux.sh test_20d */
+       /* Message below is checked in sanity-selinux test_20d
+        * and sanity-sec test_49
+        */
        CDEBUG(D_INFO, "%s: get xattr '%s' for "DFID"\n",
               exp->exp_obd->obd_name, name, PFID(fid));
        rc = mdc_xattr_common(exp, &RQF_MDS_GETXATTR, fid, MDS_GETXATTR,
@@ -505,50 +507,10 @@ out:
        return rc;
 }
 
-#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
-static int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md)
-{
-        struct req_capsule     *pill = &req->rq_pill;
-        struct mdt_body        *body = md->body;
-        struct posix_acl       *acl;
-        void                   *buf;
-        int                     rc;
-        ENTRY;
-
-       if (!body->mbo_aclsize)
-               RETURN(0);
-
-       buf = req_capsule_server_sized_get(pill, &RMF_ACL, body->mbo_aclsize);
-
-       if (!buf)
-               RETURN(-EPROTO);
-
-       acl = posix_acl_from_xattr(&init_user_ns, buf, body->mbo_aclsize);
-       if (acl == NULL)
-               RETURN(0);
-        if (IS_ERR(acl)) {
-                rc = PTR_ERR(acl);
-                CERROR("convert xattr to acl: %d\n", rc);
-                RETURN(rc);
-        }
-
-        rc = posix_acl_valid(&init_user_ns, acl);
-        if (rc) {
-                CERROR("validate acl: %d\n", rc);
-                posix_acl_release(acl);
-                RETURN(rc);
-        }
-
-        md->posix_acl = acl;
-        RETURN(0);
-}
-#else
-#define mdc_unpack_acl(req, md) 0
-#endif
-
-int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req,
-                      struct obd_export *dt_exp, struct obd_export *md_exp,
-                      struct lustre_md *md)
+static int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req,
+                            struct obd_export *dt_exp,
+                            struct obd_export *md_exp,
+                            struct lustre_md *md)
 {
         struct req_capsule *pill = &req->rq_pill;
         int rc;
@@ -643,38 +605,30 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req,
                        }
                }
        }
-        rc = 0;
+       rc = 0;
 
        if (md->body->mbo_valid & OBD_MD_FLACL) {
                /* for ACL, it's possible that FLACL is set but aclsize is zero.
                 * only when aclsize != 0 there's an actual segment for ACL
                 * in reply buffer.
                 */
-               if (md->body->mbo_aclsize) {
-                        rc = mdc_unpack_acl(req, md);
-                        if (rc)
-                                GOTO(out, rc);
-#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
-                } else {
-                        md->posix_acl = NULL;
-#endif
-                }
-        }
+               rc = mdc_unpack_acl(req, md);
+               if (rc)
+                       GOTO(out, rc);
+       }
 
-        EXIT;
+       EXIT;
 out:
-        if (rc) {
-#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
-                posix_acl_release(md->posix_acl);
-#endif
-        }
-        return rc;
+       if (rc)
+               lmd_clear_acl(md);
+
+       return rc;
 }
 
-int mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md)
+static int mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md)
 {
-        ENTRY;
-        RETURN(0);
+       ENTRY;
+       RETURN(0);
 }
 
 void mdc_replay_open(struct ptlrpc_request *req)
@@ -684,6 +638,7 @@ void mdc_replay_open(struct ptlrpc_request *req)
        struct obd_client_handle *och;
        struct lustre_handle old_open_handle = { };
        struct mdt_body *body;
+       struct ldlm_reply *rep;
        ENTRY;
 
        if (mod == NULL) {
@@ -696,6 +651,11 @@ void mdc_replay_open(struct ptlrpc_request *req)
        body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
        LASSERT(body != NULL);
 
+       rep = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP);
+       if (rep != NULL && rep->lock_policy_res2 != 0)
+               DEBUG_REQ(D_ERROR, req, "Open request replay failed with %ld ",
+                       (long int)rep->lock_policy_res2);
+
        spin_lock(&req->rq_lock);
        och = mod->mod_och;
        if (och && och->och_open_handle.cookie)
@@ -853,18 +813,18 @@ static void mdc_free_open(struct md_open_data *mod)
                ptlrpc_request_committed(mod->mod_close_req, committed);
 }
 
-int mdc_clear_open_replay_data(struct obd_export *exp,
-                               struct obd_client_handle *och)
+static int mdc_clear_open_replay_data(struct obd_export *exp,
+                                     struct obd_client_handle *och)
 {
-        struct md_open_data *mod = och->och_mod;
-        ENTRY;
+       struct md_open_data *mod = och->och_mod;
+       ENTRY;
 
-        /**
-         * It is possible to not have \var mod in a case of eviction between
-         * lookup and ll_file_open().
-         **/
-        if (mod == NULL)
-                RETURN(0);
+       /**
+        * It is possible to not have \var mod in a case of eviction between
+        * lookup and ll_file_open().
+        **/
+       if (mod == NULL)
+               RETURN(0);
 
        LASSERT(mod != LP_POISON);
        LASSERT(mod->mod_open_req != NULL);
@@ -876,11 +836,11 @@ int mdc_clear_open_replay_data(struct obd_export *exp,
        spin_unlock(&mod->mod_open_req->rq_lock);
        mdc_free_open(mod);
 
-        mod->mod_och = NULL;
-        och->och_mod = NULL;
-        obd_mod_put(mod);
+       mod->mod_och = NULL;
+       och->och_mod = NULL;
+       obd_mod_put(mod);
 
-        RETURN(0);
+       RETURN(0);
 }
 
 static int mdc_close(struct obd_export *exp, struct md_op_data *op_data,
@@ -1822,6 +1782,7 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archive_count,
                *archive_array = archive_count;
 
        ptlrpc_request_set_replen(req);
+       req->rq_no_resend = 1;
 
        rc = mdc_queue_wait(req);
        GOTO(out, rc);
@@ -2991,13 +2952,15 @@ static int __init mdc_init(void)
                goto out_dev;
        }
 
-       rc = class_register_type(&mdc_obd_ops, &mdc_md_ops, true, NULL,
+       rc = class_register_type(&mdc_obd_ops, &mdc_md_ops, true,
                                 LUSTRE_MDC_NAME, &mdc_device_type);
        if (rc)
-               goto out_dev;
+               goto out_class;
 
        return 0;
 
+out_class:
+       class_destroy(mdc_changelog_class);
 out_dev:
        unregister_chrdev_region(mdc_changelog_dev, MDC_CHANGELOG_DEV_COUNT);
        return rc;
@@ -3005,9 +2968,10 @@ out_dev:
 
 static void __exit mdc_exit(void)
 {
+       class_unregister_type(LUSTRE_MDC_NAME);
        class_destroy(mdc_changelog_class);
        unregister_chrdev_region(mdc_changelog_dev, MDC_CHANGELOG_DEV_COUNT);
-       class_unregister_type(LUSTRE_MDC_NAME);
+       idr_destroy(&mdc_changelog_minor_idr);
 }
 
 MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");