public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Yangtao Li <frank.li@vivo.com>
Cc: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] btrfs: convert to spinlock guards in btrfs_update_ioctl_balance_args()
Date: Wed, 9 Apr 2025 20:30:22 +0200	[thread overview]
Message-ID: <20250409183022.GG13292@suse.cz> (raw)
In-Reply-To: <20250409125724.145597-1-frank.li@vivo.com>

On Wed, Apr 09, 2025 at 06:57:22AM -0600, Yangtao Li wrote:
> To simplify handling, use the guard helper to let the compiler care for
> unlocking.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>  fs/btrfs/ioctl.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 63aeacc54945..7cec105a4cb0 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -3438,9 +3438,8 @@ void btrfs_update_ioctl_balance_args(struct btrfs_fs_info *fs_info,
>  	memcpy(&bargs->meta, &bctl->meta, sizeof(bargs->meta));
>  	memcpy(&bargs->sys, &bctl->sys, sizeof(bargs->sys));
>  
> -	spin_lock(&fs_info->balance_lock);
> +	guard(spinlock)(&fs_info->balance_lock);

Please don't do the guard() conversions in fs/btrfs/, the explicit
locking is the preferred style. If other subsystems use the scoped
locking guards then let them do it.

I personally hate it as it totally disrupts the perception of visibly
demarcated critical sections. I don't see the benefit comparing saved
lines of code vs clear and understandable code.

We rarely have a clear case for the guards, I found a few where it
could be used but then this means we have 2 styles of locking, yet
another code pattern to learn.

  parent reply	other threads:[~2025-04-09 18:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-09 12:57 [PATCH 1/2] btrfs: convert to spinlock guards in btrfs_update_ioctl_balance_args() Yangtao Li
2025-04-09 12:57 ` [PATCH 2/2] btrfs: convert to mutex guard in btrfs_ioctl_balance_progress() Yangtao Li
2025-04-10 14:45   ` kernel test robot
2025-04-09 18:30 ` David Sterba [this message]
2025-04-10 11:11   ` 回复: [PATCH 1/2] btrfs: convert to spinlock guards in btrfs_update_ioctl_balance_args() 李扬韬
2025-04-15 17:53     ` David Sterba
2025-04-17 13:38       ` 回复: " 李扬韬

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250409183022.GG13292@suse.cz \
    --to=dsterba@suse.cz \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=frank.li@vivo.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox