Re: [PATCH V5 8/9] null_blk: serialize configfs attribute stores with device setup

Bart Van Assche <[email protected]>
Newsgroups org.kernel.vger.linux-block,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.