X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fptlrpc%2Fsec_ctx.c;h=6342749de6fbb3a35078810499404d0b0cde9b86;hb=25860230aa806351e946a5c1c585e50521983d8e;hp=431f4b37a41476cfe81ac95850735763c728a0d2;hpb=3000a83dcd3c201f383c0507d33e7861fc695997;p=fs%2Flustre-release.git diff --git a/lustre/ptlrpc/sec_ctx.c b/lustre/ptlrpc/sec_ctx.c index 431f4b3..6342749 100644 --- a/lustre/ptlrpc/sec_ctx.c +++ b/lustre/ptlrpc/sec_ctx.c @@ -20,27 +20,53 @@ * * GPL HEADER END */ -#ifdef __KERNEL__ +/* + * Copyright (c) 2014, 2017, Intel Corporation. + */ #define DEBUG_SUBSYSTEM S_FILTER #include +#include #include #include +#include + +#include "ptlrpc_internal.h" /* refine later and change to seqlock or simlar from libcfs */ /* Debugging check only needed during development */ #ifdef OBD_CTXT_DEBUG # define ASSERT_CTXT_MAGIC(magic) LASSERT((magic) == OBD_RUN_CTXT_MAGIC) -# define ASSERT_NOT_KERNEL_CTXT(msg) LASSERTF(!segment_eq(get_fs(), get_ds()),\ +# define ASSERT_NOT_KERNEL_CTXT(msg) LASSERTF(!segment_eq(get_fs(), KERNEL_DS),\ msg) -# define ASSERT_KERNEL_CTXT(msg) LASSERTF(segment_eq(get_fs(), get_ds()), msg) +# define ASSERT_KERNEL_CTXT(msg) LASSERTF(segment_eq(get_fs(), KERNEL_DS), msg) #else # define ASSERT_CTXT_MAGIC(magic) do {} while(0) # define ASSERT_NOT_KERNEL_CTXT(msg) do {} while(0) # define ASSERT_KERNEL_CTXT(msg) do {} while(0) #endif +static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, + struct dentry *dentry) +{ + struct path path; + struct path old_pwd; + + path.mnt = mnt; + path.dentry = dentry; + path_get(&path); + spin_lock(&fs->lock); + write_seqcount_begin(&fs->seq); + old_pwd = fs->pwd; + fs->pwd = path; + write_seqcount_end(&fs->seq); + spin_unlock(&fs->lock); + + if (old_pwd.dentry) + path_put(&old_pwd); +} + /* push / pop to root of obd store */ void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx) { @@ -92,35 +118,3 @@ void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx) current->fs->umask = saved->umask; } EXPORT_SYMBOL(pop_ctxt); - -/* utility to rename a file */ -int lustre_rename(struct dentry *dir, struct vfsmount *mnt, - char *oldname, char *newname) -{ - struct dentry *dchild_old, *dchild_new; - int err = 0; - ENTRY; - - ASSERT_KERNEL_CTXT("kernel doing rename outside kernel context\n"); - CDEBUG(D_INODE, "renaming file %.*s to %.*s\n", - (int)strlen(oldname), oldname, (int)strlen(newname), newname); - - dchild_old = ll_lookup_one_len(oldname, dir, strlen(oldname)); - if (IS_ERR(dchild_old)) - RETURN(PTR_ERR(dchild_old)); - - if (!dchild_old->d_inode) - GOTO(put_old, err = -ENOENT); - - dchild_new = ll_lookup_one_len(newname, dir, strlen(newname)); - if (IS_ERR(dchild_new)) - GOTO(put_old, err = PTR_ERR(dchild_new)); - - err = ll_vfs_rename(dir->d_inode, dchild_old, dir->d_inode, dchild_new); - - dput(dchild_new); -put_old: - dput(dchild_old); - RETURN(err); -} -#endif /* __KERNEL__ */