mbox series

[v3,0/6] ceph: print the client global id for debug logs

Message ID 20230614013025.291314-1-xiubli@redhat.com
Headers show
Series ceph: print the client global id for debug logs | expand

Message

Xiubo Li June 14, 2023, 1:30 a.m. UTC
From: Xiubo Li <xiubli@redhat.com>

V3:
- print the function name as default in the *_client() helpers
- some minor improvment in the log messages.

Xiubo Li (6):
  ceph: add the *_client debug macros support
  ceph: pass the mdsc to several helpers
  ceph: rename _to_client() to _to_fs_client()
  ceph: move mdsmap.h to fs/ceph/
  ceph: add ceph_inode_to_client() helper support
  ceph: print the client global_id in all the debug logs

 fs/ceph/acl.c                       |   6 +-
 fs/ceph/addr.c                      | 307 ++++++-----
 fs/ceph/cache.c                     |   2 +-
 fs/ceph/caps.c                      | 805 ++++++++++++++++------------
 fs/ceph/crypto.c                    |  44 +-
 fs/ceph/debugfs.c                   |  10 +-
 fs/ceph/dir.c                       | 241 +++++----
 fs/ceph/export.c                    |  52 +-
 fs/ceph/file.c                      | 283 ++++++----
 fs/ceph/inode.c                     | 547 +++++++++++--------
 fs/ceph/ioctl.c                     |  21 +-
 fs/ceph/locks.c                     |  60 ++-
 fs/ceph/mds_client.c                | 646 ++++++++++++----------
 fs/ceph/mds_client.h                |   5 +-
 fs/ceph/mdsmap.c                    |  29 +-
 {include/linux => fs}/ceph/mdsmap.h |   5 +-
 fs/ceph/metric.c                    |   5 +-
 fs/ceph/quota.c                     |  29 +-
 fs/ceph/snap.c                      | 199 ++++---
 fs/ceph/super.c                     |  92 ++--
 fs/ceph/super.h                     |  19 +-
 fs/ceph/xattr.c                     | 110 ++--
 include/linux/ceph/ceph_debug.h     |  44 +-
 23 files changed, 2088 insertions(+), 1473 deletions(-)
 rename {include/linux => fs}/ceph/mdsmap.h (92%)

Comments

Ilya Dryomov June 14, 2023, 8:21 a.m. UTC | #1
On Wed, Jun 14, 2023 at 3:33 AM <xiubli@redhat.com> wrote:
>
> From: Xiubo Li <xiubli@redhat.com>
>
> This will help print the fsid and client's global_id in debug logs,
> and also print the function names.
>
> URL: https://tracker.ceph.com/issues/61590
> Cc: Patrick Donnelly <pdonnell@redhat.com>
> Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
> Signed-off-by: Xiubo Li <xiubli@redhat.com>
> ---
>  include/linux/ceph/ceph_debug.h | 44 ++++++++++++++++++++++++++++++++-
>  1 file changed, 43 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/ceph/ceph_debug.h b/include/linux/ceph/ceph_debug.h
> index d5a5da838caf..26b9212bf359 100644
> --- a/include/linux/ceph/ceph_debug.h
> +++ b/include/linux/ceph/ceph_debug.h
> @@ -19,12 +19,22 @@
>         pr_debug("%.*s %12.12s:%-4d : " fmt,                            \
>                  8 - (int)sizeof(KBUILD_MODNAME), "    ",               \
>                  kbasename(__FILE__), __LINE__, ##__VA_ARGS__)
> +#  define dout_client(client, fmt, ...)                                        \
> +       pr_debug("%.*s %12.12s:%-4d : [%pU %lld] " fmt,                 \
> +                8 - (int)sizeof(KBUILD_MODNAME), "    ",               \
> +                kbasename(__FILE__), __LINE__,                         \
> +                &client->fsid, client->monc.auth->global_id,           \
> +                ##__VA_ARGS__)
>  # else
>  /* faux printk call just to see any compiler warnings. */
>  #  define dout(fmt, ...)       do {                            \
>                 if (0)                                          \
>                         printk(KERN_DEBUG fmt, ##__VA_ARGS__);  \
>         } while (0)
> +#  define dout_client(client, fmt, ...)        do {                    \
> +               if (0)                                          \
> +                       printk(KERN_DEBUG fmt, ##__VA_ARGS__);  \
> +       } while (0)
>  # endif
>
>  #else
> @@ -33,7 +43,39 @@
>   * or, just wrap pr_debug
>   */
>  # define dout(fmt, ...)        pr_debug(" " fmt, ##__VA_ARGS__)
> -
> +# define dout_client(client, fmt, ...)                                 \
> +       pr_debug("[%pU %lld] %s: " fmt, &client->fsid,                  \
> +                client->monc.auth->global_id, __func__,                \
> +                ##__VA_ARGS__)
>  #endif
>
> +# define pr_notice_client(client, fmt, ...)                            \
> +       pr_notice("[%pU %lld] %s: " fmt, &client->fsid,                 \
> +                 client->monc.auth->global_id, __func__,               \
> +                 ##__VA_ARGS__)

Hi Xiubo,

We definitely don't want the framework to include function names in
user-facing messages (i.e. in pr_* messages).  In the example that
spawned this series ("ceph: mds3 session blocklisted"), it's really
irrelevant to the user which function happens to detect blocklisting.

It's a bit less clear-cut for dout() messages, but honestly I don't
think it's needed there either.  I know that we include it manually in
many places but most of the time it's actually redundant.

Thanks,

                Ilya
Xiubo Li June 15, 2023, 1:49 a.m. UTC | #2
On 6/14/23 16:21, Ilya Dryomov wrote:
> On Wed, Jun 14, 2023 at 3:33 AM <xiubli@redhat.com> wrote:
>> From: Xiubo Li <xiubli@redhat.com>
>>
>> This will help print the fsid and client's global_id in debug logs,
>> and also print the function names.
>>
>> URL: https://tracker.ceph.com/issues/61590
>> Cc: Patrick Donnelly <pdonnell@redhat.com>
>> Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
>> Signed-off-by: Xiubo Li <xiubli@redhat.com>
>> ---
>>   include/linux/ceph/ceph_debug.h | 44 ++++++++++++++++++++++++++++++++-
>>   1 file changed, 43 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/linux/ceph/ceph_debug.h b/include/linux/ceph/ceph_debug.h
>> index d5a5da838caf..26b9212bf359 100644
>> --- a/include/linux/ceph/ceph_debug.h
>> +++ b/include/linux/ceph/ceph_debug.h
>> @@ -19,12 +19,22 @@
>>          pr_debug("%.*s %12.12s:%-4d : " fmt,                            \
>>                   8 - (int)sizeof(KBUILD_MODNAME), "    ",               \
>>                   kbasename(__FILE__), __LINE__, ##__VA_ARGS__)
>> +#  define dout_client(client, fmt, ...)                                        \
>> +       pr_debug("%.*s %12.12s:%-4d : [%pU %lld] " fmt,                 \
>> +                8 - (int)sizeof(KBUILD_MODNAME), "    ",               \
>> +                kbasename(__FILE__), __LINE__,                         \
>> +                &client->fsid, client->monc.auth->global_id,           \
>> +                ##__VA_ARGS__)
>>   # else
>>   /* faux printk call just to see any compiler warnings. */
>>   #  define dout(fmt, ...)       do {                            \
>>                  if (0)                                          \
>>                          printk(KERN_DEBUG fmt, ##__VA_ARGS__);  \
>>          } while (0)
>> +#  define dout_client(client, fmt, ...)        do {                    \
>> +               if (0)                                          \
>> +                       printk(KERN_DEBUG fmt, ##__VA_ARGS__);  \
>> +       } while (0)
>>   # endif
>>
>>   #else
>> @@ -33,7 +43,39 @@
>>    * or, just wrap pr_debug
>>    */
>>   # define dout(fmt, ...)        pr_debug(" " fmt, ##__VA_ARGS__)
>> -
>> +# define dout_client(client, fmt, ...)                                 \
>> +       pr_debug("[%pU %lld] %s: " fmt, &client->fsid,                  \
>> +                client->monc.auth->global_id, __func__,                \
>> +                ##__VA_ARGS__)
>>   #endif
>>
>> +# define pr_notice_client(client, fmt, ...)                            \
>> +       pr_notice("[%pU %lld] %s: " fmt, &client->fsid,                 \
>> +                 client->monc.auth->global_id, __func__,               \
>> +                 ##__VA_ARGS__)
> Hi Xiubo,
>
> We definitely don't want the framework to include function names in
> user-facing messages (i.e. in pr_* messages).  In the example that
> spawned this series ("ceph: mds3 session blocklisted"), it's really
> irrelevant to the user which function happens to detect blocklisting.
>
> It's a bit less clear-cut for dout() messages, but honestly I don't
> think it's needed there either.  I know that we include it manually in
> many places but most of the time it's actually redundant.

The function name will include the most info needed in the log messages, 
before almost all the log messages will add that explicitly or will add 
one function name directly. Which may make the length of the 'fmt' 
string exceeded 80 chars.

If this doesn't make sense I will remove this from the framework.

Thanks

- Xiubo


> Thanks,
>
>                  Ilya
>
Ilya Dryomov June 15, 2023, 12:50 p.m. UTC | #3
On Thu, Jun 15, 2023 at 3:49 AM Xiubo Li <xiubli@redhat.com> wrote:
>
>
> On 6/14/23 16:21, Ilya Dryomov wrote:
> > On Wed, Jun 14, 2023 at 3:33 AM <xiubli@redhat.com> wrote:
> >> From: Xiubo Li <xiubli@redhat.com>
> >>
> >> This will help print the fsid and client's global_id in debug logs,
> >> and also print the function names.
> >>
> >> URL: https://tracker.ceph.com/issues/61590
> >> Cc: Patrick Donnelly <pdonnell@redhat.com>
> >> Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
> >> Signed-off-by: Xiubo Li <xiubli@redhat.com>
> >> ---
> >>   include/linux/ceph/ceph_debug.h | 44 ++++++++++++++++++++++++++++++++-
> >>   1 file changed, 43 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/include/linux/ceph/ceph_debug.h b/include/linux/ceph/ceph_debug.h
> >> index d5a5da838caf..26b9212bf359 100644
> >> --- a/include/linux/ceph/ceph_debug.h
> >> +++ b/include/linux/ceph/ceph_debug.h
> >> @@ -19,12 +19,22 @@
> >>          pr_debug("%.*s %12.12s:%-4d : " fmt,                            \
> >>                   8 - (int)sizeof(KBUILD_MODNAME), "    ",               \
> >>                   kbasename(__FILE__), __LINE__, ##__VA_ARGS__)
> >> +#  define dout_client(client, fmt, ...)                                        \
> >> +       pr_debug("%.*s %12.12s:%-4d : [%pU %lld] " fmt,                 \
> >> +                8 - (int)sizeof(KBUILD_MODNAME), "    ",               \
> >> +                kbasename(__FILE__), __LINE__,                         \
> >> +                &client->fsid, client->monc.auth->global_id,           \
> >> +                ##__VA_ARGS__)
> >>   # else
> >>   /* faux printk call just to see any compiler warnings. */
> >>   #  define dout(fmt, ...)       do {                            \
> >>                  if (0)                                          \
> >>                          printk(KERN_DEBUG fmt, ##__VA_ARGS__);  \
> >>          } while (0)
> >> +#  define dout_client(client, fmt, ...)        do {                    \
> >> +               if (0)                                          \
> >> +                       printk(KERN_DEBUG fmt, ##__VA_ARGS__);  \
> >> +       } while (0)
> >>   # endif
> >>
> >>   #else
> >> @@ -33,7 +43,39 @@
> >>    * or, just wrap pr_debug
> >>    */
> >>   # define dout(fmt, ...)        pr_debug(" " fmt, ##__VA_ARGS__)
> >> -
> >> +# define dout_client(client, fmt, ...)                                 \
> >> +       pr_debug("[%pU %lld] %s: " fmt, &client->fsid,                  \
> >> +                client->monc.auth->global_id, __func__,                \
> >> +                ##__VA_ARGS__)
> >>   #endif
> >>
> >> +# define pr_notice_client(client, fmt, ...)                            \
> >> +       pr_notice("[%pU %lld] %s: " fmt, &client->fsid,                 \
> >> +                 client->monc.auth->global_id, __func__,               \
> >> +                 ##__VA_ARGS__)
> > Hi Xiubo,
> >
> > We definitely don't want the framework to include function names in
> > user-facing messages (i.e. in pr_* messages).  In the example that
> > spawned this series ("ceph: mds3 session blocklisted"), it's really
> > irrelevant to the user which function happens to detect blocklisting.
> >
> > It's a bit less clear-cut for dout() messages, but honestly I don't
> > think it's needed there either.  I know that we include it manually in
> > many places but most of the time it's actually redundant.
>
> The function name will include the most info needed in the log messages,
> before almost all the log messages will add that explicitly or will add
> one function name directly. Which may make the length of the 'fmt'
> string exceeded 80 chars.
>
> If this doesn't make sense I will remove this from the framework.

I'm fine with keeping it for dout() messages.  To further help with
line lengths, how about naming the new macro doutc()?  Since it takes
an extra argument before the format string, it feels distinctive enough
despite it being just a single character.

Thanks,

                Ilya
Xiubo Li June 15, 2023, 12:53 p.m. UTC | #4
On 6/15/23 20:50, Ilya Dryomov wrote:
> On Thu, Jun 15, 2023 at 3:49 AM Xiubo Li <xiubli@redhat.com> wrote:
>>
>> On 6/14/23 16:21, Ilya Dryomov wrote:
>>> On Wed, Jun 14, 2023 at 3:33 AM <xiubli@redhat.com> wrote:
>>>> From: Xiubo Li <xiubli@redhat.com>
>>>>
>>>> This will help print the fsid and client's global_id in debug logs,
>>>> and also print the function names.
>>>>
>>>> URL: https://tracker.ceph.com/issues/61590
>>>> Cc: Patrick Donnelly <pdonnell@redhat.com>
>>>> Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
>>>> Signed-off-by: Xiubo Li <xiubli@redhat.com>
>>>> ---
>>>>    include/linux/ceph/ceph_debug.h | 44 ++++++++++++++++++++++++++++++++-
>>>>    1 file changed, 43 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/include/linux/ceph/ceph_debug.h b/include/linux/ceph/ceph_debug.h
>>>> index d5a5da838caf..26b9212bf359 100644
>>>> --- a/include/linux/ceph/ceph_debug.h
>>>> +++ b/include/linux/ceph/ceph_debug.h
>>>> @@ -19,12 +19,22 @@
>>>>           pr_debug("%.*s %12.12s:%-4d : " fmt,                            \
>>>>                    8 - (int)sizeof(KBUILD_MODNAME), "    ",               \
>>>>                    kbasename(__FILE__), __LINE__, ##__VA_ARGS__)
>>>> +#  define dout_client(client, fmt, ...)                                        \
>>>> +       pr_debug("%.*s %12.12s:%-4d : [%pU %lld] " fmt,                 \
>>>> +                8 - (int)sizeof(KBUILD_MODNAME), "    ",               \
>>>> +                kbasename(__FILE__), __LINE__,                         \
>>>> +                &client->fsid, client->monc.auth->global_id,           \
>>>> +                ##__VA_ARGS__)
>>>>    # else
>>>>    /* faux printk call just to see any compiler warnings. */
>>>>    #  define dout(fmt, ...)       do {                            \
>>>>                   if (0)                                          \
>>>>                           printk(KERN_DEBUG fmt, ##__VA_ARGS__);  \
>>>>           } while (0)
>>>> +#  define dout_client(client, fmt, ...)        do {                    \
>>>> +               if (0)                                          \
>>>> +                       printk(KERN_DEBUG fmt, ##__VA_ARGS__);  \
>>>> +       } while (0)
>>>>    # endif
>>>>
>>>>    #else
>>>> @@ -33,7 +43,39 @@
>>>>     * or, just wrap pr_debug
>>>>     */
>>>>    # define dout(fmt, ...)        pr_debug(" " fmt, ##__VA_ARGS__)
>>>> -
>>>> +# define dout_client(client, fmt, ...)                                 \
>>>> +       pr_debug("[%pU %lld] %s: " fmt, &client->fsid,                  \
>>>> +                client->monc.auth->global_id, __func__,                \
>>>> +                ##__VA_ARGS__)
>>>>    #endif
>>>>
>>>> +# define pr_notice_client(client, fmt, ...)                            \
>>>> +       pr_notice("[%pU %lld] %s: " fmt, &client->fsid,                 \
>>>> +                 client->monc.auth->global_id, __func__,               \
>>>> +                 ##__VA_ARGS__)
>>> Hi Xiubo,
>>>
>>> We definitely don't want the framework to include function names in
>>> user-facing messages (i.e. in pr_* messages).  In the example that
>>> spawned this series ("ceph: mds3 session blocklisted"), it's really
>>> irrelevant to the user which function happens to detect blocklisting.
>>>
>>> It's a bit less clear-cut for dout() messages, but honestly I don't
>>> think it's needed there either.  I know that we include it manually in
>>> many places but most of the time it's actually redundant.
>> The function name will include the most info needed in the log messages,
>> before almost all the log messages will add that explicitly or will add
>> one function name directly. Which may make the length of the 'fmt'
>> string exceeded 80 chars.
>>
>> If this doesn't make sense I will remove this from the framework.
> I'm fine with keeping it for dout() messages.
Okay.
>    To further help with
> line lengths, how about naming the new macro doutc()?  Since it takes
> an extra argument before the format string, it feels distinctive enough
> despite it being just a single character.

Yeah, this looks much better.

Will fix this.

Thanks

- Xiubo

> Thanks,
>
>                  Ilya
>
Xiubo Li June 15, 2023, 12:57 p.m. UTC | #5
On 6/15/23 20:50, Ilya Dryomov wrote:
> On Thu, Jun 15, 2023 at 3:49 AM Xiubo Li <xiubli@redhat.com> wrote:
>>
>> On 6/14/23 16:21, Ilya Dryomov wrote:
>>> On Wed, Jun 14, 2023 at 3:33 AM <xiubli@redhat.com> wrote:
>>>> From: Xiubo Li <xiubli@redhat.com>
>>>>
>>>> This will help print the fsid and client's global_id in debug logs,
>>>> and also print the function names.
>>>>
>>>> URL: https://tracker.ceph.com/issues/61590
>>>> Cc: Patrick Donnelly <pdonnell@redhat.com>
>>>> Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
>>>> Signed-off-by: Xiubo Li <xiubli@redhat.com>
>>>> ---
>>>>    include/linux/ceph/ceph_debug.h | 44 ++++++++++++++++++++++++++++++++-
>>>>    1 file changed, 43 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/include/linux/ceph/ceph_debug.h b/include/linux/ceph/ceph_debug.h
>>>> index d5a5da838caf..26b9212bf359 100644
>>>> --- a/include/linux/ceph/ceph_debug.h
>>>> +++ b/include/linux/ceph/ceph_debug.h
>>>> @@ -19,12 +19,22 @@
>>>>           pr_debug("%.*s %12.12s:%-4d : " fmt,                            \
>>>>                    8 - (int)sizeof(KBUILD_MODNAME), "    ",               \
>>>>                    kbasename(__FILE__), __LINE__, ##__VA_ARGS__)
>>>> +#  define dout_client(client, fmt, ...)                                        \
>>>> +       pr_debug("%.*s %12.12s:%-4d : [%pU %lld] " fmt,                 \
>>>> +                8 - (int)sizeof(KBUILD_MODNAME), "    ",               \
>>>> +                kbasename(__FILE__), __LINE__,                         \
>>>> +                &client->fsid, client->monc.auth->global_id,           \
>>>> +                ##__VA_ARGS__)
>>>>    # else
>>>>    /* faux printk call just to see any compiler warnings. */
>>>>    #  define dout(fmt, ...)       do {                            \
>>>>                   if (0)                                          \
>>>>                           printk(KERN_DEBUG fmt, ##__VA_ARGS__);  \
>>>>           } while (0)
>>>> +#  define dout_client(client, fmt, ...)        do {                    \
>>>> +               if (0)                                          \
>>>> +                       printk(KERN_DEBUG fmt, ##__VA_ARGS__);  \
>>>> +       } while (0)
>>>>    # endif
>>>>
>>>>    #else
>>>> @@ -33,7 +43,39 @@
>>>>     * or, just wrap pr_debug
>>>>     */
>>>>    # define dout(fmt, ...)        pr_debug(" " fmt, ##__VA_ARGS__)
>>>> -
>>>> +# define dout_client(client, fmt, ...)                                 \
>>>> +       pr_debug("[%pU %lld] %s: " fmt, &client->fsid,                  \
>>>> +                client->monc.auth->global_id, __func__,                \
>>>> +                ##__VA_ARGS__)
>>>>    #endif
>>>>
>>>> +# define pr_notice_client(client, fmt, ...)                            \
>>>> +       pr_notice("[%pU %lld] %s: " fmt, &client->fsid,                 \
>>>> +                 client->monc.auth->global_id, __func__,               \
>>>> +                 ##__VA_ARGS__)
>>> Hi Xiubo,
>>>
>>> We definitely don't want the framework to include function names in
>>> user-facing messages (i.e. in pr_* messages).  In the example that
>>> spawned this series ("ceph: mds3 session blocklisted"), it's really
>>> irrelevant to the user which function happens to detect blocklisting.
>>>
>>> It's a bit less clear-cut for dout() messages, but honestly I don't
>>> think it's needed there either.  I know that we include it manually in
>>> many places but most of the time it's actually redundant.
>> The function name will include the most info needed in the log messages,
>> before almost all the log messages will add that explicitly or will add
>> one function name directly. Which may make the length of the 'fmt'
>> string exceeded 80 chars.
>>
>> If this doesn't make sense I will remove this from the framework.
> I'm fine with keeping it for dout() messages.  To further help with
> line lengths, how about naming the new macro doutc()?  Since it takes
> an extra argument before the format string, it feels distinctive enough
> despite it being just a single character.

What about the others macros ? Such as for the 'pr_info_client()',etc ?

Thanks

- Xiubo


> Thanks,
>
>                  Ilya
>
Ilya Dryomov June 15, 2023, 1:44 p.m. UTC | #6
On Thu, Jun 15, 2023 at 2:57 PM Xiubo Li <xiubli@redhat.com> wrote:
>
>
> On 6/15/23 20:50, Ilya Dryomov wrote:
> > On Thu, Jun 15, 2023 at 3:49 AM Xiubo Li <xiubli@redhat.com> wrote:
> >>
> >> On 6/14/23 16:21, Ilya Dryomov wrote:
> >>> On Wed, Jun 14, 2023 at 3:33 AM <xiubli@redhat.com> wrote:
> >>>> From: Xiubo Li <xiubli@redhat.com>
> >>>>
> >>>> This will help print the fsid and client's global_id in debug logs,
> >>>> and also print the function names.
> >>>>
> >>>> URL: https://tracker.ceph.com/issues/61590
> >>>> Cc: Patrick Donnelly <pdonnell@redhat.com>
> >>>> Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
> >>>> Signed-off-by: Xiubo Li <xiubli@redhat.com>
> >>>> ---
> >>>>    include/linux/ceph/ceph_debug.h | 44 ++++++++++++++++++++++++++++++++-
> >>>>    1 file changed, 43 insertions(+), 1 deletion(-)
> >>>>
> >>>> diff --git a/include/linux/ceph/ceph_debug.h b/include/linux/ceph/ceph_debug.h
> >>>> index d5a5da838caf..26b9212bf359 100644
> >>>> --- a/include/linux/ceph/ceph_debug.h
> >>>> +++ b/include/linux/ceph/ceph_debug.h
> >>>> @@ -19,12 +19,22 @@
> >>>>           pr_debug("%.*s %12.12s:%-4d : " fmt,                            \
> >>>>                    8 - (int)sizeof(KBUILD_MODNAME), "    ",               \
> >>>>                    kbasename(__FILE__), __LINE__, ##__VA_ARGS__)
> >>>> +#  define dout_client(client, fmt, ...)                                        \
> >>>> +       pr_debug("%.*s %12.12s:%-4d : [%pU %lld] " fmt,                 \
> >>>> +                8 - (int)sizeof(KBUILD_MODNAME), "    ",               \
> >>>> +                kbasename(__FILE__), __LINE__,                         \
> >>>> +                &client->fsid, client->monc.auth->global_id,           \
> >>>> +                ##__VA_ARGS__)
> >>>>    # else
> >>>>    /* faux printk call just to see any compiler warnings. */
> >>>>    #  define dout(fmt, ...)       do {                            \
> >>>>                   if (0)                                          \
> >>>>                           printk(KERN_DEBUG fmt, ##__VA_ARGS__);  \
> >>>>           } while (0)
> >>>> +#  define dout_client(client, fmt, ...)        do {                    \
> >>>> +               if (0)                                          \
> >>>> +                       printk(KERN_DEBUG fmt, ##__VA_ARGS__);  \
> >>>> +       } while (0)
> >>>>    # endif
> >>>>
> >>>>    #else
> >>>> @@ -33,7 +43,39 @@
> >>>>     * or, just wrap pr_debug
> >>>>     */
> >>>>    # define dout(fmt, ...)        pr_debug(" " fmt, ##__VA_ARGS__)
> >>>> -
> >>>> +# define dout_client(client, fmt, ...)                                 \
> >>>> +       pr_debug("[%pU %lld] %s: " fmt, &client->fsid,                  \
> >>>> +                client->monc.auth->global_id, __func__,                \
> >>>> +                ##__VA_ARGS__)
> >>>>    #endif
> >>>>
> >>>> +# define pr_notice_client(client, fmt, ...)                            \
> >>>> +       pr_notice("[%pU %lld] %s: " fmt, &client->fsid,                 \
> >>>> +                 client->monc.auth->global_id, __func__,               \
> >>>> +                 ##__VA_ARGS__)
> >>> Hi Xiubo,
> >>>
> >>> We definitely don't want the framework to include function names in
> >>> user-facing messages (i.e. in pr_* messages).  In the example that
> >>> spawned this series ("ceph: mds3 session blocklisted"), it's really
> >>> irrelevant to the user which function happens to detect blocklisting.
> >>>
> >>> It's a bit less clear-cut for dout() messages, but honestly I don't
> >>> think it's needed there either.  I know that we include it manually in
> >>> many places but most of the time it's actually redundant.
> >> The function name will include the most info needed in the log messages,
> >> before almost all the log messages will add that explicitly or will add
> >> one function name directly. Which may make the length of the 'fmt'
> >> string exceeded 80 chars.
> >>
> >> If this doesn't make sense I will remove this from the framework.
> > I'm fine with keeping it for dout() messages.  To further help with
> > line lengths, how about naming the new macro doutc()?  Since it takes
> > an extra argument before the format string, it feels distinctive enough
> > despite it being just a single character.
>
> What about the others macros ? Such as for the 'pr_info_client()',etc ?

pr_info() and friends are used throughout the kernel, so the name is
very recognizable.  We also have a lot fewer of them compared to douts,
so I would stick with pr_info_client() (i.e. no shorthands).

Thanks,

                Ilya
Xiubo Li June 15, 2023, 2:21 p.m. UTC | #7
On 6/15/23 21:44, Ilya Dryomov wrote:
> On Thu, Jun 15, 2023 at 2:57 PM Xiubo Li <xiubli@redhat.com> wrote:
>>
>> On 6/15/23 20:50, Ilya Dryomov wrote:
>>> On Thu, Jun 15, 2023 at 3:49 AM Xiubo Li <xiubli@redhat.com> wrote:
>>>> On 6/14/23 16:21, Ilya Dryomov wrote:
>>>>> On Wed, Jun 14, 2023 at 3:33 AM <xiubli@redhat.com> wrote:
>>>>>> From: Xiubo Li <xiubli@redhat.com>
>>>>>>
>>>>>> This will help print the fsid and client's global_id in debug logs,
>>>>>> and also print the function names.
>>>>>>
>>>>>> URL: https://tracker.ceph.com/issues/61590
>>>>>> Cc: Patrick Donnelly <pdonnell@redhat.com>
>>>>>> Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
>>>>>> Signed-off-by: Xiubo Li <xiubli@redhat.com>
>>>>>> ---
>>>>>>     include/linux/ceph/ceph_debug.h | 44 ++++++++++++++++++++++++++++++++-
>>>>>>     1 file changed, 43 insertions(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/include/linux/ceph/ceph_debug.h b/include/linux/ceph/ceph_debug.h
>>>>>> index d5a5da838caf..26b9212bf359 100644
>>>>>> --- a/include/linux/ceph/ceph_debug.h
>>>>>> +++ b/include/linux/ceph/ceph_debug.h
>>>>>> @@ -19,12 +19,22 @@
>>>>>>            pr_debug("%.*s %12.12s:%-4d : " fmt,                            \
>>>>>>                     8 - (int)sizeof(KBUILD_MODNAME), "    ",               \
>>>>>>                     kbasename(__FILE__), __LINE__, ##__VA_ARGS__)
>>>>>> +#  define dout_client(client, fmt, ...)                                        \
>>>>>> +       pr_debug("%.*s %12.12s:%-4d : [%pU %lld] " fmt,                 \
>>>>>> +                8 - (int)sizeof(KBUILD_MODNAME), "    ",               \
>>>>>> +                kbasename(__FILE__), __LINE__,                         \
>>>>>> +                &client->fsid, client->monc.auth->global_id,           \
>>>>>> +                ##__VA_ARGS__)
>>>>>>     # else
>>>>>>     /* faux printk call just to see any compiler warnings. */
>>>>>>     #  define dout(fmt, ...)       do {                            \
>>>>>>                    if (0)                                          \
>>>>>>                            printk(KERN_DEBUG fmt, ##__VA_ARGS__);  \
>>>>>>            } while (0)
>>>>>> +#  define dout_client(client, fmt, ...)        do {                    \
>>>>>> +               if (0)                                          \
>>>>>> +                       printk(KERN_DEBUG fmt, ##__VA_ARGS__);  \
>>>>>> +       } while (0)
>>>>>>     # endif
>>>>>>
>>>>>>     #else
>>>>>> @@ -33,7 +43,39 @@
>>>>>>      * or, just wrap pr_debug
>>>>>>      */
>>>>>>     # define dout(fmt, ...)        pr_debug(" " fmt, ##__VA_ARGS__)
>>>>>> -
>>>>>> +# define dout_client(client, fmt, ...)                                 \
>>>>>> +       pr_debug("[%pU %lld] %s: " fmt, &client->fsid,                  \
>>>>>> +                client->monc.auth->global_id, __func__,                \
>>>>>> +                ##__VA_ARGS__)
>>>>>>     #endif
>>>>>>
>>>>>> +# define pr_notice_client(client, fmt, ...)                            \
>>>>>> +       pr_notice("[%pU %lld] %s: " fmt, &client->fsid,                 \
>>>>>> +                 client->monc.auth->global_id, __func__,               \
>>>>>> +                 ##__VA_ARGS__)
>>>>> Hi Xiubo,
>>>>>
>>>>> We definitely don't want the framework to include function names in
>>>>> user-facing messages (i.e. in pr_* messages).  In the example that
>>>>> spawned this series ("ceph: mds3 session blocklisted"), it's really
>>>>> irrelevant to the user which function happens to detect blocklisting.
>>>>>
>>>>> It's a bit less clear-cut for dout() messages, but honestly I don't
>>>>> think it's needed there either.  I know that we include it manually in
>>>>> many places but most of the time it's actually redundant.
>>>> The function name will include the most info needed in the log messages,
>>>> before almost all the log messages will add that explicitly or will add
>>>> one function name directly. Which may make the length of the 'fmt'
>>>> string exceeded 80 chars.
>>>>
>>>> If this doesn't make sense I will remove this from the framework.
>>> I'm fine with keeping it for dout() messages.  To further help with
>>> line lengths, how about naming the new macro doutc()?  Since it takes
>>> an extra argument before the format string, it feels distinctive enough
>>> despite it being just a single character.
>> What about the others macros ? Such as for the 'pr_info_client()',etc ?
> pr_info() and friends are used throughout the kernel, so the name is
> very recognizable.  We also have a lot fewer of them compared to douts,
> so I would stick with pr_info_client() (i.e. no shorthands).

Okay. Thanks

- Xiubo


> Thanks,
>
>                  Ilya
>
Xiubo Li June 24, 2023, 1:37 a.m. UTC | #8
On 6/15/23 21:44, Ilya Dryomov wrote:
> On Thu, Jun 15, 2023 at 2:57 PM Xiubo Li <xiubli@redhat.com> wrote:
>>
>> On 6/15/23 20:50, Ilya Dryomov wrote:
>>> On Thu, Jun 15, 2023 at 3:49 AM Xiubo Li <xiubli@redhat.com> wrote:
>>>> On 6/14/23 16:21, Ilya Dryomov wrote:
>>>>> On Wed, Jun 14, 2023 at 3:33 AM <xiubli@redhat.com> wrote:
>>>>>> From: Xiubo Li <xiubli@redhat.com>
>>>>>>
>>>>>> This will help print the fsid and client's global_id in debug logs,
>>>>>> and also print the function names.
>>>>>>
>>>>>> URL: https://tracker.ceph.com/issues/61590
>>>>>> Cc: Patrick Donnelly <pdonnell@redhat.com>
>>>>>> Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
>>>>>> Signed-off-by: Xiubo Li <xiubli@redhat.com>
>>>>>> ---
>>>>>>     include/linux/ceph/ceph_debug.h | 44 ++++++++++++++++++++++++++++++++-
>>>>>>     1 file changed, 43 insertions(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/include/linux/ceph/ceph_debug.h b/include/linux/ceph/ceph_debug.h
>>>>>> index d5a5da838caf..26b9212bf359 100644
>>>>>> --- a/include/linux/ceph/ceph_debug.h
>>>>>> +++ b/include/linux/ceph/ceph_debug.h
>>>>>> @@ -19,12 +19,22 @@
>>>>>>            pr_debug("%.*s %12.12s:%-4d : " fmt,                            \
>>>>>>                     8 - (int)sizeof(KBUILD_MODNAME), "    ",               \
>>>>>>                     kbasename(__FILE__), __LINE__, ##__VA_ARGS__)
>>>>>> +#  define dout_client(client, fmt, ...)                                        \
>>>>>> +       pr_debug("%.*s %12.12s:%-4d : [%pU %lld] " fmt,                 \
>>>>>> +                8 - (int)sizeof(KBUILD_MODNAME), "    ",               \
>>>>>> +                kbasename(__FILE__), __LINE__,                         \
>>>>>> +                &client->fsid, client->monc.auth->global_id,           \
>>>>>> +                ##__VA_ARGS__)
>>>>>>     # else
>>>>>>     /* faux printk call just to see any compiler warnings. */
>>>>>>     #  define dout(fmt, ...)       do {                            \
>>>>>>                    if (0)                                          \
>>>>>>                            printk(KERN_DEBUG fmt, ##__VA_ARGS__);  \
>>>>>>            } while (0)
>>>>>> +#  define dout_client(client, fmt, ...)        do {                    \
>>>>>> +               if (0)                                          \
>>>>>> +                       printk(KERN_DEBUG fmt, ##__VA_ARGS__);  \
>>>>>> +       } while (0)
>>>>>>     # endif
>>>>>>
>>>>>>     #else
>>>>>> @@ -33,7 +43,39 @@
>>>>>>      * or, just wrap pr_debug
>>>>>>      */
>>>>>>     # define dout(fmt, ...)        pr_debug(" " fmt, ##__VA_ARGS__)
>>>>>> -
>>>>>> +# define dout_client(client, fmt, ...)                                 \
>>>>>> +       pr_debug("[%pU %lld] %s: " fmt, &client->fsid,                  \
>>>>>> +                client->monc.auth->global_id, __func__,                \
>>>>>> +                ##__VA_ARGS__)
>>>>>>     #endif
>>>>>>
>>>>>> +# define pr_notice_client(client, fmt, ...)                            \
>>>>>> +       pr_notice("[%pU %lld] %s: " fmt, &client->fsid,                 \
>>>>>> +                 client->monc.auth->global_id, __func__,               \
>>>>>> +                 ##__VA_ARGS__)
>>>>> Hi Xiubo,
>>>>>
>>>>> We definitely don't want the framework to include function names in
>>>>> user-facing messages (i.e. in pr_* messages).  In the example that
>>>>> spawned this series ("ceph: mds3 session blocklisted"), it's really
>>>>> irrelevant to the user which function happens to detect blocklisting.
>>>>>
>>>>> It's a bit less clear-cut for dout() messages, but honestly I don't
>>>>> think it's needed there either.  I know that we include it manually in
>>>>> many places but most of the time it's actually redundant.
>>>> The function name will include the most info needed in the log messages,
>>>> before almost all the log messages will add that explicitly or will add
>>>> one function name directly. Which may make the length of the 'fmt'
>>>> string exceeded 80 chars.
>>>>
>>>> If this doesn't make sense I will remove this from the framework.
>>> I'm fine with keeping it for dout() messages.  To further help with
>>> line lengths, how about naming the new macro doutc()?  Since it takes
>>> an extra argument before the format string, it feels distinctive enough
>>> despite it being just a single character.
>> What about the others macros ? Such as for the 'pr_info_client()',etc ?
> pr_info() and friends are used throughout the kernel, so the name is
> very recognizable.  We also have a lot fewer of them compared to douts,
> so I would stick with pr_info_client() (i.e. no shorthands).

Okay. Thanks

- Xiubo


> Thanks,
>
>                  Ilya
>