예제 #1
0
파일: quota_check.c 프로젝트: DCteam/lustre
static int target_quotacheck_thread(void *data)
{
        struct quotacheck_thread_args *qta = data;
        struct obd_export *exp;
        struct obd_device *obd;
        struct obd_quotactl *oqctl;
        struct lvfs_run_ctxt saved;
        int rc;

        cfs_daemonize_ctxt("quotacheck");

        exp = qta->qta_exp;
        obd = qta->qta_obd;
        oqctl = &qta->qta_oqctl;

        push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);

        rc = fsfilt_quotacheck(obd, qta->qta_sb, oqctl);
        if (rc)
                CERROR("%s: fsfilt_quotacheck: %d\n", obd->obd_name, rc);

        pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);

        rc = target_quotacheck_callback(exp, oqctl);
        class_export_put(exp);
        cfs_up(qta->qta_sem);
        OBD_FREE_PTR(qta);
        return rc;
}
예제 #2
0
파일: mdt_capa.c 프로젝트: hpc/lustre
static int mdt_ck_thread_main(void *args)
{
        struct mdt_device      *mdt = args;
        struct ptlrpc_thread   *thread = &mdt->mdt_ck_thread;
        struct lustre_capa_key *bkey = &mdt->mdt_capa_keys[0],
                               *rkey = &mdt->mdt_capa_keys[1];
        struct lustre_capa_key *tmp;
        struct lu_env           env;
        struct mdt_thread_info *info;
        struct md_device       *next;
        struct l_wait_info      lwi = { 0 };
        mdsno_t                 mdsnum;
        int                     rc;
        ENTRY;

        cfs_daemonize_ctxt("mdt_ck");
        cfs_block_allsigs();

        thread_set_flags(thread, SVC_RUNNING);
        cfs_waitq_signal(&thread->t_ctl_waitq);

        rc = lu_env_init(&env, LCT_MD_THREAD|LCT_REMEMBER|LCT_NOREF);
        if (rc)
                RETURN(rc);

        thread->t_env = &env;
        env.le_ctx.lc_thread = thread;
        env.le_ctx.lc_cookie = 0x1;

        info = lu_context_key_get(&env.le_ctx, &mdt_thread_key);
        LASSERT(info != NULL);

        tmp = &info->mti_capa_key;
        mdsnum = mdt_md_site(mdt)->ms_node_id;
        while (1) {
                l_wait_event(thread->t_ctl_waitq,
                             thread_is_stopping(thread) ||
                             thread_is_event(thread),
                             &lwi);

                if (thread_is_stopping(thread))
                        break;
                thread_clear_flags(thread, SVC_EVENT);

                if (cfs_time_before(cfs_time_current(), mdt->mdt_ck_expiry))
                        break;

                *tmp = *rkey;
                make_capa_key(tmp, mdsnum, rkey->lk_keyid);

                next = mdt->mdt_child;
                rc = next->md_ops->mdo_update_capa_key(&env, next, tmp);
                if (!rc) {
                        cfs_spin_lock(&capa_lock);
                        *bkey = *rkey;
                        *rkey = *tmp;
                        cfs_spin_unlock(&capa_lock);

                        rc = write_capa_keys(&env, mdt, mdt->mdt_capa_keys);
                        if (rc) {
                                cfs_spin_lock(&capa_lock);
                                *rkey = *bkey;
                                memset(bkey, 0, sizeof(*bkey));
                                cfs_spin_unlock(&capa_lock);
                        } else {
                                set_capa_key_expiry(mdt);
                                DEBUG_CAPA_KEY(D_SEC, rkey, "new");
                        }
                }
                if (rc) {
                        DEBUG_CAPA_KEY(D_ERROR, rkey, "update failed for");
                        /* next retry is in 300 sec */
                        mdt->mdt_ck_expiry = jiffies + 300 * CFS_HZ;
                }

                cfs_timer_arm(&mdt->mdt_ck_timer, mdt->mdt_ck_expiry);
                CDEBUG(D_SEC, "mdt_ck_timer %lu\n", mdt->mdt_ck_expiry);
        }
        lu_env_fini(&env);

        thread_set_flags(thread, SVC_STOPPED);
        cfs_waitq_signal(&thread->t_ctl_waitq);
        RETURN(0);
}