mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Zizhi Wo <wozizhi@huaweicloud.com>,
	axboe@kernel.dk, dlemoal@kernel.org, nilay@linux.ibm.com,
	kch@nvidia.com, johannes.thumshirn@wdc.com, kbusch@kernel.org,
	linux-block@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, yangerkun@huawei.com,
	chengzhihao1@huawei.com, wozizhi@huawei.com
Subject: Re: [PATCH V5 8/9] null_blk: serialize configfs attribute stores with device setup
Date: Fri, 24 Jul 2026 14:13:43 -0700	[thread overview]
Message-ID: <75009f4e-7f03-4911-bf51-27377c1ee11a@acm.org> (raw)
In-Reply-To: <20260714041805.1088702-9-wozizhi@huaweicloud.com>

On 7/13/26 9:18 PM, Zizhi Wo wrote:
>   	ret = nullb_device_##TYPE##_attr_store(&new_value, page, count);\
>   	if (ret < 0)							\
>   		return ret;						\
> +	ret = 0;							\
> +	mutex_lock(&lock);						\
>   	if (apply_fn)							\
>   		ret = apply_fn(dev, new_value);				\
>   	else if (test_bit(NULLB_DEV_FL_CONFIGURED, &dev->flags)) 	\
>   		ret = -EBUSY;						\
> +	if (!ret)							\
> +		dev->NAME = new_value;					\
> +	mutex_unlock(&lock);						\
>   	if (ret < 0)							\
>   		return ret;						\
> -	dev->NAME = new_value;						\
>   	return count;							\
>   }									\

If guard()() would be used instead of explicit mutex_lock() and
mutex_unlock() calls, the if (ret) test wouldn't have to be duplicated,
isn't it?

Additionally, the above changes modify the behavior if apply_fn()
returns a strictly positive value (> 0).

Bart.

  reply	other threads:[~2026-07-24 21:13 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14  4:17 [PATCH V5 0/9] null_blk: fix init/exit races and memleaks Zizhi Wo
2026-07-14  4:17 ` [PATCH V5 1/9] null_blk: use DEFINE_MUTEX for the file-scope mutex Zizhi Wo
2026-07-14  4:17 ` [PATCH V5 2/9] null_blk: register configfs subsystem after creating default devices Zizhi Wo
2026-07-14  4:17 ` [PATCH V5 3/9] null_blk: move unregister_blkdev() after destroying dev in null_exit() Zizhi Wo
2026-07-14  4:18 ` [PATCH V5 4/9] null_blk: free global tag_set on init error path Zizhi Wo
2026-07-14  4:18 ` [PATCH V5 5/9] null_blk: free zones array on device power-off Zizhi Wo
2026-07-15 14:14   ` Nilay Shroff
2026-07-24 21:08   ` Bart Van Assche
2026-07-14  4:18 ` [PATCH V5 6/9] null_blk: clean up null_del_dev() to use cached dev pointer Zizhi Wo
2026-07-24 21:08   ` Bart Van Assche
2026-07-14  4:18 ` [PATCH V5 7/9] null_blk: reject per-device queue resize for shared tag set Zizhi Wo
2026-07-15 13:42   ` Nilay Shroff
2026-07-24 21:09   ` Bart Van Assche
2026-07-14  4:18 ` [PATCH V5 8/9] null_blk: serialize configfs attribute stores with device setup Zizhi Wo
2026-07-24 21:13   ` Bart Van Assche [this message]
2026-07-25  1:22     ` Zizhi Wo
2026-07-14  4:18 ` [PATCH V5 9/9] null_blk: serialize configfs attribute shows with the file-scope lock Zizhi Wo
2026-07-24 21:16   ` Bart Van Assche
2026-07-25  1:27     ` Zizhi Wo
2026-07-24  1:18 ` [PATCH V5 0/9] null_blk: fix init/exit races and memleaks Zizhi Wo

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=75009f4e-7f03-4911-bf51-27377c1ee11a@acm.org \
    --to=bvanassche@acm.org \
    --cc=axboe@kernel.dk \
    --cc=chengzhihao1@huawei.com \
    --cc=dlemoal@kernel.org \
    --cc=johannes.thumshirn@wdc.com \
    --cc=kbusch@kernel.org \
    --cc=kch@nvidia.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nilay@linux.ibm.com \
    --cc=wozizhi@huawei.com \
    --cc=wozizhi@huaweicloud.com \
    --cc=yangerkun@huawei.com \
    /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

all inboxes | Powered by JetHome®