linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH next] ceph: Fix debugfs_simple_attr.cocci warnings
@ 2019-12-23 14:39 Chen Wandun
  2020-01-06 15:04 ` Ilya Dryomov
  0 siblings, 1 reply; 2+ messages in thread
From: Chen Wandun @ 2019-12-23 14:39 UTC (permalink / raw)
  To: jlayton, sage, idryomov, ceph-devel, linux-kernel; +Cc: chenwandun

Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE
for debugfs files.

Semantic patch information:
Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file()
imposes some significant overhead as compared to
DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe().

Signed-off-by: Chen Wandun <chenwandun@huawei.com>
---
 fs/ceph/debugfs.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c
index c281f32..60a0f1a 100644
--- a/fs/ceph/debugfs.c
+++ b/fs/ceph/debugfs.c
@@ -243,8 +243,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)
@@ -264,11 +264,11 @@ void ceph_fs_debugfs_init(struct ceph_fs_client *fsc)
 
 	dout("ceph_fs_debugfs_init\n");
 	fsc->debugfs_congestion_kb =
-		debugfs_create_file("writeback_congestion_kb",
-				    0600,
-				    fsc->client->debugfs_dir,
-				    fsc,
-				    &congestion_kb_fops);
+		debugfs_create_file_unsafe("writeback_congestion_kb",
+					   0600,
+					   fsc->client->debugfs_dir,
+					   fsc,
+					   &congestion_kb_fops);
 
 	snprintf(name, sizeof(name), "../../bdi/%s",
 		 dev_name(fsc->sb->s_bdi->dev));
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH next] ceph: Fix debugfs_simple_attr.cocci warnings
  2019-12-23 14:39 [PATCH next] ceph: Fix debugfs_simple_attr.cocci warnings Chen Wandun
@ 2020-01-06 15:04 ` Ilya Dryomov
  0 siblings, 0 replies; 2+ messages in thread
From: Ilya Dryomov @ 2020-01-06 15:04 UTC (permalink / raw)
  To: Chen Wandun; +Cc: Jeff Layton, Sage Weil, Ceph Development, LKML

On Mon, Dec 23, 2019 at 3:32 PM Chen Wandun <chenwandun@huawei.com> wrote:
>
> Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE
> for debugfs files.
>
> Semantic patch information:
> Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file()
> imposes some significant overhead as compared to
> DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe().
>
> Signed-off-by: Chen Wandun <chenwandun@huawei.com>
> ---
>  fs/ceph/debugfs.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c
> index c281f32..60a0f1a 100644
> --- a/fs/ceph/debugfs.c
> +++ b/fs/ceph/debugfs.c
> @@ -243,8 +243,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)
> @@ -264,11 +264,11 @@ void ceph_fs_debugfs_init(struct ceph_fs_client *fsc)
>
>         dout("ceph_fs_debugfs_init\n");
>         fsc->debugfs_congestion_kb =
> -               debugfs_create_file("writeback_congestion_kb",
> -                                   0600,
> -                                   fsc->client->debugfs_dir,
> -                                   fsc,
> -                                   &congestion_kb_fops);
> +               debugfs_create_file_unsafe("writeback_congestion_kb",
> +                                          0600,
> +                                          fsc->client->debugfs_dir,
> +                                          fsc,
> +                                          &congestion_kb_fops);

Hi Chen,

debugfs_create_file_unsafe() has "unsafe" in its name for a reason.
Have you verified that this conversion is safe?

Thanks,

                Ilya

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-06 14:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-23 14:39 [PATCH next] ceph: Fix debugfs_simple_attr.cocci warnings Chen Wandun
2020-01-06 15:04 ` Ilya Dryomov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).