Re: [PATCH V5 8/9] null_blk: serialize configfs attribute stores with device setup
Zizhi Wo <[email protected]>
| Newsgroups | org.kernel.vger.linux-block,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
在 2026/7/25 5:13, Bart Van Assche 写道: > 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? Yes. > > Additionally, the above changes modify the behavior if apply_fn() > returns a strictly positive value (> 0). > > Bart. Yes, I made this change because the current apply_fn() never return a value greater than 0. Thanks for the suggestion. I'll switch to using guard() in the next version. Thanks, Zizhi Wo