From a0c5a3fe1233ceb39ed1ed8cb55b5642d6a60ac4 Mon Sep 17 00:00:00 2001 From: yangsheng Date: Thu, 14 May 2009 09:58:11 +0000 Subject: [PATCH] Branch b_release_1_8_1 b=18668 i=panda, johann Quota patch for SLES11 support. --- lustre/autoconf/lustre-core.m4 | 71 ++++++++++++++++++++++++++++++++++ lustre/include/linux/lustre_compat25.h | 39 +++++++++++++++++++ lustre/include/lustre/lustre_user.h | 11 ------ lustre/include/lustre_quota.h | 28 +++++++++++++- lustre/lvfs/fsfilt_ext3.c | 46 +++++++++++----------- lustre/lvfs/lustre_quota_fmt.c | 6 ++- lustre/lvfs/lustre_quota_fmt.h | 2 +- lustre/lvfs/lustre_quota_fmt_convert.c | 4 +- lustre/lvfs/quotafmt_test.c | 2 +- lustre/mds/mds_fs.c | 2 +- lustre/obdfilter/filter.c | 2 +- lustre/quota/quota_context.c | 8 ++-- lustre/quota/quota_interface.c | 8 ++-- lustre/utils/lfs.c | 1 + 14 files changed, 179 insertions(+), 51 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 172cf6f..5623ec4 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -1586,6 +1586,71 @@ LB_LINUX_TRY_COMPILE([ ]) ]) +# 2.6.27 sles11 remove the bi_hw_segments +AC_DEFUN([LC_BI_HW_SEGMENTS], +[AC_MSG_CHECKING([struct bio has a bi_hw_segments field]) +LB_LINUX_TRY_COMPILE([ + #include +],[ + struct bio io; + io.bi_hw_segments = 0; +],[ + AC_DEFINE(HAVE_BI_HW_SEGMENTS, 1, + [struct bio has a bi_hw_segments field]) + AC_MSG_RESULT([yes]) +],[ + AC_MSG_RESULT([no]) +]) +]) + +# 2.6.27 sles11 move the quotaio_v1.h to fs +AC_DEFUN([LC_HAVE_QUOTAIO_V1_H], +[LB_CHECK_FILE([$LINUX/include/linux/quotaio_v1.h],[ + AC_DEFINE(HAVE_QUOTAIO_V1_H, 1, + [kernel has include/linux/quotaio_v1.h]) +],[ + AC_MSG_RESULT([no]) +]) +]) + +# sles10 sp2 need 5 parameter for vfs_symlink +AC_DEFUN([LC_VFS_SYMLINK_5ARGS], +[AC_MSG_CHECKING([vfs_symlink need 5 parameter]) +LB_LINUX_TRY_COMPILE([ + #include +],[ + struct inode *dir = NULL; + struct dentry *dentry = NULL; + struct vfsmount *mnt = NULL; + const char * path = NULL; + vfs_symlink(dir, dentry, mnt, path, 0); +],[ + AC_DEFINE(HAVE_VFS_SYMLINK_5ARGS, 1, + [vfs_symlink need 5 parameteres]) + AC_MSG_RESULT([yes]) +],[ + AC_MSG_RESULT([no]) +]) +]) + +# 2.6.27 removed the read_inode from super_operations. +AC_DEFUN([LC_READ_INODE_IN_SBOPS], +[AC_MSG_CHECKING([super_operations has a read_inode field]) +LB_LINUX_TRY_COMPILE([ + #include +],[ + struct super_operations *sop; + sop->read_inode(NULL); +],[ + AC_DEFINE(HAVE_READ_INODE_IN_SBOPS, 1, + [super_operations has a read_inode]) + AC_MSG_RESULT([yes]) +],[ + AC_MSG_RESULT([no]) +]) +]) + +# # Ensure stack size big than 8k in Lustre server AC_DEFUN([LC_STACK_SIZE], [AC_MSG_CHECKING([stack size big than 8k]) @@ -1735,6 +1800,12 @@ AC_DEFUN([LC_PROG_LINUX], LC_FILE_REMOVE_SUID LC_TRYLOCKPAGE LC_RW_TREE_LOCK + LC_READ_INODE_IN_SBOPS + + # 2.6.27.15-2 sles11 + LC_BI_HW_SEGMENTS + LC_HAVE_QUOTAIO_V1_H + LC_VFS_SYMLINK_5ARGS ]) # diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index 1902b6e..94f0138 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -562,5 +562,44 @@ static inline long labs(long x) #define sysctl_vfs_cache_pressure 100 #endif +#ifdef HAVE_SB_HAS_QUOTA_ACTIVE +#define ll_sb_has_quota_active(sb, type) sb_has_quota_active(sb, type) +#else +#define ll_sb_has_quota_active(sb, type) sb_has_quota_enabled(sb, type) +#endif + +#ifdef HAVE_SB_ANY_QUOTA_ACTIVE +#define ll_sb_any_quota_active(sb) sb_any_quota_active(sb) +#else +#define ll_sb_any_quota_active(sb) sb_any_quota_enabled(sb) +#endif + +static inline int +ll_quota_on(struct super_block *sb, int off, int ver, char *name, int remount) +{ + if (sb->s_qcop->quota_on) { + return sb->s_qcop->quota_on(sb, off, ver, name +#ifdef HAVE_QUOTA_ON_5ARGS + , remount +#endif + ); + } + else + return -ENOSYS; +} + +static inline int ll_quota_off(struct super_block *sb, int off, int remount) +{ + if (sb->s_qcop->quota_off) { + return sb->s_qcop->quota_off(sb, off +#ifdef HAVE_QUOTA_OFF_3ARGS + , remount +#endif + ); + } + else + return -ENOSYS; +} + #endif /* __KERNEL__ */ #endif /* _COMPAT25_H */ diff --git a/lustre/include/lustre/lustre_user.h b/lustre/include/lustre/lustre_user.h index 281c488..c1c493f 100644 --- a/lustre/include/lustre/lustre_user.h +++ b/lustre/include/lustre/lustre_user.h @@ -265,17 +265,6 @@ struct mds_grp_downcall_data { }; #ifdef NEED_QUOTA_DEFS -#ifndef QUOTABLOCK_BITS -#define QUOTABLOCK_BITS 10 -#endif - -#ifndef QUOTABLOCK_SIZE -#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS) -#endif - -#ifndef toqb -#define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS) -#endif #ifndef QIF_BLIMITS #define QIF_BLIMITS 1 diff --git a/lustre/include/lustre_quota.h b/lustre/include/lustre_quota.h index 82d4abe..7609909 100644 --- a/lustre/include/lustre_quota.h +++ b/lustre/include/lustre_quota.h @@ -60,8 +60,28 @@ struct client_obd; #define NR_DQHASH 45 #endif +#ifndef QUOTABLOCK_BITS +#define QUOTABLOCK_BITS 10 +#endif + +#ifndef QUOTABLOCK_SIZE +#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS) +#endif + +#ifndef toqb +#define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS) +#endif + #ifdef HAVE_QUOTA_SUPPORT +#ifndef MAX_IQ_TIME +#define MAX_IQ_TIME 604800 /* (7*24*60*60) 1 week */ +#endif + +#ifndef MAX_DQ_TIME +#define MAX_DQ_TIME 604800 /* (7*24*60*60) 1 week */ +#endif + #ifdef __KERNEL__ #ifdef LPROCFS @@ -176,7 +196,11 @@ int lustre_get_qids(struct file *file, struct inode *inode, int type, struct list_head *list); int lustre_quota_convert(struct lustre_quota_info *lqi, int type); -#define LL_DQUOT_OFF(sb) DQUOT_OFF(sb) +#ifdef HAVE_VFS_DQ_OFF +#define LL_DQUOT_OFF(sb, remount) vfs_dq_off(sb, remount) +#else +#define LL_DQUOT_OFF(sb, remount) DQUOT_OFF(sb) +#endif typedef int (*dqacq_handler_t) (struct obd_device * obd, struct qunit_data * qd, int opc); @@ -333,7 +357,7 @@ struct lustre_quota_ctxt { #else -#define LL_DQUOT_OFF(sb) do {} while(0) +#define LL_DQUOT_OFF(sb, remount) do {} while(0) struct lustre_quota_info { }; diff --git a/lustre/lvfs/fsfilt_ext3.c b/lustre/lvfs/fsfilt_ext3.c index 14dcac4..e981caa 100644 --- a/lustre/lvfs/fsfilt_ext3.c +++ b/lustre/lvfs/fsfilt_ext3.c @@ -52,8 +52,15 @@ #include #include #include -#include -#include +#ifdef HAVE_QUOTAIO_V1_H +# include +# include +#else +# include +# include +# include +# define V2_DQTREEOFF QT_TREEOFF +#endif #include #include @@ -364,7 +371,7 @@ static int fsfilt_ext3_credits_needed(int objcount, struct fsfilt_objinfo *fso, /* We assume that there will be 1 bit set in s_dquot.flags for each * quota file that is active. This is at least true for now. */ - needed += hweight32(sb_any_quota_enabled(sb)) * + needed += hweight32(ll_sb_any_quota_active(sb)) * FSFILT_SINGLEDATA_TRANS_BLOCKS(sb); #endif @@ -1427,28 +1434,22 @@ static int fsfilt_ext3_quotactl(struct super_block *sb, lustre_quota_version_t qfmt = oqc->qc_id; char *name[][MAXQUOTAS] = LUSTRE_OPQFILES_NAMES; - if (!qcop->quota_on) - GOTO(out, rc = -ENOSYS); - - rc = qcop->quota_on(sb, i, QFMT_VFS_V0, - name[qfmt][i]); + rc = ll_quota_on(sb, i, QFMT_VFS_V0, + name[qfmt][i], 0); #ifdef HAVE_QUOTA64 if (rc == -ENOENT || rc == -EINVAL) { /* see bug 13904 */ rc = lustre_slave_quota_convert(qfmt, i); if (!rc) - rc = qcop->quota_on(sb, i, - QFMT_VFS_V0, - name[qfmt][i]); + rc = ll_quota_on(sb, i, + QFMT_VFS_V0, + name[qfmt][i], 0); else if (rc == -ESTALE) rc = -ENOENT; } #endif - } else if (oqc->qc_cmd == Q_QUOTAOFF) { - if (!qcop->quota_off) - GOTO(out, rc = -ENOSYS); - rc = qcop->quota_off(sb, i); - } + } else if (oqc->qc_cmd == Q_QUOTAOFF) + rc = ll_quota_off(sb, i, 0); if (rc == -EBUSY) error = rc; @@ -1684,8 +1685,11 @@ static inline struct inode *ext3_iget_inuse(struct super_block *sb, struct inode *inode = NULL; if (ext3_test_bit(index, bitmap_bh->b_data)) +#ifdef HAVE_READ_INODE_IN_SBOPS inode = iget(sb, ino); - +#else + inode = ext3_iget(sb, ino); +#endif return inode; } @@ -1747,11 +1751,7 @@ static int add_inode_quota(struct inode *inode, struct qchk_ctxt *qctxt, static int v2_write_dqheader(struct file *f, int type) { static const __u32 quota_magics[] = V2_INITQMAGICS; -#ifdef HAVE_QUOTA64 - static const __u32 quota_versions[] = V2_INITQVERSIONS_R0; -#else - static const __u32 quota_versions[] = V2_INITQVERSIONS; -#endif + static const __u32 quota_versions[] = LUSTRE_INITQVERSIONS_V1; struct v2_disk_dqheader dqhead; loff_t offset = 0; @@ -1793,7 +1793,7 @@ static int v2_write_dqinfo(struct file *f, int type, struct if_dqinfo *info) static int v3_write_dqheader(struct file *f, int type) { static const __u32 quota_magics[] = V2_INITQMAGICS; - static const __u32 quota_versions[] = V2_INITQVERSIONS_R1; + static const __u32 quota_versions[] = LUSTRE_INITQVERSIONS_V2; struct v2_disk_dqheader dqhead; loff_t offset = 0; diff --git a/lustre/lvfs/lustre_quota_fmt.c b/lustre/lvfs/lustre_quota_fmt.c index f1abc3a..8e0f68c 100644 --- a/lustre/lvfs/lustre_quota_fmt.c +++ b/lustre/lvfs/lustre_quota_fmt.c @@ -50,7 +50,9 @@ #include #include #include -#include +#ifdef HAVE_QUOTAIO_V1_H +# include +#endif #include #include @@ -62,7 +64,7 @@ #ifdef HAVE_QUOTA_SUPPORT static const uint lustre_initqversions[][MAXQUOTAS] = { - [LUSTRE_QUOTA_V1] = LUSTRE_INITQVERSIONS, + [LUSTRE_QUOTA_V1] = LUSTRE_INITQVERSIONS_V1, [LUSTRE_QUOTA_V2] = LUSTRE_INITQVERSIONS_V2 }; diff --git a/lustre/lvfs/lustre_quota_fmt.h b/lustre/lvfs/lustre_quota_fmt.h index a9fbcfc..ab43160 100644 --- a/lustre/lvfs/lustre_quota_fmt.h +++ b/lustre/lvfs/lustre_quota_fmt.h @@ -62,7 +62,7 @@ } /* for the verson 1 of lustre_disk_dqblk*/ -#define LUSTRE_INITQVERSIONS {\ +#define LUSTRE_INITQVERSIONS_V1 {\ 0, /* USRQUOTA */\ 0 /* GRPQUOTA */\ } diff --git a/lustre/lvfs/lustre_quota_fmt_convert.c b/lustre/lvfs/lustre_quota_fmt_convert.c index de85f8b..9737e3b 100644 --- a/lustre/lvfs/lustre_quota_fmt_convert.c +++ b/lustre/lvfs/lustre_quota_fmt_convert.c @@ -50,7 +50,9 @@ #include #include #include -#include +#ifdef HAVE_QUOTAIO_V1_H +# include +#endif #include #include diff --git a/lustre/lvfs/quotafmt_test.c b/lustre/lvfs/quotafmt_test.c index a371193..0690ca3 100644 --- a/lustre/lvfs/quotafmt_test.c +++ b/lustre/lvfs/quotafmt_test.c @@ -67,7 +67,7 @@ static int quotfmt_initialize(struct lustre_quota_info *lqi, { struct lustre_disk_dqheader dqhead; static const uint quota_magics[] = LUSTRE_INITQMAGICS; - static const uint quota_versions[] = LUSTRE_INITQVERSIONS; + static const uint quota_versions[] = LUSTRE_INITQVERSIONS_V1; struct file *fp; struct inode *parent_inode = tgt->obd_lvfs_ctxt.pwd->d_inode; size_t size; diff --git a/lustre/mds/mds_fs.c b/lustre/mds/mds_fs.c index 13bbfb6..b433a57 100644 --- a/lustre/mds/mds_fs.c +++ b/lustre/mds/mds_fs.c @@ -921,7 +921,7 @@ int mds_fs_cleanup(struct obd_device *obd) OBD_SLAB_FREE_PTR(saved, obd_lvfs_ctxt_cache); shrink_dcache_parent(mds->mds_fid_de); dput(mds->mds_fid_de); - LL_DQUOT_OFF(obd->u.obt.obt_sb); + LL_DQUOT_OFF(obd->u.obt.obt_sb, 0); return rc; } diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index ac1db3d..ac22f63 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -2240,7 +2240,7 @@ static int filter_cleanup(struct obd_device *obd) filter_post(obd); - LL_DQUOT_OFF(obd->u.obt.obt_sb); + LL_DQUOT_OFF(obd->u.obt.obt_sb, 0); shrink_dcache_sb(obd->u.obt.obt_sb); server_put_mount(obd->obd_name, filter->fo_vfsmnt); diff --git a/lustre/quota/quota_context.c b/lustre/quota/quota_context.c index a918574..ce3a512 100644 --- a/lustre/quota/quota_context.c +++ b/lustre/quota/quota_context.c @@ -235,7 +235,7 @@ check_cur_qunit(struct obd_device *obd, int ret = 0; ENTRY; - if (!sb_any_quota_enabled(sb)) + if (!ll_sb_any_quota_active(sb)) RETURN(0); spin_lock(&qctxt->lqc_lock); @@ -357,7 +357,7 @@ int compute_remquota(struct obd_device *obd, struct lustre_quota_ctxt *qctxt, int ret = QUOTA_RET_OK; ENTRY; - if (!sb_any_quota_enabled(sb)) + if (!ll_sb_any_quota_active(sb)) RETURN(QUOTA_RET_NOQUOTA); /* ignore root user */ @@ -1279,7 +1279,7 @@ static int qslave_recovery_main(void *arg) int ret; LOCK_DQONOFF_MUTEX(dqopt); - if (!sb_has_quota_enabled(qctxt->lqc_sb, type)) { + if (!ll_sb_has_quota_active(qctxt->lqc_sb, type)) { UNLOCK_DQONOFF_MUTEX(dqopt); break; } @@ -1340,7 +1340,7 @@ qslave_start_recovery(struct obd_device *obd, struct lustre_quota_ctxt *qctxt) int rc; ENTRY; - if (!sb_any_quota_enabled(qctxt->lqc_sb)) + if (!ll_sb_any_quota_active(qctxt->lqc_sb)) goto exit; data.obd = obd; diff --git a/lustre/quota/quota_interface.c b/lustre/quota/quota_interface.c index 4303f57..8109e88 100644 --- a/lustre/quota/quota_interface.c +++ b/lustre/quota/quota_interface.c @@ -150,7 +150,7 @@ static int filter_quota_enforce(struct obd_device *obd, unsigned int ignore) { ENTRY; - if (!sb_any_quota_enabled(obd->u.obt.obt_sb)) + if (!ll_sb_any_quota_active(obd->u.obt.obt_sb)) RETURN(0); if (ignore) { @@ -172,7 +172,7 @@ static int filter_quota_getflag(struct obd_device *obd, struct obdo *oa) struct obd_quotactl *oqctl; ENTRY; - if (!sb_any_quota_enabled(obt->obt_sb)) + if (!ll_sb_any_quota_active(obt->obt_sb)) RETURN(0); OBD_ALLOC_PTR(oqctl); @@ -472,7 +472,7 @@ int quota_is_set(struct obd_device *obd, unsigned int uid, __u32 id[MAXQUOTAS] = { uid, gid }; int i, q_set = 0; - if (!sb_any_quota_enabled(obd->u.obt.obt_qctxt.lqc_sb)) + if (!ll_sb_any_quota_active(obd->u.obt.obt_qctxt.lqc_sb)) RETURN(0); for (i = 0; i < MAXQUOTAS; i++) { @@ -515,7 +515,7 @@ static int quota_pending_commit(struct obd_device *obd, unsigned int uid, CDEBUG(D_QUOTA, "commit pending quota for %s\n", obd->obd_name); CLASSERT(MAXQUOTAS < 4); - if (!sb_any_quota_enabled(qctxt->lqc_sb)) + if (!ll_sb_any_quota_active(qctxt->lqc_sb)) RETURN(0); do_gettimeofday(&work_start); diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 5397f81..0bcc4f7 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -71,6 +71,7 @@ #include #include #include +#include #include "parser.h" #include "obdctl.h" -- 1.8.3.1