1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * lustre VFS/process permission interface
27 #include <libcfs/kp30.h>
28 #include <linux/lustre_ucache.h>
30 #define LL_FID_NAMELEN (16 + 1 + 8 + 1)
32 #if defined __KERNEL__
33 #include <linux/lustre_compat25.h>
34 #include <linux/lvfs_linux.h>
36 struct group_info { /* unused */ };
40 #include <lvfs_user_fs.h>
46 struct upcall_cache_entry *luc_uce;
55 struct lvfs_callback_ops {
56 struct dentry *(*l_fid2dentry)(__u64 id_ino, __u32 gen, __u64 gr, void *data);
59 #define OBD_RUN_CTXT_MAGIC 0xC0FFEEAA
60 #define OBD_CTXT_DEBUG /* development-only debugging */
61 struct lvfs_run_ctxt {
62 struct vfsmount *pwdmnt;
65 struct lvfs_ucred luc;
67 struct lvfs_callback_ops cb_ops;
68 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
69 struct group_info *group_info;
71 struct group_info group_info;
79 #define OBD_SET_CTXT_MAGIC(ctxt) (ctxt)->magic = OBD_RUN_CTXT_MAGIC
81 #define OBD_SET_CTXT_MAGIC(ctxt) do {} while(0)
85 struct dentry *lvfs_fid2dentry(struct lvfs_run_ctxt *, __u64, __u32, __u64 ,void *data);
87 void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx,
88 struct lvfs_ucred *cred);
89 void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx,
90 struct lvfs_ucred *cred);
94 struct dentry *simple_mkdir(struct dentry *dir, char *name, int mode, int fix);
95 struct dentry *simple_mknod(struct dentry *dir, char *name, int mode, int fix);
96 int lustre_fread(struct file *file, void *buf, int len, loff_t *off);
97 int lustre_fwrite(struct file *file, const void *buf, int len, loff_t *off);
98 int lustre_fsync(struct file *file);
99 long l_readdir(struct file * file, struct list_head *dentry_list);
101 static inline void l_dput(struct dentry *de)
103 if (!de || IS_ERR(de))
105 //shrink_dcache_parent(de);
106 LASSERT(atomic_read(&de->d_count) > 0);
110 /* We need to hold the inode semaphore over the dcache lookup itself, or we
111 * run the risk of entering the filesystem lookup path concurrently on SMP
112 * systems, and instantiating two inodes for the same entry. We still
113 * protect against concurrent addition/removal races with the DLM locking.
115 static inline struct dentry *ll_lookup_one_len(const char *fid_name,
116 struct dentry *dparent,
119 struct dentry *dchild;
121 LOCK_INODE_MUTEX(dparent->d_inode);
122 dchild = lookup_one_len(fid_name, dparent, fid_namelen);
123 UNLOCK_INODE_MUTEX(dparent->d_inode);
125 if (IS_ERR(dchild) || dchild->d_inode == NULL)
128 if (is_bad_inode(dchild->d_inode)) {
129 CERROR("bad inode returned %lu/%u\n",
130 dchild->d_inode->i_ino, dchild->d_inode->i_generation);
132 dchild = ERR_PTR(-ENOENT);
137 static inline void ll_sleep(int t)
139 set_current_state(TASK_INTERRUPTIBLE);
140 schedule_timeout(t * HZ);
141 set_current_state(TASK_RUNNING);