From: Paulo Alcantara <pc@manguebit.com>
To: Alexander Aring <aahringo@redhat.com>, Steve French <smfrench@gmail.com>
Cc: Zorro Lang <zlang@kernel.org>, Zorro Lang <zlang@redhat.com>,
fstests@vger.kernel.org, gfs2@lists.linux.dev,
jlayton@kernel.org, linux-cifs@vger.kernel.org
Subject: Re: [PATCHv2] generic: add fcntl corner cases tests
Date: Fri, 01 Mar 2024 20:59:01 -0300 [thread overview]
Message-ID: <a6806fcca760e734f272596cafc2390f@manguebit.com> (raw)
In-Reply-To: <CAK-6q+isU4cQN6OV_bLmoKwULsisAUpkAZA+c6SRgOCk8Z9T=g@mail.gmail.com>
Alexander Aring <aahringo@redhat.com> writes:
> Hi,
>
> On Fri, Mar 1, 2024 at 11:25 AM Paulo Alcantara <pc@manguebit.com> wrote:
>>
>> Hi Zorro,
>>
>> The problem is that cifs.ko is returning -EACCES from fcntl(2) called
>> in do_test_equal_file_lock() but it is expecting -EAGAIN to be
>> returned, so it hangs in wait4(2):
>>
>> ...
>> [pid 14846] fcntl(3, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=1}) = -1 EACCES (Permission denied)
>> [pid 14846] wait4(-1,
>>
>> The man page says:
>>
>> F_SETLK (struct flock *)
>> Acquire a lock (when l_type is F_RDLCK or F_WRLCK) or release a
>> lock (when l_type is F_UNLCK) on the bytes specified by the
>> l_whence, l_start, and l_len fields of lock. If a conflicting
>> lock is held by another process, this call returns -1 and sets
>> errno to EACCES or EAGAIN. (The error returned in this case
>> differs across implementations, so POSIX requires a portable ap‐
>> plication to check for both errors.)
>>
>> so fcntl_lock_corner_tests should also handle -EACCES.
>>
>
> yes, that is a bug in the test but in my opinion there is still an
> issue. The mentioned fcntl(F_SETLK) above is just a sanity check to
> print out if something is not correct and it will print out that
> something is not correct and fails.
Yes, I agree it might be a cifs.ko issue. However, it's still important
making sure that the test exits gracefully and then report an error
rather than hanging.
> The problem is that wait() below, the child processes are not
> returning and are in a blocking state which should not be the case.
>
> What the test is doing is the following:
>
> parent:
>
> 1. lock(A) # should be successful to acquire
Client successfully acquires it.
> child:
> thread0:
> 2. lock(A) # should block
> thread1:
> 3. lock(A) # should block
OK - both threads are blocked.
> parent:
>
> 5. sleep(3) #wait until child are in blocking state of lock(A)
OK.
> 5. unlock(A) # both threads of the child should unlock and exit
At this point, both threads are woken up and one of them acquires the
lock and returns. The other thread gets blocked again because it finds
a conflicting lock that was taken from the other thread. The child then
never exits because it is waiting in pthread_join().
> 6. sleep 3 # wait for pending unlock op (not really sure if it's necessary)
> ...
> 7. trylock(A) # mentioned sanity check
Client returns -EACCES because one of the child threads acquired the
lock.
> The unlock(A) should unblock the child threads, it is important to
> mention that this test does a lock corner test and the lock(A) in both
> threads ends in a ->lock() call with a "struct file_lock" that has
> mostly the same fields. We had issues with that in gfs2 and a lookup
> function to find the right request with an async complete handler of
> the lock operation.
Alex, thanks for the explanation! As we've talked, there might be a
missing check of fl_owner or some sort of protocol limitation while
checking for lock conflicts.
Steve, any thoughts on this?
next prev parent reply other threads:[~2024-03-01 23:59 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-25 20:18 [PATCHv2] generic: add fcntl corner cases tests Alexander Aring
2023-11-02 14:37 ` Alexander Aring
2024-02-01 15:03 ` Alexander Aring
2024-02-01 17:10 ` Jeff Layton
2024-02-02 12:04 ` Zorro Lang
2024-02-02 12:19 ` Alexander Aring
2024-02-02 12:27 ` Zorro Lang
2024-02-02 12:36 ` Jeff Layton
2024-02-02 12:46 ` Zorro Lang
2024-02-09 5:26 ` Zorro Lang
2024-02-09 5:35 ` Steve French
2024-02-09 11:43 ` Zorro Lang
2024-03-01 10:38 ` Zorro Lang
2024-03-01 14:08 ` Alexander Aring
2024-03-01 16:25 ` Paulo Alcantara
2024-03-01 17:23 ` Alexander Aring
2024-03-01 23:59 ` Paulo Alcantara [this message]
2024-03-03 5:08 ` Zorro Lang
2024-03-07 15:58 ` Anand Jain
2024-03-30 7:25 ` Zorro Lang
2024-04-02 14:56 ` Alexander Aring
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=a6806fcca760e734f272596cafc2390f@manguebit.com \
--to=pc@manguebit.com \
--cc=aahringo@redhat.com \
--cc=fstests@vger.kernel.org \
--cc=gfs2@lists.linux.dev \
--cc=jlayton@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=smfrench@gmail.com \
--cc=zlang@kernel.org \
--cc=zlang@redhat.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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox