aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-03-30 19:06:04 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-03-30 19:06:04 -0400
commitcf2f7d7c90279cdbc12429de278f3d27ac2050ae (patch)
treec84bb54712f566e6497ccadd1ae9f42b4baf0c63 /fs
parent53d8f67082c9b86699dd88b7f9e667e245193f21 (diff)
parenta9caa3de249a6c43bc9c6aec87881f09276677e3 (diff)
Merge branch 'proc-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/adobriyan/proc
* 'proc-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/adobriyan/proc: Revert "proc: revert /proc/uptime to ->read_proc hook" proc 2/2: remove struct proc_dir_entry::owner proc 1/2: do PDE usecounting even for ->read_proc, ->write_proc proc: fix sparse warnings in pagemap_read() proc: move fs/proc/inode-alloc.txt comment into a source file
Diffstat (limited to 'fs')
-rw-r--r--fs/afs/proc.c1
-rw-r--r--fs/cifs/cifs_debug.c1
-rw-r--r--fs/jfs/jfs_debug.c1
-rw-r--r--fs/nfs/client.c2
-rw-r--r--fs/proc/generic.c63
-rw-r--r--fs/proc/inode-alloc.txt14
-rw-r--r--fs/proc/inode.c21
-rw-r--r--fs/proc/internal.h1
-rw-r--r--fs/proc/proc_tty.c1
-rw-r--r--fs/proc/task_mmu.c8
-rw-r--r--fs/proc/uptime.c38
-rw-r--r--fs/reiserfs/procfs.c5
12 files changed, 81 insertions, 75 deletions
diff --git a/fs/afs/proc.c b/fs/afs/proc.c
index 7578c1ab9e0b..8630615e57fe 100644
--- a/fs/afs/proc.c
+++ b/fs/afs/proc.c
@@ -146,7 +146,6 @@ int afs_proc_init(void)
146 proc_afs = proc_mkdir("fs/afs", NULL); 146 proc_afs = proc_mkdir("fs/afs", NULL);
147 if (!proc_afs) 147 if (!proc_afs)
148 goto error_dir; 148 goto error_dir;
149 proc_afs->owner = THIS_MODULE;
150 149
151 p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops); 150 p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
152 if (!p) 151 if (!p)
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index 877e4d9a1159..7f19fefd3d45 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -404,7 +404,6 @@ cifs_proc_init(void)
404 if (proc_fs_cifs == NULL) 404 if (proc_fs_cifs == NULL)
405 return; 405 return;
406 406
407 proc_fs_cifs->owner = THIS_MODULE;
408 proc_create("DebugData", 0, proc_fs_cifs, &cifs_debug_data_proc_fops); 407 proc_create("DebugData", 0, proc_fs_cifs, &cifs_debug_data_proc_fops);
409 408
410#ifdef CONFIG_CIFS_STATS 409#ifdef CONFIG_CIFS_STATS
diff --git a/fs/jfs/jfs_debug.c b/fs/jfs/jfs_debug.c
index 6a73de84bcef..dd824d9b0b1a 100644
--- a/fs/jfs/jfs_debug.c
+++ b/fs/jfs/jfs_debug.c
@@ -90,7 +90,6 @@ void jfs_proc_init(void)
90 90
91 if (!(base = proc_mkdir("fs/jfs", NULL))) 91 if (!(base = proc_mkdir("fs/jfs", NULL)))
92 return; 92 return;
93 base->owner = THIS_MODULE;
94 93
95 for (i = 0; i < NPROCENT; i++) 94 for (i = 0; i < NPROCENT; i++)
96 proc_create(Entries[i].name, 0, base, Entries[i].proc_fops); 95 proc_create(Entries[i].name, 0, base, Entries[i].proc_fops);
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 574158ae2398..2277421656e7 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1606,8 +1606,6 @@ int __init nfs_fs_proc_init(void)
1606 if (!proc_fs_nfs) 1606 if (!proc_fs_nfs)
1607 goto error_0; 1607 goto error_0;
1608 1608
1609 proc_fs_nfs->owner = THIS_MODULE;
1610
1611 /* a file of servers with which we're dealing */ 1609 /* a file of servers with which we're dealing */
1612 p = proc_create("servers", S_IFREG|S_IRUGO, 1610 p = proc_create("servers", S_IFREG|S_IRUGO,
1613 proc_fs_nfs, &nfs_server_list_fops); 1611 proc_fs_nfs, &nfs_server_list_fops);
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 5d2989e9dcc1..fa678abc9db1 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -37,7 +37,7 @@ static int proc_match(int len, const char *name, struct proc_dir_entry *de)
37#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024) 37#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
38 38
39static ssize_t 39static ssize_t
40proc_file_read(struct file *file, char __user *buf, size_t nbytes, 40__proc_file_read(struct file *file, char __user *buf, size_t nbytes,
41 loff_t *ppos) 41 loff_t *ppos)
42{ 42{
43 struct inode * inode = file->f_path.dentry->d_inode; 43 struct inode * inode = file->f_path.dentry->d_inode;
@@ -183,19 +183,47 @@ proc_file_read(struct file *file, char __user *buf, size_t nbytes,
183} 183}
184 184
185static ssize_t 185static ssize_t
186proc_file_read(struct file *file, char __user *buf, size_t nbytes,
187 loff_t *ppos)
188{
189 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
190 ssize_t rv = -EIO;
191
192 spin_lock(&pde->pde_unload_lock);
193 if (!pde->proc_fops) {
194 spin_unlock(&pde->pde_unload_lock);
195 return rv;
196 }
197 pde->pde_users++;
198 spin_unlock(&pde->pde_unload_lock);
199
200 rv = __proc_file_read(file, buf, nbytes, ppos);
201
202 pde_users_dec(pde);
203 return rv;
204}
205
206static ssize_t
186proc_file_write(struct file *file, const char __user *buffer, 207proc_file_write(struct file *file, const char __user *buffer,
187 size_t count, loff_t *ppos) 208 size_t count, loff_t *ppos)
188{ 209{
189 struct inode *inode = file->f_path.dentry->d_inode; 210 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
190 struct proc_dir_entry * dp; 211 ssize_t rv = -EIO;
191 212
192 dp = PDE(inode); 213 if (pde->write_proc) {
193 214 spin_lock(&pde->pde_unload_lock);
194 if (!dp->write_proc) 215 if (!pde->proc_fops) {
195 return -EIO; 216 spin_unlock(&pde->pde_unload_lock);
217 return rv;
218 }
219 pde->pde_users++;
220 spin_unlock(&pde->pde_unload_lock);
196 221
197 /* FIXME: does this routine need ppos? probably... */ 222 /* FIXME: does this routine need ppos? probably... */
198 return dp->write_proc(file, buffer, count, dp->data); 223 rv = pde->write_proc(file, buffer, count, pde->data);
224 pde_users_dec(pde);
225 }
226 return rv;
199} 227}
200 228
201 229
@@ -307,6 +335,21 @@ static DEFINE_SPINLOCK(proc_inum_lock); /* protects the above */
307/* 335/*
308 * Return an inode number between PROC_DYNAMIC_FIRST and 336 * Return an inode number between PROC_DYNAMIC_FIRST and
309 * 0xffffffff, or zero on failure. 337 * 0xffffffff, or zero on failure.
338 *
339 * Current inode allocations in the proc-fs (hex-numbers):
340 *
341 * 00000000 reserved
342 * 00000001-00000fff static entries (goners)
343 * 001 root-ino
344 *
345 * 00001000-00001fff unused
346 * 0001xxxx-7fffxxxx pid-dir entries for pid 1-7fff
347 * 80000000-efffffff unused
348 * f0000000-ffffffff dynamic entries
349 *
350 * Goal:
351 * Once we split the thing into several virtual filesystems,
352 * we will get rid of magical ranges (and this comment, BTW).
310 */ 353 */
311static unsigned int get_inode_number(void) 354static unsigned int get_inode_number(void)
312{ 355{
diff --git a/fs/proc/inode-alloc.txt b/fs/proc/inode-alloc.txt
deleted file mode 100644
index 77212f938c2c..000000000000
--- a/fs/proc/inode-alloc.txt
+++ /dev/null
@@ -1,14 +0,0 @@
1Current inode allocations in the proc-fs (hex-numbers):
2
3 00000000 reserved
4 00000001-00000fff static entries (goners)
5 001 root-ino
6
7 00001000-00001fff unused
8 0001xxxx-7fffxxxx pid-dir entries for pid 1-7fff
9 80000000-efffffff unused
10 f0000000-ffffffff dynamic entries
11
12Goal:
13 a) once we'll split the thing into several virtual filesystems we
14 will get rid of magical ranges (and this file, BTW).
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index d8bb5c671f42..d78ade305541 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -58,11 +58,8 @@ static void proc_delete_inode(struct inode *inode)
58 58
59 /* Let go of any associated proc directory entry */ 59 /* Let go of any associated proc directory entry */
60 de = PROC_I(inode)->pde; 60 de = PROC_I(inode)->pde;
61 if (de) { 61 if (de)
62 if (de->owner)
63 module_put(de->owner);
64 de_put(de); 62 de_put(de);
65 }
66 if (PROC_I(inode)->sysctl) 63 if (PROC_I(inode)->sysctl)
67 sysctl_head_put(PROC_I(inode)->sysctl); 64 sysctl_head_put(PROC_I(inode)->sysctl);
68 clear_inode(inode); 65 clear_inode(inode);
@@ -127,7 +124,7 @@ static void __pde_users_dec(struct proc_dir_entry *pde)
127 complete(pde->pde_unload_completion); 124 complete(pde->pde_unload_completion);
128} 125}
129 126
130static void pde_users_dec(struct proc_dir_entry *pde) 127void pde_users_dec(struct proc_dir_entry *pde)
131{ 128{
132 spin_lock(&pde->pde_unload_lock); 129 spin_lock(&pde->pde_unload_lock);
133 __pde_users_dec(pde); 130 __pde_users_dec(pde);
@@ -449,12 +446,9 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
449{ 446{
450 struct inode * inode; 447 struct inode * inode;
451 448
452 if (!try_module_get(de->owner))
453 goto out_mod;
454
455 inode = iget_locked(sb, ino); 449 inode = iget_locked(sb, ino);
456 if (!inode) 450 if (!inode)
457 goto out_ino; 451 return NULL;
458 if (inode->i_state & I_NEW) { 452 if (inode->i_state & I_NEW) {
459 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 453 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
460 PROC_I(inode)->fd = 0; 454 PROC_I(inode)->fd = 0;
@@ -485,16 +479,9 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
485 } 479 }
486 } 480 }
487 unlock_new_inode(inode); 481 unlock_new_inode(inode);
488 } else { 482 } else
489 module_put(de->owner);
490 de_put(de); 483 de_put(de);
491 }
492 return inode; 484 return inode;
493
494out_ino:
495 module_put(de->owner);
496out_mod:
497 return NULL;
498} 485}
499 486
500int proc_fill_super(struct super_block *s) 487int proc_fill_super(struct super_block *s)
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index cd53ff838498..f6db9618a888 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -91,3 +91,4 @@ struct pde_opener {
91 int (*release)(struct inode *, struct file *); 91 int (*release)(struct inode *, struct file *);
92 struct list_head lh; 92 struct list_head lh;
93}; 93};
94void pde_users_dec(struct proc_dir_entry *pde);
diff --git a/fs/proc/proc_tty.c b/fs/proc/proc_tty.c
index d153946d6d15..4a9e0f65ae60 100644
--- a/fs/proc/proc_tty.c
+++ b/fs/proc/proc_tty.c
@@ -152,7 +152,6 @@ void proc_tty_register_driver(struct tty_driver *driver)
152 if (!ent) 152 if (!ent)
153 return; 153 return;
154 ent->read_proc = driver->ops->read_proc; 154 ent->read_proc = driver->ops->read_proc;
155 ent->owner = driver->owner;
156 ent->data = driver; 155 ent->data = driver;
157 156
158 driver->proc_entry = ent; 157 driver->proc_entry = ent;
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 94063840832a..b0ae0be4801f 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -693,8 +693,8 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
693 goto out_pages; 693 goto out_pages;
694 } 694 }
695 695
696 pm.out = (u64 *)buf; 696 pm.out = (u64 __user *)buf;
697 pm.end = (u64 *)(buf + count); 697 pm.end = (u64 __user *)(buf + count);
698 698
699 pagemap_walk.pmd_entry = pagemap_pte_range; 699 pagemap_walk.pmd_entry = pagemap_pte_range;
700 pagemap_walk.pte_hole = pagemap_pte_hole; 700 pagemap_walk.pte_hole = pagemap_pte_hole;
@@ -720,9 +720,9 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
720 if (ret == PM_END_OF_BUFFER) 720 if (ret == PM_END_OF_BUFFER)
721 ret = 0; 721 ret = 0;
722 /* don't need mmap_sem for these, but this looks cleaner */ 722 /* don't need mmap_sem for these, but this looks cleaner */
723 *ppos += (char *)pm.out - buf; 723 *ppos += (char __user *)pm.out - buf;
724 if (!ret) 724 if (!ret)
725 ret = (char *)pm.out - buf; 725 ret = (char __user *)pm.out - buf;
726 726
727out_pages: 727out_pages:
728 for (; pagecount; pagecount--) { 728 for (; pagecount; pagecount--) {
diff --git a/fs/proc/uptime.c b/fs/proc/uptime.c
index df26aa88fa47..0c10a0b3f146 100644
--- a/fs/proc/uptime.c
+++ b/fs/proc/uptime.c
@@ -1,45 +1,43 @@
1#include <linux/fs.h>
1#include <linux/init.h> 2#include <linux/init.h>
2#include <linux/proc_fs.h> 3#include <linux/proc_fs.h>
3#include <linux/sched.h> 4#include <linux/sched.h>
5#include <linux/seq_file.h>
4#include <linux/time.h> 6#include <linux/time.h>
5#include <asm/cputime.h> 7#include <asm/cputime.h>
6 8
7static int proc_calc_metrics(char *page, char **start, off_t off, 9static int uptime_proc_show(struct seq_file *m, void *v)
8 int count, int *eof, int len)
9{
10 if (len <= off + count)
11 *eof = 1;
12 *start = page + off;
13 len -= off;
14 if (len > count)
15 len = count;
16 if (len < 0)
17 len = 0;
18 return len;
19}
20
21static int uptime_read_proc(char *page, char **start, off_t off, int count,
22 int *eof, void *data)
23{ 10{
24 struct timespec uptime; 11 struct timespec uptime;
25 struct timespec idle; 12 struct timespec idle;
26 int len;
27 cputime_t idletime = cputime_add(init_task.utime, init_task.stime); 13 cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
28 14
29 do_posix_clock_monotonic_gettime(&uptime); 15 do_posix_clock_monotonic_gettime(&uptime);
30 monotonic_to_bootbased(&uptime); 16 monotonic_to_bootbased(&uptime);
31 cputime_to_timespec(idletime, &idle); 17 cputime_to_timespec(idletime, &idle);
32 len = sprintf(page, "%lu.%02lu %lu.%02lu\n", 18 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
33 (unsigned long) uptime.tv_sec, 19 (unsigned long) uptime.tv_sec,
34 (uptime.tv_nsec / (NSEC_PER_SEC / 100)), 20 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
35 (unsigned long) idle.tv_sec, 21 (unsigned long) idle.tv_sec,
36 (idle.tv_nsec / (NSEC_PER_SEC / 100))); 22 (idle.tv_nsec / (NSEC_PER_SEC / 100)));
37 return proc_calc_metrics(page, start, off, count, eof, len); 23 return 0;
38} 24}
39 25
26static int uptime_proc_open(struct inode *inode, struct file *file)
27{
28 return single_open(file, uptime_proc_show, NULL);
29}
30
31static const struct file_operations uptime_proc_fops = {
32 .open = uptime_proc_open,
33 .read = seq_read,
34 .llseek = seq_lseek,
35 .release = single_release,
36};
37
40static int __init proc_uptime_init(void) 38static int __init proc_uptime_init(void)
41{ 39{
42 create_proc_read_entry("uptime", 0, NULL, uptime_read_proc, NULL); 40 proc_create("uptime", 0, NULL, &uptime_proc_fops);
43 return 0; 41 return 0;
44} 42}
45module_init(proc_uptime_init); 43module_init(proc_uptime_init);
diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
index d5066400638a..9229e5514a4e 100644
--- a/fs/reiserfs/procfs.c
+++ b/fs/reiserfs/procfs.c
@@ -492,7 +492,6 @@ int reiserfs_proc_info_init(struct super_block *sb)
492 spin_lock_init(&__PINFO(sb).lock); 492 spin_lock_init(&__PINFO(sb).lock);
493 REISERFS_SB(sb)->procdir = proc_mkdir(b, proc_info_root); 493 REISERFS_SB(sb)->procdir = proc_mkdir(b, proc_info_root);
494 if (REISERFS_SB(sb)->procdir) { 494 if (REISERFS_SB(sb)->procdir) {
495 REISERFS_SB(sb)->procdir->owner = THIS_MODULE;
496 REISERFS_SB(sb)->procdir->data = sb; 495 REISERFS_SB(sb)->procdir->data = sb;
497 add_file(sb, "version", show_version); 496 add_file(sb, "version", show_version);
498 add_file(sb, "super", show_super); 497 add_file(sb, "super", show_super);
@@ -556,9 +555,7 @@ int reiserfs_proc_info_global_init(void)
556{ 555{
557 if (proc_info_root == NULL) { 556 if (proc_info_root == NULL) {
558 proc_info_root = proc_mkdir(proc_info_root_name, NULL); 557 proc_info_root = proc_mkdir(proc_info_root_name, NULL);
559 if (proc_info_root) { 558 if (!proc_info_root) {
560 proc_info_root->owner = THIS_MODULE;
561 } else {
562 reiserfs_warning(NULL, "cannot create /proc/%s", 559 reiserfs_warning(NULL, "cannot create /proc/%s",
563 proc_info_root_name); 560 proc_info_root_name);
564 return 1; 561 return 1;