X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fquota%2Fquota_master.c;h=5ffdf8d01e5d24933c90556ad2dc0d8846341876;hb=3aa228ee8f7a2ad13e60b1b8a92867339fcf3b71;hp=8b4c358d41835173757bfd54803e0e15c10c92e3;hpb=d2d56f38da01001c92a09afc6b52b5acbd9bc13c;p=fs%2Flustre-release.git diff --git a/lustre/quota/quota_master.c b/lustre/quota/quota_master.c index 8b4c358..5ffdf8d 100644 --- a/lustre/quota/quota_master.c +++ b/lustre/quota/quota_master.c @@ -1,17 +1,45 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * - * lustre/quota/quota_master.c - * Lustre Quota Master request handler + * GPL HEADER START * - * Copyright (c) 2001-2005 Cluster File Systems, Inc. - * Author: Niu YaWei + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * This file is part of Lustre, http://www.lustre.org. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. * - * No redistribution or use is permitted outside of Cluster File Systems, Inc. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + * GPL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Use is subject to license terms. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Sun Microsystems, Inc. + * + * lustre/quota/quota_master.c + * + * Lustre Quota Master request handler + * + * Author: Niu YaWei */ + #ifndef EXPORT_SYMTAB # define EXPORT_SYMTAB #endif @@ -48,13 +76,13 @@ int lustre_dquot_init(void) LASSERT(lustre_dquot_cachep == NULL); lustre_dquot_cachep = cfs_mem_cache_create("lustre_dquot_cache", - sizeof(struct lustre_dquot), - 0, 0); + sizeof(struct lustre_dquot), + 0, 0); if (!lustre_dquot_cachep) return (-ENOMEM); for (i = 0; i < NR_DQHASH; i++) { - INIT_LIST_HEAD(lustre_dquot_hash + i); + CFS_INIT_LIST_HEAD(lustre_dquot_hash + i); } RETURN(0); } @@ -112,11 +140,11 @@ static struct lustre_dquot *alloc_dquot(struct lustre_quota_info *lqi, struct lustre_dquot *dquot = NULL; ENTRY; - OBD_SLAB_ALLOC(dquot, lustre_dquot_cachep, GFP_NOFS, sizeof(*dquot)); + OBD_SLAB_ALLOC(dquot, lustre_dquot_cachep, CFS_ALLOC_IO, sizeof(*dquot)); if (dquot == NULL) RETURN(NULL); - INIT_LIST_HEAD(&dquot->dq_hash); + CFS_INIT_LIST_HEAD(&dquot->dq_hash); init_mutex_locked(&dquot->dq_sem); dquot->dq_refcnt = 1; dquot->dq_info = lqi; @@ -212,10 +240,8 @@ int dqacq_handler(struct obd_device *obd, struct qunit_data *qdata, int opc) int rc = 0; ENTRY; - OBD_FAIL_RETURN(OBD_FAIL_OBD_DQACQ, -EIO); - - /* slaves never acquires qunit for user root */ - LASSERT(qdata->qd_id || qdata_type); + if (OBD_FAIL_CHECK(OBD_FAIL_OBD_DQACQ)) + RETURN(-EIO); dquot = lustre_dqget(obd, info, qdata->qd_id, qdata_type); if (IS_ERR(dquot)) @@ -338,7 +364,7 @@ int filter_quota_adjust(struct obd_device *obd, unsigned int qcids[], int rc2 = 0; ENTRY; - if (rc && rc != -EDQUOT && rc != ENOLCK) + if (rc && rc != -EDQUOT) RETURN(0); switch (opc) { @@ -651,31 +677,32 @@ static int mds_init_slave_ilimits(struct obd_device *obd, /* XXX: for file limits only adjust local now */ unsigned int uid = 0, gid = 0; struct obd_quotactl *ioqc = NULL; + int flag; int rc; ENTRY; /* if we are going to set zero limit, needn't init slaves */ - if (!oqctl->qc_dqblk.dqb_ihardlimit && !oqctl->qc_dqblk.dqb_isoftlimit) + if (!oqctl->qc_dqblk.dqb_ihardlimit && !oqctl->qc_dqblk.dqb_isoftlimit && + set) RETURN(0); - - if (!set) - goto acquire; OBD_ALLOC_PTR(ioqc); if (!ioqc) RETURN(-ENOMEM); - - ioqc->qc_cmd = Q_INITQUOTA; + + flag = oqctl->qc_dqblk.dqb_ihardlimit || + oqctl->qc_dqblk.dqb_isoftlimit || set; + ioqc->qc_cmd = flag ? Q_INITQUOTA : Q_SETQUOTA; ioqc->qc_id = oqctl->qc_id; ioqc->qc_type = oqctl->qc_type; ioqc->qc_dqblk.dqb_valid = QIF_ILIMITS; - ioqc->qc_dqblk.dqb_ihardlimit = MIN_QLIMIT; + ioqc->qc_dqblk.dqb_ihardlimit = flag ? MIN_QLIMIT : 0; /* set local limit to MIN_QLIMIT */ rc = fsfilt_quotactl(obd, obd->u.obt.obt_sb, ioqc); if (rc) GOTO(out, rc); -acquire: + /* trigger local qunit pre-acquire */ if (oqctl->qc_type == USRQUOTA) uid = oqctl->qc_id; @@ -701,29 +728,30 @@ static int mds_init_slave_blimits(struct obd_device *obd, struct mds_obd *mds = &obd->u.mds; struct obd_quotactl *ioqc; unsigned int uid = 0, gid = 0; + int flag; int rc; ENTRY; /* if we are going to set zero limit, needn't init slaves */ - if (!oqctl->qc_dqblk.dqb_bhardlimit && !oqctl->qc_dqblk.dqb_bsoftlimit) + if (!oqctl->qc_dqblk.dqb_bhardlimit && !oqctl->qc_dqblk.dqb_bsoftlimit && + set) RETURN(0); OBD_ALLOC_PTR(ioqc); if (!ioqc) RETURN(-ENOMEM); - ioqc->qc_cmd = Q_INITQUOTA; + flag = oqctl->qc_dqblk.dqb_bhardlimit || + oqctl->qc_dqblk.dqb_bsoftlimit || set; + ioqc->qc_cmd = flag ? Q_INITQUOTA : Q_SETQUOTA; ioqc->qc_id = oqctl->qc_id; ioqc->qc_type = oqctl->qc_type; ioqc->qc_dqblk.dqb_valid = QIF_BLIMITS; - ioqc->qc_dqblk.dqb_bhardlimit = set ? MIN_QLIMIT : 0; + ioqc->qc_dqblk.dqb_bhardlimit = flag ? MIN_QLIMIT : 0; - /* set local limit to MIN_QLIMIT */ - if (set) { - rc = fsfilt_quotactl(obd, obd->u.obt.obt_sb, ioqc); - if (rc) - GOTO(out, rc); - } + rc = fsfilt_quotactl(obd, obd->u.obt.obt_sb, ioqc); + if (rc) + GOTO(out, rc); /* trigger local qunit pre-acquire */ if (oqctl->qc_type == USRQUOTA) @@ -1065,7 +1093,7 @@ static int qmaster_recovery_main(void *arg) up(&mds->mds_qonoff_sem); continue; } - INIT_LIST_HEAD(&id_list); + CFS_INIT_LIST_HEAD(&id_list); rc = fsfilt_qids(obd, qinfo->qi_files[type], NULL, type, &id_list); up(&mds->mds_qonoff_sem);