Sparse fix for scsi_request_fn
Subsystems (2)
Introduce new __holds() macro to tell sparse it's OK to drop and then reacquire a lock within a function. Use it in scsi_request_fn.
drivers/scsi/scsi_lib.c +1 -0
@@ -1374,6 +1372,7 @@ static void scsi_softirq_done(struct request *rq)* Lock status: IO request lock assumed to be held when called. */ static void scsi_request_fn (struct request_queue *q) + __holds(q->queue_lock) {struct scsi_device *sdev = q->queuedata;struct Scsi_Host *shost;
include/linux/compiler.h +2 -0
@@ -12,6 +12,7 @@# define __iomem __attribute__((noderef, address_space(2)))# define __acquires (x) __attribute__((context(x,0,1)))# define __releases (x) __attribute__((context(x,1,0))) +# define __holds (x) __attribute__((context(x,1,1)))# define __acquire (x) __context__(x,1)# define __release (x) __context__(x,-1)# define __cond_lock (x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
@@ -29,6 +30,7 @@ extern void __chk_io_ptr(const volatile void __iomem *); # define __builtin_warning(x, y...) (1)# define __acquires (x)# define __releases (x) +# define __holds (x)# define __acquire (x) (void)0# define __release (x) (void)0# define __cond_lock (x,c) (c)
Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Quoted 3 lines · Matthew Wilcox
Introduce new
__holds()macro to tell sparse it's OK to drop and then reacquire a lock within a function. Use it inscsi_request_fn.
Umm. This is why we write things like
static void double_lock_balance(struct rq *this_rq, struct rq *busiest)
__releases(this_rq->lock)
__acquires(busiest->lock)
__acquires(this_rq->lock)
{
...ie your "__holds()" is nothing new, and should be written as a pair of __releases(x) and __acquires(x), which is more readable anyway (since it actually says what the function does!)
Linus
Quoted 9 lines · Linus Torvalds
Umm. This is why we write things like
static void double_lock_balance(struct rq *this_rq, struct rq *busiest) __releases(this_rq->lock) __acquires(busiest->lock) __acquires(this_rq->lock) { ...
Quoted 3 lines
ie your "
__holds()" is nothing new, and should be written as a pair of__releases(x)and__acquires(x), which is more readable anyway (since it actually says what the function does!)
Thanks, I hadn't realised that sparse would unify the two declarations.
Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."