Whamcloud - gitweb
LU-1842 quota: remove quota code
[fs/lustre-release.git] / lustre / mdd / mdd_dir.c
index f142139..ba8d76a 100644 (file)
@@ -835,34 +835,9 @@ static int mdd_link(const struct lu_env *env, struct md_object *tgt_obj,
         struct mdd_device *mdd = mdo2mdd(src_obj);
         struct dynlock_handle *dlh;
         struct thandle *handle;
-#ifdef HAVE_QUOTA_SUPPORT
-        struct obd_device *obd = mdd->mdd_obd_dev;
-        struct obd_export *exp = md_quota(env)->mq_exp;
-        struct mds_obd *mds = &obd->u.mds;
-        unsigned int qids[MAXQUOTAS] = { 0, 0 };
-        int quota_opc = 0, rec_pending[MAXQUOTAS] = { 0, 0 };
-#endif
         int rc;
         ENTRY;
 
-#ifdef HAVE_QUOTA_SUPPORT
-        if (mds->mds_quota) {
-                struct lu_attr *la_tmp = &mdd_env_info(env)->mti_la;
-
-                rc = mdd_la_get(env, mdd_tobj, la_tmp, BYPASS_CAPA);
-                if (!rc) {
-                        void *data = NULL;
-                        mdd_data_get(env, mdd_tobj, &data);
-                        quota_opc = FSFILT_OP_LINK;
-                        mdd_quota_wrapper(la_tmp, qids);
-                        /* get block quota for parent */
-                        lquota_chkquota(mds_quota_interface_ref, obd, exp,
-                                        qids, rec_pending, 1, NULL,
-                                        LQUOTA_FLAGS_BLK, data, 1);
-                }
-        }
-#endif
-
         handle = mdd_trans_create(env, mdd);
         if (IS_ERR(handle))
                 GOTO(out_pending, rc = PTR_ERR(handle));
@@ -923,16 +898,6 @@ out_trans:
 stop:
         mdd_trans_stop(env, mdd, rc, handle);
 out_pending:
-#ifdef HAVE_QUOTA_SUPPORT
-        if (quota_opc) {
-                lquota_pending_commit(mds_quota_interface_ref, obd,
-                                      qids, rec_pending, 1);
-                /* Trigger dqacq for the parent owner. If failed,
-                 * the next call for lquota_chkquota will process it. */
-                lquota_adjust(mds_quota_interface_ref, obd, 0, qids, rc,
-                              quota_opc);
-        }
-#endif
         return rc;
 }
 
@@ -1062,13 +1027,6 @@ static int mdd_unlink(const struct lu_env *env, struct md_object *pobj,
         struct mdd_device *mdd = mdo2mdd(pobj);
         struct dynlock_handle *dlh;
         struct thandle    *handle;
-#ifdef HAVE_QUOTA_SUPPORT
-        struct obd_device *obd = mdd->mdd_obd_dev;
-        struct mds_obd *mds = &obd->u.mds;
-        unsigned int qcids[MAXQUOTAS] = { 0, 0 };
-        unsigned int qpids[MAXQUOTAS] = { 0, 0 };
-        int quota_opc = 0;
-#endif
        int rc, is_dir;
         ENTRY;
 
@@ -1153,23 +1111,6 @@ static int mdd_unlink(const struct lu_env *env, struct md_object *pobj,
                rc = mdd_la_get(env, mdd_cobj, cattr,
                                mdd_object_capa(env, mdd_cobj));
 
-#ifdef HAVE_QUOTA_SUPPORT
-        if (mds->mds_quota && ma->ma_valid & MA_INODE &&
-            ma->ma_attr.la_nlink == 0) {
-                struct lu_attr *la_tmp = &mdd_env_info(env)->mti_la;
-
-                rc = mdd_la_get(env, mdd_pobj, la_tmp, BYPASS_CAPA);
-                if (!rc) {
-                        mdd_quota_wrapper(la_tmp, qpids);
-                        if (mdd_cobj->mod_count == 0) {
-                                quota_opc = FSFILT_OP_UNLINK;
-                                mdd_quota_wrapper(&ma->ma_attr, qcids);
-                        } else {
-                                quota_opc = FSFILT_OP_UNLINK_PARTIAL_PARENT;
-                        }
-                }
-        }
-#endif
         if (!is_dir)
                 /* old files may not have link ea; ignore errors */
                 mdd_links_rename(env, mdd_cobj, mdo2fid(mdd_pobj),
@@ -1209,13 +1150,6 @@ stop:
 #warning "please remove this after 2.4 (LOD/OSP)."
 #endif
 
-#ifdef HAVE_QUOTA_SUPPORT
-        if (quota_opc)
-                /* Trigger dqrel on the owner of child and parent. If failed,
-                 * the next call for lquota_chkquota will process it. */
-                lquota_adjust(mds_quota_interface_ref, obd, qcids, qpids, rc,
-                              quota_opc);
-#endif
         return rc;
 }
 
@@ -1626,17 +1560,6 @@ static int mdd_create(const struct lu_env *env, struct md_object *pobj,
         const char             *name = lname->ln_name;
         int rc, created = 0, initialized = 0, inserted = 0, lmm_size = 0;
         int got_def_acl = 0;
-#ifdef HAVE_QUOTA_SUPPORT
-        struct obd_device *obd = mdd->mdd_obd_dev;
-        struct obd_export *exp = md_quota(env)->mq_exp;
-        struct mds_obd *mds = &obd->u.mds;
-        unsigned int qcids[MAXQUOTAS] = { 0, 0 };
-        unsigned int qpids[MAXQUOTAS] = { 0, 0 };
-        int quota_opc = 0, block_count = 0;
-        int inode_pending[MAXQUOTAS] = { 0, 0 };
-        int block_pending[MAXQUOTAS] = { 0, 0 };
-        int parent_pending[MAXQUOTAS] = { 0, 0 };
-#endif
         ENTRY;
 
         /*
@@ -1684,45 +1607,6 @@ static int mdd_create(const struct lu_env *env, struct md_object *pobj,
         if (rc)
                 RETURN(rc);
 
-#ifdef HAVE_QUOTA_SUPPORT
-        if (mds->mds_quota) {
-               int same = 0;
-
-               quota_opc = FSFILT_OP_CREATE;
-               mdd_quota_wrapper(attr, qcids);
-               mdd_quota_wrapper(pattr, qpids);
-               /* get file quota for child */
-               lquota_chkquota(mds_quota_interface_ref, obd, exp,
-                               qcids, inode_pending, 1, NULL, 0, NULL,
-                               0);
-               switch (attr->la_mode & S_IFMT) {
-               case S_IFLNK:
-               case S_IFDIR:
-                       block_count = 2;
-                       break;
-               case S_IFREG:
-                       block_count = 1;
-                       break;
-               }
-               if (qcids[USRQUOTA] == qpids[USRQUOTA] &&
-                   qcids[GRPQUOTA] == qpids[GRPQUOTA]) {
-                       block_count += 1;
-                       same = 1;
-               }
-               /* get block quota for child and parent */
-               if (block_count)
-                       lquota_chkquota(mds_quota_interface_ref, obd,
-                                       exp, qcids, block_pending,
-                                       block_count, NULL,
-                                       LQUOTA_FLAGS_BLK, NULL, 0);
-               if (!same)
-                       lquota_chkquota(mds_quota_interface_ref, obd,
-                                       exp, qpids, parent_pending, 1,
-                                       NULL, LQUOTA_FLAGS_BLK, NULL,
-                                       0);
-        }
-#endif
-
         if (OBD_FAIL_CHECK(OBD_FAIL_MDS_DQACQ_NET))
                 GOTO(out_pending, rc = -EINPROGRESS);
 
@@ -1899,20 +1783,6 @@ out_free:
         /* finish lov_create stuff, free all temporary data */
         mdd_lov_create_finish(env, mdd, lmm, lmm_size, spec);
 out_pending:
-#ifdef HAVE_QUOTA_SUPPORT
-        if (quota_opc) {
-                lquota_pending_commit(mds_quota_interface_ref, obd, qcids,
-                                      inode_pending, 0);
-                lquota_pending_commit(mds_quota_interface_ref, obd, qcids,
-                                      block_pending, 1);
-                lquota_pending_commit(mds_quota_interface_ref, obd, qpids,
-                                      parent_pending, 1);
-                /* Trigger dqacq on the owner of child and parent. If failed,
-                 * the next call for lquota_chkquota will process it. */
-                lquota_adjust(mds_quota_interface_ref, obd, qcids, qpids, rc,
-                              quota_opc);
-        }
-#endif
         /* The child object shouldn't be cached anymore */
         if (rc)
                 cfs_set_bit(LU_OBJECT_HEARD_BANSHEE,
@@ -2139,48 +2009,11 @@ static int mdd_rename(const struct lu_env *env,
         int is_dir;
        unsigned cl_flags = 0;
         int rc, rc2;
-
-#ifdef HAVE_QUOTA_SUPPORT
-        struct obd_device *obd = mdd->mdd_obd_dev;
-        struct obd_export *exp = md_quota(env)->mq_exp;
-        struct mds_obd *mds = &obd->u.mds;
-        unsigned int qspids[MAXQUOTAS] = { 0, 0 };
-        unsigned int qtcids[MAXQUOTAS] = { 0, 0 };
-        unsigned int qtpids[MAXQUOTAS] = { 0, 0 };
-        int quota_copc = 0, quota_popc = 0;
-        int rec_pending[MAXQUOTAS] = { 0, 0 };
-#endif
         ENTRY;
 
         if (tobj)
                 mdd_tobj = md2mdd_obj(tobj);
 
-#ifdef HAVE_QUOTA_SUPPORT
-        if (mds->mds_quota) {
-                struct lu_attr *la_tmp = &mdd_env_info(env)->mti_la;
-
-                rc = mdd_la_get(env, mdd_spobj, la_tmp, BYPASS_CAPA);
-                if (!rc) {
-                        mdd_quota_wrapper(la_tmp, qspids);
-                        if (!tobj) {
-                                rc = mdd_la_get(env, mdd_tpobj, la_tmp,
-                                                BYPASS_CAPA);
-                                if (!rc) {
-                                        void *data = NULL;
-                                        mdd_data_get(env, mdd_tpobj, &data);
-                                        quota_popc = FSFILT_OP_LINK;
-                                        mdd_quota_wrapper(la_tmp, qtpids);
-                                        /* get block quota for target parent */
-                                        lquota_chkquota(mds_quota_interface_ref,
-                                                        obd, exp, qtpids,
-                                                        rec_pending, 1, NULL,
-                                                        LQUOTA_FLAGS_BLK,
-                                                        data, 1);
-                                }
-                        }
-                }
-        }
-#endif
         mdd_sobj = mdd_object_find(env, mdd, lf);
 
         handle = mdd_trans_create(env, mdd);
@@ -2339,15 +2172,8 @@ static int mdd_rename(const struct lu_env *env,
                ma->ma_attr = *tg_attr;
                ma->ma_valid |= MA_INODE;
 
-               if (so_attr->la_nlink == 0) {
+               if (so_attr->la_nlink == 0)
                        cl_flags |= CLF_RENAME_LAST;
-#ifdef HAVE_QUOTA_SUPPORT
-                       if (mds->mds_quota && mdd_tobj->mod_count == 0) {
-                               quota_copc = FSFILT_OP_UNLINK_PARTIAL_CHILD;
-                               mdd_quota_wrapper(&ma->ma_attr, qtcids);
-                       }
-#endif
-               }
         }
 
         la->la_valid = LA_CTIME | LA_MTIME;
@@ -2435,27 +2261,6 @@ stop:
         if (mdd_sobj)
                 mdd_object_put(env, mdd_sobj);
 out_pending:
-#ifdef HAVE_QUOTA_SUPPORT
-        if (mds->mds_quota) {
-                if (quota_popc)
-                        lquota_pending_commit(mds_quota_interface_ref, obd,
-                                              qtpids, rec_pending, 1);
-
-                if (quota_copc) {
-                        /* Trigger dqrel on the source owner of parent.
-                         * If failed, the next call for lquota_chkquota will
-                         * process it. */
-                        lquota_adjust(mds_quota_interface_ref, obd, 0, qspids, rc,
-                                      FSFILT_OP_UNLINK_PARTIAL_PARENT);
-
-                        /* Trigger dqrel on the target owner of child.
-                         * If failed, the next call for lquota_chkquota
-                         * will process it. */
-                        lquota_adjust(mds_quota_interface_ref, obd, qtcids,
-                                      qtpids, rc, quota_copc);
-                }
-        }
-#endif
         return rc;
 }