[PATCH 1/2] nvmet: make 'readonly' setting configurable
Keith Busch
kbusch at kernel.org
Tue Apr 8 07:24:39 PDT 2025
On Fri, Apr 04, 2025 at 08:21:26AM +0200, Christoph Hellwig wrote:
> On Thu, Apr 03, 2025 at 09:44:55AM -0600, Keith Busch wrote:
> > > + mutex_lock(&ns->subsys->lock);
> > > + if (ns->enabled) {
> > > + pr_err("the ns:%d is already enabled.\n", ns->nsid);
> > > + mutex_unlock(&ns->subsys->lock);
> > > + return -EINVAL;
> > > + }
> > > + ns->readonly = val;
> > > + mutex_unlock(&ns->subsys->lock);
> >
> > Not sure how people feel about the "cleanup" constructs. If we're okay
> > using them in this driver, this is a simple use case for the guard to
> > manage the mutex:
> >
> > guard(mutex)(&ns->subsys->lock);
> >
> > And then you don't need to worry about unlocking.
>
> I really hate it with passion as the syntax is so butt ugly and has
> no explicit unlock point.
Okay, that's why I asked. Some subsystems have embraced it, but not
others. Since we haven't considered it for nvme yet, this looked like an
opportunity to feel that out, and it's totally fine with me if we avoid
the guard model.
More information about the Linux-nvme
mailing list