Commit 1cf97d0d3a1b0232a3fde25deac3b3fd288627e2

Authored by Al Viro
1 parent c88b1e70ae

configfs: fold create_dir() into its only caller

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Showing 1 changed file with 29 additions and 34 deletions Side-by-side Diff

... ... @@ -260,37 +260,6 @@
260 260 inode->i_op = &configfs_symlink_inode_operations;
261 261 }
262 262  
263   -static int create_dir(struct config_item *k, struct dentry *d)
264   -{
265   - int error;
266   - umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO;
267   - struct dentry *p = d->d_parent;
268   -
269   - BUG_ON(!k);
270   -
271   - error = configfs_dirent_exists(p->d_fsdata, d->d_name.name);
272   - if (!error)
273   - error = configfs_make_dirent(p->d_fsdata, d, k, mode,
274   - CONFIGFS_DIR | CONFIGFS_USET_CREATING);
275   - if (!error) {
276   - configfs_set_dir_dirent_depth(p->d_fsdata, d->d_fsdata);
277   - error = configfs_create(d, mode, init_dir);
278   - if (!error) {
279   - inc_nlink(p->d_inode);
280   - } else {
281   - struct configfs_dirent *sd = d->d_fsdata;
282   - if (sd) {
283   - spin_lock(&configfs_dirent_lock);
284   - list_del_init(&sd->s_sibling);
285   - spin_unlock(&configfs_dirent_lock);
286   - configfs_put(sd);
287   - }
288   - }
289   - }
290   - return error;
291   -}
292   -
293   -
294 263 /**
295 264 * configfs_create_dir - create a directory for an config_item.
296 265 * @item: config_itemwe're creating directory for.
297 266  
298 267  
... ... @@ -300,11 +269,37 @@
300 269 * until it is validated by configfs_dir_set_ready()
301 270 */
302 271  
303   -static int configfs_create_dir(struct config_item * item, struct dentry *dentry)
  272 +static int configfs_create_dir(struct config_item *item, struct dentry *dentry)
304 273 {
305   - int error = create_dir(item, dentry);
306   - if (!error)
  274 + int error;
  275 + umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO;
  276 + struct dentry *p = dentry->d_parent;
  277 +
  278 + BUG_ON(!item);
  279 +
  280 + error = configfs_dirent_exists(p->d_fsdata, dentry->d_name.name);
  281 + if (unlikely(error))
  282 + return error;
  283 +
  284 + error = configfs_make_dirent(p->d_fsdata, dentry, item, mode,
  285 + CONFIGFS_DIR | CONFIGFS_USET_CREATING);
  286 + if (unlikely(error))
  287 + return error;
  288 +
  289 + configfs_set_dir_dirent_depth(p->d_fsdata, dentry->d_fsdata);
  290 + error = configfs_create(dentry, mode, init_dir);
  291 + if (!error) {
  292 + inc_nlink(p->d_inode);
307 293 item->ci_dentry = dentry;
  294 + } else {
  295 + struct configfs_dirent *sd = dentry->d_fsdata;
  296 + if (sd) {
  297 + spin_lock(&configfs_dirent_lock);
  298 + list_del_init(&sd->s_sibling);
  299 + spin_unlock(&configfs_dirent_lock);
  300 + configfs_put(sd);
  301 + }
  302 + }
308 303 return error;
309 304 }
310 305