Re: Re: About function __create_file in debugfs

2012-09-10 Thread Jianpeng Ma
On 2012-09-08 23:25 gregkh  Wrote:
>On Sat, Sep 08, 2012 at 05:41:05PM +0800, Jianpeng Ma wrote:
>> Hi:
>>  At present,i used blktrace to trace block io.But i always met error, 
>> the message like:
>> >BLKTRACESETUP(2) /dev/sdc failed: 2/No such file or directory
>> >Thread 0 failed open /sys/kernel/debug/block/(null)/trace0: 2/No such file 
>> >or directory
>> >Thread 2 failed open /sys/kernel/debug/block/(null)/trace2: 2/No such file 
>> >or directory
>> >Thread 3 failed open /sys/kernel/debug/block/(null)/trace3: 2/No such file 
>> >or directory
>> 
>> >Thread 1 failed open /sys/kernel/debug/block/(null)/trace1: 2/No such file 
>> >or directory
>> >FAILED to start thread on CPU 0: 1/Operation not permitted
>> >FAILED to start thread on CPU 1: 1/Operation not permitted
>> >FAILED to start thread on CPU 2: 1/Operation not permitted
>> >FAILED to start thread on CPU 3: 1/Operation not permitted
>> 
>> But those isn't important. I add some message in kernel and found the reason 
>> is inode already existed.
>> But the function __create_file dosen't return correctly errno.So blktrace 
>> tool can't print correctly message.
>> I think func __create_file should return correctly message(ERR_PTR(error)) 
>> not NULL.
>
>Patches are always welcome :)
>
>greg k-h

Thanks, the patch is:
Func debugfs_create_symlink/debugfs_create_file/debugfs_create_dir,
it only return NULL when error counted. We should correctly error info
instead of.

Signed-off-by: Jianpeng Ma 
---
 fs/debugfs/inode.c |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 4733eab..1e94350 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -302,8 +302,10 @@ struct dentry *__create_file(const char *name, umode_t 
mode,
 
error = simple_pin_fs(_fs_type, _mount,
  _mount_count);
-   if (error)
+   if (error) {
+   dentry = ERR_PTR(error);
goto exit;
+   }
 
/* If the parent is not specified, we create it in the root.
 * We need the root dentry to do this, which is in the super 
@@ -337,7 +339,7 @@ struct dentry *__create_file(const char *name, umode_t mode,
mutex_unlock(>d_inode->i_mutex);
 
if (error) {
-   dentry = NULL;
+   dentry = ERR_PTR(error);
simple_release_fs(_mount, _mount_count);
}
 exit:
@@ -442,10 +444,10 @@ struct dentry *debugfs_create_symlink(const char *name, 
struct dentry *parent,
 
link = kstrdup(target, GFP_KERNEL);
if (!link)
-   return NULL;
+   return ERR_PTR(-ENOMEM);
 
result = __create_file(name, S_IFLNK | S_IRWXUGO, parent, link, NULL);
-   if (!result)
+   if (IS_ERR_OR_NULL(result))
kfree(link);
return result;
 }
-- 
1.7.9.5


But i searched kernel-code and found at-least 100 places used those code.
How about those code? Am i correct those or not?
Thanks!N�Р骒r��yb�X�肚�v�^�)藓{.n�+�伐�{��赙zXФ�≤�}��财�z�:+v�����赙zZ+��+zf"�h���~i���z��wア�?�ㄨ��&�)撷f��^j谦y�m��@A�a囤�
0鹅h���i

Re: Re: About function __create_file in debugfs

2012-09-10 Thread Jianpeng Ma
On 2012-09-08 23:25 gregkh gre...@linuxfoundation.org Wrote:
On Sat, Sep 08, 2012 at 05:41:05PM +0800, Jianpeng Ma wrote:
 Hi:
  At present,i used blktrace to trace block io.But i always met error, 
 the message like:
 BLKTRACESETUP(2) /dev/sdc failed: 2/No such file or directory
 Thread 0 failed open /sys/kernel/debug/block/(null)/trace0: 2/No such file 
 or directory
 Thread 2 failed open /sys/kernel/debug/block/(null)/trace2: 2/No such file 
 or directory
 Thread 3 failed open /sys/kernel/debug/block/(null)/trace3: 2/No such file 
 or directory
 
 Thread 1 failed open /sys/kernel/debug/block/(null)/trace1: 2/No such file 
 or directory
 FAILED to start thread on CPU 0: 1/Operation not permitted
 FAILED to start thread on CPU 1: 1/Operation not permitted
 FAILED to start thread on CPU 2: 1/Operation not permitted
 FAILED to start thread on CPU 3: 1/Operation not permitted
 
 But those isn't important. I add some message in kernel and found the reason 
 is inode already existed.
 But the function __create_file dosen't return correctly errno.So blktrace 
 tool can't print correctly message.
 I think func __create_file should return correctly message(ERR_PTR(error)) 
 not NULL.

Patches are always welcome :)

greg k-h

Thanks, the patch is:
Func debugfs_create_symlink/debugfs_create_file/debugfs_create_dir,
it only return NULL when error counted. We should correctly error info
instead of.

Signed-off-by: Jianpeng Ma majianp...@gmail.com
---
 fs/debugfs/inode.c |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 4733eab..1e94350 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -302,8 +302,10 @@ struct dentry *__create_file(const char *name, umode_t 
mode,
 
error = simple_pin_fs(debug_fs_type, debugfs_mount,
  debugfs_mount_count);
-   if (error)
+   if (error) {
+   dentry = ERR_PTR(error);
goto exit;
+   }
 
/* If the parent is not specified, we create it in the root.
 * We need the root dentry to do this, which is in the super 
@@ -337,7 +339,7 @@ struct dentry *__create_file(const char *name, umode_t mode,
mutex_unlock(parent-d_inode-i_mutex);
 
if (error) {
-   dentry = NULL;
+   dentry = ERR_PTR(error);
simple_release_fs(debugfs_mount, debugfs_mount_count);
}
 exit:
@@ -442,10 +444,10 @@ struct dentry *debugfs_create_symlink(const char *name, 
struct dentry *parent,
 
link = kstrdup(target, GFP_KERNEL);
if (!link)
-   return NULL;
+   return ERR_PTR(-ENOMEM);
 
result = __create_file(name, S_IFLNK | S_IRWXUGO, parent, link, NULL);
-   if (!result)
+   if (IS_ERR_OR_NULL(result))
kfree(link);
return result;
 }
-- 
1.7.9.5


But i searched kernel-code and found at-least 100 places used those code.
How about those code? Am i correct those or not?
Thanks!N�Р骒r��yb�X�肚�v�^�)藓{.n�+�伐�{��赙zXФ�≤�}��财�z�j:+v�����赙zZ+��+zf"�h���~i���z��wア�?�ㄨ���)撷f��^j谦y�m��@A�a囤�
0鹅h���i

Re: About function __create_file in debugfs

2012-09-08 Thread gregkh
On Sat, Sep 08, 2012 at 05:41:05PM +0800, Jianpeng Ma wrote:
> Hi:
>   At present,i used blktrace to trace block io.But i always met error, 
> the message like:
> >BLKTRACESETUP(2) /dev/sdc failed: 2/No such file or directory
> >Thread 0 failed open /sys/kernel/debug/block/(null)/trace0: 2/No such file 
> >or directory
> >Thread 2 failed open /sys/kernel/debug/block/(null)/trace2: 2/No such file 
> >or directory
> >Thread 3 failed open /sys/kernel/debug/block/(null)/trace3: 2/No such file 
> >or directory
> 
> >Thread 1 failed open /sys/kernel/debug/block/(null)/trace1: 2/No such file 
> >or directory
> >FAILED to start thread on CPU 0: 1/Operation not permitted
> >FAILED to start thread on CPU 1: 1/Operation not permitted
> >FAILED to start thread on CPU 2: 1/Operation not permitted
> >FAILED to start thread on CPU 3: 1/Operation not permitted
> 
> But those isn't important. I add some message in kernel and found the reason 
> is inode already existed.
> But the function __create_file dosen't return correctly errno.So blktrace 
> tool can't print correctly message.
> I think func __create_file should return correctly message(ERR_PTR(error)) 
> not NULL.

Patches are always welcome :)

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: About function __create_file in debugfs

2012-09-08 Thread gregkh
On Sat, Sep 08, 2012 at 05:41:05PM +0800, Jianpeng Ma wrote:
 Hi:
   At present,i used blktrace to trace block io.But i always met error, 
 the message like:
 BLKTRACESETUP(2) /dev/sdc failed: 2/No such file or directory
 Thread 0 failed open /sys/kernel/debug/block/(null)/trace0: 2/No such file 
 or directory
 Thread 2 failed open /sys/kernel/debug/block/(null)/trace2: 2/No such file 
 or directory
 Thread 3 failed open /sys/kernel/debug/block/(null)/trace3: 2/No such file 
 or directory
 
 Thread 1 failed open /sys/kernel/debug/block/(null)/trace1: 2/No such file 
 or directory
 FAILED to start thread on CPU 0: 1/Operation not permitted
 FAILED to start thread on CPU 1: 1/Operation not permitted
 FAILED to start thread on CPU 2: 1/Operation not permitted
 FAILED to start thread on CPU 3: 1/Operation not permitted
 
 But those isn't important. I add some message in kernel and found the reason 
 is inode already existed.
 But the function __create_file dosen't return correctly errno.So blktrace 
 tool can't print correctly message.
 I think func __create_file should return correctly message(ERR_PTR(error)) 
 not NULL.

Patches are always welcome :)

greg k-h
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/