History

saner proc_get_inode() calling conventions

Make it drop the pde in *all* cases when no new reference to it is put into an inode - both when an inode had already been set up (as we were already doing) and when inode allocation has failed. Makes for simpler logics in callers...

Al Viro committed 13 years ago

Commit d3d009c1 parent 87e0aab2 files · +10 −21Browse files

Unified · Split

2 files
  1. fs/proc/generic.c +7 −14
  2. fs/proc/inode.c +3 −7
fs/proc/generic.c+7−14
@@ -412,8 +412,7 @@ static const struct dentry_operations proc_dentry_operations = · 411 unmodified lines
412412 struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
413413 struct dentry *dentry)
414414 {
415− struct inode *inode = NULL;
416− int error = -ENOENT;
415+ struct inode *inode;
417416
418417 spin_lock(&proc_subdir_lock);
419418 for (de = de->subdir; de ; de = de->next) {
@@ -422,22 +421,16 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir, · 2 unmodified lines
422421 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
423422 pde_get(de);
424423 spin_unlock(&proc_subdir_lock);
425− error = -ENOMEM;
426424 inode = proc_get_inode(dir->i_sb, de);
427− goto out_unlock;
425+ if (!inode)
426+ return ERR_PTR(-ENOMEM);
427+ d_set_d_op(dentry, &proc_dentry_operations);
428+ d_add(dentry, inode);
429+ return NULL;
428430 }
429431 }
430432 spin_unlock(&proc_subdir_lock);
431−out_unlock:
432−
433− if (inode) {
434− d_set_d_op(dentry, &proc_dentry_operations);
435− d_add(dentry, inode);
436− return NULL;
437− }
438− if (de)
439− pde_put(de);
440− return ERR_PTR(error);
433+ return ERR_PTR(-ENOENT);
441434 }
442435
443436 struct dentry *proc_lookup(struct inode *dir, struct dentry *dentry,
fs/proc/inode.c+3−7
@@ -445,12 +445,9 @@ static const struct file_operations proc_reg_file_ops_no_compat = { · 444 unmodified lines
445445
446446 struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
447447 {
448− struct inode * inode;
448+ struct inode *inode = iget_locked(sb, de->low_ino);
449449
450− inode = iget_locked(sb, de->low_ino);
451− if (!inode)
452− return NULL;
453− if (inode->i_state & I_NEW) {
450+ if (inode && (inode->i_state & I_NEW)) {
454451 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
455452 PROC_I(inode)->pde = de;
456453
@@ -482,7 +479,7 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de) · 25 unmodified lines
482479 } else
483480 pde_put(de);
484481 return inode;
485−}
482+}
486483
487484 int proc_fill_super(struct super_block *s)
488485 {
@@ -499,7 +496,6 @@ int proc_fill_super(struct super_block *s) · 10 unmodified lines
499496 root_inode = proc_get_inode(s, &proc_root);
500497 if (!root_inode) {
501498 printk(KERN_ERR "proc_fill_super: get root inode failed\n");
502− pde_put(&proc_root);
503499 return -ENOMEM;
504500 }
505501

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t