ceph: Replace DEFINE_SIMPLE_ATTRIBUTE with DEFINE_DEBUGFS_ATTRIBUTE
PATCH 1/1 ceph: Replace DEFINE_SIMPLE_ATTRIBUTE with DEFINE_DEBUGFS_ATTRIBUTE
Fix the following coccicheck warning:
./fs/ceph/debugfs.c:347:0-23: WARNING: congestion_kb_fops should be defined with DEFINE_DEBUGFS_ATTRIBUTE.
--- fs/ceph/debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ceph/debugfs.c +2 -2
@@ -344,8 +344,8 @@ static int congestion_kb_get(void *data, u64 *val)return 0 ; } -DEFINE_SIMPLE_ATTRIBUTE (congestion_kb_fops, congestion_kb_get, - congestion_kb_set,"%llu\n" ); +DEFINE_DEBUGFS_ATTRIBUTE (congestion_kb_fops, congestion_kb_get, + congestion_kb_set,"%llu\n" );void ceph_fs_debugfs_cleanup (struct ceph_fs_client *fsc)
Signature · 1 line
1.8.3.1
Quoted 26 lines · Jiapeng Chong
Fix the following coccicheck warning:
./fs/ceph/debugfs.c:347:0-23: WARNING:
congestion_kb_fopsshould be defined withDEFINE_DEBUGFS_ATTRIBUTE.Reported-by Abaci Robot <[email protected]>Signed-off-by Jiapeng Chong <[email protected]>---
fs/ceph/debugfs.c | 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)fs/ceph/debugfs.c +0
-0@@ -344,8 +344,8 @@ static int congestion_kb_get(void *data, u64 *val) return 0; }fs/ceph/debugfs.c +2
-2-DEFINE_SIMPLE_ATTRIBUTE (congestion_kb_fops, congestion_kb_get, - congestion_kb_set,"%llu\n" ); +DEFINE_DEBUGFS_ATTRIBUTE (congestion_kb_fops, congestion_kb_get, + congestion_kb_set,"%llu\n" );
Quoted 3 lines
void
ceph_fs_debugfs_cleanup(struct ceph_fs_client *fsc)
Looks reasonable. Merged into ceph-client/testing branch.
Thanks!
Signature · 1 line
Jeff Layton <[email protected]>
Ilya Dryomov
maintainerQuoted 17 lines · Jiapeng Chong
Fix the following coccicheck warning:
./fs/ceph/debugfs.c:347:0-23: WARNING:
congestion_kb_fopsshould be defined withDEFINE_DEBUGFS_ATTRIBUTE.Reported-by Abaci Robot <[email protected]>Signed-off-by Jiapeng Chong <[email protected]>--- fs/ceph/debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/ceph/debugfs.c +0
-0
fs/ceph/debugfs.c static int congestion_kb_get(void *data, u64 *val) · line 351
Quoted 10 lines
fs/ceph/debugfs.c +2
-2@@ -344,8 +344,8 @@ static int congestion_kb_get(void *data, u64 *val)return 0 ; } -DEFINE_SIMPLE_ATTRIBUTE (congestion_kb_fops, congestion_kb_get, - congestion_kb_set,"%llu\n" ); +DEFINE_DEBUGFS_ATTRIBUTE (congestion_kb_fops, congestion_kb_get, + congestion_kb_set,"%llu\n" );void ceph_fs_debugfs_cleanup (struct ceph_fs_client *fsc)
Hi Jiapeng,
What is the benefit of this conversion?
From a quick look, with DEFINE_DEBUGFS_ATTRIBUTE writeback_congestion_kb file would no longer be seekable. It may not matter much, but something that should have been mentioned.
Futher, debugfs_create_file() creates a full proxy for fops, protecting against removal races. DEFINE_DEBUGFS_ATTRIBUTE adds its own protection but just for ->read() and ->write(). I don't think we need both.
Thanks,
Ilya
Quoted 34 lines · Ilya Dryomov
Quoted 17 lines · Jiapeng Chong
Fix the following coccicheck warning:
./fs/ceph/debugfs.c:347:0-23: WARNING:
congestion_kb_fopsshould be defined withDEFINE_DEBUGFS_ATTRIBUTE.Reported-by Abaci Robot <[email protected]>Signed-off-by Jiapeng Chong <[email protected]>---
fs/ceph/debugfs.c | 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)fs/ceph/debugfs.c +0
-0fs/ceph/debugfs.c static int congestion_kb_get(void *data, u64 *val) · line 351
Quoted 10 lines
fs/ceph/debugfs.c +2
-2@@ -344,8 +344,8 @@ static int congestion_kb_get(void *data, u64 *val) return 0; } -DEFINE_SIMPLE_ATTRIBUTE (congestion_kb_fops, congestion_kb_get, - congestion_kb_set,"%llu\n" ); +DEFINE_DEBUGFS_ATTRIBUTE (congestion_kb_fops, congestion_kb_get, + congestion_kb_set,"%llu\n" ); void ceph_fs_debugfs_cleanup(struct ceph_fs_client *fsc)Hi Jiapeng,
What is the benefit of this conversion?
Quoted 8 lines
From a quick look, with
DEFINE_DEBUGFS_ATTRIBUTEwriteback_congestion_kbfile would no longer be seekable. It may not matter much, but something that should have been mentioned.Futher,
debugfs_create_file()creates a full proxy for fops, protecting against removal races.DEFINE_DEBUGFS_ATTRIBUTEadds its own protection but just for ->read() and ->write(). I don't think we need both.
The coccinelle script clarifies some of this. See the commit log here:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5103068eaca290f890a30aae70085fac44cecaf6
That said, it also mentions that the file should be converted to use debugfs_create_file_unsafe now as well, and that wasn't done in this patch. Jiapeng, was that intentional? If so, why?
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 45 lines · Jeff Layton
Quoted 34 lines · Ilya Dryomov
Quoted 17 lines · Jiapeng Chong
Fix the following coccicheck warning:
./fs/ceph/debugfs.c:347:0-23: WARNING:
congestion_kb_fopsshould be defined withDEFINE_DEBUGFS_ATTRIBUTE.Reported-by Abaci Robot <[email protected]>Signed-off-by Jiapeng Chong <[email protected]>---
fs/ceph/debugfs.c | 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)fs/ceph/debugfs.c +0
-0fs/ceph/debugfs.c static int congestion_kb_get(void *data, u64 *val) · line 351
Quoted 10 lines
fs/ceph/debugfs.c +2
-2@@ -344,8 +344,8 @@ static int congestion_kb_get(void *data, u64 *val) return 0; } -DEFINE_SIMPLE_ATTRIBUTE (congestion_kb_fops, congestion_kb_get, - congestion_kb_set,"%llu\n" ); +DEFINE_DEBUGFS_ATTRIBUTE (congestion_kb_fops, congestion_kb_get, + congestion_kb_set,"%llu\n" ); void ceph_fs_debugfs_cleanup(struct ceph_fs_client *fsc)Hi Jiapeng,
What is the benefit of this conversion?
Quoted 8 lines
From a quick look, with
DEFINE_DEBUGFS_ATTRIBUTEwriteback_congestion_kbfile would no longer be seekable. It may not matter much, but something that should have been mentioned.Futher,
debugfs_create_file()creates a full proxy for fops, protecting against removal races.DEFINE_DEBUGFS_ATTRIBUTEadds its own protection but just for ->read() and ->write(). I don't think we need both.
Quoted 8 lines
The coccinelle script clarifies some of this. See the commit log here:
That said, it also mentions that the file should be converted to use
debugfs_create_file_unsafenow as well, and that wasn't done in this patch. Jiapeng, was that intentional? If so, why?
For now, I've dropped this patch until the situation with debugfs_create_file_unsafe is clear.
Signature · 1 line
Jeff Layton <[email protected]>