diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/9p/fid.c | 17 | ||||
-rw-r--r-- | fs/9p/fid.h | 1 | ||||
-rw-r--r-- | fs/proc/array.c | 44 | ||||
-rw-r--r-- | fs/sysfs/bin.c | 7 | ||||
-rw-r--r-- | fs/sysfs/dir.c | 21 |
5 files changed, 42 insertions, 48 deletions
diff --git a/fs/9p/fid.c b/fs/9p/fid.c index 08fa320b7e6d..15e05a15b575 100644 --- a/fs/9p/fid.c +++ b/fs/9p/fid.c | |||
@@ -92,23 +92,6 @@ struct p9_fid *v9fs_fid_lookup(struct dentry *dentry) | |||
92 | return fid; | 92 | return fid; |
93 | } | 93 | } |
94 | 94 | ||
95 | struct p9_fid *v9fs_fid_lookup_remove(struct dentry *dentry) | ||
96 | { | ||
97 | struct p9_fid *fid; | ||
98 | struct v9fs_dentry *dent; | ||
99 | |||
100 | dent = dentry->d_fsdata; | ||
101 | fid = v9fs_fid_lookup(dentry); | ||
102 | if (!IS_ERR(fid)) { | ||
103 | spin_lock(&dent->lock); | ||
104 | list_del(&fid->dlist); | ||
105 | spin_unlock(&dent->lock); | ||
106 | } | ||
107 | |||
108 | return fid; | ||
109 | } | ||
110 | |||
111 | |||
112 | /** | 95 | /** |
113 | * v9fs_fid_clone - lookup the fid for a dentry, clone a private copy and | 96 | * v9fs_fid_clone - lookup the fid for a dentry, clone a private copy and |
114 | * release it | 97 | * release it |
diff --git a/fs/9p/fid.h b/fs/9p/fid.h index 47a0ba742872..26e07df783b9 100644 --- a/fs/9p/fid.h +++ b/fs/9p/fid.h | |||
@@ -28,6 +28,5 @@ struct v9fs_dentry { | |||
28 | }; | 28 | }; |
29 | 29 | ||
30 | struct p9_fid *v9fs_fid_lookup(struct dentry *dentry); | 30 | struct p9_fid *v9fs_fid_lookup(struct dentry *dentry); |
31 | struct p9_fid *v9fs_fid_lookup_remove(struct dentry *dentry); | ||
32 | struct p9_fid *v9fs_fid_clone(struct dentry *dentry); | 31 | struct p9_fid *v9fs_fid_clone(struct dentry *dentry); |
33 | int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid); | 32 | int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid); |
diff --git a/fs/proc/array.c b/fs/proc/array.c index 965625a0977d..ee4814dd98f9 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
@@ -320,7 +320,21 @@ int proc_pid_status(struct task_struct *task, char *buffer) | |||
320 | return buffer - orig; | 320 | return buffer - orig; |
321 | } | 321 | } |
322 | 322 | ||
323 | static clock_t task_utime(struct task_struct *p) | 323 | /* |
324 | * Use precise platform statistics if available: | ||
325 | */ | ||
326 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING | ||
327 | static cputime_t task_utime(struct task_struct *p) | ||
328 | { | ||
329 | return p->utime; | ||
330 | } | ||
331 | |||
332 | static cputime_t task_stime(struct task_struct *p) | ||
333 | { | ||
334 | return p->stime; | ||
335 | } | ||
336 | #else | ||
337 | static cputime_t task_utime(struct task_struct *p) | ||
324 | { | 338 | { |
325 | clock_t utime = cputime_to_clock_t(p->utime), | 339 | clock_t utime = cputime_to_clock_t(p->utime), |
326 | total = utime + cputime_to_clock_t(p->stime); | 340 | total = utime + cputime_to_clock_t(p->stime); |
@@ -337,10 +351,10 @@ static clock_t task_utime(struct task_struct *p) | |||
337 | } | 351 | } |
338 | utime = (clock_t)temp; | 352 | utime = (clock_t)temp; |
339 | 353 | ||
340 | return utime; | 354 | return clock_t_to_cputime(utime); |
341 | } | 355 | } |
342 | 356 | ||
343 | static clock_t task_stime(struct task_struct *p) | 357 | static cputime_t task_stime(struct task_struct *p) |
344 | { | 358 | { |
345 | clock_t stime; | 359 | clock_t stime; |
346 | 360 | ||
@@ -349,10 +363,12 @@ static clock_t task_stime(struct task_struct *p) | |||
349 | * the total, to make sure the total observed by userspace | 363 | * the total, to make sure the total observed by userspace |
350 | * grows monotonically - apps rely on that): | 364 | * grows monotonically - apps rely on that): |
351 | */ | 365 | */ |
352 | stime = nsec_to_clock_t(p->se.sum_exec_runtime) - task_utime(p); | 366 | stime = nsec_to_clock_t(p->se.sum_exec_runtime) - |
367 | cputime_to_clock_t(task_utime(p)); | ||
353 | 368 | ||
354 | return stime; | 369 | return clock_t_to_cputime(stime); |
355 | } | 370 | } |
371 | #endif | ||
356 | 372 | ||
357 | static int do_task_stat(struct task_struct *task, char *buffer, int whole) | 373 | static int do_task_stat(struct task_struct *task, char *buffer, int whole) |
358 | { | 374 | { |
@@ -368,8 +384,7 @@ static int do_task_stat(struct task_struct *task, char *buffer, int whole) | |||
368 | unsigned long long start_time; | 384 | unsigned long long start_time; |
369 | unsigned long cmin_flt = 0, cmaj_flt = 0; | 385 | unsigned long cmin_flt = 0, cmaj_flt = 0; |
370 | unsigned long min_flt = 0, maj_flt = 0; | 386 | unsigned long min_flt = 0, maj_flt = 0; |
371 | cputime_t cutime, cstime; | 387 | cputime_t cutime, cstime, utime, stime; |
372 | clock_t utime, stime; | ||
373 | unsigned long rsslim = 0; | 388 | unsigned long rsslim = 0; |
374 | char tcomm[sizeof(task->comm)]; | 389 | char tcomm[sizeof(task->comm)]; |
375 | unsigned long flags; | 390 | unsigned long flags; |
@@ -387,8 +402,7 @@ static int do_task_stat(struct task_struct *task, char *buffer, int whole) | |||
387 | 402 | ||
388 | sigemptyset(&sigign); | 403 | sigemptyset(&sigign); |
389 | sigemptyset(&sigcatch); | 404 | sigemptyset(&sigcatch); |
390 | cutime = cstime = cputime_zero; | 405 | cutime = cstime = utime = stime = cputime_zero; |
391 | utime = stime = 0; | ||
392 | 406 | ||
393 | rcu_read_lock(); | 407 | rcu_read_lock(); |
394 | if (lock_task_sighand(task, &flags)) { | 408 | if (lock_task_sighand(task, &flags)) { |
@@ -414,15 +428,15 @@ static int do_task_stat(struct task_struct *task, char *buffer, int whole) | |||
414 | do { | 428 | do { |
415 | min_flt += t->min_flt; | 429 | min_flt += t->min_flt; |
416 | maj_flt += t->maj_flt; | 430 | maj_flt += t->maj_flt; |
417 | utime += task_utime(t); | 431 | utime = cputime_add(utime, task_utime(t)); |
418 | stime += task_stime(t); | 432 | stime = cputime_add(stime, task_stime(t)); |
419 | t = next_thread(t); | 433 | t = next_thread(t); |
420 | } while (t != task); | 434 | } while (t != task); |
421 | 435 | ||
422 | min_flt += sig->min_flt; | 436 | min_flt += sig->min_flt; |
423 | maj_flt += sig->maj_flt; | 437 | maj_flt += sig->maj_flt; |
424 | utime += cputime_to_clock_t(sig->utime); | 438 | utime = cputime_add(utime, sig->utime); |
425 | stime += cputime_to_clock_t(sig->stime); | 439 | stime = cputime_add(stime, sig->stime); |
426 | } | 440 | } |
427 | 441 | ||
428 | sid = signal_session(sig); | 442 | sid = signal_session(sig); |
@@ -471,8 +485,8 @@ static int do_task_stat(struct task_struct *task, char *buffer, int whole) | |||
471 | cmin_flt, | 485 | cmin_flt, |
472 | maj_flt, | 486 | maj_flt, |
473 | cmaj_flt, | 487 | cmaj_flt, |
474 | utime, | 488 | cputime_to_clock_t(utime), |
475 | stime, | 489 | cputime_to_clock_t(stime), |
476 | cputime_to_clock_t(cutime), | 490 | cputime_to_clock_t(cutime), |
477 | cputime_to_clock_t(cstime), | 491 | cputime_to_clock_t(cstime), |
478 | priority, | 492 | priority, |
diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c index 135353f8a296..5afe2a26f5d8 100644 --- a/fs/sysfs/bin.c +++ b/fs/sysfs/bin.c | |||
@@ -248,12 +248,7 @@ int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr) | |||
248 | 248 | ||
249 | void sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr) | 249 | void sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr) |
250 | { | 250 | { |
251 | if (sysfs_hash_and_remove(kobj->sd, attr->attr.name) < 0) { | 251 | sysfs_hash_and_remove(kobj->sd, attr->attr.name); |
252 | printk(KERN_ERR "%s: " | ||
253 | "bad dentry or inode or no such file: \"%s\"\n", | ||
254 | __FUNCTION__, attr->attr.name); | ||
255 | dump_stack(); | ||
256 | } | ||
257 | } | 252 | } |
258 | 253 | ||
259 | EXPORT_SYMBOL_GPL(sysfs_create_bin_file); | 254 | EXPORT_SYMBOL_GPL(sysfs_create_bin_file); |
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 048e6054c2fd..83e76b3813c9 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c | |||
@@ -762,12 +762,15 @@ static int sysfs_count_nlink(struct sysfs_dirent *sd) | |||
762 | static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry, | 762 | static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry, |
763 | struct nameidata *nd) | 763 | struct nameidata *nd) |
764 | { | 764 | { |
765 | struct dentry *ret = NULL; | ||
765 | struct sysfs_dirent * parent_sd = dentry->d_parent->d_fsdata; | 766 | struct sysfs_dirent * parent_sd = dentry->d_parent->d_fsdata; |
766 | struct sysfs_dirent * sd; | 767 | struct sysfs_dirent * sd; |
767 | struct bin_attribute *bin_attr; | 768 | struct bin_attribute *bin_attr; |
768 | struct inode *inode; | 769 | struct inode *inode; |
769 | int found = 0; | 770 | int found = 0; |
770 | 771 | ||
772 | mutex_lock(&sysfs_mutex); | ||
773 | |||
771 | for (sd = parent_sd->s_children; sd; sd = sd->s_sibling) { | 774 | for (sd = parent_sd->s_children; sd; sd = sd->s_sibling) { |
772 | if (sysfs_type(sd) && | 775 | if (sysfs_type(sd) && |
773 | !strcmp(sd->s_name, dentry->d_name.name)) { | 776 | !strcmp(sd->s_name, dentry->d_name.name)) { |
@@ -778,14 +781,14 @@ static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry, | |||
778 | 781 | ||
779 | /* no such entry */ | 782 | /* no such entry */ |
780 | if (!found) | 783 | if (!found) |
781 | return NULL; | 784 | goto out_unlock; |
782 | 785 | ||
783 | /* attach dentry and inode */ | 786 | /* attach dentry and inode */ |
784 | inode = sysfs_get_inode(sd); | 787 | inode = sysfs_get_inode(sd); |
785 | if (!inode) | 788 | if (!inode) { |
786 | return ERR_PTR(-ENOMEM); | 789 | ret = ERR_PTR(-ENOMEM); |
787 | 790 | goto out_unlock; | |
788 | mutex_lock(&sysfs_mutex); | 791 | } |
789 | 792 | ||
790 | if (inode->i_state & I_NEW) { | 793 | if (inode->i_state & I_NEW) { |
791 | /* initialize inode according to type */ | 794 | /* initialize inode according to type */ |
@@ -815,9 +818,9 @@ static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry, | |||
815 | sysfs_instantiate(dentry, inode); | 818 | sysfs_instantiate(dentry, inode); |
816 | sysfs_attach_dentry(sd, dentry); | 819 | sysfs_attach_dentry(sd, dentry); |
817 | 820 | ||
821 | out_unlock: | ||
818 | mutex_unlock(&sysfs_mutex); | 822 | mutex_unlock(&sysfs_mutex); |
819 | 823 | return ret; | |
820 | return NULL; | ||
821 | } | 824 | } |
822 | 825 | ||
823 | const struct inode_operations sysfs_dir_inode_operations = { | 826 | const struct inode_operations sysfs_dir_inode_operations = { |
@@ -942,6 +945,8 @@ int sysfs_rename_dir(struct kobject *kobj, struct sysfs_dirent *new_parent_sd, | |||
942 | if (error) | 945 | if (error) |
943 | goto out_drop; | 946 | goto out_drop; |
944 | 947 | ||
948 | mutex_lock(&sysfs_mutex); | ||
949 | |||
945 | dup_name = sd->s_name; | 950 | dup_name = sd->s_name; |
946 | sd->s_name = new_name; | 951 | sd->s_name = new_name; |
947 | 952 | ||
@@ -949,8 +954,6 @@ int sysfs_rename_dir(struct kobject *kobj, struct sysfs_dirent *new_parent_sd, | |||
949 | d_add(new_dentry, NULL); | 954 | d_add(new_dentry, NULL); |
950 | d_move(sd->s_dentry, new_dentry); | 955 | d_move(sd->s_dentry, new_dentry); |
951 | 956 | ||
952 | mutex_lock(&sysfs_mutex); | ||
953 | |||
954 | sysfs_unlink_sibling(sd); | 957 | sysfs_unlink_sibling(sd); |
955 | sysfs_get(new_parent_sd); | 958 | sysfs_get(new_parent_sd); |
956 | sysfs_put(sd->s_parent); | 959 | sysfs_put(sd->s_parent); |