From: John L. Hammond Date: Mon, 30 Dec 2013 16:05:36 +0000 (-0500) Subject: LU-2753 lvfs: cleanup lvfs.h and collateral X-Git-Tag: 2.5.54~1 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=3e7573cc14a331f01150814495e2345793e22f06;p=fs%2Flustre-release.git LU-2753 lvfs: cleanup lvfs.h and collateral Remove the unused struct lvfs_ucred. Remove the ucred pointer argument from {push,pop}_ctxt() to which all called passed NULL. Remove the now unused functions {push,pop}_group_info(). Delete lvfs_linux.h. Remove the cb_ops member from lvfs_run_ctxt which was read but never set. Remove the unused functions {l,ll}_dentry_open(). Reduce the number of gratuitous includes of lvfs.h. Signed-off-by: John L. Hammond Signed-off-by: James Simmons Change-Id: Ia7f61e4c5a6af73381a39740dc76367655d18985 Reviewed-on: http://review.whamcloud.com/6660 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Mike Pershin --- diff --git a/lustre/include/darwin/lvfs.h b/lustre/include/darwin/lvfs.h index 01dce37..a51a4dc 100644 --- a/lustre/include/darwin/lvfs.h +++ b/lustre/include/darwin/lvfs.h @@ -39,18 +39,6 @@ #error Do not #include this file directly. #include instead #endif -#ifdef LLOG_LVFS -#undef LLOG_LVFS -#endif - -struct lvfs_ucred { - __u32 luc_fsuid; - __u32 luc_fsgid; - kernel_cap_t luc_cap; - __u32 luc_uid; - __u32 luc_umask; -}; - struct lvfs_run_ctxt { int pid; }; diff --git a/lustre/include/linux/Makefile.am b/lustre/include/linux/Makefile.am index 5c1af1d..e1bd8c6 100644 --- a/lustre/include/linux/Makefile.am +++ b/lustre/include/linux/Makefile.am @@ -44,6 +44,5 @@ endif EXTRA_DIST = lprocfs_status.h lustre_acl.h lustre_debug.h lustre_lib.h \ lustre_dlm.h lustre_handles.h lustre_net.h obd_class.h obd_support.h \ - lustre_log.h lustre_compat25.h \ - obd.h lvfs.h lvfs_linux.h lustre_lite.h lustre_quota.h \ + obd.h lvfs.h lustre_log.h lustre_compat25.h lustre_lite.h lustre_quota.h \ lustre_user.h lustre_patchless_compat.h lustre_intent.h lustre_common.h diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index 880e6eb..6187194 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -101,25 +101,6 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, generic_permission(inode, mask, check_acl) #endif -#ifdef HAVE_DENTRY_OPEN_USE_PATH -#define ll_dentry_open(a,b,c) dentry_open(a,b,c) -#else -/* - * dentry_open handles its own reference counting since Linux v3.6 - * (commit 765927b2). Callers should free their own references. - * - * Prior versions expected the caller to increment the references. - * The references are retained on success and freed on error. - */ -static inline struct file *ll_dentry_open(struct path *path, int flags, - const struct cred *cred) -{ - mntget(path->mnt); - dget(path->dentry); - return dentry_open(path->dentry, path->mnt, flags, cred); -} -#endif - #ifdef HAVE_4ARGS_VFS_SYMLINK #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \ vfs_symlink(dir, dentry, path, mode) diff --git a/lustre/include/linux/lvfs.h b/lustre/include/linux/lvfs.h index 68b4317..f13bf58 100644 --- a/lustre/include/linux/lvfs.h +++ b/lustre/include/linux/lvfs.h @@ -48,38 +48,24 @@ #if defined __KERNEL__ #include #include -#include +#include #else #include #endif -#define LLOG_LVFS +#define OBD_RUN_CTXT_MAGIC 0xC0FFEEAA +#define OBD_CTXT_DEBUG /* development-only debugging */ -/* simple.c */ +struct dt_device; -struct lvfs_ucred { - __u32 luc_uid; - __u32 luc_gid; - __u32 luc_fsuid; - __u32 luc_fsgid; - kernel_cap_t luc_cap; - __u32 luc_umask; - struct group_info *luc_ginfo; - struct md_identity *luc_identity; -}; - -#define OBD_RUN_CTXT_MAGIC 0xC0FFEEAA -#define OBD_CTXT_DEBUG /* development-only debugging */ struct lvfs_run_ctxt { - struct vfsmount *pwdmnt; - struct dentry *pwd; - mm_segment_t fs; - struct lvfs_ucred luc; - int ngroups; - struct group_info *group_info; + struct vfsmount *pwdmnt; + struct dentry *pwd; + mm_segment_t fs; + uint32_t umask; struct dt_device *dt; #ifdef OBD_CTXT_DEBUG - __u32 magic; + uint32_t magic; #endif }; @@ -91,18 +77,6 @@ struct lvfs_run_ctxt { #ifdef __KERNEL__ -int lustre_rename(struct dentry *dir, struct vfsmount *mnt, char *oldname, - char *newname); - -static inline void l_dput(struct dentry *de) -{ - if (!de || IS_ERR(de)) - return; - //shrink_dcache_parent(de); - LASSERT(d_count(de) > 0); - dput(de); -} - /* We need to hold the inode semaphore over the dcache lookup itself, or we * run the risk of entering the filesystem lookup path concurrently on SMP * systems, and instantiating two inodes for the same entry. We still diff --git a/lustre/include/linux/lvfs_linux.h b/lustre/include/linux/lvfs_linux.h deleted file mode 100644 index 154832b..0000000 --- a/lustre/include/linux/lvfs_linux.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef __LVFS_LINUX_H__ -#define __LVFS_LINUX_H__ - -#include -#include -#include -#include -#include - -#include - -#define l_file file -#define l_dentry dentry - -#define l_filp_open filp_open - -struct lvfs_run_ctxt; - -struct l_linux_dirent { - cfs_list_t lld_list; - ino_t lld_ino; - unsigned long lld_off; - char lld_name[LL_FID_NAMELEN]; -}; -struct l_readdir_callback { - struct l_linux_dirent *lrc_dirent; - cfs_list_t *lrc_list; -}; - -#endif /* __LVFS_LINUX_H__ */ diff --git a/lustre/include/lvfs.h b/lustre/include/lvfs.h index 7f16cfc..293abbd 100644 --- a/lustre/include/lvfs.h +++ b/lustre/include/lvfs.h @@ -39,8 +39,6 @@ #ifndef __LVFS_H__ #define __LVFS_H__ -#define LL_FID_NAMELEN (16 + 1 + 8 + 1) - #include #if defined(__linux__) #include @@ -52,15 +50,7 @@ #error Unsupported operating system. #endif -#include - -#ifdef LIBLUSTRE -#include -#endif - -/* lvfs_linux.c */ -void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx, - struct lvfs_ucred *cred); -void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx, - struct lvfs_ucred *cred); +/* ptlrpc_sec_ctx.c */ +void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx); +void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx); #endif diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 3b76c34..d6622b4 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -68,6 +68,7 @@ #include #include #include +#include #define MAX_OBD_DEVICES 8192 diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index 254a7de..210f273 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -38,7 +38,6 @@ #define _OBD_SUPPORT #include -#include #include #if defined(__linux__) diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 330c771..d548988 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -50,6 +50,7 @@ #if defined(__KERNEL__) +#include #include #include #include diff --git a/lustre/obdclass/idmap.c b/lustre/obdclass/idmap.c index 6313ec8..afd2f03 100644 --- a/lustre/obdclass/idmap.c +++ b/lustre/obdclass/idmap.c @@ -42,6 +42,8 @@ #define DEBUG_SUBSYSTEM S_SEC +#include + #include #include #include diff --git a/lustre/osd-ldiskfs/osd_compat.c b/lustre/osd-ldiskfs/osd_compat.c index 6e28728..b4a018c 100644 --- a/lustre/osd-ldiskfs/osd_compat.c +++ b/lustre/osd-ldiskfs/osd_compat.c @@ -62,19 +62,12 @@ static void osd_push_ctxt(const struct osd_device *dev, struct lvfs_run_ctxt *newctxt, struct lvfs_run_ctxt *save) { - OBD_SET_CTXT_MAGIC(newctxt); - newctxt->pwdmnt = dev->od_mnt; - newctxt->pwd = dev->od_mnt->mnt_root; - newctxt->fs = get_ds(); + OBD_SET_CTXT_MAGIC(newctxt); + newctxt->pwdmnt = dev->od_mnt; + newctxt->pwd = dev->od_mnt->mnt_root; + newctxt->fs = get_ds(); - push_ctxt(save, newctxt, NULL); -} - -static void osd_pop_ctxt(const struct osd_device *dev, - struct lvfs_run_ctxt *new, - struct lvfs_run_ctxt *save) -{ - pop_ctxt(save, new, NULL); + push_ctxt(save, newctxt); } /* utility to make a directory */ @@ -200,7 +193,7 @@ static int osd_mdt_init(const struct lu_env *env, struct osd_device *dev) GOTO(cleanup, rc); cleanup: - pop_ctxt(&save, &new, NULL); + pop_ctxt(&save, &new); if (rc) { if (omm->omm_remote_parent != NULL) dput(omm->omm_remote_parent); @@ -418,7 +411,7 @@ static int osd_ost_init(const struct lu_env *env, struct osd_device *dev) GOTO(cleanup, rc); cleanup: - osd_pop_ctxt(dev, &new, &save); + pop_ctxt(&new, &save); if (IS_ERR(d)) { OBD_FREE_PTR(dev->od_ost_map); RETURN(PTR_ERR(d)); diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index 18a0a2a..3c02805 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -2041,10 +2041,10 @@ int osd_scrub_setup(const struct lu_env *env, struct osd_device *dev) spin_lock_init(&scrub->os_lock); CFS_INIT_LIST_HEAD(&scrub->os_inconsistent_items); - push_ctxt(&saved, ctxt, NULL); + push_ctxt(&saved, ctxt); filp = filp_open(osd_scrub_name, O_RDWR | O_CREAT, 0644); if (IS_ERR(filp)) { - pop_ctxt(&saved, ctxt, NULL); + pop_ctxt(&saved, ctxt); RETURN(PTR_ERR(filp)); } @@ -2056,13 +2056,13 @@ int osd_scrub_setup(const struct lu_env *env, struct osd_device *dev) rc = osd_ea_fid_set(info, inode, fid, LMAC_NOT_IN_OI, 0); if (rc != 0) { filp_close(filp, 0); - pop_ctxt(&saved, ctxt, NULL); + pop_ctxt(&saved, ctxt); RETURN(rc); } scrub->os_inode = igrab(inode); filp_close(filp, 0); - pop_ctxt(&saved, ctxt, NULL); + pop_ctxt(&saved, ctxt); rc = osd_scrub_file_load(scrub); if (rc == -ENOENT) { diff --git a/lustre/ptlrpc/ptlrpc_internal.h b/lustre/ptlrpc/ptlrpc_internal.h index d0c58d8..a83bca9 100644 --- a/lustre/ptlrpc/ptlrpc_internal.h +++ b/lustre/ptlrpc/ptlrpc_internal.h @@ -282,6 +282,9 @@ void sptlrpc_conf_choose_flavor(enum lustre_sec_part from, int sptlrpc_conf_init(void); void sptlrpc_conf_fini(void); +int lustre_rename(struct dentry *dir, struct vfsmount *mnt, char *old_name, + char *new_name); + /* sec.c */ int sptlrpc_init(void); void sptlrpc_fini(void); diff --git a/lustre/ptlrpc/sec_config.c b/lustre/ptlrpc/sec_config.c index 75b71d5..d0e8ff9 100644 --- a/lustre/ptlrpc/sec_config.c +++ b/lustre/ptlrpc/sec_config.c @@ -1025,11 +1025,11 @@ int sptlrpc_target_local_copy_conf(struct obd_device *obd, int rc; ENTRY; - ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); + ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); if (ctxt == NULL) - RETURN(-EINVAL); + RETURN(-EINVAL); - push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); + push_ctxt(&saved, &obd->obd_lvfs_ctxt); dentry = ll_lookup_one_len(MOUNT_CONFIGS_DIR, current->fs->pwd.dentry, strlen(MOUNT_CONFIGS_DIR)); @@ -1064,13 +1064,13 @@ out_close: rc = lustre_rename(dentry, obd->obd_lvfs_ctxt.pwdmnt, LOG_SPTLRPC_TMP, LOG_SPTLRPC); out_dput: - l_dput(dentry); + dput(dentry); out_ctx: - pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - llog_ctxt_put(ctxt); - CDEBUG(D_SEC, "target %s: write local sptlrpc conf: rc = %d\n", - obd->obd_name, rc); - RETURN(rc); + pop_ctxt(&saved, &obd->obd_lvfs_ctxt); + llog_ctxt_put(ctxt); + CDEBUG(D_SEC, "target %s: write local sptlrpc conf: rc = %d\n", + obd->obd_name, rc); + RETURN(rc); } static int local_read_handler(const struct lu_env *env, @@ -1122,7 +1122,7 @@ int sptlrpc_target_local_read_conf(struct obd_device *obd, RETURN(-EINVAL); } - push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); + push_ctxt(&saved, &obd->obd_lvfs_ctxt); rc = llog_open(NULL, ctxt, &llh, NULL, LOG_SPTLRPC, LLOG_OPEN_EXISTS); if (rc < 0) { @@ -1151,11 +1151,11 @@ int sptlrpc_target_local_read_conf(struct obd_device *obd, out_close: llog_close(NULL, llh); out_pop: - pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - llog_ctxt_put(ctxt); - CDEBUG(D_SEC, "target %s: read local sptlrpc conf: rc = %d\n", - obd->obd_name, rc); - RETURN(rc); + pop_ctxt(&saved, &obd->obd_lvfs_ctxt); + llog_ctxt_put(ctxt); + CDEBUG(D_SEC, "target %s: read local sptlrpc conf: rc = %d\n", + obd->obd_name, rc); + RETURN(rc); } #endif /* __KRENEL__ */ diff --git a/lustre/ptlrpc/sec_ctx.c b/lustre/ptlrpc/sec_ctx.c index 3da4c25..29ffc95 100644 --- a/lustre/ptlrpc/sec_ctx.c +++ b/lustre/ptlrpc/sec_ctx.c @@ -24,23 +24,10 @@ #define DEBUG_SUBSYSTEM S_FILTER -#include #include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include #include -#include -#include - /* refine later and change to seqlock or simlar from libcfs */ /* Debugging check only needed during development */ #ifdef OBD_CTXT_DEBUG @@ -54,43 +41,8 @@ # define ASSERT_KERNEL_CTXT(msg) do {} while(0) #endif -static void push_group_info(struct lvfs_run_ctxt *save, - struct group_info *ginfo) -{ - if (!ginfo) { - save->ngroups = current_ngroups; - current_ngroups = 0; - } else { - struct cred *cred; - task_lock(current); - save->group_info = current_cred()->group_info; - if ((cred = prepare_creds())) { - cred->group_info = ginfo; - commit_creds(cred); - } - task_unlock(current); - } -} - -static void pop_group_info(struct lvfs_run_ctxt *save, - struct group_info *ginfo) -{ - if (!ginfo) { - current_ngroups = save->ngroups; - } else { - struct cred *cred; - task_lock(current); - if ((cred = prepare_creds())) { - cred->group_info = save->group_info; - commit_creds(cred); - } - task_unlock(current); - } -} - /* push / pop to root of obd store */ -void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx, - struct lvfs_ucred *uc) +void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx) { /* if there is underlaying dt_device then push_ctxt is not needed */ if (new_ctx->dt != NULL) @@ -105,44 +57,20 @@ void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx, LASSERT(d_count(new_ctx->pwd)); save->pwd = dget(current->fs->pwd.dentry); save->pwdmnt = mntget(current->fs->pwd.mnt); - save->luc.luc_umask = current_umask(); - save->ngroups = current_cred()->group_info->ngroups; + save->umask = current_umask(); LASSERT(save->pwd); LASSERT(save->pwdmnt); LASSERT(new_ctx->pwd); LASSERT(new_ctx->pwdmnt); - if (uc) { - struct cred *cred; - save->luc.luc_uid = current_uid(); - save->luc.luc_gid = current_gid(); - save->luc.luc_fsuid = current_fsuid(); - save->luc.luc_fsgid = current_fsgid(); - save->luc.luc_cap = current_cap(); - - if ((cred = prepare_creds())) { - cred->uid = uc->luc_uid; - cred->gid = uc->luc_gid; - cred->fsuid = uc->luc_fsuid; - cred->fsgid = uc->luc_fsgid; - cred->cap_effective = uc->luc_cap; - commit_creds(cred); - } - - push_group_info(save, - uc->luc_ginfo ?: - uc->luc_identity ? uc->luc_identity->mi_ginfo : - NULL); - } current->fs->umask = 0; /* umask already applied on client */ set_fs(new_ctx->fs); ll_set_fs_pwd(current->fs, new_ctx->pwdmnt, new_ctx->pwd); } EXPORT_SYMBOL(push_ctxt); -void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx, - struct lvfs_ucred *uc) +void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx) { /* if there is underlaying dt_device then pop_ctxt is not needed */ if (new_ctx->dt != NULL) @@ -161,23 +89,7 @@ void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx, dput(saved->pwd); mntput(saved->pwdmnt); - current->fs->umask = saved->luc.luc_umask; - if (uc) { - struct cred *cred; - if ((cred = prepare_creds())) { - cred->uid = saved->luc.luc_uid; - cred->gid = saved->luc.luc_gid; - cred->fsuid = saved->luc.luc_fsuid; - cred->fsgid = saved->luc.luc_fsgid; - cred->cap_effective = saved->luc.luc_cap; - commit_creds(cred); - } - - pop_group_info(saved, - uc->luc_ginfo ?: - uc->luc_identity ? uc->luc_identity->mi_ginfo : - NULL); - } + current->fs->umask = saved->umask; } EXPORT_SYMBOL(pop_ctxt); @@ -211,5 +123,4 @@ put_old: dput(dchild_old); RETURN(err); } -EXPORT_SYMBOL(lustre_rename); #endif /* __KERNEL__ */