Re: [Nfs-ganesha-devel] Race between fsal_find_fd() and 'open downgrade'

2018-01-10 Thread Pradeep
Thanks Frank. I will try it out. Any concerns on holding the lock
across system calls (though this is read lock)?

On 1/10/18, Frank Filz <ffilz...@mindspring.com> wrote:
> We have a patch under review for FSAL_GPFS for that issue, awaiting the
> submitter to extend the patch to cover other FSALs also. If you want to
> verify the fix would work for your case, it should be easy to take the fix
> and do the same thing in FSAL_VFS.
>
> https://review.gerrithub.io/#/c/390141/
>
> As soon as this patch is merged into V2.6, it will be slated for backport
> to
> V2.5-stable.
>
> Frank
>
>> -Original Message-
>> From: Pradeep [mailto:pradeep.tho...@gmail.com]
>> Sent: Wednesday, January 10, 2018 8:06 PM
>> To: nfs-ganesha-devel <nfs-ganesha-devel@lists.sourceforge.net>
>> Subject: [Nfs-ganesha-devel] Race between fsal_find_fd() and 'open
>> downgrade'
>>
>> Hello,
>>
>> I'm seeing a write failure because another thread in ganesha doing 'open
>> downgrade' closed the FD the find_fd() returned. Any suggestion on how to
>> fix the race?
>>
>> vfs_reopen2()
>> {...
>> status = vfs_open_my_fd(myself, openflags, posix_flags, my_fd);
>>
>> if (!FSAL_IS_ERROR(status)) {
>> /* Close the existing file descriptor and copy the new
>>  * one over.
>>  */
>> vfs_close_my_fd(my_share_fd);
>> *my_share_fd = fd;
>>
>> vfs_write2()
>> {
>> ..
>> status = find_fd(_fd, obj_hdl, bypass, state, openflags,
>>  _lock, , false);
>>
>> if (FSAL_IS_ERROR(status)) {
>> LogDebug(COMPONENT_FSAL,
>>  "find_fd failed %s",
>> msg_fsal_err(status.major));
>> goto out;
>> }
>>
>> fsal_set_credentials(op_ctx->creds);
>>
>> nb_written = pwrite(my_fd, buffer, buffer_size, offset);
>>
>>
> 
> --
>> Check out the vibrant tech community on one of the world's most engaging
>> tech sites, Slashdot.org! http://sdm.link/slashdot
>> ___
>> Nfs-ganesha-devel mailing list
>> Nfs-ganesha-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
>

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Nfs-ganesha-devel mailing list
Nfs-ganesha-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel


Re: [Nfs-ganesha-devel] Race between fsal_find_fd() and 'open downgrade'

2018-01-10 Thread Frank Filz
We have a patch under review for FSAL_GPFS for that issue, awaiting the
submitter to extend the patch to cover other FSALs also. If you want to
verify the fix would work for your case, it should be easy to take the fix
and do the same thing in FSAL_VFS.

https://review.gerrithub.io/#/c/390141/

As soon as this patch is merged into V2.6, it will be slated for backport to
V2.5-stable.

Frank

> -Original Message-
> From: Pradeep [mailto:pradeep.tho...@gmail.com]
> Sent: Wednesday, January 10, 2018 8:06 PM
> To: nfs-ganesha-devel <nfs-ganesha-devel@lists.sourceforge.net>
> Subject: [Nfs-ganesha-devel] Race between fsal_find_fd() and 'open
> downgrade'
> 
> Hello,
> 
> I'm seeing a write failure because another thread in ganesha doing 'open
> downgrade' closed the FD the find_fd() returned. Any suggestion on how to
> fix the race?
> 
> vfs_reopen2()
> {...
> status = vfs_open_my_fd(myself, openflags, posix_flags, my_fd);
> 
> if (!FSAL_IS_ERROR(status)) {
> /* Close the existing file descriptor and copy the new
>  * one over.
>  */
> vfs_close_my_fd(my_share_fd);
> *my_share_fd = fd;
> 
> vfs_write2()
> {
> ..
> status = find_fd(_fd, obj_hdl, bypass, state, openflags,
>  _lock, , false);
> 
> if (FSAL_IS_ERROR(status)) {
> LogDebug(COMPONENT_FSAL,
>  "find_fd failed %s", msg_fsal_err(status.major));
> goto out;
> }
> 
> fsal_set_credentials(op_ctx->creds);
> 
> nb_written = pwrite(my_fd, buffer, buffer_size, offset);
> 
>

--
> Check out the vibrant tech community on one of the world's most engaging
> tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Nfs-ganesha-devel mailing list
> Nfs-ganesha-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Nfs-ganesha-devel mailing list
Nfs-ganesha-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel


[Nfs-ganesha-devel] Race between fsal_find_fd() and 'open downgrade'

2018-01-10 Thread Pradeep
Hello,

I'm seeing a write failure because another thread in ganesha doing 'open
downgrade' closed the FD the find_fd() returned. Any suggestion on how
to fix the race?

vfs_reopen2()
{...
status = vfs_open_my_fd(myself, openflags, posix_flags, my_fd);

if (!FSAL_IS_ERROR(status)) {
/* Close the existing file descriptor and copy the new
 * one over.
 */
vfs_close_my_fd(my_share_fd);
*my_share_fd = fd;

vfs_write2()
{
..
status = find_fd(_fd, obj_hdl, bypass, state, openflags,
 _lock, , false);

if (FSAL_IS_ERROR(status)) {
LogDebug(COMPONENT_FSAL,
 "find_fd failed %s", msg_fsal_err(status.major));
goto out;
}

fsal_set_credentials(op_ctx->creds);

nb_written = pwrite(my_fd, buffer, buffer_size, offset);

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Nfs-ganesha-devel mailing list
Nfs-ganesha-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel