From f879fa12af6a701c9d86e2ee67b9e9aee2d63c24 Mon Sep 17 00:00:00 2001 From: green Date: Mon, 27 Jun 2005 20:52:21 +0000 Subject: [PATCH] Branch: b1_4 b=6929 r=adilger Remove quota bits. This still needs some more work, mostly in makefiles to not ship remaining quota files. --- ldiskfs/ldiskfs/Makefile.in | 10 +- lustre/include/liblustre.h | 3 + lustre/include/linux/lustre_fsfilt.h | 16 +- lustre/include/linux/lustre_lib.h | 5 + lustre/include/linux/lustre_quota.h | 101 +------ lustre/ldiskfs/Makefile.in | 10 +- lustre/ldiskfs/quotafmt_test.c | 2 + lustre/ldlm/ldlm_lib.c | 56 ---- lustre/lov/lov_internal.h | 4 + lustre/lov/lov_obd.c | 60 +---- lustre/lvfs/Makefile.in | 6 +- lustre/lvfs/autoMakefile.am | 5 +- lustre/lvfs/fsfilt_ext3.c | 509 +---------------------------------- lustre/lvfs/quotacheck_test.c | 13 +- lustre/lvfs/quotactl_test.c | 13 +- lustre/mdc/mdc_internal.h | 25 ++ lustre/mdc/mdc_request.c | 91 ------- lustre/mds/Makefile.in | 2 +- lustre/mds/autoMakefile.am | 3 +- lustre/mds/handler.c | 215 +-------------- lustre/mds/lproc_mds.c | 119 +------- lustre/mds/mds_fs.c | 14 +- lustre/mds/mds_internal.h | 47 +++- lustre/mds/mds_open.c | 57 +--- lustre/mds/quota_context.c | 12 +- lustre/mds/quota_master.c | 12 +- lustre/obdclass/genops.c | 7 + lustre/obdfilter/filter.c | 73 +---- lustre/obdfilter/filter_internal.h | 64 ++++- lustre/obdfilter/filter_io_26.c | 69 +---- lustre/obdfilter/lproc_obdfilter.c | 117 +------- lustre/osc/Makefile.in | 2 +- lustre/osc/autoMakefile.am | 2 +- lustre/osc/osc_internal.h | 39 +++ lustre/osc/osc_quota.c | 107 +++++++- lustre/osc/osc_request.c | 92 ------- lustre/ost/ost_handler.c | 127 --------- lustre/ost/ost_internal.h | 17 ++ lustre/ptlrpc/Makefile.in | 2 +- 39 files changed, 379 insertions(+), 1749 deletions(-) diff --git a/ldiskfs/ldiskfs/Makefile.in b/ldiskfs/ldiskfs/Makefile.in index be51da2..7236410 100644 --- a/ldiskfs/ldiskfs/Makefile.in +++ b/ldiskfs/ldiskfs/Makefile.in @@ -1,6 +1,6 @@ default: all -MODULES := ldiskfs quotafmt_test +MODULES := ldiskfs #quotafmt_test # copy makefile over to not break patches ext3_extra := $(wildcard @LINUX@/fs/ext3/Makefile) @@ -11,13 +11,13 @@ linux_headers := $(wildcard @LINUX@/include/linux/ext3*.h) ext3_sources := $(filter-out %.mod.c,$(wildcard @LINUX@/fs/ext3/*.c)) new_sources := iopen.c iopen.h extents.c mballoc.c new_headers := ext3_extents.h -quotafmt_sources := lustre_quota_fmt.c -quotafmt_headers := lustre_quota_fmt.h +#quotafmt_sources := lustre_quota_fmt.c +#quotafmt_headers := lustre_quota_fmt.h ldiskfs_patched_sources := $(notdir $(ext3_sources) $(ext3_headers)) $(new_sources) $(new_headers) -ldiskfs_sources := $(ldiskfs_patched_sources) $(quotafmt_sources) $(quotafmt_headers) +ldiskfs_sources := $(ldiskfs_patched_sources) #$(quotafmt_sources) $(quotafmt_headers) ldiskfs-objs := $(filter %.o,$(ldiskfs_sources:.c=.o)) -quotafmt-objs := quotafmt_test.o +#quotafmt-objs := quotafmt_test.o EXTRA_PRE_CFLAGS := -I@LINUX@/fs -I@LUSTRE@ -I@LUSTRE@/ldiskfs diff --git a/lustre/include/liblustre.h b/lustre/include/liblustre.h index e41e3bc..3b5d977 100644 --- a/lustre/include/liblustre.h +++ b/lustre/include/liblustre.h @@ -818,6 +818,9 @@ struct file_lock { result; \ }) +#ifndef ENOTSUPP +#define ENOTSUPP ENOTSUP +#endif #include #include diff --git a/lustre/include/linux/lustre_fsfilt.h b/lustre/include/linux/lustre_fsfilt.h index a90ed40..11fd2a9 100644 --- a/lustre/include/linux/lustre_fsfilt.h +++ b/lustre/include/linux/lustre_fsfilt.h @@ -301,27 +301,35 @@ static inline int fsfilt_quotacheck(struct obd_device *obd, struct super_block *sb, struct obd_quotactl *oqctl) { - return obd->obd_fsops->fs_quotacheck(sb, oqctl); + if (obd->obd_fsops->fs_quotacheck) + return obd->obd_fsops->fs_quotacheck(sb, oqctl); + return -ENOTSUPP; } static inline int fsfilt_quotactl(struct obd_device *obd, struct super_block *sb, struct obd_quotactl *oqctl) { - return obd->obd_fsops->fs_quotactl(sb, oqctl); + if (obd->obd_fsops->fs_quotactl) + return obd->obd_fsops->fs_quotactl(sb, oqctl); + return -ENOTSUPP; } static inline int fsfilt_quotainfo(struct obd_device *obd, struct lustre_quota_info *lqi, int type, int cmd) { - return obd->obd_fsops->fs_quotainfo(lqi, type, cmd); + if (obd->obd_fsops->fs_quotainfo) + return obd->obd_fsops->fs_quotainfo(lqi, type, cmd); + return -ENOTSUPP; } static inline int fsfilt_dquot(struct obd_device *obd, struct lustre_dquot *dquot, int cmd) { - return obd->obd_fsops->fs_dquot(dquot, cmd); + if (obd->obd_fsops->fs_dquot) + return obd->obd_fsops->fs_dquot(dquot, cmd); + return -ENOTSUPP; } static inline int fsfilt_map_inode_pages(struct obd_device *obd, diff --git a/lustre/include/linux/lustre_lib.h b/lustre/include/linux/lustre_lib.h index 71b9ff4..b2baf7e 100644 --- a/lustre/include/linux/lustre_lib.h +++ b/lustre/include/linux/lustre_lib.h @@ -95,9 +95,14 @@ int target_handle_reconnect(struct lustre_handle *conn, struct obd_export *exp, int target_handle_ping(struct ptlrpc_request *req); void target_committed_to_req(struct ptlrpc_request *req); +#ifdef HAVE_QUOTA_SUPPORT /* quotacheck callback, dqacq/dqrel callback handler */ int target_handle_qc_callback(struct ptlrpc_request *req); int target_handle_dqacq_callback(struct ptlrpc_request *req); +#else +#define target_handle_dqacq_callback(req) ldlm_callback_reply(req, -ENOTSUPP) +#define target_handle_qc_callback(req) (0) +#endif void target_cancel_recovery_timer(struct obd_device *obd); diff --git a/lustre/include/linux/lustre_quota.h b/lustre/include/linux/lustre_quota.h index 91da654..5c2f352 100644 --- a/lustre/include/linux/lustre_quota.h +++ b/lustre/include/linux/lustre_quota.h @@ -7,76 +7,21 @@ #ifdef __KERNEL__ # include #endif -#include #include -#define QUSG(count, isblk) (isblk ? toqb(count) : count) - -/* If the (quota limit < qunit * slave count), the slave which can't - * acquire qunit should set it's local limit as MIN_QLIMIT */ -#define MIN_QLIMIT 1 - -#ifndef NR_DQHASH -#define NR_DQHASH 45 -#endif +#ifdef HAVE_QUOTA_SUPPORT +#include +#else -/* structures to access admin quotafile */ struct lustre_mem_dqinfo { - unsigned int dqi_bgrace; - unsigned int dqi_igrace; - unsigned long dqi_flags; - unsigned int dqi_blocks; - unsigned int dqi_free_blk; - unsigned int dqi_free_entry; }; struct lustre_quota_info { - struct semaphore qi_sem; - struct file *qi_files[MAXQUOTAS]; - struct lustre_mem_dqinfo qi_info[MAXQUOTAS]; }; -#ifdef __KERNEL__ struct lustre_dquot { - struct list_head dq_hash; - struct list_head dq_unused; - - /* this semaphore is unused until we implement wb dquot cache */ - struct semaphore dq_sem; - atomic_t dq_refcnt; - - struct lustre_quota_info *dq_info; - loff_t dq_off; - unsigned int dq_id; - int dq_type; - unsigned long dq_flags; - struct mem_dqblk dq_dqb; }; -#endif - -#define QFILE_CHK 1 -#define QFILE_RD_INFO 2 -#define QFILE_WR_INFO 3 -#define QFILE_INIT_INFO 4 -#define QFILE_RD_DQUOT 5 -#define QFILE_WR_DQUOT 6 - -/* admin quotafile operations */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) -int lustre_check_quota_file(struct lustre_quota_info *lqi, int type); -int lustre_read_quota_info(struct lustre_quota_info *lqi, int type); -int lustre_write_quota_info(struct lustre_quota_info *lqi, int type); -#ifdef __KERNEL__ -int lustre_read_dquot(struct lustre_dquot *dquot); -int lustre_commit_dquot(struct lustre_dquot *dquot); -#endif -int lustre_init_quota_info(struct lustre_quota_info *lqi, int type); -#else - -#ifndef DQ_FAKE_B -#define DQ_FAKE_B 6 -#endif static inline int lustre_check_quota_file(struct lustre_quota_info *lqi, int type) @@ -108,42 +53,19 @@ static inline int lustre_init_quota_info(struct lustre_quota_info *lqi, { return 0; } -#endif /* KERNEL_VERSION(2,5,0) */ -/* quota context structures */ struct obd_device; + typedef int (*dqacq_handler_t) (struct obd_device * obd, struct qunit_data * qd, int opc); struct lustre_quota_ctxt { - struct super_block *lqc_sb; - struct obd_import *lqc_import; - dqacq_handler_t lqc_handler; - unsigned long lqc_flags; - unsigned long lqc_iunit_sz; - unsigned long lqc_itune_sz; - unsigned long lqc_bunit_sz; - unsigned long lqc_btune_sz; }; struct lustre_qunit { - struct list_head lq_hash; - atomic_t lq_refcnt; - struct lustre_quota_ctxt *lq_ctxt; - struct qunit_data lq_data; - unsigned int lq_opc; - struct list_head lq_waiters; }; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) -int qctxt_init(struct lustre_quota_ctxt *qctxt, struct super_block *sb, - dqacq_handler_t handler); -void qctxt_cleanup(struct lustre_quota_ctxt *qctxt, int force); -int qctxt_adjust_qunit(struct obd_device *obd, struct lustre_quota_ctxt *qctxt, - uid_t uid, gid_t gid, __u32 isblk); -int qctxt_wait_on_dqacq(struct obd_device *obd, struct lustre_quota_ctxt *qctxt, - uid_t uid, gid_t gid, __u32 isblk); -#else +struct super_block; static inline int qctxt_init(struct lustre_quota_ctxt *qctxt, struct super_block *sb, dqacq_handler_t handler) { @@ -165,18 +87,11 @@ static inline int qctxt_wait_on_dqacq(struct obd_device *obd, { return 0; } -#endif /* KERNEL_VERSION(2,5,0) */ - -/* quota check & quotactl */ -#define LUSTRE_ADMIN_QUOTAFILES {\ - "admin_quotafile.usr", /* user admin quotafile */\ - "admin_quotafile.grp" /* group admin quotafile */\ -} struct quotacheck_info { - struct completion qi_starting; - struct obd_export *qi_exp; - struct obd_quotactl qi_oqctl; }; +#define DQUOT_OFF(sb) do {} while(0) + +#endif /*!HAVE_QUOTA_SUPPORT */ #endif /* _LUSTRE_QUOTA_H */ diff --git a/lustre/ldiskfs/Makefile.in b/lustre/ldiskfs/Makefile.in index be51da2..7236410 100644 --- a/lustre/ldiskfs/Makefile.in +++ b/lustre/ldiskfs/Makefile.in @@ -1,6 +1,6 @@ default: all -MODULES := ldiskfs quotafmt_test +MODULES := ldiskfs #quotafmt_test # copy makefile over to not break patches ext3_extra := $(wildcard @LINUX@/fs/ext3/Makefile) @@ -11,13 +11,13 @@ linux_headers := $(wildcard @LINUX@/include/linux/ext3*.h) ext3_sources := $(filter-out %.mod.c,$(wildcard @LINUX@/fs/ext3/*.c)) new_sources := iopen.c iopen.h extents.c mballoc.c new_headers := ext3_extents.h -quotafmt_sources := lustre_quota_fmt.c -quotafmt_headers := lustre_quota_fmt.h +#quotafmt_sources := lustre_quota_fmt.c +#quotafmt_headers := lustre_quota_fmt.h ldiskfs_patched_sources := $(notdir $(ext3_sources) $(ext3_headers)) $(new_sources) $(new_headers) -ldiskfs_sources := $(ldiskfs_patched_sources) $(quotafmt_sources) $(quotafmt_headers) +ldiskfs_sources := $(ldiskfs_patched_sources) #$(quotafmt_sources) $(quotafmt_headers) ldiskfs-objs := $(filter %.o,$(ldiskfs_sources:.c=.o)) -quotafmt-objs := quotafmt_test.o +#quotafmt-objs := quotafmt_test.o EXTRA_PRE_CFLAGS := -I@LINUX@/fs -I@LUSTRE@ -I@LUSTRE@/ldiskfs diff --git a/lustre/ldiskfs/quotafmt_test.c b/lustre/ldiskfs/quotafmt_test.c index ead691c..53985d2 100644 --- a/lustre/ldiskfs/quotafmt_test.c +++ b/lustre/ldiskfs/quotafmt_test.c @@ -1,6 +1,8 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * + * No redistribution or use is permitted outside of Cluster File Systems, Inc. + * * Kernel module to test lustre administrative quotafile format APIs * from the OBD setup function */ #ifndef EXPORT_SYMTAB diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index cdc43ab..6728a31 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -1362,60 +1362,4 @@ void target_committed_to_req(struct ptlrpc_request *req) obd->obd_last_committed, req->rq_xid); } -int target_handle_qc_callback(struct ptlrpc_request *req) -{ - struct obd_quotactl *oqctl; - struct client_obd *cli = &req->rq_export->exp_obd->u.cli; - - oqctl = lustre_swab_reqbuf(req, 0, sizeof(*oqctl), - lustre_swab_obd_quotactl); - - spin_lock(&cli->cl_qchk_lock); - cli->cl_qchk_stat = oqctl->qc_stat; - spin_unlock(&cli->cl_qchk_lock); - - return 0; -} - -int target_handle_dqacq_callback(struct ptlrpc_request *req) -{ - struct obd_device *obd = req->rq_export->exp_obd; - struct obd_device *master_obd; - struct lustre_quota_ctxt *qctxt; - struct qunit_data *qdata, *rep; - int rc = 0, repsize = sizeof(struct qunit_data); - ENTRY; - - rc = lustre_pack_reply(req, 1, &repsize, NULL); - if (rc) { - CERROR("packing reply failed!: rc = %d\n", rc); - RETURN(rc); - } - rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*rep)); - LASSERT(rep); - - qdata = lustre_swab_reqbuf(req, 0, sizeof(*qdata), lustre_swab_qdata); - if (qdata == NULL) { - CERROR("unpacking request buffer failed!"); - RETURN(-EPROTO); - } - - /* we use the observer */ - LASSERT(obd->obd_observer && obd->obd_observer->obd_observer); - master_obd = obd->obd_observer->obd_observer; - qctxt = &master_obd->u.mds.mds_quota_ctxt; - - LASSERT(qctxt->lqc_handler); - rc = qctxt->lqc_handler(master_obd, qdata, req->rq_reqmsg->opc); - if (rc && rc != -EDQUOT) - CERROR("dqacq failed! (rc:%d)\n", rc); - - /* the qd_count might be changed in lqc_handler */ - memcpy(rep, qdata, sizeof(*rep)); - req->rq_status = rc; - rc = ptlrpc_reply(req); - - RETURN(rc); -} - EXPORT_SYMBOL(target_committed_to_req); diff --git a/lustre/lov/lov_internal.h b/lustre/lov/lov_internal.h index 3127d08..64a41b2 100644 --- a/lustre/lov/lov_internal.h +++ b/lustre/lov/lov_internal.h @@ -220,4 +220,8 @@ int lov_getstripe(struct obd_export *exp, /* lproc_lov.c */ extern struct file_operations lov_proc_target_fops; +/* Quota stuff */ +int lov_quotacheck(struct obd_export *exp, struct obd_quotactl *oqctl); +int lov_quotactl(struct obd_export *exp, struct obd_quotactl *oqctl); + #endif diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index aa11c83..dd4dd30 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -2188,64 +2188,6 @@ int lov_complete_many(struct obd_export *exp, struct lov_stripe_md *lsm, } #endif -static int lov_quotacheck(struct obd_export *exp, struct obd_quotactl *oqctl) -{ - struct obd_device *obd = class_exp2obd(exp); - struct lov_obd *lov = &obd->u.lov; - int i, rc = 0; - ENTRY; - - for (i = 0; i < lov->desc.ld_tgt_count; i++) { - int err; - - if (!lov->tgts[i].active) { - CDEBUG(D_HA, "lov idx %d inactive\n", i); - continue; - } - - err = obd_quotacheck(lov->tgts[i].ltd_exp, oqctl); - if (err) { - if (lov->tgts[i].active && !rc) - rc = err; - continue; - } - } - - RETURN(rc); -} - -static int lov_quotactl(struct obd_export *exp, struct obd_quotactl *oqctl) -{ - struct obd_device *obd = class_exp2obd(exp); - struct lov_obd *lov = &obd->u.lov; - __u64 curspace = oqctl->qc_dqblk.dqb_curspace; - int i, rc = 0; - ENTRY; - - for (i = 0; i < lov->desc.ld_tgt_count; i++) { - int err; - - if (!lov->tgts[i].active) { - CDEBUG(D_HA, "lov idx %d inactive\n", i); - continue; - } - - err = obd_quotactl(lov->tgts[i].ltd_exp, oqctl); - if (err) { - if (lov->tgts[i].active && !rc) - rc = err; - continue; - } - - if (oqctl->qc_cmd == Q_GETQUOTA) - curspace += oqctl->qc_dqblk.dqb_curspace; - } - - if (oqctl->qc_cmd == Q_GETQUOTA) - oqctl->qc_dqblk.dqb_curspace = curspace; - RETURN(rc); -} - struct obd_ops lov_obd_ops = { .o_owner = THIS_MODULE, .o_setup = lov_setup, @@ -2286,8 +2228,10 @@ struct obd_ops lov_obd_ops = { .o_llog_init = lov_llog_init, .o_llog_finish = lov_llog_finish, .o_notify = lov_notify, +#ifdef HAVE_QUOTA_SUPPORT .o_quotacheck = lov_quotacheck, .o_quotactl = lov_quotactl, +#endif }; int __init lov_init(void) diff --git a/lustre/lvfs/Makefile.in b/lustre/lvfs/Makefile.in index bcbeae9..02fb755 100644 --- a/lustre/lvfs/Makefile.in +++ b/lustre/lvfs/Makefile.in @@ -1,9 +1,9 @@ -MODULES := lvfs quotactl_test quotacheck_test +MODULES := lvfs #quotactl_test quotacheck_test @SERVER_TRUE@MODULES += fsfilt_@BACKINGFS@ lvfs-objs := lvfs_common.o lvfs_linux.o fsfilt.o -quotactl-objs := quotactl_test.o -quotaccheck-objs := quotacheck_test.o +#quotactl-objs := quotactl_test.o +#quotaccheck-objs := quotacheck_test.o ifeq ($(PATCHLEVEL),6) fsfilt_@BACKINGFS@-objs := fsfilt-@BACKINGFS@.o diff --git a/lustre/lvfs/autoMakefile.am b/lustre/lvfs/autoMakefile.am index 808a764..869900f 100644 --- a/lustre/lvfs/autoMakefile.am +++ b/lustre/lvfs/autoMakefile.am @@ -40,6 +40,9 @@ ldiskfs_sed_flags = \ fsfilt_ldiskfs.c: fsfilt_ext3.c sed $(strip $(ldiskfs_sed_flags)) $< > $@ +fsfilt_ldiskfs_quota.h: fsfilt_ext3_quota.h + sed $(strip $(ldiskfs_sed_flags)) $< > $@ + else @@ -49,7 +52,7 @@ endif # MODULES DIST_SOURCES = fsfilt.c fsfilt_ext3.c fsfilt_reiserfs.c lvfs_common.c \ lvfs_internal.h lvfs_linux.c lvfs_userfs.c \ - quotacheck_test.c quotactl_test.c + quotacheck_test.c quotactl_test.c fsfilt_ext3_quota.h MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ CLEANFILES = fsfilt-*.c fsfilt_ldiskfs.c fsfilt_extN.c sources diff --git a/lustre/lvfs/fsfilt_ext3.c b/lustre/lvfs/fsfilt_ext3.c index 6da50c3..d52c088 100644 --- a/lustre/lvfs/fsfilt_ext3.c +++ b/lustre/lvfs/fsfilt_ext3.c @@ -1178,179 +1178,6 @@ static int fsfilt_ext3_get_op_len(int op, struct fsfilt_objinfo *fso, int logs) return 0; } -static const char *op_quotafile[] = { "aquota.user", "aquota.group" }; - -static int fsfilt_ext3_quotactl(struct super_block *sb, - struct obd_quotactl *oqc) -{ - int i, rc = 0, error = 0; - struct if_dqinfo *info = (struct if_dqinfo *)&oqc->qc_dqinfo; - struct if_dqblk *dqblk = (struct if_dqblk *)&oqc->qc_dqblk; - ENTRY; - - /* XXX: quotaoff */ - return -EOPNOTSUPP; - - for (i = 0; i < MAXQUOTAS; i++) if (Q_TYPESET(oqc, i)) { - switch (oqc->qc_cmd) { - case Q_QUOTAON: { - rc = sb->s_qcop->quota_on(sb, i, oqc->qc_id, - (char *)op_quotafile[i]); - if (rc == -EBUSY) - error = rc; - else if (rc) - GOTO(out, rc); - break; - } - case Q_QUOTAOFF: { - sb->s_qcop->quota_off(sb, i); - break; - } - case Q_GETOINFO: - case Q_GETINFO: - rc = sb->s_qcop->get_info(sb, i, info); - GOTO(out, rc); - case Q_SETQUOTA: - rc = sb->s_qcop->set_dqblk(sb, i, oqc->qc_id, dqblk); - GOTO(out, rc); - case Q_GETOQUOTA: - case Q_GETQUOTA: - rc = sb->s_qcop->get_dqblk(sb, i, oqc->qc_id, dqblk); - GOTO(out, rc); - default: - CERROR("unsupported quotactl command: %d", oqc->qc_cmd); - LBUG(); - } - } -out: - if (!rc && error) - rc = error; - RETURN(rc); -} - -struct chkquot { - struct hlist_node cq_hash; - struct list_head cq_list; - qid_t cq_id; - short cq_type; - __u32 cq_bhardlimit; - __u32 cq_bsoftlimit; - qsize_t cq_curspace; - __u32 cq_ihardlimit; - __u32 cq_isoftlimit; - __u32 cq_curinodes; - __u64 cq_btime; - __u64 cq_itime; -}; - -static inline unsigned int const -chkquot_hash(qid_t id, int type) -{ - return (id * (MAXQUOTAS - type)) % NR_DQHASH; -} - -static inline struct chkquot * -find_chkquot(struct hlist_head *head, qid_t id, int type) -{ - struct hlist_node *node, *next; - struct chkquot *cq = NULL; - - hlist_for_each_safe(node, next, head) { - cq = hlist_entry(node, struct chkquot, cq_hash); - if (cq->cq_id == id && cq->cq_type == type) - return cq; - } - - return NULL; -} - -static struct chkquot *alloc_chkquot(qid_t id, int type) -{ - struct chkquot *cq; - - OBD_ALLOC(cq, sizeof(*cq)); - if (cq) { -#if 0 /* XXX: 2.4 doesn't support this macro */ - INIT_HLIST_NODE(&cq->cq_hash); -#endif - INIT_LIST_HEAD(&cq->cq_list); - cq->cq_id = id; - cq->cq_type = type; - } - - return cq; -} - -static struct chkquot * -cqget(struct super_block *sb, struct hlist_head *hash, struct list_head *list, - qid_t id, int type, int first_check) -{ - struct hlist_head *head = hash + chkquot_hash(id, type); - struct if_dqblk dqb; - struct chkquot *cq; - int rc; - - cq = find_chkquot(head, id, type); - if (cq) - return cq; - - cq = alloc_chkquot(id, type); - if (!cq) - return NULL; - - if (!first_check) { - rc = sb->s_qcop->get_dqblk(sb, type, id, &dqb); - if (!rc) { - cq->cq_bhardlimit = dqb.dqb_bhardlimit; - cq->cq_bsoftlimit = dqb.dqb_bsoftlimit; - cq->cq_ihardlimit = dqb.dqb_ihardlimit; - cq->cq_isoftlimit = dqb.dqb_isoftlimit; - cq->cq_btime = dqb.dqb_btime; - cq->cq_itime = dqb.dqb_itime; - } - } - - hlist_add_head(&cq->cq_hash, head); - list_add_tail(&cq->cq_list, list); - - return cq; -} - -static inline int quota_onoff(struct super_block *sb, int cmd, int type) -{ - struct obd_quotactl *oqctl; - int rc; - - OBD_ALLOC(oqctl, sizeof(*oqctl)); - - oqctl->qc_cmd = cmd; - oqctl->qc_id = QFMT_LDISKFS; - oqctl->qc_type = type; - rc = fsfilt_ext3_quotactl(sb, oqctl); - - OBD_FREE(oqctl, sizeof(*oqctl)); - return rc; -} - -static inline void read_old_dqinfo(struct super_block *sb, int type, - struct if_dqinfo *dqinfo) -{ - struct obd_quotactl *oqctl; - int rc; - ENTRY; - - OBD_ALLOC(oqctl, sizeof(*oqctl)); - - oqctl->qc_cmd = Q_GETINFO; - oqctl->qc_type = type; - rc = fsfilt_ext3_quotactl(sb, oqctl); - if (!rc) - memcpy(dqinfo + type, &oqctl->qc_dqinfo, sizeof(*dqinfo)); - - OBD_FREE(oqctl, sizeof(*oqctl)); - EXIT; -} - static inline struct ext3_group_desc * get_group_desc(struct super_block *sb, int group) { @@ -1389,337 +1216,9 @@ static inline struct inode *ext3_iget_inuse(struct super_block *sb, return inode; } -struct qchk_ctxt { - struct hlist_head hash[NR_DQHASH]; - struct list_head list; - int first_check[MAXQUOTAS]; - struct if_dqinfo dqinfo[MAXQUOTAS]; -}; - -static int add_inode_quota(struct inode *inode, struct qchk_ctxt *qctxt, - struct obd_quotactl *oqc) -{ - struct chkquot *cq; - loff_t size = 0; - qid_t qid[MAXQUOTAS]; - int cnt; - - if (!inode) - return 0; - - qid[USRQUOTA] = inode->i_uid; - qid[GRPQUOTA] = inode->i_gid; - - if (S_ISDIR(inode->i_mode) || - S_ISREG(inode->i_mode) || - S_ISLNK(inode->i_mode)) - size = inode_get_bytes(inode); - - for (cnt = 0; cnt < MAXQUOTAS; cnt++) if (Q_TYPESET(oqc, cnt)) { - cq = cqget(inode->i_sb, qctxt->hash, &qctxt->list, qid[cnt], - cnt, qctxt->first_check[cnt]); - if (!cq) - return -ENOMEM; - - cq->cq_curspace += size; - cq->cq_curinodes ++; - } - - return 0; -} - -static int v2_write_dqheader(struct file *f, int type) -{ - int quota_magics[] = V2_INITQMAGICS; - int quota_versions[] = V2_INITQVERSIONS; - struct v2_disk_dqheader dqhead; - ssize_t size; - loff_t offset = 0; - mm_segment_t fs; - - dqhead.dqh_magic = cpu_to_le32(quota_magics[type]); - dqhead.dqh_version = cpu_to_le32(quota_versions[type]); - - fs = get_fs(); - set_fs(KERNEL_DS); - size = f->f_op->write(f, (char *)&dqhead, sizeof(dqhead), &offset); - set_fs(fs); - if (size != sizeof(dqhead)) { - CERROR("error writing dqhead in quota file"); - return -1; - } - - return 0; -} - -/* write dqinfo struct in a new quota file */ -static int v2_write_dqinfo(struct file *f, int type, struct if_dqinfo *info) -{ - struct v2_disk_dqinfo dqinfo; - int blocks = V2_DQTREEOFF + 1; - ssize_t size; - loff_t offset = V2_DQINFOOFF; - mm_segment_t fs; - - if (info) { - dqinfo.dqi_bgrace = cpu_to_le32(info->dqi_bgrace); - dqinfo.dqi_igrace = cpu_to_le32(info->dqi_igrace); - dqinfo.dqi_flags = cpu_to_le32(info->dqi_flags & DQF_MASK & - ~DQF_INFO_DIRTY); - } else { - dqinfo.dqi_bgrace = cpu_to_le32(MAX_DQ_TIME); - dqinfo.dqi_igrace = cpu_to_le32(MAX_IQ_TIME); - dqinfo.dqi_flags = 0; - } - - dqinfo.dqi_blocks = cpu_to_le32(blocks); - dqinfo.dqi_free_blk = 0; - dqinfo.dqi_free_entry = 0; - - fs = get_fs(); - set_fs(KERNEL_DS); - size = f->f_op->write(f, (char *)&dqinfo, sizeof(dqinfo), &offset); - set_fs(fs); - - if (size != sizeof(dqinfo)) { - CERROR("error writing dqinfo in quota file"); - return -1; - } - - return 0; -} - -static int create_new_quota_files(struct qchk_ctxt *qctxt, - struct obd_quotactl *oqc) -{ - int i, rc = 0; - ENTRY; - - for (i = 0; i < MAXQUOTAS; i++) if (Q_TYPESET(oqc, i)) { - struct if_dqinfo *info = qctxt->first_check[i]? NULL: - &qctxt->dqinfo[i]; - struct file *file; - - file = filp_open(op_quotafile[i], - O_RDWR | O_CREAT | O_TRUNC, 0644); - if (IS_ERR(file)) { - rc = PTR_ERR(file); - CERROR("can't create %s file: rc = %d\n", - op_quotafile[i], rc); - GOTO(out, rc); - } - - rc = v2_write_dqheader(file, i); - if (rc) { - filp_close(file, 0); - GOTO(out, rc = -EIO); - } - - rc = v2_write_dqinfo(file, i, info); - if (rc) { - filp_close(file, 0); - GOTO(out, rc = -EIO); - } - - filp_close(file, 0); - } - -out: - RETURN(rc); -} - - -static int commit_chkquot(struct super_block *sb, struct qchk_ctxt *qctxt, - struct chkquot *cq) -{ - struct obd_quotactl oqc = { 0, }; - struct timeval now; - - do_gettimeofday(&now); - - if (cq->cq_bsoftlimit && - toqb(cq->cq_curspace) >= cq->cq_bsoftlimit && - !cq->cq_btime) - cq->cq_btime = now.tv_sec + - qctxt->dqinfo[cq->cq_type].dqi_bgrace; - - if (cq->cq_isoftlimit && - cq->cq_curinodes >= cq->cq_isoftlimit && - !cq->cq_itime) - cq->cq_itime = now.tv_sec + - qctxt->dqinfo[cq->cq_type].dqi_igrace; - - oqc.qc_cmd = Q_SETQUOTA; - oqc.qc_type = cq->cq_type; - oqc.qc_id = cq->cq_id; - oqc.qc_dqblk.dqb_bhardlimit = cq->cq_bhardlimit; - oqc.qc_dqblk.dqb_bsoftlimit = cq->cq_bsoftlimit; - oqc.qc_dqblk.dqb_curspace = cq->cq_curspace; - oqc.qc_dqblk.dqb_ihardlimit = cq->cq_ihardlimit; - oqc.qc_dqblk.dqb_isoftlimit = cq->cq_isoftlimit; - oqc.qc_dqblk.dqb_curinodes = cq->cq_curinodes; - oqc.qc_dqblk.dqb_btime = cq->cq_btime; - oqc.qc_dqblk.dqb_itime = cq->cq_itime; - oqc.qc_dqblk.dqb_valid = QIF_ALL; - - return fsfilt_ext3_quotactl(sb, &oqc); -} - -static int prune_chkquots(struct super_block *sb, - struct qchk_ctxt *qctxt, int error) -{ - struct chkquot *cq, *tmp; - int rc; - - list_for_each_entry_safe(cq, tmp, &qctxt->list, cq_list) { - if (!error) { - rc = commit_chkquot(sb, qctxt, cq); - if (rc) - error = rc; - } - hlist_del_init(&cq->cq_hash); - list_del(&cq->cq_list); - OBD_FREE(cq, sizeof(*cq)); - } - - return error; -} - -static int fsfilt_ext3_quotacheck(struct super_block *sb, - struct obd_quotactl *oqc) -{ - struct ext3_sb_info *sbi = EXT3_SB(sb); - int i, group; - struct qchk_ctxt *qctxt; - struct buffer_head *bitmap_bh = NULL; - unsigned long ino; - struct inode *inode; - int rc; - ENTRY; - - /* turn on quota and read dqinfo if existed */ - OBD_ALLOC(qctxt, sizeof(*qctxt)); - if (!qctxt) - RETURN(-ENOMEM); - - for (i = 0; i < NR_DQHASH; i++) - INIT_HLIST_HEAD(&qctxt->hash[i]); - INIT_LIST_HEAD(&qctxt->list); - - for (i = 0; i < MAXQUOTAS; i++) if (Q_TYPESET(oqc, i)) { - rc = quota_onoff(sb, Q_QUOTAON, i); - if (!rc || rc == -EBUSY) - read_old_dqinfo(sb, i, qctxt->dqinfo); - else if (rc == -ENOENT) - qctxt->first_check[i] = 1; - else if (rc) - GOTO(out, rc); - } - - /* check quota and update in hash */ - for (group = 0; group < sbi->s_groups_count; group++) { - ino = group * sbi->s_inodes_per_group + 1; - brelse(bitmap_bh); - bitmap_bh = read_inode_bitmap(sb, group); - - for (i = 0; i < sbi->s_inodes_per_group; i++, ino++) { - if (ino < sbi->s_first_ino) - continue; - - inode = ext3_iget_inuse(sb, bitmap_bh, i, ino); - rc = add_inode_quota(inode, qctxt, oqc); - iput(inode); - if (rc) { - brelse(bitmap_bh); - GOTO(out, rc); - } - } - } - brelse(bitmap_bh); - - /* turn off quota cause we are to dump chkquot to files */ - quota_onoff(sb, Q_QUOTAOFF, oqc->qc_type); - - rc = create_new_quota_files(qctxt, oqc); - if (rc) - GOTO(out, rc); - - /* we use vfs functions to set dqblk, so turn quota on */ - rc = quota_onoff(sb, Q_QUOTAON, oqc->qc_type); - if (rc) - GOTO(out, rc); - -out: - /* dump and free chkquot */ - rc = prune_chkquots(sb, qctxt, rc); - OBD_FREE(qctxt, sizeof(*qctxt)); - - /* turn off quota, `lfs quotacheck` will turn on when all - * nodes quotacheck finish. */ - quota_onoff(sb, Q_QUOTAOFF, oqc->qc_type); - - if (rc) - CERROR("quotacheck failed: rc = %d\n", rc); - - oqc->qc_stat = rc; - RETURN(rc); -} - -static int fsfilt_ext3_quotainfo(struct lustre_quota_info *lqi, int type, int cmd) -{ - int rc = 0; - ENTRY; - - switch (cmd) { - case QFILE_CHK: - rc = lustre_check_quota_file(lqi, type); - break; - case QFILE_RD_INFO: - rc = lustre_read_quota_info(lqi, type); - break; - case QFILE_WR_INFO: - rc = lustre_write_quota_info(lqi, type); - break; - case QFILE_INIT_INFO: - rc = lustre_init_quota_info(lqi, type); - break; - default: - CERROR("Unsupported admin quota file cmd %d\n", cmd); - LBUG(); - break; - } - RETURN(rc); -} - -static int fsfilt_ext3_dquot(struct lustre_dquot *dquot, int cmd) -{ - int rc = 0; - ENTRY; - - switch (cmd) { - case QFILE_RD_DQUOT: - rc = lustre_read_dquot(dquot); - break; - case QFILE_WR_DQUOT: - if (dquot->dq_dqb.dqb_ihardlimit || - dquot->dq_dqb.dqb_isoftlimit || - dquot->dq_dqb.dqb_bhardlimit || - dquot->dq_dqb.dqb_bsoftlimit) - clear_bit(DQ_FAKE_B, &dquot->dq_flags); - else - set_bit(DQ_FAKE_B, &dquot->dq_flags); - - rc = lustre_commit_dquot(dquot); - if (rc >= 0) - rc = 0; - break; - default: - CERROR("Unsupported admin quota file cmd %d\n", cmd); - LBUG(); - break; - } - RETURN(rc); -} +#ifdef HAVE_QUOTA_SUPPORT +# include "fsfilt_ext3_quota.h" +#endif static struct fsfilt_operations fsfilt_ext3_ops = { .fs_type = "ext3", @@ -1744,10 +1243,12 @@ static struct fsfilt_operations fsfilt_ext3_ops = { .fs_setup = fsfilt_ext3_setup, .fs_send_bio = fsfilt_ext3_send_bio, .fs_get_op_len = fsfilt_ext3_get_op_len, +#ifdef HAVE_QUOTA_SUPPORT .fs_quotactl = fsfilt_ext3_quotactl, .fs_quotacheck = fsfilt_ext3_quotacheck, .fs_quotainfo = fsfilt_ext3_quotainfo, .fs_dquot = fsfilt_ext3_dquot, +#endif }; static int __init fsfilt_ext3_init(void) diff --git a/lustre/lvfs/quotacheck_test.c b/lustre/lvfs/quotacheck_test.c index a997dcc..87c9b7b 100644 --- a/lustre/lvfs/quotacheck_test.c +++ b/lustre/lvfs/quotacheck_test.c @@ -6,18 +6,7 @@ * * This file is part of Lustre, http://www.lustre.org/ * - * Lustre is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * Lustre 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 for more details. - * - * You should have received a copy of the GNU General Public License - * along with Lustre; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * No redistribution or use is permitted outside of Cluster File Systems, Inc. * * A kernel module which tests the fsfilt quotacheck API from the OBD setup function. */ diff --git a/lustre/lvfs/quotactl_test.c b/lustre/lvfs/quotactl_test.c index 30c3c8c..1e03388 100644 --- a/lustre/lvfs/quotactl_test.c +++ b/lustre/lvfs/quotactl_test.c @@ -6,18 +6,7 @@ * * This file is part of Lustre, http://www.lustre.org/ * - * Lustre is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * Lustre 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 for more details. - * - * You should have received a copy of the GNU General Public License - * along with Lustre; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * No redistribution or use is permitted outside of Cluster File Systems, Inc. * * A kernel module which tests the fsfilt quotactl API from the OBD setup function. */ diff --git a/lustre/mdc/mdc_internal.h b/lustre/mdc/mdc_internal.h index 568df2c..c08b0ab 100644 --- a/lustre/mdc/mdc_internal.h +++ b/lustre/mdc/mdc_internal.h @@ -1,3 +1,4 @@ +#include void mdc_pack_req_body(struct ptlrpc_request *); void mdc_pack_rep_body(struct ptlrpc_request *); void mdc_readdir_pack(struct ptlrpc_request *req, __u64 offset, __u32 size, @@ -66,3 +67,27 @@ static inline void mdc_put_rpc_lock(struct mdc_rpc_lock *lck, up(&lck->rpcl_sem); } } + +/* Quota stuff */ +#ifdef HAVE_QUOTA_SUPPORT +int mdc_quotacheck(struct obd_export *exp, struct obd_quotactl *oqctl); +int mdc_poll_quotacheck(struct obd_export *exp, struct if_quotacheck *qchk); +int mdc_quotactl(struct obd_export *exp, struct obd_quotactl *oqctl); +#else +static inline int mdc_quotacheck(struct obd_export *exp, struct obd_quotactl *oqctl) +{ + return -ENOTSUPP; +} + +static inline int mdc_poll_quotacheck(struct obd_export *exp, struct if_quotacheck *qchk) +{ + return -ENOTSUPP; +} + +static inline int mdc_quotactl(struct obd_export *exp, struct obd_quotactl *oqctl) +{ + return -ENOTSUPP; +} +#endif + + diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index a04d020..04c0485 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -618,97 +618,6 @@ int mdc_readpage(struct obd_export *exp, struct ll_fid *mdc_fid, __u64 offset, return rc; } -static int mdc_quotacheck(struct obd_export *exp, struct obd_quotactl *oqctl) -{ - struct client_obd *cli = &exp->exp_obd->u.cli; - struct ptlrpc_request *req; - struct obd_quotactl *body; - int size = sizeof(*body); - int rc; - ENTRY; - - req = ptlrpc_prep_req(class_exp2cliimp(exp), MDS_QUOTACHECK, 1, &size, - NULL); - if (!req) - GOTO(out, rc = -ENOMEM); - - body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body)); - memcpy(body, oqctl, sizeof(*body)); - - req->rq_replen = lustre_msg_size(0, NULL); - - spin_lock(&cli->cl_qchk_lock); - cli->cl_qchk_stat = CL_QUOTACHECKING; - spin_unlock(&cli->cl_qchk_lock); - rc = ptlrpc_queue_wait(req); - if (rc) { - spin_lock(&cli->cl_qchk_lock); - cli->cl_qchk_stat = rc; - spin_unlock(&cli->cl_qchk_lock); - } -out: - ptlrpc_req_finished(req); - RETURN (rc); -} - -static int mdc_poll_quotacheck(struct obd_export *exp, - struct if_quotacheck *qchk) -{ - struct client_obd *cli = &exp->exp_obd->u.cli; - int stat; - ENTRY; - - spin_lock(&cli->cl_qchk_lock); - stat = cli->cl_qchk_stat; - spin_unlock(&cli->cl_qchk_lock); - - qchk->stat = stat; - if (stat == CL_QUOTACHECKING) { - qchk->stat = -ENODATA; - stat = 0; - } else if (stat) { - if (qchk->stat > CL_QUOTACHECKING) - qchk->stat = stat = -EINTR; - - strncpy(qchk->obd_type, LUSTRE_MDS_NAME, 10); - qchk->obd_uuid = cli->cl_import->imp_target_uuid; - } - RETURN(stat); -} - -static int mdc_quotactl(struct obd_export *exp, struct obd_quotactl *oqctl) -{ - struct ptlrpc_request *req; - struct obd_quotactl *oqc; - int size = sizeof(*oqctl); - int rc; - ENTRY; - - req = ptlrpc_prep_req(class_exp2cliimp(exp), MDS_QUOTACTL, 1, &size, - NULL); - if (!req) - GOTO(out, rc = -ENOMEM); - - memcpy(lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*oqctl)), oqctl, size); - - req->rq_replen = lustre_msg_size(1, &size); - - rc = ptlrpc_queue_wait(req); - if (!rc) { - oqc = lustre_swab_repbuf(req, 0, sizeof (*oqc), - lustre_swab_obd_quotactl); - if (oqc == NULL) { - CERROR ("Can't unpack mds_body\n"); - GOTO(out, rc = -EPROTO); - } - - memcpy(oqctl, oqc, sizeof(*oqctl)); - } -out: - ptlrpc_req_finished(req); - RETURN (rc); -} - static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, void *karg, void *uarg) { diff --git a/lustre/mds/Makefile.in b/lustre/mds/Makefile.in index a7882cc..3e8cff6 100644 --- a/lustre/mds/Makefile.in +++ b/lustre/mds/Makefile.in @@ -3,7 +3,7 @@ mds-objs := mds_log.o mds_unlink_open.o mds_lov.o handler.o mds_reint.o mds-objs += mds_fs.o lproc_mds.o mds_open.o mds_lib.o ifeq ($(PATCHLEVEL),6) -mds-objs += quota_master.o +#mds-objs += quota_master.o endif @INCLUDE_RULES@ diff --git a/lustre/mds/autoMakefile.am b/lustre/mds/autoMakefile.am index 13e06a3..e5bdbcf 100644 --- a/lustre/mds/autoMakefile.am +++ b/lustre/mds/autoMakefile.am @@ -8,5 +8,4 @@ modulefs_DATA = mds$(KMODEXT) endif MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ -DIST_SOURCES := $(mds-objs:%.o=%.c) mds_internal.h -DIST_SOURCES += quota_context.c quota_master.c +DIST_SOURCES := $(mds-objs:%.o=%.c) mds_internal.h diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 512c9af..81ddfaf 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -57,8 +57,6 @@ #include "mds_internal.h" -static struct quotacheck_info qchkinfo; - static int mds_intent_policy(struct ldlm_namespace *ns, struct ldlm_lock **lockp, void *req_cookie, ldlm_mode_t mode, int flags, void *data); @@ -1026,205 +1024,6 @@ out: RETURN(0); } -static int mds_quotacheck_callback(struct obd_export *exp, - struct obd_quotactl *oqctl) -{ - struct ptlrpc_request *req; - struct obd_quotactl *body; - int rc, size = sizeof(*oqctl); - - req = ptlrpc_prep_req(exp->exp_imp_reverse, OBD_QC_CALLBACK, - 1, &size, NULL); - if (!req) - RETURN(-ENOMEM); - - body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body)); - memcpy(body, oqctl, sizeof(*oqctl)); - - req->rq_replen = lustre_msg_size(0, NULL); - - rc = ptlrpc_queue_wait(req); - ptlrpc_req_finished(req); - - RETURN(rc); -} - - -static int mds_quotacheck_thread(void *data) -{ - unsigned long flags; - struct quotacheck_info *qchki = data; - struct obd_device *obd; - struct obd_export *exp; - struct obd_quotactl *oqctl; - struct lvfs_run_ctxt saved; - int rc; - - lock_kernel(); - ptlrpc_daemonize(); - - SIGNAL_MASK_LOCK(current, flags); - sigfillset(¤t->blocked); - RECALC_SIGPENDING; - SIGNAL_MASK_UNLOCK(current, flags); - - THREAD_NAME(current->comm, sizeof(current->comm) - 1, "quotacheck"); - unlock_kernel(); - - complete(&qchki->qi_starting); - - exp = qchki->qi_exp; - oqctl = &qchki->qi_oqctl; - obd = exp->exp_obd; - - push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - - rc = fsfilt_quotacheck(obd, obd->u.mds.mds_sb, oqctl); - if (rc) - CERROR("%s: fsfilt_quotacheck: %d\n", obd->obd_name, rc); - - pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - - rc = mds_quotacheck_callback(exp, oqctl); - - atomic_inc(&obd->u.mds.mds_quotachecking); - - return rc; -} - -static int mds_quotacheck(struct ptlrpc_request *req) -{ - struct obd_device *obd = req->rq_export->exp_obd; - struct mds_obd *mds = &obd->u.mds; - struct obd_quotactl *oqctl; - int rc = 0; - ENTRY; - - oqctl = lustre_swab_reqbuf(req, 0, sizeof(*oqctl), - lustre_swab_obd_quotactl); - if (oqctl == NULL) - RETURN(-EPROTO); - - rc = lustre_pack_reply(req, 0, NULL, NULL); - if (rc) { - CERROR("mds: out of memory while packing quotacheck reply\n"); - RETURN(rc); - } - - /* XXX: quotaoff */ - GOTO(out, rc = -EOPNOTSUPP); - - if (!atomic_dec_and_test(&mds->mds_quotachecking)) { - atomic_inc(&mds->mds_quotachecking); - GOTO(out, rc = -EBUSY); - } - - init_completion(&qchkinfo.qi_starting); - qchkinfo.qi_exp = req->rq_export; - memcpy(&qchkinfo.qi_oqctl, oqctl, sizeof(*oqctl)); - - rc = init_admin_quotafiles(obd, &qchkinfo.qi_oqctl); - if (rc) { - CERROR("init_admin_quotafiles failed: %d\n", rc); - atomic_inc(&mds->mds_quotachecking); - GOTO(out, rc); - } - - rc = kernel_thread(mds_quotacheck_thread, &qchkinfo, CLONE_VM|CLONE_FILES); - if (rc < 0) { - CERROR("%s: error starting mds_quotacheck_thread: %d\n", - obd->obd_name, rc); - atomic_inc(&mds->mds_quotachecking); - } else { - CDEBUG(D_INFO, "%s: mds_quotacheck_thread: %d\n", - obd->obd_name, rc); - wait_for_completion(&qchkinfo.qi_starting); - rc = 0; - } -out: - req->rq_status = rc; - RETURN(0); -} - -static int mds_quotactl(struct ptlrpc_request *req) -{ - struct obd_device *obd = req->rq_export->exp_obd; - struct obd_quotactl *oqctl, *repoqc; - struct lvfs_run_ctxt saved; - int rc = 0, size = sizeof(*repoqc); - ENTRY; - - oqctl = lustre_swab_reqbuf(req, 0, sizeof(*oqctl), - lustre_swab_obd_quotactl); - if (oqctl == NULL) - RETURN(-EPROTO); - - rc = lustre_pack_reply(req, 1, &size, NULL); - if (rc) - RETURN(rc); - - /* XXX: quotaoff */ - GOTO(out, rc = -EOPNOTSUPP); - - repoqc = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*repoqc)); - memcpy(repoqc, oqctl, sizeof(*repoqc)); - - switch (repoqc->qc_cmd) { - case Q_QUOTAON: - rc = mds_quota_on(obd, repoqc); - break; - case Q_QUOTAOFF: - mds_quota_off(obd, repoqc); - break; - case Q_SETINFO: - rc = mds_set_dqinfo(obd, repoqc); - break; - case Q_GETINFO: - rc = mds_get_dqinfo(obd, repoqc); - break; - case Q_SETQUOTA: - rc = mds_set_dqblk(obd, repoqc); - break; - case Q_GETQUOTA: - rc = mds_get_dqblk(obd, repoqc); - break; - case Q_GETOINFO: - case Q_GETOQUOTA: - break; - default: - CERROR("%s: unsupported mds_quotactl command: %d\n", - obd->obd_name, repoqc->qc_cmd); - LBUG(); - } - - if (rc) { - CDEBUG(D_INFO, "mds_quotactl admin op failed: rc = %d\n", rc); - GOTO(out, rc); - } - - if (repoqc->qc_cmd == Q_QUOTAON || repoqc->qc_cmd == Q_QUOTAOFF || - Q_GETOCMD(repoqc) || repoqc->qc_cmd == Q_GETQUOTA) { - struct obd_quotactl *loqc = repoqc; - - if (repoqc->qc_cmd == Q_GETQUOTA) - loqc = oqctl; - - push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - rc = fsfilt_quotactl(obd, obd->u.mds.mds_sb, loqc); - pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - - if (!rc && loqc->qc_cmd == Q_GETQUOTA) { - repoqc->qc_dqblk.dqb_curinodes += - loqc->qc_dqblk.dqb_curinodes; - repoqc->qc_dqblk.dqb_curspace += - loqc->qc_dqblk.dqb_curspace; - } - } -out: - req->rq_status = rc; - RETURN(0); -} - int mds_reint(struct ptlrpc_request *req, int offset, struct lustre_handle *lockh) { @@ -1696,15 +1495,12 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf) LASSERT(!lvfs_check_rdonly(lvfs_sbdev(mnt->mnt_sb))); - sema_init(&mds->mds_quota_info.qi_sem, 1); sema_init(&mds->mds_orphan_recovery_sem, 1); sema_init(&mds->mds_epoch_sem, 1); spin_lock_init(&mds->mds_transno_lock); mds->mds_max_mdsize = sizeof(struct lov_mds_md); mds->mds_max_cookiesize = sizeof(struct llog_cookie); - atomic_set(&mds->mds_quotachecking, 1); - sprintf(ns_name, "mds-%s", obd->obd_uuid.uuid); obd->obd_namespace = ldlm_namespace_new(ns_name, LDLM_NAMESPACE_SERVER); if (obd->obd_namespace == NULL) { @@ -1743,14 +1539,7 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf) "mds_ldlm_client", &obd->obd_ldlm_client); obd->obd_replayable = 1; - /* initialize quota master and quota context */ - sema_init(&mds->mds_quota_info.qi_sem, 1); - rc = qctxt_init(&mds->mds_quota_ctxt, mds->mds_sb, dqacq_handler); - if (rc) { - CERROR("initialize quota context failed! (rc:%d)\n", rc); - qctxt_cleanup(&mds->mds_quota_ctxt, 0); - GOTO(err_fs, rc); - } + mds_quota_setup(mds); rc = mds_postsetup(obd); if (rc) @@ -1987,7 +1776,7 @@ static int mds_cleanup(struct obd_device *obd) lprocfs_obd_cleanup(obd); - qctxt_cleanup(&mds->mds_quota_ctxt, 0); + mds_quota_cleanup(mds); mds_update_server_data(obd, 1); if (mds->mds_lov_objids != NULL) { diff --git a/lustre/mds/lproc_mds.c b/lustre/mds/lproc_mds.c index 1185866..fe5d6f5 100644 --- a/lustre/mds/lproc_mds.c +++ b/lustre/mds/lproc_mds.c @@ -29,6 +29,8 @@ #include #include +#include "mds_internal.h" + #ifdef LPROCFS static int lprocfs_mds_rd_mntdev(char *page, char **start, off_t off, int count, int *eof, void *data) @@ -42,121 +44,6 @@ static int lprocfs_mds_rd_mntdev(char *page, char **start, off_t off, int count, return snprintf(page, count, "%s\n",obd->u.mds.mds_vfsmnt->mnt_devname); } -static int lprocfs_mds_rd_bunit(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - LASSERT(obd != NULL); - - return snprintf(page, count, "%lu\n", - obd->u.mds.mds_quota_ctxt.lqc_bunit_sz); -} - -static int lprocfs_mds_rd_iunit(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - LASSERT(obd != NULL); - - return snprintf(page, count, "%lu\n", - obd->u.mds.mds_quota_ctxt.lqc_iunit_sz); -} - -static int lprocfs_mds_wr_bunit(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - int val, rc = 0; - LASSERT(obd != NULL); - - rc = lprocfs_write_helper(buffer, count, &val); - if (rc) - return rc; - - if (val % QUOTABLOCK_SIZE || - val <= obd->u.mds.mds_quota_ctxt.lqc_btune_sz) - return -EINVAL; - - obd->u.mds.mds_quota_ctxt.lqc_bunit_sz = val; - return count; -} - -static int lprocfs_mds_wr_iunit(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - int val, rc = 0; - LASSERT(obd != NULL); - - rc = lprocfs_write_helper(buffer, count, &val); - if (rc) - return rc; - - if (val <= obd->u.mds.mds_quota_ctxt.lqc_itune_sz) - return -EINVAL; - - obd->u.mds.mds_quota_ctxt.lqc_iunit_sz = val; - return count; -} - -static int lprocfs_mds_rd_btune(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - LASSERT(obd != NULL); - - return snprintf(page, count, "%lu\n", - obd->u.mds.mds_quota_ctxt.lqc_btune_sz); -} - -static int lprocfs_mds_rd_itune(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - LASSERT(obd != NULL); - - return snprintf(page, count, "%lu\n", - obd->u.mds.mds_quota_ctxt.lqc_itune_sz); -} - -static int lprocfs_mds_wr_btune(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - int val, rc = 0; - LASSERT(obd != NULL); - - rc = lprocfs_write_helper(buffer, count, &val); - if (rc) - return rc; - - if (val <= QUOTABLOCK_SIZE * MIN_QLIMIT || val % QUOTABLOCK_SIZE || - val >= obd->u.mds.mds_quota_ctxt.lqc_bunit_sz) - return -EINVAL; - - obd->u.mds.mds_quota_ctxt.lqc_btune_sz = val; - return count; -} - -static int lprocfs_mds_wr_itune(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - int val, rc = 0; - LASSERT(obd != NULL); - - rc = lprocfs_write_helper(buffer, count, &val); - if (rc) - return rc; - - if (val <= MIN_QLIMIT || - val >= obd->u.mds.mds_quota_ctxt.lqc_iunit_sz) - return -EINVAL; - - obd->u.mds.mds_quota_ctxt.lqc_itune_sz = val; - return count; -} - struct lprocfs_vars lprocfs_mds_obd_vars[] = { { "uuid", lprocfs_rd_uuid, 0, 0 }, { "blocksize", lprocfs_rd_blksize, 0, 0 }, @@ -170,10 +57,12 @@ struct lprocfs_vars lprocfs_mds_obd_vars[] = { { "recovery_status", lprocfs_obd_rd_recovery_status, 0, 0 }, { "evict_client", 0, lprocfs_wr_evict_client, 0 }, { "num_exports", lprocfs_rd_num_exports, 0, 0 }, +#ifdef HAVE_QUOTA_SUPPORT { "quota_bunit_sz", lprocfs_mds_rd_bunit, lprocfs_mds_wr_bunit, 0 }, { "quota_btune_sz", lprocfs_mds_rd_btune, lprocfs_mds_wr_btune, 0 }, { "quota_iunit_sz", lprocfs_mds_rd_iunit, lprocfs_mds_wr_iunit, 0 }, { "quota_itune_sz", lprocfs_mds_rd_itune, lprocfs_mds_wr_itune, 0 }, +#endif { 0 } }; diff --git a/lustre/mds/mds_fs.c b/lustre/mds/mds_fs.c index 9266426..329f900 100644 --- a/lustre/mds/mds_fs.c +++ b/lustre/mds/mds_fs.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) #include #endif @@ -563,17 +563,9 @@ int mds_fs_cleanup(struct obd_device *obd) l_dput(mds->mds_pending_dir); mds->mds_pending_dir = NULL; } - - /* close admin quota files */ - down(&mds->mds_quota_info.qi_sem); - for (i = 0; i < MAXQUOTAS; i++) { - if (mds->mds_quota_info.qi_files[i]) { - filp_close(mds->mds_quota_info.qi_files[i], 0); - mds->mds_quota_info.qi_files[i] = NULL; - } - } - up(&mds->mds_quota_info.qi_sem); + mds_fs_quota_cleanup(mds); + pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); shrink_dcache_parent(mds->mds_fid_de); dput(mds->mds_fid_de); diff --git a/lustre/mds/mds_internal.h b/lustre/mds/mds_internal.h index b33d53e..ceca1cb 100644 --- a/lustre/mds/mds_internal.h +++ b/lustre/mds/mds_internal.h @@ -193,7 +193,7 @@ void mds_pack_inode2body(struct mds_body *body, struct inode *inode); #endif /* mds/quota_master.c */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) && defined (HAVE_QUOTA_SUPPORT) int lustre_dquot_init(void); void lustre_dquot_exit(void); int dqacq_handler(struct obd_device *obd, struct qunit_data *qdata, int opc); @@ -228,6 +228,49 @@ static inline int mds_set_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl) { return 0; } static inline int mds_get_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl) { return 0; } -#endif /* KERNEL_VERSION(2,5,0) */ +#endif /* KERNEL_VERSION(2,5,0) && QUOTA */ + +#ifdef HAVE_QUOTA_SUPPORT +/* Internal quota stuff */ +int mds_quotacheck(struct ptlrpc_request *req); +int mds_quotactl(struct ptlrpc_request *req); +void mds_quota_setup(struct mds_obd *mds); +void mds_quota_cleanup(struct mds_obd *mds); +void mds_fs_quota_cleanup(struct mds_obd *mds); + +#ifdef LPROCFS +int lprocfs_mds_rd_bunit(char *page, char **start, off_t off, int count, + int *eof, void *data); +int lprocfs_mds_rd_iunit(char *page, char **start, off_t off, int count, + int *eof, void *data); +int lprocfs_mds_wr_bunit(struct file *file, const char *buffer, + unsigned long count, void *data); +int lprocfs_mds_wr_iunit(struct file *file, const char *buffer, + unsigned long count, void *data); +int lprocfs_mds_rd_btune(char *page, char **start, off_t off, int count, + int *eof, void *data); +int lprocfs_mds_rd_itune(char *page, char **start, off_t off, int count, + int *eof, void *data); +int lprocfs_mds_wr_btune(struct file *file, const char *buffer, + unsigned long count, void *data); +int lprocfs_mds_wr_itune(struct file *file, const char *buffer, + unsigned long count, void *data); +#endif /* LPROCFS */ +#else /* QUOTA */ +static inline int mds_quotacheck(struct ptlrpc_request *req) +{ + req->rq_status = -EOPNOTSUPP; + return -EOPNOTSUPP; +} +static inline int mds_quotactl(struct ptlrpc_request *req) +{ + req->rq_status = -EOPNOTSUPP; + return -EOPNOTSUPP; +} +static inline void mds_quota_setup(struct mds_obd *mds) {} +static inline void mds_quota_cleanup(struct mds_obd *mds) {} +static inline void mds_fs_quota_cleanup(struct mds_obd *mds) {} +#endif /* Quota */ + #endif /* _MDS_INTERNAL_H */ diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c index e1697b4..39cf431 100644 --- a/lustre/mds/mds_open.c +++ b/lustre/mds/mds_open.c @@ -305,8 +305,7 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset, struct mds_update_record *rec, struct mds_obd *mds, struct obd_device *obd, struct dentry *dchild, void **handle, - obd_id **ids, struct llog_cookie **ret_logcookies, - int *setattr_async_flag) + obd_id **ids) { struct obdo *oa; struct obd_trans_info oti = { 0 }; @@ -367,8 +366,6 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset, RETURN(0); } - LASSERT(ret_logcookies); - LASSERT(setattr_async_flag); if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_MDS_ALLOC_OBDO)) GOTO(out_ids, rc = -ENOMEM); @@ -427,7 +424,6 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset, } GOTO(out_oa, rc); } - *setattr_async_flag = 1; } else { rc = obd_iocontrol(OBD_IOC_LOV_SETEA, mds->mds_osc_exp, 0, &lsm, rec->ur_eadata); @@ -462,36 +458,14 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset, lmm_size = rc; body->eadatasize = rc; - if (*handle == NULL) { - if (*setattr_async_flag) - *handle = fsfilt_start_log(obd, inode, - FSFILT_OP_CREATE, NULL, - le32_to_cpu(lmm->lmm_stripe_count)); - else - *handle = fsfilt_start(obd, inode, FSFILT_OP_CREATE, NULL); - } + if (*handle == NULL) + *handle = fsfilt_start(obd, inode, FSFILT_OP_CREATE, NULL); if (IS_ERR(*handle)) { rc = PTR_ERR(*handle); *handle = NULL; GOTO(out_oa, rc); } - /* write mds setattr log for created objects */ - if (*setattr_async_flag && lmm_size) { - struct llog_cookie *logcookies = NULL; - - OBD_ALLOC(logcookies, mds->mds_max_cookiesize); - if (logcookies == NULL) - GOTO(out_oa, rc = -ENOMEM); - *ret_logcookies = logcookies; - - if (mds_log_op_setattr(obd, inode, lmm, lmm_size, logcookies, - mds->mds_max_cookiesize) <= 0) { - OBD_FREE(logcookies, mds->mds_max_cookiesize); - *ret_logcookies = NULL; - } - } - rc = fsfilt_set_md(obd, inode, *handle, lmm, lmm_size); lmm_buf = lustre_msg_buf(req->rq_repmsg, offset, 0); lmm_bufsize = req->rq_repmsg->buflens[offset]; @@ -664,9 +638,7 @@ static int accmode(struct inode *inode, int flags) /* Handles object creation, actual opening, and I/O epoch */ static int mds_finish_open(struct ptlrpc_request *req, struct dentry *dchild, struct mds_body *body, int flags, void **handle, - struct mds_update_record *rec,struct ldlm_reply *rep, - struct llog_cookie **logcookies, - int *setattr_async_flag) + struct mds_update_record *rec,struct ldlm_reply *rep) { struct mds_obd *mds = mds_req2mds(req); struct obd_device *obd = req->rq_export->exp_obd; @@ -696,8 +668,7 @@ static int mds_finish_open(struct ptlrpc_request *req, struct dentry *dchild, if (!(body->valid & OBD_MD_FLEASIZE)) { /* no EA: create objects */ rc = mds_create_objects(req, 2, rec, mds, obd, - dchild, handle, &ids, - logcookies, setattr_async_flag); + dchild, handle, &ids); if (rc) { CERROR("mds_create_objects: rc = %d\n", rc); up(&dchild->d_inode->i_sem); @@ -774,8 +745,7 @@ static int mds_open_by_fid(struct ptlrpc_request *req, struct ll_fid *fid, intent_set_disposition(rep, DISP_LOOKUP_POS); open: - rc = mds_finish_open(req, dchild, body, flags, &handle, rec, rep, - NULL, NULL); + rc = mds_finish_open(req, dchild, body, flags, &handle, rec, rep); rc = mds_finish_transno(mds, dchild ? dchild->d_inode : NULL, handle, req, rc, rep ? rep->lock_policy_res1 : 0); /* XXX what do we do here if mds_finish_transno itself failed? */ @@ -848,10 +818,6 @@ int mds_open(struct mds_update_record *rec, int offset, int parent_mode = LCK_PR; void *handle = NULL; struct dentry_params dp; - struct lov_mds_md *lmm = NULL; - int lmm_size = 0; - struct llog_cookie *logcookies = NULL; - int setattr_async_flag = 0; uid_t parent_uid = 0; gid_t parent_gid = 0; ENTRY; @@ -1082,21 +1048,12 @@ int mds_open(struct mds_update_record *rec, int offset, /* Step 5: mds_open it */ rc = mds_finish_open(req, dchild, body, rec->ur_flags, &handle, rec, - rep, &logcookies, &setattr_async_flag); + rep); GOTO(cleanup, rc); cleanup: rc = mds_finish_transno(mds, dchild ? dchild->d_inode : NULL, handle, req, rc, rep ? rep->lock_policy_res1 : 0); - /* do mds to ost setattr for new created objects */ - if (rc == 0 && setattr_async_flag) { - lmm = lustre_msg_buf(req->rq_repmsg, 2, 0); - lmm_size = req->rq_repmsg->buflens[2]; - mds_osc_setattr_async(obd, dchild->d_inode, lmm, lmm_size, - logcookies); - } - if (logcookies) - OBD_FREE(logcookies, mds->mds_max_cookiesize); cleanup_no_trans: switch (cleanup_phase) { diff --git a/lustre/mds/quota_context.c b/lustre/mds/quota_context.c index d601edb..1672bb2 100644 --- a/lustre/mds/quota_context.c +++ b/lustre/mds/quota_context.c @@ -9,18 +9,8 @@ * * This file is part of Lustre, http://www.lustre.org. * - * Lustre is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. + * No redistribution or use is permitted outside of Cluster File Systems, Inc. * - * Lustre 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 for more details. - * - * You should have received a copy of the GNU General Public License - * along with Lustre; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef EXPORT_SYMTAB # define EXPORT_SYMTAB diff --git a/lustre/mds/quota_master.c b/lustre/mds/quota_master.c index 5346ddc..36c27e0 100644 --- a/lustre/mds/quota_master.c +++ b/lustre/mds/quota_master.c @@ -9,18 +9,8 @@ * * This file is part of Lustre, http://www.lustre.org. * - * Lustre is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. + * No redistribution or use is permitted outside of Cluster File Systems, Inc. * - * Lustre 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 for more details. - * - * You should have received a copy of the GNU General Public License - * along with Lustre; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef EXPORT_SYMTAB # define EXPORT_SYMTAB diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 5a0060f..a4960ae 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -50,12 +50,14 @@ kmem_cache_t *obdo_cachep = NULL; EXPORT_SYMBOL(obdo_cachep); kmem_cache_t *import_cachep = NULL; +#ifdef HAVE_QUOTA_SUPPORT kmem_cache_t *qunit_cachep = NULL; struct list_head qunit_hash[NR_DQHASH]; spinlock_t qunit_hash_lock = SPIN_LOCK_UNLOCKED; EXPORT_SYMBOL(qunit_cachep); EXPORT_SYMBOL(qunit_hash); EXPORT_SYMBOL(qunit_hash_lock); +#endif int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c); @@ -370,6 +372,7 @@ struct obd_device * class_devices_in_group(struct obd_uuid *grp_uuid, int *next) static void obd_cleanup_qunit_cache(void) { +#ifdef HAVE_QUOTA_SUPPORT int i; ENTRY; @@ -384,6 +387,7 @@ static void obd_cleanup_qunit_cache(void) qunit_cachep = NULL; } EXIT; +#endif } void obd_cleanup_caches(void) @@ -405,6 +409,8 @@ void obd_cleanup_caches(void) static int obd_init_qunit_cache(void) { + +#ifdef HAVE_QUOTA_SUPPORT int i; ENTRY; @@ -419,6 +425,7 @@ static int obd_init_qunit_cache(void) for (i = 0; i < NR_DQHASH; i++) INIT_LIST_HEAD(qunit_hash + i); spin_unlock(&qunit_hash_lock); +#endif RETURN(0); } diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 93d4996..97ea2dd 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -42,7 +42,6 @@ #include #include #include -#include #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) # include # include @@ -1278,8 +1277,6 @@ int filter_common_setup(struct obd_device *obd, obd_count len, void *buf, spin_lock_init(&filter->fo_w_disk_iosize.oh_lock); filter->fo_readcache_max_filesize = FILTER_MAX_CACHE_SIZE; - atomic_set(&filter->fo_quotachecking, 1); - sprintf(ns_name, "filter-%s", obd->obd_uuid.uuid); obd->obd_namespace = ldlm_namespace_new(ns_name, LDLM_NAMESPACE_SERVER); if (obd->obd_namespace == NULL) @@ -1297,10 +1294,8 @@ int filter_common_setup(struct obd_device *obd, obd_count len, void *buf, GOTO(err_post, rc); } - rc = qctxt_init(&filter->fo_quota_ctxt, filter->fo_sb, NULL); + rc = filter_quota_setup(filter); if (rc) { - CERROR("initialize quota context failed! (rc:%d)\n", rc); - qctxt_cleanup(&filter->fo_quota_ctxt, 0); GOTO(err_post, rc); } @@ -1468,7 +1463,7 @@ static int filter_cleanup(struct obd_device *obd) ping_evictor_stop(); - qctxt_cleanup(&filter->fo_quota_ctxt, 0); + filter_quota_cleanup(filter); ldlm_namespace_free(obd->obd_namespace, obd->obd_force); @@ -2548,8 +2543,7 @@ static int filter_set_info(struct obd_export *exp, __u32 keylen, ctxt = llog_get_context(obd, LLOG_MDS_OST_REPL_CTXT); rc = llog_receptor_accept(ctxt, exp->exp_imp_reverse); - /* setup the quota context import */ - obd->u.filter.fo_quota_ctxt.lqc_import = exp->exp_imp_reverse; + filter_quota_set_info(exp, obd); RETURN(rc); } @@ -2622,67 +2616,6 @@ int filter_iocontrol(unsigned int cmd, struct obd_export *exp, RETURN(0); } -static int filter_quotacheck(struct obd_export *exp, struct obd_quotactl *oqctl) -{ - struct lvfs_run_ctxt saved; - struct obd_device *obd = exp->exp_obd; - int rc; - - push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - - rc = fsfilt_quotacheck(obd, obd->u.filter.fo_sb, oqctl); - if (rc) - CERROR("%s: fsfilt_quotacheck: %d\n", obd->obd_name, rc); - - pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - - RETURN(rc); -} - -static int filter_quotactl(struct obd_export *exp, struct obd_quotactl *oqctl) -{ - struct obd_device *obd = exp->exp_obd; - struct lvfs_run_ctxt saved; - int rc = 0; - ENTRY; - - if (oqctl->qc_cmd == Q_QUOTAON || oqctl->qc_cmd == Q_QUOTAOFF || - oqctl->qc_cmd == Q_GETOINFO || oqctl->qc_cmd == Q_GETOQUOTA || - oqctl->qc_cmd == Q_GETQUOTA) { - push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - rc = fsfilt_quotactl(obd, obd->u.filter.fo_sb, oqctl); - pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - } else if (oqctl->qc_cmd == Q_INITQUOTA) { - unsigned int uid = 0, gid = 0; - - /* initialize quota limit to MIN_QLIMIT */ - LASSERT(oqctl->qc_dqblk.dqb_valid == QIF_BLIMITS); - LASSERT(oqctl->qc_dqblk.dqb_bhardlimit == MIN_QLIMIT); - LASSERT(oqctl->qc_dqblk.dqb_bsoftlimit == 0); - oqctl->qc_cmd = Q_SETQUOTA; - rc = fsfilt_quotactl(obd, obd->u.filter.fo_sb, oqctl); - /* this value will be replied to client, we must restore it */ - oqctl->qc_cmd = Q_INITQUOTA; - if (rc) - RETURN(rc); - - /* trigger qunit pre-acquire */ - if (oqctl->qc_type == USRQUOTA) - uid = oqctl->qc_id; - else - gid = oqctl->qc_id; - - rc = qctxt_adjust_qunit(obd, &obd->u.filter.fo_quota_ctxt, - uid, gid, 1); - } else { - CERROR("%s: unsupported filter_quotactl command: %d\n", - obd->obd_name, oqctl->qc_cmd); - LBUG(); - } - - RETURN(rc); -} - static struct dentry *filter_lvfs_fid2dentry(__u64 id, __u32 gen, __u64 gr, void *data) { diff --git a/lustre/obdfilter/filter_internal.h b/lustre/obdfilter/filter_internal.h index 05419a1..1c30fbc 100644 --- a/lustre/obdfilter/filter_internal.h +++ b/lustre/obdfilter/filter_internal.h @@ -185,8 +185,70 @@ static inline void filter_tally_write(struct filter_obd *filter, unsigned long *blocks, int blocks_per_page) {} static inline void filter_tally_read(struct filter_obd *filter, struct niobuf_local *lnb, int niocount) {} -static inline int lproc_filter_attach_seqstat(struct obd_device *dev) {} +static inline int lproc_filter_attach_seqstat(struct obd_device *dev) {}; #endif +/* Quota stuff */ +#ifdef HAVE_QUOTA_SUPPORT +int filter_quota_setup(struct filter_obd *filter); +void filter_quota_cleanup(struct filter_obd *filter); +void filter_quota_set_info(struct obd_export *exp, struct obd_device *obd); +int filter_quotacheck(struct obd_export *exp, struct obd_quotactl *oqctl); +int filter_quotactl(struct obd_export *exp, struct obd_quotactl *oqctl); +int filter_quota_enforcement(struct obd_device *obd, + unsigned int fsuid, unsigned int fsgid, + struct lvfs_ucred **ret_uc); +int filter_get_quota_flag(struct obd_device *obd, struct obdo *oa); +int filter_quota_check_master(struct obd_device *obd, struct inode *inode); + +#ifdef LPROCFS +int lprocfs_filter_rd_bunit(char *page, char **start, off_t off, + int count, int *eof, void *data); +int lprocfs_filter_rd_iunit(char *page, char **start, off_t off, + int count, int *eof, void *data); +int lprocfs_filter_wr_bunit(struct file *file, const char *buffer, + unsigned long count, void *data); +int lprocfs_filter_wr_iunit(struct file *file, const char *buffer, + unsigned long count, void *data); +int lprocfs_filter_rd_btune(char *page, char **start, off_t off, + int count, int *eof, void *data); +int lprocfs_filter_rd_itune(char *page, char **start, off_t off, + int count, int *eof, void *data); +int lprocfs_filter_wr_btune(struct file *file, const char *buffer, + unsigned long count, void *data); +int lprocfs_filter_wr_itune(struct file *file, const char *buffer, + unsigned long count, void *data); +#endif /* LPROCFS */ +#else /* Quota */ +static inline int filter_quota_setup(struct filter_obd *filter) +{ + return 0; +} +static inline void filter_quota_cleanup(struct filter_obd *filter) {} +static inline void filter_quota_set_info(struct obd_export *exp, struct obd_device *obd) {} +static inline int filter_quotacheck(struct obd_export *exp, struct obd_quotactl *oqctl) +{ + return -ENOTSUPP; +} +static inline int filter_quotactl(struct obd_export *exp, struct obd_quotactl *oqctl) +{ + return -ENOTSUPP; +} +static inline int filter_quota_enforcement(struct obd_device *obd, + unsigned int fsuid, unsigned int fsgid, + struct lvfs_ucred **ret_uc) +{ + return 0; +} +static inline int filter_get_quota_flag(struct obd_device *obd, + struct obdo *oa) +{ + return 0; +} +static inline int filter_quota_check_master(struct obd_device *obd, struct inode *inode) +{ + return 0; +} +#endif /* Quota */ #endif diff --git a/lustre/obdfilter/filter_io_26.c b/lustre/obdfilter/filter_io_26.c index bf3d22b..a706583 100644 --- a/lustre/obdfilter/filter_io_26.c +++ b/lustre/obdfilter/filter_io_26.c @@ -403,71 +403,6 @@ static int filter_clear_page_cache(struct inode *inode, return 0; } -static int filter_quota_enforcement(struct obd_device *obd, - unsigned int fsuid, unsigned int fsgid, - struct lvfs_ucred **ret_uc) -{ - struct filter_obd *filter = &obd->u.filter; - struct lvfs_ucred *uc = NULL; - ENTRY; - - if (!sb_any_quota_enabled(filter->fo_sb)) - RETURN(0); - - OBD_ALLOC(uc, sizeof(*uc)); - if (!uc) - RETURN(-ENOMEM); - *ret_uc = uc; - - uc->luc_fsuid = fsuid; - uc->luc_fsgid = fsgid; - uc->luc_cap = current->cap_effective; - if (!fsuid) - cap_raise(uc->luc_cap, CAP_SYS_RESOURCE); - else - cap_lower(uc->luc_cap, CAP_SYS_RESOURCE); - - RETURN(0); -} - -static int filter_get_quota_flag(struct obd_device *obd, - struct obdo *oa) -{ - struct filter_obd *filter = &obd->u.filter; - int cnt; - int rc = 0, err; - ENTRY; - - if (!sb_any_quota_enabled(filter->fo_sb)) - RETURN(rc); - - oa->o_flags = QUOTA_OK; - - for (cnt = 0; cnt < MAXQUOTAS; cnt++) { - struct obd_quotactl oqctl; - - oqctl.qc_cmd = Q_GETQUOTA; - oqctl.qc_type = cnt; - oqctl.qc_id = (cnt == USRQUOTA) ? oa->o_uid : oa->o_gid; - err = fsfilt_quotactl(obd, filter->fo_sb, &oqctl); - if (err) { - if (!rc) - rc = err; - continue; - } - - /* set over quota flags for a uid/gid */ - oa->o_valid |= (cnt == USRQUOTA) ? - OBD_MD_FLUSRQUOTA : OBD_MD_FLGRPQUOTA; - if (oqctl.qc_dqblk.dqb_bhardlimit && - (toqb(oqctl.qc_dqblk.dqb_curspace) > oqctl.qc_dqblk.dqb_bhardlimit)) - oa->o_flags |= (cnt == USRQUOTA) ? - OBD_FL_NO_USRQUOTA : OBD_FL_NO_GRPQUOTA; - } - - RETURN(rc); -} - /* Must be called with i_sem taken for writes; this will drop it */ int filter_direct_io(int rw, struct dentry *dchild, void *iobuf, struct obd_export *exp, struct iattr *attr, @@ -477,7 +412,6 @@ int filter_direct_io(int rw, struct dentry *dchild, void *iobuf, struct dio_request *dreq = iobuf; struct inode *inode = dchild->d_inode; int blocks_per_page = PAGE_SIZE >> inode->i_blkbits; - struct lustre_quota_ctxt *qctxt = &obd->u.filter.fo_quota_ctxt; int rc, rc2; ENTRY; @@ -512,8 +446,7 @@ remap: * pre-dqacq in time or this user has exceeded quota limit, we * have to wait for the completion of in flight dqacq/dqrel, * then try again */ - if (qctxt_wait_on_dqacq(obd, qctxt, inode->i_uid, - inode->i_gid, 1) == -EAGAIN) + if (filter_quota_check_master(obd, inode)) goto remap; } diff --git a/lustre/obdfilter/lproc_obdfilter.c b/lustre/obdfilter/lproc_obdfilter.c index 94cf781..ab7e4c5 100644 --- a/lustre/obdfilter/lproc_obdfilter.c +++ b/lustre/obdfilter/lproc_obdfilter.c @@ -117,121 +117,6 @@ int lprocfs_filter_wr_readcache(struct file *file, const char *buffer, return count; } -static int lprocfs_filter_rd_bunit(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - LASSERT(obd != NULL); - - return snprintf(page, count, "%lu\n", - obd->u.filter.fo_quota_ctxt.lqc_bunit_sz); -} - -static int lprocfs_filter_rd_iunit(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - LASSERT(obd != NULL); - - return snprintf(page, count, "%lu\n", - obd->u.filter.fo_quota_ctxt.lqc_iunit_sz); -} - -static int lprocfs_filter_wr_bunit(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - int val, rc = 0; - LASSERT(obd != NULL); - - rc = lprocfs_write_helper(buffer, count, &val); - if (rc) - return rc; - - if (val % QUOTABLOCK_SIZE || - val <= obd->u.filter.fo_quota_ctxt.lqc_btune_sz) - return -EINVAL; - - obd->u.filter.fo_quota_ctxt.lqc_bunit_sz = val; - return count; -} - -static int lprocfs_filter_wr_iunit(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - int val, rc = 0; - LASSERT(obd != NULL); - - rc = lprocfs_write_helper(buffer, count, &val); - if (rc) - return rc; - - if (val <= obd->u.filter.fo_quota_ctxt.lqc_itune_sz) - return -EINVAL; - - obd->u.filter.fo_quota_ctxt.lqc_iunit_sz = val; - return count; -} - -static int lprocfs_filter_rd_btune(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - LASSERT(obd != NULL); - - return snprintf(page, count, "%lu\n", - obd->u.filter.fo_quota_ctxt.lqc_btune_sz); -} - -static int lprocfs_filter_rd_itune(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - LASSERT(obd != NULL); - - return snprintf(page, count, "%lu\n", - obd->u.filter.fo_quota_ctxt.lqc_itune_sz); -} - -static int lprocfs_filter_wr_btune(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - int val, rc = 0; - LASSERT(obd != NULL); - - rc = lprocfs_write_helper(buffer, count, &val); - if (rc) - return rc; - - if (val <= QUOTABLOCK_SIZE * MIN_QLIMIT || val % QUOTABLOCK_SIZE || - val >= obd->u.filter.fo_quota_ctxt.lqc_bunit_sz) - return -EINVAL; - - obd->u.filter.fo_quota_ctxt.lqc_btune_sz = val; - return count; -} - -static int lprocfs_filter_wr_itune(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - int val, rc = 0; - LASSERT(obd != NULL); - - rc = lprocfs_write_helper(buffer, count, &val); - if (rc) - return rc; - - if (val <= MIN_QLIMIT || - val >= obd->u.filter.fo_quota_ctxt.lqc_iunit_sz) - return -EINVAL; - - obd->u.filter.fo_quota_ctxt.lqc_itune_sz = val; - return count; -} - static struct lprocfs_vars lprocfs_obd_vars[] = { { "uuid", lprocfs_rd_uuid, 0, 0 }, { "blocksize", lprocfs_rd_blksize, 0, 0 }, @@ -253,6 +138,7 @@ static struct lprocfs_vars lprocfs_obd_vars[] = { { "readcache_max_filesize", lprocfs_filter_rd_readcache, lprocfs_filter_wr_readcache, 0 }, +#ifdef HAVE_QUOTA_SUPPORT { "quota_bunit_sz", lprocfs_filter_rd_bunit, lprocfs_filter_wr_bunit, 0}, { "quota_btune_sz", lprocfs_filter_rd_btune, @@ -261,6 +147,7 @@ static struct lprocfs_vars lprocfs_obd_vars[] = { lprocfs_filter_wr_iunit, 0}, { "quota_itune_sz", lprocfs_filter_rd_itune, lprocfs_filter_wr_itune, 0}, +#endif { 0 } }; diff --git a/lustre/osc/Makefile.in b/lustre/osc/Makefile.in index 52fece6..568a725 100644 --- a/lustre/osc/Makefile.in +++ b/lustre/osc/Makefile.in @@ -1,4 +1,4 @@ MODULES := osc -osc-objs := osc_request.o lproc_osc.o osc_lib.o osc_create.o osc_quota.o +osc-objs := osc_request.o lproc_osc.o osc_lib.o osc_create.o @INCLUDE_RULES@ diff --git a/lustre/osc/autoMakefile.am b/lustre/osc/autoMakefile.am index be3ff47..af0649d 100644 --- a/lustre/osc/autoMakefile.am +++ b/lustre/osc/autoMakefile.am @@ -5,7 +5,7 @@ if LIBLUSTRE noinst_LIBRARIES = libosc.a -libosc_a_SOURCES = osc_request.c osc_lib.c osc_create.c osc_quota.c osc_internal.h +libosc_a_SOURCES = osc_request.c osc_lib.c osc_create.c osc_internal.h libosc_a_CPPFLAGS = $(LLCPPFLAGS) libosc_a_CFLAGS = $(LLCFLAGS) endif diff --git a/lustre/osc/osc_internal.h b/lustre/osc/osc_internal.h index 95fe8ee..60e9160 100644 --- a/lustre/osc/osc_internal.h +++ b/lustre/osc/osc_internal.h @@ -56,6 +56,8 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa, struct lov_stripe_md **ea, struct obd_trans_info *oti); void oscc_init(struct obd_device *obd); void osc_wake_cache_waiters(struct client_obd *cli); + +#ifdef HAVE_QUOTA_SUPPORT int osc_get_quota_flag(struct client_obd *cli, unsigned int uid, unsigned int gid); int osc_set_quota_flag(struct client_obd *cli, @@ -64,6 +66,43 @@ int osc_set_quota_flag(struct client_obd *cli, int osc_qinfo_cleanup(struct client_obd *cli); int osc_qinfo_init(void); void osc_qinfo_exit(void); +int osc_quotacheck(struct obd_export *exp, struct obd_quotactl *oqctl); +int osc_poll_quotacheck(struct obd_export *exp, struct if_quotacheck *qchk); +int osc_quotactl(struct obd_export *exp, struct obd_quotactl *oqctl); +#else +static inline int osc_get_quota_flag(struct client_obd *cli, + unsigned int uid, unsigned int gid) +{ + return QUOTA_OK; +} +static inline int osc_set_quota_flag(struct client_obd *cli, + unsigned int uid, unsigned int gid, + obd_flag valid, obd_flag flags) +{ + return 0; +} +static inline int osc_qinfo_cleanup(struct client_obd *cli) +{ + return 0; +} +static inline int osc_qinfo_init(void) +{ + return 0; +} +static inline void osc_qinfo_exit(void) {} +static inline int osc_quotacheck(struct obd_export *exp, struct obd_quotactl *oqctl) +{ + return -ENOTSUPP; +} +static inline int osc_poll_quotacheck(struct obd_export *exp, struct if_quotacheck *qchk) +{ + return -ENOTSUPP; +} +static inline int osc_quotactl(struct obd_export *exp, struct obd_quotactl *oqctl) +{ + return -ENOTSUPP; +} +#endif #ifdef LPROCFS int lproc_osc_attach_seqstat(struct obd_device *dev); diff --git a/lustre/osc/osc_quota.c b/lustre/osc/osc_quota.c index a12158e..60446b2 100644 --- a/lustre/osc/osc_quota.c +++ b/lustre/osc/osc_quota.c @@ -3,20 +3,8 @@ * * Copyright (c) 2003 Cluster File Systems, Inc. * - * This file is part of Lustre, http://www.lustre.org. + * No redistribution or use is permitted outside of Cluster File Systems, Inc. * - * Lustre is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * Lustre 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 for more details. - * - * You should have received a copy of the GNU General Public License - * along with Lustre; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef EXPORT_SYMTAB @@ -243,3 +231,96 @@ void osc_qinfo_exit(void) LASSERTF(kmem_cache_destroy(qinfo_cachep) == 0, "couldn't destroy osc quota info slab\n"); } + +int osc_quotacheck(struct obd_export *exp, struct obd_quotactl *oqctl) +{ + struct client_obd *cli = &exp->exp_obd->u.cli; + struct ptlrpc_request *req; + struct obd_quotactl *body; + int size = sizeof(*body); + int rc; + ENTRY; + + req = ptlrpc_prep_req(class_exp2cliimp(exp), OST_QUOTACHECK, 1, &size, + NULL); + if (!req) + GOTO(out, rc = -ENOMEM); + + body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body)); + memcpy(body, oqctl, sizeof(*body)); + + req->rq_replen = lustre_msg_size(0, NULL); + + spin_lock(&cli->cl_qchk_lock); + cli->cl_qchk_stat = CL_QUOTACHECKING; + spin_unlock(&cli->cl_qchk_lock); + + rc = ptlrpc_queue_wait(req); + if (rc) { + spin_lock(&cli->cl_qchk_lock); + cli->cl_qchk_stat = rc; + spin_unlock(&cli->cl_qchk_lock); + } + out: + ptlrpc_req_finished(req); + RETURN (rc); +} + +int osc_poll_quotacheck(struct obd_export *exp, + struct if_quotacheck *qchk) +{ + struct client_obd *cli = &exp->exp_obd->u.cli; + int stat; + ENTRY; + + spin_lock(&cli->cl_qchk_lock); + stat = cli->cl_qchk_stat; + spin_unlock(&cli->cl_qchk_lock); + + qchk->stat = stat; + if (stat == CL_QUOTACHECKING) { + qchk->stat = -ENODATA; + stat = 0; + } else if (qchk->stat) { + if (qchk->stat > CL_QUOTACHECKING) + qchk->stat = stat = -EINTR; + + strncpy(qchk->obd_type, "obdfilter", 10); + qchk->obd_uuid = cli->cl_import->imp_target_uuid; + } + RETURN(stat); +} + +int osc_quotactl(struct obd_export *exp, struct obd_quotactl *oqctl) +{ + struct ptlrpc_request *req; + struct obd_quotactl *oqc; + int size = sizeof(*oqctl); + int rc; + ENTRY; + + req = ptlrpc_prep_req(class_exp2cliimp(exp), OST_QUOTACTL, 1, &size, + NULL); + if (!req) + GOTO(out, rc = -ENOMEM); + + memcpy(lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*oqctl)), oqctl, size); + + req->rq_replen = lustre_msg_size(1, &size); + + rc = ptlrpc_queue_wait(req); + if (!rc) { + oqc = lustre_swab_repbuf(req, 0, sizeof (*oqc), + lustre_swab_obd_quotactl); + if (oqc == NULL) { + CERROR ("Can't unpack mds_body\n"); + GOTO(out, rc = -EPROTO); + } + + memcpy(oqctl, oqc, sizeof(*oqctl)); + } +out: + ptlrpc_req_finished(req); + RETURN (rc); +} + diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 3601f9d..993c2c5 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -2847,98 +2847,6 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump) RETURN(rc); } -static int osc_quotacheck(struct obd_export *exp, struct obd_quotactl *oqctl) -{ - struct client_obd *cli = &exp->exp_obd->u.cli; - struct ptlrpc_request *req; - struct obd_quotactl *body; - int size = sizeof(*body); - int rc; - ENTRY; - - req = ptlrpc_prep_req(class_exp2cliimp(exp), OST_QUOTACHECK, 1, &size, - NULL); - if (!req) - GOTO(out, rc = -ENOMEM); - - body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body)); - memcpy(body, oqctl, sizeof(*body)); - - req->rq_replen = lustre_msg_size(0, NULL); - - spin_lock(&cli->cl_qchk_lock); - cli->cl_qchk_stat = CL_QUOTACHECKING; - spin_unlock(&cli->cl_qchk_lock); - - rc = ptlrpc_queue_wait(req); - if (rc) { - spin_lock(&cli->cl_qchk_lock); - cli->cl_qchk_stat = rc; - spin_unlock(&cli->cl_qchk_lock); - } - out: - ptlrpc_req_finished(req); - RETURN (rc); -} - -static int osc_poll_quotacheck(struct obd_export *exp, - struct if_quotacheck *qchk) -{ - struct client_obd *cli = &exp->exp_obd->u.cli; - int stat; - ENTRY; - - spin_lock(&cli->cl_qchk_lock); - stat = cli->cl_qchk_stat; - spin_unlock(&cli->cl_qchk_lock); - - qchk->stat = stat; - if (stat == CL_QUOTACHECKING) { - qchk->stat = -ENODATA; - stat = 0; - } else if (qchk->stat) { - if (qchk->stat > CL_QUOTACHECKING) - qchk->stat = stat = -EINTR; - - strncpy(qchk->obd_type, "obdfilter", 10); - qchk->obd_uuid = cli->cl_import->imp_target_uuid; - } - RETURN(stat); -} - -static int osc_quotactl(struct obd_export *exp, struct obd_quotactl *oqctl) -{ - struct ptlrpc_request *req; - struct obd_quotactl *oqc; - int size = sizeof(*oqctl); - int rc; - ENTRY; - - req = ptlrpc_prep_req(class_exp2cliimp(exp), OST_QUOTACTL, 1, &size, - NULL); - if (!req) - GOTO(out, rc = -ENOMEM); - - memcpy(lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*oqctl)), oqctl, size); - - req->rq_replen = lustre_msg_size(1, &size); - - rc = ptlrpc_queue_wait(req); - if (!rc) { - oqc = lustre_swab_repbuf(req, 0, sizeof (*oqc), - lustre_swab_obd_quotactl); - if (oqc == NULL) { - CERROR ("Can't unpack mds_body\n"); - GOTO(out, rc = -EPROTO); - } - - memcpy(oqctl, oqc, sizeof(*oqctl)); - } -out: - ptlrpc_req_finished(req); - RETURN (rc); -} - static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, void *karg, void *uarg) { diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index 4c868c553..7c23137 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -48,8 +48,6 @@ #include #include "ost_internal.h" -static struct quotacheck_info qchkinfo; - void oti_init(struct obd_trans_info *oti, struct ptlrpc_request *req) { if (oti == NULL) @@ -929,131 +927,6 @@ static int ost_filter_recovery_request(struct ptlrpc_request *req, } } -static int ost_quotacheck_callback(struct obd_export *exp, - struct obd_quotactl *oqctl) -{ - struct ptlrpc_request *req; - struct obd_quotactl *body; - int rc, size = sizeof(*oqctl); - - req = ptlrpc_prep_req(exp->exp_imp_reverse, OBD_QC_CALLBACK, - 1, &size, NULL); - if (!req) - RETURN(-ENOMEM); - - body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body)); - memcpy(body, oqctl, sizeof(*oqctl)); - - req->rq_replen = lustre_msg_size(0, NULL); - - rc = ptlrpc_queue_wait(req); - ptlrpc_req_finished(req); - - RETURN(rc); -} - -static int ost_quotacheck_thread(void *data) -{ - unsigned long flags; - struct quotacheck_info *qchki = data; - struct obd_export *exp; - struct obd_quotactl *oqctl; - struct filter_obd *filter; - int rc; - - lock_kernel(); - ptlrpc_daemonize(); - - SIGNAL_MASK_LOCK(current, flags); - sigfillset(¤t->blocked); - RECALC_SIGPENDING; - SIGNAL_MASK_UNLOCK(current, flags); - - THREAD_NAME(current->comm, sizeof(current->comm) - 1, "%s", "quotacheck"); - unlock_kernel(); - - complete(&qchki->qi_starting); - - exp = qchki->qi_exp; - filter = &exp->exp_obd->u.filter; - oqctl = &qchki->qi_oqctl; - - obd_quotacheck(exp, oqctl); - rc = ost_quotacheck_callback(exp, oqctl); - - atomic_inc(&filter->fo_quotachecking); - - return rc; -} - -static int ost_quotacheck(struct ptlrpc_request *req) -{ - struct obd_device *obd = req->rq_export->exp_obd; - struct filter_obd *filter = &obd->u.filter; - struct obd_quotactl *oqctl; - int rc; - ENTRY; - - oqctl = lustre_swab_reqbuf(req, 0, sizeof(*oqctl), - lustre_swab_obd_quotactl); - if (oqctl == NULL) - GOTO(out, rc = -EPROTO); - - rc = lustre_pack_reply(req, 0, NULL, NULL); - if (rc) { - CERROR("ost: out of memory while packing quotacheck reply\n"); - GOTO(out, rc = -ENOMEM); - } - - if (!atomic_dec_and_test(&filter->fo_quotachecking)) { - atomic_inc(&filter->fo_quotachecking); - GOTO(out, rc = -EBUSY); - } - - init_completion(&qchkinfo.qi_starting); - qchkinfo.qi_exp = req->rq_export; - memcpy(&qchkinfo.qi_oqctl, oqctl, sizeof(*oqctl)); - - rc = kernel_thread(ost_quotacheck_thread, &qchkinfo, CLONE_VM|CLONE_FILES); - if (rc < 0) { - CERROR("%s: error starting ost_quotacheck_thread: %d\n", - obd->obd_name, rc); - atomic_inc(&filter->fo_quotachecking); - } else { - CDEBUG(D_INFO, "%s: ost_quotacheck_thread: %d\n", - obd->obd_name, rc); - wait_for_completion(&qchkinfo.qi_starting); - rc = 0; - } - - EXIT; -out: - return rc; -} - -static int ost_quotactl(struct ptlrpc_request *req) -{ - struct obd_quotactl *oqctl, *repoqc; - int rc, size = sizeof(*repoqc); - ENTRY; - - oqctl = lustre_swab_reqbuf(req, 0, sizeof(*oqctl), - lustre_swab_obd_quotactl); - if (oqctl == NULL) - GOTO(out, rc = -EPROTO); - - rc = lustre_pack_reply(req, 1, &size, NULL); - if (rc) - GOTO(out, rc); - - repoqc = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*repoqc)); - memcpy(repoqc, oqctl, sizeof(*repoqc)); - - req->rq_status = obd_quotactl(req->rq_export, repoqc); -out: - RETURN(rc); -} - static int ost_handle(struct ptlrpc_request *req) { struct obd_trans_info trans_info = { 0, }; diff --git a/lustre/ost/ost_internal.h b/lustre/ost/ost_internal.h index f7cd79a..9f31f25 100644 --- a/lustre/ost/ost_internal.h +++ b/lustre/ost/ost_internal.h @@ -11,4 +11,21 @@ extern void ost_print_req(void *seq_file, struct ptlrpc_request *req); # define ost_print_req NULL #endif +#ifdef HAVE_QUOTA_SUPPORT +/* Quota stuff */ +int ost_quotacheck(struct ptlrpc_request *req); +int ost_quotactl(struct ptlrpc_request *req); +#else +static inline int ost_quotacheck(struct ptlrpc_request *req) +{ + req->rq_status = -ENOTSUPP; + return -ENOTSUPP; +} +static inline int ost_quotactl(struct ptlrpc_request *req) +{ + req->rq_status = -ENOTSUPP; + return -ENOTSUPP; +} +#endif + #endif /* OST_INTERNAL_H */ diff --git a/lustre/ptlrpc/Makefile.in b/lustre/ptlrpc/Makefile.in index 85b84ec2..002e5ef 100644 --- a/lustre/ptlrpc/Makefile.in +++ b/lustre/ptlrpc/Makefile.in @@ -17,7 +17,7 @@ ptlrpc_objs += pers.o lproc_ptlrpc.o ptlrpc-objs := $(ldlm_objs) $(ptlrpc_objs) ifeq ($(PATCHLEVEL),6) -ptlrpc-objs += @top_srcdir@/lustre/mds/quota_context.o +#ptlrpc-objs += @top_srcdir@/lustre/mds/quota_context.o endif default: all -- 1.8.3.1