Linux-Fsdevel Archive on lore.kernel.org
 help / color / Atom feed
From: NeilBrown <neilb@suse.de>
To: yangerkun <yangerkun@huawei.com>,
	sfrench@samba.org, jlayton@kernel.org, neilb@suse.com
Cc: linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] cifs: remove the retry in cifs_poxis_lock_set
Date: Wed, 01 Jul 2020 08:34:26 +1000
Message-ID: <878sg42nf1.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <62b291ab-291c-339f-e8e8-ba7b0c4f6670@huawei.com>


[-- Attachment #1: Type: text/plain, Size: 1860 bytes --]

On Tue, Jun 30 2020, yangerkun wrote:

> Ping...
>
> 在 2020/6/24 15:10, yangerkun 写道:
>> The caller of cifs_posix_lock_set will do retry(like
>> fcntl_setlk64->do_lock_file_wait) if we will wait for any file_lock.
>> So the retry in cifs_poxis_lock_set seems duplicated, remove it to
>> make a cleanup.

If cifs_posix_try_lock() returns FILE_LOCK_DEFERRED (which it might
after your patch), then cifs_setlk() will check the return value:

		if (!rc || rc < 0)
			return rc;

These tests will fail (as FILE_LOCK_DEFERRED is 1) and so it will
continue on as though the lock was granted.

So I think your patch is wrong.
However I think your goal is correct.  cifs shouldn't be waiting.
No other filesystem waits when it gets FILE_LOCK_DEFERRED.

So maybe try to fix up your patch.

Thanks,
NeilBrown


>> 
>> Signed-off-by: yangerkun <yangerkun@huawei.com>
>> ---
>>   fs/cifs/file.c | 8 --------
>>   1 file changed, 8 deletions(-)
>> 
>> diff --git a/fs/cifs/file.c b/fs/cifs/file.c
>> index 9b0f8f33f832..2c9c24b1805d 100644
>> --- a/fs/cifs/file.c
>> +++ b/fs/cifs/file.c
>> @@ -1162,7 +1162,6 @@ cifs_posix_lock_set(struct file *file, struct file_lock *flock)
>>   	if ((flock->fl_flags & FL_POSIX) == 0)
>>   		return rc;
>>   
>> -try_again:
>>   	cifs_down_write(&cinode->lock_sem);
>>   	if (!cinode->can_cache_brlcks) {
>>   		up_write(&cinode->lock_sem);
>> @@ -1171,13 +1170,6 @@ cifs_posix_lock_set(struct file *file, struct file_lock *flock)
>>   
>>   	rc = posix_lock_file(file, flock, NULL);
>>   	up_write(&cinode->lock_sem);
>> -	if (rc == FILE_LOCK_DEFERRED) {
>> -		rc = wait_event_interruptible(flock->fl_wait,
>> -					list_empty(&flock->fl_blocked_member));
>> -		if (!rc)
>> -			goto try_again;
>> -		locks_delete_block(flock);
>> -	}
>>   	return rc;
>>   }
>>   
>> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply index

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-24  7:10 yangerkun
2020-06-30 12:24 ` yangerkun
2020-06-30 22:34   ` NeilBrown [this message]
2020-07-01  1:24     ` yangerkun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878sg42nf1.fsf@notabene.neil.brown.name \
    --to=neilb@suse.de \
    --cc=jlayton@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=neilb@suse.com \
    --cc=samba-technical@lists.samba.org \
    --cc=sfrench@samba.org \
    --cc=yangerkun@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Fsdevel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-fsdevel/0 linux-fsdevel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-fsdevel linux-fsdevel/ https://lore.kernel.org/linux-fsdevel \
		linux-fsdevel@vger.kernel.org
	public-inbox-index linux-fsdevel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-fsdevel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git