X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fquota%2Fquota_interface.c;h=53d450c6cc8ef04ccc3c6560b1905d4a94e0eb17;hp=3c3b16f2632008a346d582943f05e13da2d7ddce;hb=bd12686ac514c0379eaf2834544b7562739f11f2;hpb=62ef9c949753efb9535fa5b1eb2eb38ec663917f diff --git a/lustre/quota/quota_interface.c b/lustre/quota/quota_interface.c index 3c3b16f..53d450c 100644 --- a/lustre/quota/quota_interface.c +++ b/lustre/quota/quota_interface.c @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -26,17 +24,16 @@ * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2011, 2012, Whamcloud, Inc. */ /* * This file is part of Lustre, http://www.lustre.org/ * Lustre is a trademark of Sun Microsystems, Inc. */ -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif #define DEBUG_SUBSYSTEM S_LQUOTA #ifdef __KERNEL__ @@ -45,7 +42,6 @@ # include # include # include -# include # include # include # include @@ -65,10 +61,8 @@ #ifdef __KERNEL__ -#ifdef HAVE_QUOTA_SUPPORT - static cfs_time_t last_print = 0; -static spinlock_t last_print_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(last_print_lock); static int filter_quota_setup(struct obd_device *obd) { @@ -76,9 +70,9 @@ static int filter_quota_setup(struct obd_device *obd) struct obd_device_target *obt = &obd->u.obt; ENTRY; - init_rwsem(&obt->obt_rwsem); + cfs_init_rwsem(&obt->obt_rwsem); obt->obt_qfmt = LUSTRE_QUOTA_V2; - sema_init(&obt->obt_quotachecking, 1); + cfs_sema_init(&obt->obt_quotachecking, 1); rc = qctxt_init(obd, NULL); if (rc) CERROR("initialize quota context failed! (rc:%d)\n", rc); @@ -103,14 +97,14 @@ static int filter_quota_setinfo(struct obd_device *obd, void *data) LASSERT(imp != NULL); /* setup the quota context import */ - spin_lock(&qctxt->lqc_lock); + cfs_spin_lock(&qctxt->lqc_lock); if (qctxt->lqc_import != NULL) { - spin_unlock(&qctxt->lqc_lock); + cfs_spin_unlock(&qctxt->lqc_lock); if (qctxt->lqc_import == imp) CDEBUG(D_WARNING, "%s: lqc_import(%p) of obd(%p) was " "activated already.\n", obd->obd_name, imp, obd); else - CDEBUG(D_ERROR, "%s: lqc_import(%p:%p) of obd(%p) was " + CERROR("%s: lqc_import(%p:%p) of obd(%p) was " "activated by others.\n", obd->obd_name, qctxt->lqc_import, imp, obd); } else { @@ -120,7 +114,7 @@ static int filter_quota_setinfo(struct obd_device *obd, void *data) imp->imp_connect_data.ocd_connect_flags |= (exp->exp_connect_flags & (OBD_CONNECT_QUOTA64 | OBD_CONNECT_CHANGE_QS)); - spin_unlock(&qctxt->lqc_lock); + cfs_spin_unlock(&qctxt->lqc_lock); CDEBUG(D_QUOTA, "%s: lqc_import(%p) of obd(%p) is reactivated " "now.\n", obd->obd_name, imp, obd); @@ -146,16 +140,16 @@ static int filter_quota_clearinfo(struct obd_export *exp, struct obd_device *obd /* when exp->exp_imp_reverse is destroyed, the corresponding lqc_import * should be invalid b=12374 */ - spin_lock(&qctxt->lqc_lock); + cfs_spin_lock(&qctxt->lqc_lock); if (qctxt->lqc_import == imp) { qctxt->lqc_import = NULL; - spin_unlock(&qctxt->lqc_lock); + cfs_spin_unlock(&qctxt->lqc_lock); CDEBUG(D_QUOTA, "%s: lqc_import(%p) of obd(%p) is invalid now.\n", obd->obd_name, imp, obd); ptlrpc_cleanup_imp(imp); dqacq_interrupt(qctxt); } else { - spin_unlock(&qctxt->lqc_lock); + cfs_spin_unlock(&qctxt->lqc_lock); } RETURN(0); } @@ -190,10 +184,8 @@ static int filter_quota_getflag(struct obd_device *obd, struct obdo *oa) RETURN(0); OBD_ALLOC_PTR(oqctl); - if (!oqctl) { - CERROR("Not enough memory!"); + if (!oqctl) RETURN(-ENOMEM); - } /* set over quota flags for a uid/gid */ oa->o_valid |= OBD_MD_FLUSRQUOTA | OBD_MD_FLGRPQUOTA; @@ -202,17 +194,29 @@ static int filter_quota_getflag(struct obd_device *obd, struct obdo *oa) for (cnt = 0; cnt < MAXQUOTAS; cnt++) { struct lustre_qunit_size *lqs = NULL; + /* check if quota is enabled */ + if (!ll_sb_has_quota_active(obt->obt_sb, cnt)) + continue; + lqs = quota_search_lqs(LQS_KEY(cnt, GET_OA_ID(cnt, oa)), qctxt, 0); - if (lqs == NULL || IS_ERR(lqs)) { + if (IS_ERR(lqs)) { rc = PTR_ERR(lqs); + CDEBUG(D_QUOTA, "search lqs for %s %d failed, " + "(rc = %d)\n", + cnt == USRQUOTA ? "user" : "group", + GET_OA_ID(cnt, oa), rc); break; + } else if (lqs == NULL) { + /* continue to check group quota if the file's owner + * doesn't have quota limit. LU-530 */ + continue; } else { - spin_lock(&lqs->lqs_lock); + cfs_spin_lock(&lqs->lqs_lock); if (lqs->lqs_bunit_sz <= qctxt->lqc_sync_blk) { oa->o_flags |= (cnt == USRQUOTA) ? OBD_FL_NO_USRQUOTA : OBD_FL_NO_GRPQUOTA; - spin_unlock(&lqs->lqs_lock); + cfs_spin_unlock(&lqs->lqs_lock); CDEBUG(D_QUOTA, "set sync flag: bunit(%lu), " "sync_blk(%d)\n", lqs->lqs_bunit_sz, qctxt->lqc_sync_blk); @@ -220,7 +224,7 @@ static int filter_quota_getflag(struct obd_device *obd, struct obdo *oa) lqs_putref(lqs); continue; } - spin_unlock(&lqs->lqs_lock); + cfs_spin_unlock(&lqs->lqs_lock); /* this is for quota_search_lqs */ lqs_putref(lqs); } @@ -236,14 +240,22 @@ static int filter_quota_getflag(struct obd_device *obd, struct obdo *oa) rc = err; oa->o_valid &= ~((cnt == USRQUOTA) ? OBD_MD_FLUSRQUOTA : OBD_MD_FLGRPQUOTA); + CDEBUG(D_QUOTA, "fsfilt getquota for %s %d failed, " + "(rc = %d)\n", + cnt == USRQUOTA ? "user" : "group", + cnt == USRQUOTA ? oa->o_uid : oa->o_gid, err); continue; } if (oqctl->qc_dqblk.dqb_bhardlimit && (toqb(oqctl->qc_dqblk.dqb_curspace) >= - oqctl->qc_dqblk.dqb_bhardlimit)) + oqctl->qc_dqblk.dqb_bhardlimit)) { oa->o_flags |= (cnt == USRQUOTA) ? OBD_FL_NO_USRQUOTA : OBD_FL_NO_GRPQUOTA; + CDEBUG(D_QUOTA, "out of quota for %s %d\n", + cnt == USRQUOTA ? "user" : "group", + cnt == USRQUOTA ? oa->o_uid : oa->o_gid); + } } OBD_FREE_PTR(oqctl); RETURN(rc); @@ -264,12 +276,12 @@ static int quota_check_common(struct obd_device *obd, const unsigned int id[], int rc = 0, rc2[2] = { 0, 0 }; ENTRY; - spin_lock(&qctxt->lqc_lock); + cfs_spin_lock(&qctxt->lqc_lock); if (!qctxt->lqc_valid){ - spin_unlock(&qctxt->lqc_lock); + cfs_spin_unlock(&qctxt->lqc_lock); RETURN(rc); } - spin_unlock(&qctxt->lqc_lock); + cfs_spin_unlock(&qctxt->lqc_lock); for (i = 0; i < MAXQUOTAS; i++) { struct lustre_qunit_size *lqs = NULL; @@ -280,6 +292,10 @@ static int quota_check_common(struct obd_device *obd, const unsigned int id[], QDATA_SET_BLK(&qdata[i]); qdata[i].qd_count = 0; + /* check if quota is enabled */ + if (!ll_sb_has_quota_active(qctxt->lqc_sb, i)) + continue; + /* ignore root user */ if (qdata[i].qd_id == 0 && !QDATA_IS_GRP(&qdata[i])) continue; @@ -297,7 +313,7 @@ static int quota_check_common(struct obd_device *obd, const unsigned int id[], } rc2[i] = compute_remquota(obd, qctxt, &qdata[i], isblk); - spin_lock(&lqs->lqs_lock); + cfs_spin_lock(&lqs->lqs_lock); if (!cycle) { if (isblk) { pending[i] = count * CFS_PAGE_SIZE; @@ -307,14 +323,17 @@ static int quota_check_common(struct obd_device *obd, const unsigned int id[], if (inode) { mb = pending[i]; rc = fsfilt_get_mblk(obd, qctxt->lqc_sb, - &mb, inode,frags); + &mb, inode, + frags); if (rc) - CDEBUG(D_ERROR, - "can't get extra " - "meta blocks.\n"); + CERROR("%s: can't get extra " + "meta blocks\n", + obd->obd_name); else pending[i] += mb; } + LASSERTF(pending[i] >= 0, "pending is not valid" + ", count=%d, mb=%d\n", count, mb); lqs->lqs_bwrite_pending += pending[i]; } else { pending[i] = count; @@ -352,7 +371,7 @@ static int quota_check_common(struct obd_device *obd, const unsigned int id[], rc2[i] = QUOTA_RET_ACQUOTA; } - spin_unlock(&lqs->lqs_lock); + cfs_spin_unlock(&lqs->lqs_lock); if (lqs->lqs_blk_rec < 0 && qdata[i].qd_count < @@ -384,6 +403,9 @@ int quota_is_set(struct obd_device *obd, const unsigned int id[], int flag) RETURN(0); for (i = 0; i < MAXQUOTAS; i++) { + /* check if quota is enabled */ + if (!ll_sb_has_quota_active(obd->u.obt.obt_qctxt.lqc_sb, i)) + continue; lqs = quota_search_lqs(LQS_KEY(i, id[i]), &obd->u.obt.obt_qctxt, 0); if (lqs && !IS_ERR(lqs)) { @@ -396,8 +418,9 @@ int quota_is_set(struct obd_device *obd, const unsigned int id[], int flag) return q_set; } -static int quota_chk_acq_common(struct obd_device *obd, const unsigned int id[], - int pending[], int count, quota_acquire acquire, +static int quota_chk_acq_common(struct obd_device *obd, struct obd_export *exp, + const unsigned int id[], int pending[], + int count, quota_acquire acquire, struct obd_trans_info *oti, int isblk, struct inode *inode, int frags) { @@ -412,33 +435,45 @@ static int quota_chk_acq_common(struct obd_device *obd, const unsigned int id[], if (!quota_is_set(obd, id, isblk ? QB_SET : QI_SET)) RETURN(0); + if (isblk && (exp->exp_failed || exp->exp_abort_active_req)) + /* If the client has been evicted or if it + * timed out and tried to reconnect already, + * abort the request immediately */ + RETURN(-ENOTCONN); + CDEBUG(D_QUOTA, "check quota for %s\n", obd->obd_name); pending[USRQUOTA] = pending[GRPQUOTA] = 0; /* Unfortunately, if quota master is too busy to handle the * pre-dqacq in time and quota hash on ost is used up, we * have to wait for the completion of in flight dqacq/dqrel, * in order to get enough quota for write b=12588 */ - do_gettimeofday(&work_start); + cfs_gettimeofday(&work_start); while ((rc = quota_check_common(obd, id, pending, count, cycle, isblk, inode, frags)) & QUOTA_RET_ACQUOTA) { - - spin_lock(&qctxt->lqc_lock); - if (!qctxt->lqc_import && oti) { - spin_unlock(&qctxt->lqc_lock); - - LASSERT(oti && oti->oti_thread && - oti->oti_thread->t_watchdog); - - lc_watchdog_disable(oti->oti_thread->t_watchdog); - CDEBUG(D_QUOTA, "sleep for quota master\n"); - l_wait_event(qctxt->lqc_wait_for_qmaster, check_qm(qctxt), - &lwi); - CDEBUG(D_QUOTA, "wake up when quota master is back\n"); - lc_watchdog_touch(oti->oti_thread->t_watchdog, - GET_TIMEOUT(oti->oti_thread->t_svc)); + struct ptlrpc_thread *thr = oti != NULL ? + oti->oti_thread : NULL; + + cfs_spin_lock(&qctxt->lqc_lock); + if (!qctxt->lqc_import && oti != NULL) { + cfs_spin_unlock(&qctxt->lqc_lock); + + LASSERT(thr != NULL); + /* The recovery thread doesn't have watchdog + * attached. LU-369 */ + if (thr->t_watchdog != NULL) + lc_watchdog_disable(thr->t_watchdog); + CDEBUG(D_QUOTA, "sleep for quota master\n"); + l_wait_event(qctxt->lqc_wait_for_qmaster, + check_qm(qctxt), &lwi); + + CDEBUG(D_QUOTA, "wake up when quota master is back\n"); + if (thr->t_watchdog != NULL) { + lc_watchdog_touch(thr->t_watchdog, + ptlrpc_server_get_timeout(thr->t_svcpt)); + } } else { - spin_unlock(&qctxt->lqc_lock); + cfs_spin_unlock(&qctxt->lqc_lock); } cycle++; @@ -468,49 +503,56 @@ static int quota_chk_acq_common(struct obd_device *obd, const unsigned int id[], break; } + if (isblk && (exp->exp_failed || exp->exp_abort_active_req)) + /* The client has been evicted or tried to + * to reconnect already, abort the request */ + RETURN(-ENOTCONN); + /* -EBUSY and others, wait a second and try again */ if (rc < 0) { cfs_waitq_t waitq; struct l_wait_info lwi; - if (oti && oti->oti_thread && oti->oti_thread->t_watchdog) - lc_watchdog_touch(oti->oti_thread->t_watchdog, - GET_TIMEOUT(oti->oti_thread->t_svc)); + if (thr != NULL && thr->t_watchdog != NULL) + lc_watchdog_touch(thr->t_watchdog, + ptlrpc_server_get_timeout(thr->t_svcpt)); CDEBUG(D_QUOTA, "rc: %d, count_err: %d\n", rc, count_err++); - init_waitqueue_head(&waitq); + cfs_waitq_init(&waitq); lwi = LWI_TIMEOUT(cfs_time_seconds(min(cycle, 10)), NULL, NULL); l_wait_event(waitq, 0, &lwi); } if (rc < 0 || cycle % 10 == 0) { - spin_lock(&last_print_lock); + cfs_spin_lock(&last_print_lock); if (last_print == 0 || cfs_time_before((last_print + cfs_time_seconds(30)), cfs_time_current())) { last_print = cfs_time_current(); - spin_unlock(&last_print_lock); + cfs_spin_unlock(&last_print_lock); CWARN("still haven't managed to acquire quota " "space from the quota master after %d " "retries (err=%d, rc=%d)\n", cycle, count_err - 1, rc); } else { - spin_unlock(&last_print_lock); + cfs_spin_unlock(&last_print_lock); } } CDEBUG(D_QUOTA, "recheck quota with rc: %d, cycle: %d\n", rc, cycle); } - do_gettimeofday(&work_end); + cfs_gettimeofday(&work_end); timediff = cfs_timeval_sub(&work_end, &work_start, NULL); lprocfs_counter_add(qctxt->lqc_stats, isblk ? LQUOTA_WAIT_FOR_CHK_BLK : LQUOTA_WAIT_FOR_CHK_INO, timediff); + if (rc > 0) + rc = 0; RETURN(rc); } @@ -534,7 +576,7 @@ static int quota_pending_commit(struct obd_device *obd, const unsigned int id[], if (!ll_sb_any_quota_active(qctxt->lqc_sb)) RETURN(0); - do_gettimeofday(&work_start); + cfs_gettimeofday(&work_start); for (i = 0; i < MAXQUOTAS; i++) { struct lustre_qunit_size *lqs = NULL; @@ -561,7 +603,7 @@ static int quota_pending_commit(struct obd_device *obd, const unsigned int id[], continue; } - spin_lock(&lqs->lqs_lock); + cfs_spin_lock(&lqs->lqs_lock); if (isblk) { LASSERTF(lqs->lqs_bwrite_pending >= pending[i], "there are too many blocks! [id %u] [%c] " @@ -583,14 +625,14 @@ static int quota_pending_commit(struct obd_device *obd, const unsigned int id[], obd->obd_name, isblk ? lqs->lqs_bwrite_pending : lqs->lqs_iwrite_pending, i, pending[i], isblk); - spin_unlock(&lqs->lqs_lock); + cfs_spin_unlock(&lqs->lqs_lock); /* for quota_search_lqs in pending_commit */ lqs_putref(lqs); /* for quota_search_lqs in quota_check */ lqs_putref(lqs); } - do_gettimeofday(&work_end); + cfs_gettimeofday(&work_end); timediff = cfs_timeval_sub(&work_end, &work_start, NULL); lprocfs_counter_add(qctxt->lqc_stats, isblk ? LQUOTA_WAIT_FOR_COMMIT_BLK : @@ -623,15 +665,16 @@ static int mds_quota_setup(struct obd_device *obd) RETURN(0); } - init_rwsem(&obt->obt_rwsem); + cfs_init_rwsem(&obt->obt_rwsem); obt->obt_qfmt = LUSTRE_QUOTA_V2; mds->mds_quota_info.qi_version = LUSTRE_QUOTA_V2; - sema_init(&obt->obt_quotachecking, 1); + cfs_sema_init(&obt->obt_quotachecking, 1); /* initialize quota master and quota context */ - sema_init(&mds->mds_qonoff_sem, 1); + cfs_init_rwsem(&mds->mds_qonoff_sem); rc = qctxt_init(obd, dqacq_handler); if (rc) { - CERROR("initialize quota context failed! (rc:%d)\n", rc); + CERROR("%s: initialize quota context failed! (rc:%d)\n", + obd->obd_name, rc); RETURN(rc); } mds->mds_quota = 1; @@ -676,9 +719,9 @@ static int mds_quota_fs_cleanup(struct obd_device *obd) memset(&oqctl, 0, sizeof(oqctl)); oqctl.qc_type = UGQUOTA; - down(&mds->mds_qonoff_sem); + cfs_down_write(&mds->mds_qonoff_sem); mds_admin_quota_off(obd, &oqctl); - up(&mds->mds_qonoff_sem); + cfs_up_write(&mds->mds_qonoff_sem); RETURN(0); } @@ -693,220 +736,6 @@ static int quota_acquire_common(struct obd_device *obd, const unsigned int id[], RETURN(rc); } -#endif /* HAVE_QUOTA_SUPPORT */ -#endif /* __KERNEL__ */ - -struct osc_quota_info { - struct list_head oqi_hash; /* hash list */ - struct client_obd *oqi_cli; /* osc obd */ - unsigned int oqi_id; /* uid/gid of a file */ - short oqi_type; /* quota type */ -}; - -spinlock_t qinfo_list_lock = SPIN_LOCK_UNLOCKED; - -static struct list_head qinfo_hash[NR_DQHASH]; -/* SLAB cache for client quota context */ -cfs_mem_cache_t *qinfo_cachep = NULL; - -static inline int hashfn(struct client_obd *cli, unsigned long id, int type) - __attribute__((__const__)); - -static inline int hashfn(struct client_obd *cli, unsigned long id, int type) -{ - unsigned long tmp = ((unsigned long)cli>>6) ^ id; - tmp = (tmp * (MAXQUOTAS - type)) % NR_DQHASH; - return tmp; -} - -/* caller must hold qinfo_list_lock */ -static inline void insert_qinfo_hash(struct osc_quota_info *oqi) -{ - struct list_head *head = qinfo_hash + - hashfn(oqi->oqi_cli, oqi->oqi_id, oqi->oqi_type); - - LASSERT_SPIN_LOCKED(&qinfo_list_lock); - list_add(&oqi->oqi_hash, head); -} - -/* caller must hold qinfo_list_lock */ -static inline void remove_qinfo_hash(struct osc_quota_info *oqi) -{ - LASSERT_SPIN_LOCKED(&qinfo_list_lock); - list_del_init(&oqi->oqi_hash); -} - -/* caller must hold qinfo_list_lock */ -static inline struct osc_quota_info *find_qinfo(struct client_obd *cli, - unsigned int id, int type) -{ - unsigned int hashent = hashfn(cli, id, type); - struct osc_quota_info *oqi; - ENTRY; - - LASSERT_SPIN_LOCKED(&qinfo_list_lock); - list_for_each_entry(oqi, &qinfo_hash[hashent], oqi_hash) { - if (oqi->oqi_cli == cli && - oqi->oqi_id == id && oqi->oqi_type == type) - return oqi; - } - RETURN(NULL); -} - -static struct osc_quota_info *alloc_qinfo(struct client_obd *cli, - unsigned int id, int type) -{ - struct osc_quota_info *oqi; - ENTRY; - - OBD_SLAB_ALLOC(oqi, qinfo_cachep, CFS_ALLOC_STD, sizeof(*oqi)); - if(!oqi) - RETURN(NULL); - - CFS_INIT_LIST_HEAD(&oqi->oqi_hash); - oqi->oqi_cli = cli; - oqi->oqi_id = id; - oqi->oqi_type = type; - - RETURN(oqi); -} - -static void free_qinfo(struct osc_quota_info *oqi) -{ - OBD_SLAB_FREE(oqi, qinfo_cachep, sizeof(*oqi)); -} - -int osc_quota_chkdq(struct client_obd *cli, const unsigned int qid[]) -{ - unsigned int id; - int cnt, rc = QUOTA_OK; - ENTRY; - - spin_lock(&qinfo_list_lock); - for (cnt = 0; cnt < MAXQUOTAS; cnt++) { - struct osc_quota_info *oqi = NULL; - - id = (cnt == USRQUOTA) ? qid[USRQUOTA] : qid[GRPQUOTA]; - oqi = find_qinfo(cli, id, cnt); - if (oqi) { - rc = NO_QUOTA; - break; - } - } - spin_unlock(&qinfo_list_lock); - - RETURN(rc); -} - -int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], - obd_flag valid, obd_flag flags) -{ - unsigned int id; - obd_flag noquota; - int cnt, rc = 0; - ENTRY; - - - for (cnt = 0; cnt < MAXQUOTAS; cnt++) { - struct osc_quota_info *oqi, *old; - - if (!(valid & ((cnt == USRQUOTA) ? - OBD_MD_FLUSRQUOTA : OBD_MD_FLGRPQUOTA))) - continue; - - id = (cnt == USRQUOTA) ? qid[USRQUOTA] : qid[GRPQUOTA]; - noquota = (cnt == USRQUOTA) ? - (flags & OBD_FL_NO_USRQUOTA) : (flags & OBD_FL_NO_GRPQUOTA); - - oqi = alloc_qinfo(cli, id, cnt); - if (oqi) { - spin_lock(&qinfo_list_lock); - - old = find_qinfo(cli, id, cnt); - if (old && !noquota) - remove_qinfo_hash(old); - else if (!old && noquota) - insert_qinfo_hash(oqi); - - spin_unlock(&qinfo_list_lock); - - if (old || !noquota) - free_qinfo(oqi); - if (old && !noquota) - free_qinfo(old); - } else { - CERROR("not enough mem!\n"); - rc = -ENOMEM; - break; - } - } - - RETURN(rc); -} - -int osc_quota_cleanup(struct obd_device *obd) -{ - struct client_obd *cli = &obd->u.cli; - struct osc_quota_info *oqi, *n; - int i; - ENTRY; - - spin_lock(&qinfo_list_lock); - for (i = 0; i < NR_DQHASH; i++) { - list_for_each_entry_safe(oqi, n, &qinfo_hash[i], oqi_hash) { - if (oqi->oqi_cli != cli) - continue; - remove_qinfo_hash(oqi); - free_qinfo(oqi); - } - } - spin_unlock(&qinfo_list_lock); - - RETURN(0); -} - -int osc_quota_init(void) -{ - int i; - ENTRY; - - LASSERT(qinfo_cachep == NULL); - qinfo_cachep = cfs_mem_cache_create("osc_quota_info", - sizeof(struct osc_quota_info), - 0, 0); - if (!qinfo_cachep) - RETURN(-ENOMEM); - - for (i = 0; i < NR_DQHASH; i++) - CFS_INIT_LIST_HEAD(qinfo_hash + i); - - RETURN(0); -} - -int osc_quota_exit(void) -{ - struct osc_quota_info *oqi, *n; - int i, rc; - ENTRY; - - spin_lock(&qinfo_list_lock); - for (i = 0; i < NR_DQHASH; i++) { - list_for_each_entry_safe(oqi, n, &qinfo_hash[i], oqi_hash) { - remove_qinfo_hash(oqi); - free_qinfo(oqi); - } - } - spin_unlock(&qinfo_list_lock); - - rc = cfs_mem_cache_destroy(qinfo_cachep); - LASSERTF(rc == 0, "couldn't destory qinfo_cachep slab\n"); - qinfo_cachep = NULL; - - RETURN(0); -} - -#ifdef __KERNEL__ -#ifdef HAVE_QUOTA_SUPPORT quota_interface_t mds_quota_interface = { .quota_init = mds_quota_init, .quota_exit = mds_quota_exit, @@ -938,45 +767,11 @@ quota_interface_t filter_quota_interface = { .quota_adjust_qunit = filter_quota_adjust_qunit, .quota_pending_commit = quota_pending_commit, }; -#endif -#endif /* __KERNEL__ */ - -quota_interface_t mdc_quota_interface = { - .quota_ctl = client_quota_ctl, - .quota_check = client_quota_check, - .quota_poll_check = client_quota_poll_check, -}; - -quota_interface_t lmv_quota_interface = { - .quota_ctl = lmv_quota_ctl, - .quota_check = lmv_quota_check, -}; - -quota_interface_t osc_quota_interface = { - .quota_ctl = client_quota_ctl, - .quota_check = client_quota_check, - .quota_poll_check = client_quota_poll_check, - .quota_init = osc_quota_init, - .quota_exit = osc_quota_exit, - .quota_chkdq = osc_quota_chkdq, - .quota_setdq = osc_quota_setdq, - .quota_cleanup = osc_quota_cleanup, - .quota_adjust_qunit = client_quota_adjust_qunit, -}; - -quota_interface_t lov_quota_interface = { - .quota_ctl = lov_quota_ctl, - .quota_check = lov_quota_check, - .quota_adjust_qunit = lov_quota_adjust_qunit, -}; - -#ifdef __KERNEL__ cfs_proc_dir_entry_t *lquota_type_proc_dir = NULL; -static int __init init_lustre_quota(void) +int init_lustre_quota(void) { -#ifdef HAVE_QUOTA_SUPPORT int rc = 0; lquota_type_proc_dir = lprocfs_register(OBD_LQUOTA_DEVICENAME, @@ -994,21 +789,12 @@ static int __init init_lustre_quota(void) PORTAL_SYMBOL_REGISTER(filter_quota_interface); PORTAL_SYMBOL_REGISTER(mds_quota_interface); -#endif - PORTAL_SYMBOL_REGISTER(mdc_quota_interface); - PORTAL_SYMBOL_REGISTER(lmv_quota_interface); - PORTAL_SYMBOL_REGISTER(osc_quota_interface); - PORTAL_SYMBOL_REGISTER(lov_quota_interface); + return 0; } -static void /*__exit*/ exit_lustre_quota(void) +void exit_lustre_quota(void) { - PORTAL_SYMBOL_UNREGISTER(mdc_quota_interface); - PORTAL_SYMBOL_UNREGISTER(lmv_quota_interface); - PORTAL_SYMBOL_UNREGISTER(osc_quota_interface); - PORTAL_SYMBOL_UNREGISTER(lov_quota_interface); -#ifdef HAVE_QUOTA_SUPPORT PORTAL_SYMBOL_UNREGISTER(filter_quota_interface); PORTAL_SYMBOL_UNREGISTER(mds_quota_interface); @@ -1016,21 +802,8 @@ static void /*__exit*/ exit_lustre_quota(void) if (lquota_type_proc_dir) lprocfs_remove(&lquota_type_proc_dir); -#endif } -MODULE_AUTHOR("Sun Microsystems, Inc. "); -MODULE_DESCRIPTION("Lustre Quota"); -MODULE_LICENSE("GPL"); - -cfs_module(lquota, "1.0.0", init_lustre_quota, exit_lustre_quota); - -#ifdef HAVE_QUOTA_SUPPORT EXPORT_SYMBOL(mds_quota_interface); EXPORT_SYMBOL(filter_quota_interface); -#endif -EXPORT_SYMBOL(mdc_quota_interface); -EXPORT_SYMBOL(lmv_quota_interface); -EXPORT_SYMBOL(osc_quota_interface); -EXPORT_SYMBOL(lov_quota_interface); #endif /* __KERNEL */