namei.c (5997aab0a11ea27ee8e520ecc551ed18fd3e8296) namei.c (04bb1ba14195fb5b7ddb343f7d637149662accc8)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * (C) 2001 Clemson University and The University of Chicago
4 *
5 * See COPYING in top-level directory.
6 */
7
8/*

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

105 * fsid into a handle for the object.
106 */
107static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry,
108 unsigned int flags)
109{
110 struct orangefs_inode_s *parent = ORANGEFS_I(dir);
111 struct orangefs_kernel_op_s *new_op;
112 struct inode *inode;
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * (C) 2001 Clemson University and The University of Chicago
4 *
5 * See COPYING in top-level directory.
6 */
7
8/*

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

105 * fsid into a handle for the object.
106 */
107static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry,
108 unsigned int flags)
109{
110 struct orangefs_inode_s *parent = ORANGEFS_I(dir);
111 struct orangefs_kernel_op_s *new_op;
112 struct inode *inode;
113 struct dentry *res;
114 int ret = -EINVAL;
115
116 /*
117 * in theory we could skip a lookup here (if the intent is to
118 * create) in order to avoid a potentially failed lookup, but
119 * leaving it in can skip a valid lookup and try to create a file
120 * that already exists (e.g. the vfs already handles checking for
121 * -EEXIST on O_EXCL opens, which is broken if we skip this lookup

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

153 ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
154
155 gossip_debug(GOSSIP_NAME_DEBUG,
156 "Lookup Got %pU, fsid %d (ret=%d)\n",
157 &new_op->downcall.resp.lookup.refn.khandle,
158 new_op->downcall.resp.lookup.refn.fs_id,
159 ret);
160
113 int ret = -EINVAL;
114
115 /*
116 * in theory we could skip a lookup here (if the intent is to
117 * create) in order to avoid a potentially failed lookup, but
118 * leaving it in can skip a valid lookup and try to create a file
119 * that already exists (e.g. the vfs already handles checking for
120 * -EEXIST on O_EXCL opens, which is broken if we skip this lookup

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

152 ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
153
154 gossip_debug(GOSSIP_NAME_DEBUG,
155 "Lookup Got %pU, fsid %d (ret=%d)\n",
156 &new_op->downcall.resp.lookup.refn.khandle,
157 new_op->downcall.resp.lookup.refn.fs_id,
158 ret);
159
161 if (ret < 0) {
162 if (ret == -ENOENT) {
163 /*
164 * if no inode was found, add a negative dentry to
165 * dcache anyway; if we don't, we don't hold expected
166 * lookup semantics and we most noticeably break
167 * during directory renames.
168 *
169 * however, if the operation failed or exited, do not
170 * add the dentry (e.g. in the case that a touch is
171 * issued on a file that already exists that was
172 * interrupted during this lookup -- no need to add
173 * another negative dentry for an existing file)
174 */
175
176 gossip_debug(GOSSIP_NAME_DEBUG,
177 "orangefs_lookup: Adding *negative* dentry "
178 "%p for %pd\n",
179 dentry,
180 dentry);
181
182 d_add(dentry, NULL);
183 res = NULL;
184 goto out;
185 }
186
160 if (ret >= 0) {
161 orangefs_set_timeout(dentry);
162 inode = orangefs_iget(dir->i_sb, &new_op->downcall.resp.lookup.refn);
163 } else if (ret == -ENOENT) {
164 inode = NULL;
165 } else {
187 /* must be a non-recoverable error */
166 /* must be a non-recoverable error */
188 res = ERR_PTR(ret);
189 goto out;
167 inode = ERR_PTR(ret);
190 }
191
168 }
169
192 orangefs_set_timeout(dentry);
193
194 inode = orangefs_iget(dir->i_sb, &new_op->downcall.resp.lookup.refn);
195 if (IS_ERR(inode)) {
196 gossip_debug(GOSSIP_NAME_DEBUG,
197 "error %ld from iget\n", PTR_ERR(inode));
198 res = ERR_CAST(inode);
199 goto out;
200 }
201
202 gossip_debug(GOSSIP_NAME_DEBUG,
203 "%s:%s:%d "
204 "Found good inode [%lu] with count [%d]\n",
205 __FILE__,
206 __func__,
207 __LINE__,
208 inode->i_ino,
209 (int)atomic_read(&inode->i_count));
210
211 /* update dentry/inode pair into dcache */
212 res = d_splice_alias(inode, dentry);
213
214 gossip_debug(GOSSIP_NAME_DEBUG,
215 "Lookup success (inode ct = %d)\n",
216 (int)atomic_read(&inode->i_count));
217out:
218 op_release(new_op);
170 op_release(new_op);
219 return res;
171 return d_splice_alias(inode, dentry);
220}
221
222/* return 0 on success; non-zero otherwise */
223static int orangefs_unlink(struct inode *dir, struct dentry *dentry)
224{
225 struct inode *inode = dentry->d_inode;
226 struct orangefs_inode_s *parent = ORANGEFS_I(dir);
227 struct orangefs_kernel_op_s *new_op;

--- 262 unchanged lines hidden ---
172}
173
174/* return 0 on success; non-zero otherwise */
175static int orangefs_unlink(struct inode *dir, struct dentry *dentry)
176{
177 struct inode *inode = dentry->d_inode;
178 struct orangefs_inode_s *parent = ORANGEFS_I(dir);
179 struct orangefs_kernel_op_s *new_op;

--- 262 unchanged lines hidden ---