From: Peng Tao Date: Thu, 14 Jun 2012 07:08:42 +0000 (+0800) Subject: LU-709 build: clean up quota_read, follow_link and RCU X-Git-Tag: 2.2.91~4 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=9c71dacaf0b16c10952b4d788016e70b667cd77b;ds=sidebyside LU-709 build: clean up quota_read, follow_link and RCU 1. super_operations.quota_read exists since v2.6.12 2. inode_operations->follow_link returns a cookie since v2.6.13 3. RCU exists since v2.6.12 Signed-off-by: Peng Tao Change-Id: Id79df5dcb0e3db9eb424337fd71d896ed8fefcd6 Reviewed-on: http://review.whamcloud.com/2316 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Yang Sheng Reviewed-by: Niu Yawei --- diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index daed428..7a4b5b7 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -451,76 +451,6 @@ AC_DEFUN([LC_CONFIG_GSS], fi ]) -AC_DEFUN([LC_QUOTA_READ], -[AC_MSG_CHECKING([if kernel supports quota_read]) -LB_LINUX_TRY_COMPILE([ - #include -],[ - struct super_operations sp; - void *i = (void *)sp.quota_read; -],[ - AC_MSG_RESULT([yes]) - AC_DEFINE(KERNEL_SUPPORTS_QUOTA_READ, 1, [quota_read found]) -],[ - AC_MSG_RESULT([no]) -]) -]) - -# -# LC_COOKIE_FOLLOW_LINK -# -# kernel 2.6.13+ ->follow_link returns a cookie -# -AC_DEFUN([LC_COOKIE_FOLLOW_LINK], -[AC_MSG_CHECKING([if inode_operations->follow_link returns a cookie]) -LB_LINUX_TRY_COMPILE([ - #include - #include -],[ - struct dentry *dentry = NULL; - struct nameidata nd; - - dentry->d_inode->i_op->put_link(dentry, &nd, NULL); -],[ - AC_DEFINE(HAVE_COOKIE_FOLLOW_LINK, 1, [inode_operations->follow_link returns a cookie]) - AC_MSG_RESULT([yes]) -],[ - AC_MSG_RESULT([no]) -]) -]) - -# -# LC_FUNC_RCU -# -# kernels prior than 2.6.0(?) have no RCU supported; in kernel 2.6.5(SUSE), -# call_rcu takes three parameters. -# -AC_DEFUN([LC_FUNC_RCU], -[AC_MSG_CHECKING([if kernel have RCU supported]) -LB_LINUX_TRY_COMPILE([ - #include -],[],[ - AC_DEFINE(HAVE_RCU, 1, [have RCU defined]) - AC_MSG_RESULT([yes]) - - AC_MSG_CHECKING([if call_rcu takes three parameters]) - LB_LINUX_TRY_COMPILE([ - #include - ],[ - struct rcu_head rh; - call_rcu(&rh, (void (*)(struct rcu_head *))1, NULL); - ],[ - AC_DEFINE(HAVE_CALL_RCU_PARAM, 1, [call_rcu takes three parameters]) - AC_MSG_RESULT([yes]) - ],[ - AC_MSG_RESULT([no]) - ]) - -],[ - AC_MSG_RESULT([no]) -]) -]) - AC_DEFUN([LC_PERCPU_COUNTER], [AC_MSG_CHECKING([if have struct percpu_counter defined]) LB_LINUX_TRY_COMPILE([ @@ -2080,9 +2010,6 @@ AC_DEFUN([LC_PROG_LINUX], LC_CAPA_CRYPTO LC_CONFIG_RMTCLIENT LC_CONFIG_GSS - LC_QUOTA_READ - LC_COOKIE_FOLLOW_LINK - LC_FUNC_RCU LC_PERCPU_COUNTER LC_TASK_CLENV_STORE diff --git a/lustre/include/darwin/lustre_handles.h b/lustre/include/darwin/lustre_handles.h index f6abf4b..225929e 100644 --- a/lustre/include/darwin/lustre_handles.h +++ b/lustre/include/darwin/lustre_handles.h @@ -42,4 +42,6 @@ #include #include +#define call_rcu(rcu, cb) (cb)(rcu) + #endif diff --git a/lustre/include/linux/lustre_handles.h b/lustre/include/linux/lustre_handles.h index 586351d..365010b 100644 --- a/lustre/include/linux/lustre_handles.h +++ b/lustre/include/linux/lustre_handles.h @@ -47,10 +47,8 @@ #include #include -# ifdef HAVE_RCU -# include /* for rcu_head{} */ +#include /* for rcu_head{} */ typedef struct rcu_head cfs_rcu_head_t; -# endif #endif /* ifdef __KERNEL__ */ diff --git a/lustre/include/lustre_handles.h b/lustre/include/lustre_handles.h index eddb04a..75854be 100644 --- a/lustre/include/lustre_handles.h +++ b/lustre/include/lustre_handles.h @@ -52,9 +52,9 @@ #include -#if !defined(HAVE_RCU) || !defined(__KERNEL__) +#ifndef __KERNEL__ typedef struct { - int foo; + int foo; } cfs_rcu_head_t; #endif diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index c32b09f..665dc89 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -704,16 +704,6 @@ do { \ } while(0) -#ifdef HAVE_RCU -# ifdef HAVE_CALL_RCU_PARAM -# define my_call_rcu(rcu, cb) call_rcu(rcu, cb, rcu) -# else -# define my_call_rcu(rcu, cb) call_rcu(rcu, cb) -# endif -#else -# define my_call_rcu(rcu, cb) (cb)(rcu) -#endif - #define OBD_FREE_RCU(ptr, size, handle) \ do { \ struct portals_handle *__h = (handle); \ @@ -721,7 +711,7 @@ do { \ LASSERT(handle != NULL); \ __h->h_cookie = (unsigned long)(ptr); \ __h->h_size = (size); \ - my_call_rcu(&__h->h_rcu, class_handle_free_cb); \ + call_rcu(&__h->h_rcu, class_handle_free_cb); \ POISON_PTR(ptr); \ } while(0) diff --git a/lustre/llite/symlink.c b/lustre/llite/symlink.c index 34ce7079..67a3107 100644 --- a/lustre/llite/symlink.c +++ b/lustre/llite/symlink.c @@ -139,20 +139,13 @@ static int ll_readlink(struct dentry *dentry, char *buffer, int buflen) RETURN(rc); } -#ifdef HAVE_COOKIE_FOLLOW_LINK -# define LL_FOLLOW_LINK_RETURN_TYPE void * -#else -# define LL_FOLLOW_LINK_RETURN_TYPE int -#endif - -static LL_FOLLOW_LINK_RETURN_TYPE ll_follow_link(struct dentry *dentry, - struct nameidata *nd) +static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd) { - struct inode *inode = dentry->d_inode; - struct ptlrpc_request *request = NULL; - int rc; - char *symname; - ENTRY; + struct inode *inode = dentry->d_inode; + struct ptlrpc_request *request = NULL; + int rc; + char *symname; + ENTRY; CDEBUG(D_VFSTRACE, "VFS Op\n"); /* Limit the recursive symlink depth to 5 instead of default @@ -173,48 +166,30 @@ static LL_FOLLOW_LINK_RETURN_TYPE ll_follow_link(struct dentry *dentry, GOTO(out, rc); } -#ifdef HAVE_COOKIE_FOLLOW_LINK - nd_set_link(nd, symname); - /* @symname may contain a pointer to the request message buffer, - we delay request releasing until ll_put_link then. */ - RETURN(request); -#else - if (lli->lli_symlink_name == NULL) { - /* falling back to recursive follow link if the request - * needs to be cleaned up still. */ - rc = vfs_follow_link(nd, symname); - GOTO(out, rc); - } - nd_set_link(nd, symname); - RETURN(0); -#endif + nd_set_link(nd, symname); + /* symname may contain a pointer to the request message buffer, + * we delay request releasing until ll_put_link then. + */ + RETURN(request); out: - ptlrpc_req_finished(request); -#ifdef HAVE_COOKIE_FOLLOW_LINK - RETURN(ERR_PTR(rc)); -#else - RETURN(rc); -#endif + ptlrpc_req_finished(request); + RETURN(ERR_PTR(rc)); } -#ifdef HAVE_COOKIE_FOLLOW_LINK static void ll_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) { - ptlrpc_req_finished(cookie); + ptlrpc_req_finished(cookie); } -#endif struct inode_operations ll_fast_symlink_inode_operations = { - .readlink = ll_readlink, - .setattr = ll_setattr, - .follow_link = ll_follow_link, -#ifdef HAVE_COOKIE_FOLLOW_LINK - .put_link = ll_put_link, -#endif - .getattr = ll_getattr, - .permission = ll_inode_permission, - .setxattr = ll_setxattr, - .getxattr = ll_getxattr, - .listxattr = ll_listxattr, - .removexattr = ll_removexattr, + .readlink = ll_readlink, + .setattr = ll_setattr, + .follow_link = ll_follow_link, + .put_link = ll_put_link, + .getattr = ll_getattr, + .permission = ll_inode_permission, + .setxattr = ll_setxattr, + .getxattr = ll_getxattr, + .listxattr = ll_listxattr, + .removexattr = ll_removexattr, }; diff --git a/lustre/lvfs/fsfilt_ext3.c b/lustre/lvfs/fsfilt_ext3.c index ab6e403..88fb592 100644 --- a/lustre/lvfs/fsfilt_ext3.c +++ b/lustre/lvfs/fsfilt_ext3.c @@ -2044,15 +2044,11 @@ static int fsfilt_ext3_quotacheck(struct super_block *sb, continue; - LASSERT(sb_dqopt(sb)->files[i] != NULL); - CFS_INIT_LIST_HEAD(&id_list); -#ifndef KERNEL_SUPPORTS_QUOTA_READ - rc = lustre_get_qids(sb_dqopt(sb)->files[i], NULL, i, &id_list); -#else - rc = lustre_get_qids(NULL, sb_dqopt(sb)->files[i], i, &id_list); -#endif - if (rc) - CERROR("read old limits failed. (rc:%d)\n", rc); + LASSERT(sb_dqopt(sb)->files[i] != NULL); + CFS_INIT_LIST_HEAD(&id_list); + rc = lustre_get_qids(NULL, sb_dqopt(sb)->files[i], i, &id_list); + if (rc) + CERROR("read old limits failed. (rc:%d)\n", rc); cfs_list_for_each_entry_safe(dqid, tmp, &id_list, di_link) { cfs_list_del_init(&dqid->di_link); diff --git a/lustre/lvfs/quotafmt_test.c b/lustre/lvfs/quotafmt_test.c index a964aa7..98bb156 100644 --- a/lustre/lvfs/quotafmt_test.c +++ b/lustre/lvfs/quotafmt_test.c @@ -373,37 +373,6 @@ static int quotfmt_test_4(struct lustre_quota_info *lqi) RETURN(rc); } -static int quotfmt_test_5(struct lustre_quota_info *lqi) -{ -#ifndef KERNEL_SUPPORTS_QUOTA_READ - int i, rc = 0; - - for (i = USRQUOTA; i < MAXQUOTAS && !rc; i++) { - cfs_list_t list; - struct dquot_id *dqid, *tmp; - - CFS_INIT_LIST_HEAD(&list); - rc = lustre_get_qids(lqi->qi_files[i], NULL, i, &list); - if (rc) { - CERROR("%s get all %ss (rc:%d):\n", - rc ? "error" : "success", - i == USRQUOTA ? "uid" : "gid", rc); - } - cfs_list_for_each_entry_safe(dqid, tmp, &list, di_link) { - cfs_list_del_init(&dqid->di_link); - if (rc == 0) - CDEBUG(D_INFO, "%d ", dqid->di_id); - kfree(dqid); - } - CDEBUG(D_INFO, "\n"); - } - return rc; -#else - CWARN("kernel supports quota_read OR kernel version >= 2.6.12, test skipped\n"); - return 0; -#endif -} - static int quotfmt_run_tests(struct obd_device *obd, struct obd_device *tgt) { struct lvfs_run_ctxt saved; @@ -450,14 +419,7 @@ static int quotfmt_run_tests(struct obd_device *obd, struct obd_device *tgt) GOTO(out, rc); } - CWARN("=== test 5: walk through quota file to get all ids\n"); - rc = quotfmt_test_5(lqi); - if (rc) { - CERROR("walk through quota file failed\n"); - GOTO(out, rc); - } - - out: +out: CWARN("=== Finalize quotafile test\n"); rc = quotfmt_finalize(lqi, tgt, &saved); OBD_FREE(lqi, sizeof(*lqi)); diff --git a/lustre/obdclass/lustre_handles.c b/lustre/obdclass/lustre_handles.c index 4776b27..c3013fd 100644 --- a/lustre/obdclass/lustre_handles.c +++ b/lustre/obdclass/lustre_handles.c @@ -47,7 +47,7 @@ #include #include -#if !defined(HAVE_RCU) || !defined(__KERNEL__) +#ifndef __KERNEL__ # define list_add_rcu cfs_list_add # define list_del_rcu cfs_list_del # define list_for_each_rcu cfs_list_for_each @@ -55,7 +55,7 @@ # define list_for_each_entry_rcu cfs_list_for_each_entry # define rcu_read_lock() cfs_spin_lock(&bucket->lock) # define rcu_read_unlock() cfs_spin_unlock(&bucket->lock) -#endif /* ifndef HAVE_RCU */ +#endif /* !__KERNEL__ */ static __u64 handle_base; #define HANDLE_INCR 7 diff --git a/lustre/quota/quota_context.c b/lustre/quota/quota_context.c index b6905f4..a201e66 100644 --- a/lustre/quota/quota_context.c +++ b/lustre/quota/quota_context.c @@ -1522,16 +1522,12 @@ static int qslave_recovery_main(void *arg) break; } - LASSERT(dqopt->files[type] != NULL); - CFS_INIT_LIST_HEAD(&id_list); -#ifndef KERNEL_SUPPORTS_QUOTA_READ - rc = fsfilt_qids(obd, dqopt->files[type], NULL, type, &id_list); -#else - rc = fsfilt_qids(obd, NULL, dqopt->files[type], type, &id_list); -#endif - UNLOCK_DQONOFF_MUTEX(dqopt); - if (rc) - CERROR("Get ids from quota file failed. (rc:%d)\n", rc); + LASSERT(dqopt->files[type] != NULL); + CFS_INIT_LIST_HEAD(&id_list); + rc = fsfilt_qids(obd, NULL, dqopt->files[type], type, &id_list); + UNLOCK_DQONOFF_MUTEX(dqopt); + if (rc) + CERROR("Get ids from quota file failed. (rc:%d)\n", rc); cfs_list_for_each_entry_safe(dqid, tmp, &id_list, di_link) { cfs_list_del_init(&dqid->di_link); @@ -1611,12 +1607,12 @@ inline int quota_is_off(struct lustre_quota_ctxt *qctxt, return !(qctxt->lqc_flags & UGQUOTA2LQC(oqctl->qc_type)); } -/** +/* * When quotaon, build a lqs for every uid/gid who has been set limitation * for quota. After quota_search_lqs, it will hold one ref for the lqs. * It will be released when qctxt_cleanup() is executed b=18574 * - * Should be called with obt->obt_quotachecking held. b=20152 + * Should be called with obt->obt_quotachecking held. b=20152 */ void build_lqs(struct obd_device *obd) { @@ -1633,13 +1629,8 @@ void build_lqs(struct obd_device *obd) if (sb_dqopt(qctxt->lqc_sb)->files[i] == NULL) continue; -#ifndef KERNEL_SUPPORTS_QUOTA_READ - rc = fsfilt_qids(obd, sb_dqopt(qctxt->lqc_sb)->files[i], NULL, - i, &id_list); -#else - rc = fsfilt_qids(obd, NULL, sb_dqopt(qctxt->lqc_sb)->files[i], - i, &id_list); -#endif + rc = fsfilt_qids(obd, NULL, sb_dqopt(qctxt->lqc_sb)->files[i], + i, &id_list); if (rc) { CERROR("%s: failed to get %s qids!\n", obd->obd_name, i ? "group" : "user");