Skip to content

Commit 6f8ee8d

Browse files
committed
Merge branch 'work.recursive_removal' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull another simple_recursive_removal() update from Al Viro: "I missed one case when simple_recursive_removal() was introduced" * 'work.recursive_removal' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: qib_fs: switch to simple_recursive_removal()
2 parents 23806a3 + e41d237 commit 6f8ee8d

File tree

1 file changed

+5
-63
lines changed

1 file changed

+5
-63
lines changed

drivers/infiniband/hw/qib/qib_fs.c

Lines changed: 5 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -427,79 +427,21 @@ static int add_cntr_files(struct super_block *sb, struct qib_devdata *dd)
427427
return ret;
428428
}
429429

430-
static int remove_file(struct dentry *parent, char *name)
431-
{
432-
struct dentry *tmp;
433-
int ret;
434-
435-
tmp = lookup_one_len(name, parent, strlen(name));
436-
437-
if (IS_ERR(tmp)) {
438-
ret = PTR_ERR(tmp);
439-
goto bail;
440-
}
441-
442-
spin_lock(&tmp->d_lock);
443-
if (simple_positive(tmp)) {
444-
__d_drop(tmp);
445-
spin_unlock(&tmp->d_lock);
446-
simple_unlink(d_inode(parent), tmp);
447-
} else {
448-
spin_unlock(&tmp->d_lock);
449-
}
450-
dput(tmp);
451-
452-
ret = 0;
453-
bail:
454-
/*
455-
* We don't expect clients to care about the return value, but
456-
* it's there if they need it.
457-
*/
458-
return ret;
459-
}
460-
461430
static int remove_device_files(struct super_block *sb,
462431
struct qib_devdata *dd)
463432
{
464-
struct dentry *dir, *root;
433+
struct dentry *dir;
465434
char unit[10];
466-
int ret, i;
467435

468-
root = dget(sb->s_root);
469-
inode_lock(d_inode(root));
470436
snprintf(unit, sizeof(unit), "%u", dd->unit);
471-
dir = lookup_one_len(unit, root, strlen(unit));
437+
dir = lookup_one_len_unlocked(unit, sb->s_root, strlen(unit));
472438

473439
if (IS_ERR(dir)) {
474-
ret = PTR_ERR(dir);
475440
pr_err("Lookup of %s failed\n", unit);
476-
goto bail;
441+
return PTR_ERR(dir);
477442
}
478-
479-
inode_lock(d_inode(dir));
480-
remove_file(dir, "counters");
481-
remove_file(dir, "counter_names");
482-
remove_file(dir, "portcounter_names");
483-
for (i = 0; i < dd->num_pports; i++) {
484-
char fname[24];
485-
486-
sprintf(fname, "port%dcounters", i + 1);
487-
remove_file(dir, fname);
488-
if (dd->flags & QIB_HAS_QSFP) {
489-
sprintf(fname, "qsfp%d", i + 1);
490-
remove_file(dir, fname);
491-
}
492-
}
493-
remove_file(dir, "flash");
494-
inode_unlock(d_inode(dir));
495-
ret = simple_rmdir(d_inode(root), dir);
496-
d_drop(dir);
497-
dput(dir);
498-
499-
bail:
500-
inode_unlock(d_inode(root));
501-
dput(root);
502-
return ret;
443+
simple_recursive_removal(dir, NULL);
444+
return 0;
503445
}
504446

505447
/*

0 commit comments

Comments
 (0)