namei.c (8cbdd85bda499d028b8f128191f392d701e8e41d) namei.c (f66debf1b3755039680289d83fe7a92a4ad3d77d)
1/*
2 * (C) 2001 Clemson University and The University of Chicago
3 *
4 * See COPYING in top-level directory.
5 */
6
7/*
8 * Linux VFS namei operations.

--- 10 unchanged lines hidden (view full) ---

19 umode_t mode,
20 bool exclusive)
21{
22 struct orangefs_inode_s *parent = ORANGEFS_I(dir);
23 struct orangefs_kernel_op_s *new_op;
24 struct inode *inode;
25 int ret;
26
1/*
2 * (C) 2001 Clemson University and The University of Chicago
3 *
4 * See COPYING in top-level directory.
5 */
6
7/*
8 * Linux VFS namei operations.

--- 10 unchanged lines hidden (view full) ---

19 umode_t mode,
20 bool exclusive)
21{
22 struct orangefs_inode_s *parent = ORANGEFS_I(dir);
23 struct orangefs_kernel_op_s *new_op;
24 struct inode *inode;
25 int ret;
26
27 gossip_debug(GOSSIP_NAME_DEBUG, "%s: %s\n",
27 gossip_debug(GOSSIP_NAME_DEBUG, "%s: %pd\n",
28 __func__,
28 __func__,
29 dentry->d_name.name);
29 dentry);
30
31 new_op = op_alloc(ORANGEFS_VFS_OP_CREATE);
32 if (!new_op)
33 return -ENOMEM;
34
35 new_op->upcall.req.create.parent_refn = parent->refn;
36
37 fill_default_sys_attrs(new_op->upcall.req.create.attributes,
38 ORANGEFS_TYPE_METAFILE, mode);
39
40 strncpy(new_op->upcall.req.create.d_name,
41 dentry->d_name.name, ORANGEFS_NAME_MAX);
42
43 ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
44
45 gossip_debug(GOSSIP_NAME_DEBUG,
30
31 new_op = op_alloc(ORANGEFS_VFS_OP_CREATE);
32 if (!new_op)
33 return -ENOMEM;
34
35 new_op->upcall.req.create.parent_refn = parent->refn;
36
37 fill_default_sys_attrs(new_op->upcall.req.create.attributes,
38 ORANGEFS_TYPE_METAFILE, mode);
39
40 strncpy(new_op->upcall.req.create.d_name,
41 dentry->d_name.name, ORANGEFS_NAME_MAX);
42
43 ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
44
45 gossip_debug(GOSSIP_NAME_DEBUG,
46 "%s: %s: handle:%pU: fsid:%d: new_op:%p: ret:%d:\n",
46 "%s: %pd: handle:%pU: fsid:%d: new_op:%p: ret:%d:\n",
47 __func__,
47 __func__,
48 dentry->d_name.name,
48 dentry,
49 &new_op->downcall.resp.create.refn.khandle,
50 new_op->downcall.resp.create.refn.fs_id,
51 new_op,
52 ret);
53
54 if (ret < 0)
55 goto out;
56
57 inode = orangefs_new_inode(dir->i_sb, dir, S_IFREG | mode, 0,
58 &new_op->downcall.resp.create.refn);
59 if (IS_ERR(inode)) {
49 &new_op->downcall.resp.create.refn.khandle,
50 new_op->downcall.resp.create.refn.fs_id,
51 new_op,
52 ret);
53
54 if (ret < 0)
55 goto out;
56
57 inode = orangefs_new_inode(dir->i_sb, dir, S_IFREG | mode, 0,
58 &new_op->downcall.resp.create.refn);
59 if (IS_ERR(inode)) {
60 gossip_err("%s: Failed to allocate inode for file :%s:\n",
60 gossip_err("%s: Failed to allocate inode for file :%pd:\n",
61 __func__,
61 __func__,
62 dentry->d_name.name);
62 dentry);
63 ret = PTR_ERR(inode);
64 goto out;
65 }
66
67 gossip_debug(GOSSIP_NAME_DEBUG,
63 ret = PTR_ERR(inode);
64 goto out;
65 }
66
67 gossip_debug(GOSSIP_NAME_DEBUG,
68 "%s: Assigned inode :%pU: for file :%s:\n",
68 "%s: Assigned inode :%pU: for file :%pd:\n",
69 __func__,
70 get_khandle_from_ino(inode),
69 __func__,
70 get_khandle_from_ino(inode),
71 dentry->d_name.name);
71 dentry);
72
73 d_instantiate(dentry, inode);
74 unlock_new_inode(inode);
75 dentry->d_time = jiffies + dcache_timeout_msecs*HZ/1000;
76 ORANGEFS_I(inode)->getattr_time = jiffies - 1;
77
78 gossip_debug(GOSSIP_NAME_DEBUG,
72
73 d_instantiate(dentry, inode);
74 unlock_new_inode(inode);
75 dentry->d_time = jiffies + dcache_timeout_msecs*HZ/1000;
76 ORANGEFS_I(inode)->getattr_time = jiffies - 1;
77
78 gossip_debug(GOSSIP_NAME_DEBUG,
79 "%s: dentry instantiated for %s\n",
79 "%s: dentry instantiated for %pd\n",
80 __func__,
80 __func__,
81 dentry->d_name.name);
81 dentry);
82
83 SetMtimeFlag(parent);
84 dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb);
85 mark_inode_dirty_sync(dir);
86 ret = 0;
87out:
88 op_release(new_op);
89 gossip_debug(GOSSIP_NAME_DEBUG,
82
83 SetMtimeFlag(parent);
84 dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb);
85 mark_inode_dirty_sync(dir);
86 ret = 0;
87out:
88 op_release(new_op);
89 gossip_debug(GOSSIP_NAME_DEBUG,
90 "%s: %s: returning %d\n",
90 "%s: %pd: returning %d\n",
91 __func__,
91 __func__,
92 dentry->d_name.name,
92 dentry,
93 ret);
94 return ret;
95}
96
97/*
98 * Attempt to resolve an object name (dentry->d_name), parent handle, and
99 * fsid into a handle for the object.
100 */

--- 9 unchanged lines hidden (view full) ---

110 /*
111 * in theory we could skip a lookup here (if the intent is to
112 * create) in order to avoid a potentially failed lookup, but
113 * leaving it in can skip a valid lookup and try to create a file
114 * that already exists (e.g. the vfs already handles checking for
115 * -EEXIST on O_EXCL opens, which is broken if we skip this lookup
116 * in the create path)
117 */
93 ret);
94 return ret;
95}
96
97/*
98 * Attempt to resolve an object name (dentry->d_name), parent handle, and
99 * fsid into a handle for the object.
100 */

--- 9 unchanged lines hidden (view full) ---

110 /*
111 * in theory we could skip a lookup here (if the intent is to
112 * create) in order to avoid a potentially failed lookup, but
113 * leaving it in can skip a valid lookup and try to create a file
114 * that already exists (e.g. the vfs already handles checking for
115 * -EEXIST on O_EXCL opens, which is broken if we skip this lookup
116 * in the create path)
117 */
118 gossip_debug(GOSSIP_NAME_DEBUG, "%s called on %s\n",
119 __func__, dentry->d_name.name);
118 gossip_debug(GOSSIP_NAME_DEBUG, "%s called on %pd\n",
119 __func__, dentry);
120
121 if (dentry->d_name.len > (ORANGEFS_NAME_MAX - 1))
122 return ERR_PTR(-ENAMETOOLONG);
123
124 new_op = op_alloc(ORANGEFS_VFS_OP_LOOKUP);
125 if (!new_op)
126 return ERR_PTR(-ENOMEM);
127

--- 36 unchanged lines hidden (view full) ---

164 * add the dentry (e.g. in the case that a touch is
165 * issued on a file that already exists that was
166 * interrupted during this lookup -- no need to add
167 * another negative dentry for an existing file)
168 */
169
170 gossip_debug(GOSSIP_NAME_DEBUG,
171 "orangefs_lookup: Adding *negative* dentry "
120
121 if (dentry->d_name.len > (ORANGEFS_NAME_MAX - 1))
122 return ERR_PTR(-ENAMETOOLONG);
123
124 new_op = op_alloc(ORANGEFS_VFS_OP_LOOKUP);
125 if (!new_op)
126 return ERR_PTR(-ENOMEM);
127

--- 36 unchanged lines hidden (view full) ---

164 * add the dentry (e.g. in the case that a touch is
165 * issued on a file that already exists that was
166 * interrupted during this lookup -- no need to add
167 * another negative dentry for an existing file)
168 */
169
170 gossip_debug(GOSSIP_NAME_DEBUG,
171 "orangefs_lookup: Adding *negative* dentry "
172 "%p for %s\n",
172 "%p for %pd\n",
173 dentry,
173 dentry,
174 dentry->d_name.name);
174 dentry);
175
176 d_add(dentry, NULL);
177 res = NULL;
178 goto out;
179 }
180
181 /* must be a non-recoverable error */
182 res = ERR_PTR(ret);

--- 36 unchanged lines hidden (view full) ---

219static int orangefs_unlink(struct inode *dir, struct dentry *dentry)
220{
221 struct inode *inode = dentry->d_inode;
222 struct orangefs_inode_s *parent = ORANGEFS_I(dir);
223 struct orangefs_kernel_op_s *new_op;
224 int ret;
225
226 gossip_debug(GOSSIP_NAME_DEBUG,
175
176 d_add(dentry, NULL);
177 res = NULL;
178 goto out;
179 }
180
181 /* must be a non-recoverable error */
182 res = ERR_PTR(ret);

--- 36 unchanged lines hidden (view full) ---

219static int orangefs_unlink(struct inode *dir, struct dentry *dentry)
220{
221 struct inode *inode = dentry->d_inode;
222 struct orangefs_inode_s *parent = ORANGEFS_I(dir);
223 struct orangefs_kernel_op_s *new_op;
224 int ret;
225
226 gossip_debug(GOSSIP_NAME_DEBUG,
227 "%s: called on %s\n"
227 "%s: called on %pd\n"
228 " (inode %pU): Parent is %pU | fs_id %d\n",
229 __func__,
228 " (inode %pU): Parent is %pU | fs_id %d\n",
229 __func__,
230 dentry->d_name.name,
230 dentry,
231 get_khandle_from_ino(inode),
232 &parent->refn.khandle,
233 parent->refn.fs_id);
234
235 new_op = op_alloc(ORANGEFS_VFS_OP_REMOVE);
236 if (!new_op)
237 return -ENOMEM;
238

--- 82 unchanged lines hidden (view full) ---

321 get_khandle_from_ino(inode));
322
323 d_instantiate(dentry, inode);
324 unlock_new_inode(inode);
325 dentry->d_time = jiffies + dcache_timeout_msecs*HZ/1000;
326 ORANGEFS_I(inode)->getattr_time = jiffies - 1;
327
328 gossip_debug(GOSSIP_NAME_DEBUG,
231 get_khandle_from_ino(inode),
232 &parent->refn.khandle,
233 parent->refn.fs_id);
234
235 new_op = op_alloc(ORANGEFS_VFS_OP_REMOVE);
236 if (!new_op)
237 return -ENOMEM;
238

--- 82 unchanged lines hidden (view full) ---

321 get_khandle_from_ino(inode));
322
323 d_instantiate(dentry, inode);
324 unlock_new_inode(inode);
325 dentry->d_time = jiffies + dcache_timeout_msecs*HZ/1000;
326 ORANGEFS_I(inode)->getattr_time = jiffies - 1;
327
328 gossip_debug(GOSSIP_NAME_DEBUG,
329 "Inode (Symlink) %pU -> %s\n",
329 "Inode (Symlink) %pU -> %pd\n",
330 get_khandle_from_ino(inode),
330 get_khandle_from_ino(inode),
331 dentry->d_name.name);
331 dentry);
332
333 SetMtimeFlag(parent);
334 dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb);
335 mark_inode_dirty_sync(dir);
336 ret = 0;
337out:
338 op_release(new_op);
339 return ret;

--- 45 unchanged lines hidden (view full) ---

385 get_khandle_from_ino(inode));
386
387 d_instantiate(dentry, inode);
388 unlock_new_inode(inode);
389 dentry->d_time = jiffies + dcache_timeout_msecs*HZ/1000;
390 ORANGEFS_I(inode)->getattr_time = jiffies - 1;
391
392 gossip_debug(GOSSIP_NAME_DEBUG,
332
333 SetMtimeFlag(parent);
334 dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb);
335 mark_inode_dirty_sync(dir);
336 ret = 0;
337out:
338 op_release(new_op);
339 return ret;

--- 45 unchanged lines hidden (view full) ---

385 get_khandle_from_ino(inode));
386
387 d_instantiate(dentry, inode);
388 unlock_new_inode(inode);
389 dentry->d_time = jiffies + dcache_timeout_msecs*HZ/1000;
390 ORANGEFS_I(inode)->getattr_time = jiffies - 1;
391
392 gossip_debug(GOSSIP_NAME_DEBUG,
393 "Inode (Directory) %pU -> %s\n",
393 "Inode (Directory) %pU -> %pd\n",
394 get_khandle_from_ino(inode),
394 get_khandle_from_ino(inode),
395 dentry->d_name.name);
395 dentry);
396
397 /*
398 * NOTE: we have no good way to keep nlink consistent for directories
399 * across clients; keep constant at 1.
400 */
401 SetMtimeFlag(parent);
402 dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb);
403 mark_inode_dirty_sync(dir);

--- 67 unchanged lines hidden ---
396
397 /*
398 * NOTE: we have no good way to keep nlink consistent for directories
399 * across clients; keep constant at 1.
400 */
401 SetMtimeFlag(parent);
402 dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb);
403 mark_inode_dirty_sync(dir);

--- 67 unchanged lines hidden ---