Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1482929

Re: [PATCH] staging: lustre: lustre/ldlm: Fixed sparse warnings

From "Dilger, Andreas" <andreas.dilger@intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH] staging: lustre: lustre/ldlm: Fixed sparse warnings
Date 2016-09-14 07:20 +0200
Message-ID <shaM1-4De-11@gated-at.bofh.it> (permalink)
References <sfvUC-4IV-45@gated-at.bofh.it> <sgwEW-1Zi-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sep 12, 2016, at 04:27, Greg KH <gregkh@linuxfoundation.org> wrote:
> 
> On Fri, Sep 09, 2016 at 08:50:35PM +0530, Nayeemahmed Badebade wrote:
>> Added __acquires / __releases sparse locking annotations
>> to lock_res_and_lock and unlock_res_and_lock functions in
>> l_lock.c, to fix below sparse warnings:
>> 
>> l_lock.c:47:22: warning: context imbalance in 'lock_res_and_lock' - wrong count at exit
>> l_lock.c:62:6: warning: context imbalance in 'unlock_res_and_lock' - unexpected unlock
>> 
>> Signed-off-by: Nayeemahmed Badebade <itachi.opsrc@gmail.com>
>> ---
>> drivers/staging/lustre/lustre/ldlm/l_lock.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>> 
>> diff --git a/drivers/staging/lustre/lustre/ldlm/l_lock.c b/drivers/staging/lustre/lustre/ldlm/l_lock.c
>> index ea8840c..c4b9612 100644
>> --- a/drivers/staging/lustre/lustre/ldlm/l_lock.c
>> +++ b/drivers/staging/lustre/lustre/ldlm/l_lock.c
>> @@ -45,6 +45,8 @@
>>  * being an atomic operation.
>>  */
>> struct ldlm_resource *lock_res_and_lock(struct ldlm_lock *lock)
>> +				__acquires(&lock->l_lock)
>> +				__acquires(lock->l_resource)
> 
> Hm, these are tricky, I don't want to take this type of change without
> an ack from the lustre developers...

The "__acquires(&lock->l_lock)" line here looks correct, along with the
corresponding "__releases(&lock->l_lock)" at unlock_res_and_lock().

The problem, however, is that "l_resource" is not a lock, but rather a
struct.  The call to "lock_res(lock->l_resource)" is actually locking
"lr_lock" internally.

It would be better to add "__acquires(&res->lr_lock)" at lock_res() and
"__releases(&res->lr_lock)" at unlock_res().  That will also forestall
any other warnings about an imbalance with lock_res()/unlock_res() or
their callsites.

Cheers, Andreas

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] staging: lustre: lustre/ldlm: Fixed sparse warnings Nayeemahmed Badebade <itachi.opsrc@gmail.com> - 2016-09-09 17:30 +0200
  Re: [PATCH] staging: lustre: lustre/ldlm: Fixed sparse warnings Greg KH <gregkh@linuxfoundation.org> - 2016-09-12 12:30 +0200
    Re: [PATCH] staging: lustre: lustre/ldlm: Fixed sparse warnings "Dilger, Andreas" <andreas.dilger@intel.com> - 2016-09-14 07:20 +0200
      Re: [PATCH] staging: lustre: lustre/ldlm: Fixed sparse warnings nayeem <itachi.opsrc@gmail.com> - 2016-09-15 20:40 +0200
        Re: [PATCH] staging: lustre: lustre/ldlm: Fixed sparse warnings "Dilger, Andreas" <andreas.dilger@intel.com> - 2016-09-16 10:10 +0200
          Re: [PATCH] staging: lustre: lustre/ldlm: Fixed sparse warnings nayeem <itachi.opsrc@gmail.com> - 2016-09-18 22:30 +0200
            Re: [PATCH] staging: lustre: lustre/ldlm: Fixed sparse warnings "Dilger, Andreas" <andreas.dilger@intel.com> - 2016-09-18 22:40 +0200
              [PATCH v2] staging: lustre: lustre/ldlm: Fixed sparse warnings Nayeemahmed Badebade <itachi.opsrc@gmail.com> - 2016-09-18 23:20 +0200
                Re: [PATCH v2] staging: lustre: lustre/ldlm: Fixed sparse warnings "Dilger, Andreas" <andreas.dilger@intel.com> - 2016-09-18 23:30 +0200
                Re: [PATCH v2] staging: lustre: lustre/ldlm: Fixed sparse warnings James Simmons <jsimmons@infradead.org> - 2016-09-19 22:50 +0200

csiph-web