From: "Myklebust, Trond" <Trond.Myklebust-HgOvQuBEEgTQT0dZR+AlfA@public.gmane.org>
To: Miklos Szeredi <miklos-sUDqSbJrdHQHWmgEVkV9KA@public.gmane.org>
Cc: "bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org"
<bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>,
"linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [REGRESSION] NFSv4: open(O_TRUNC) hangs
Date: Thu, 5 Apr 2012 17:31:58 +0000 [thread overview]
Message-ID: <1333647115.4573.3.camel@lade.trondhjem.org> (raw)
In-Reply-To: <87d37osrx2.fsf-d8RdFUjzFsbxNFs70CDYszOMxtEWgIxa@public.gmane.org>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 2115 bytes --]
On Tue, 2012-04-03 at 18:26 +0200, Miklos Szeredi wrote:
> Now this test program hangs on latest git.
>
> Thanks,
> Miklos
> ---
>
> #include <stdio.h>
> #include <unistd.h>
> #include <fcntl.h>
>
> int main(int argc, char *argv[])
> {
> int res;
> char *name = argv[1];
> int fd;
>
> unlink(name);
> fd = creat(name, 0644);
> write(fd, "123", 3);
> close(fd);
> close(open(name, O_RDONLY | O_TRUNC));
>
> return 0;
> }
Hi Miklos,
The following client patch fixes the regression for me.
Cheers
Trond
8<----------------------------------------------------
From 5ec0ed6cd88c65464092533787706d9ecfb85320 Mon Sep 17 00:00:00 2001
From: Trond Myklebust <Trond.Myklebust@netapp.com>
Date: Wed, 4 Apr 2012 10:51:33 -0700
Subject: [PATCH 1/2] NFSv4: Don't use open stateids that have the wrong open
mode
If the client is doing an operation that needs a particular open
mode, then nfs4_select_rw_stateid() should only copy the
open stateid if the latter has the correct open mode.
Otherwise we should just use the zero stateid.
Reported-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
---
fs/nfs/nfs4state.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 0f43414..71dcfd4 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -932,6 +932,13 @@ void nfs4_select_rw_stateid(nfs4_stateid *dst, struct nfs4_state *state,
{
if (nfs4_copy_delegation_stateid(dst, state->inode, fmode))
return;
+
+ fmode &= FMODE_READ|FMODE_WRITE;
+ if ((state->state & fmode) != fmode) {
+ nfs4_stateid_copy(dst, &zero_stateid);
+ return;
+ }
+
if (nfs4_copy_lock_stateid(dst, state, fl_owner, fl_pid))
return;
nfs4_copy_open_stateid(dst, state);
--
1.7.7.6
--
Trond Myklebust
Linux NFS client maintainer
NetApp
Trond.Myklebust@netapp.com
www.netapp.com
N§²æìr¸yúèØb²X¬¶Ç§vØ^)Þº{.nÇ+·¥{±û"Ø^nr¡ö¦zË\x1aëh¨èÚ&¢îý»\x05ËÛÔØï¦v¬Îf\x1dp)¹¹br ê+Ê+zf£¢·h§~Ûiÿûàz¹\x1e®w¥¢¸?¨èÚ&¢)ߢ^[f
next prev parent reply other threads:[~2012-04-05 17:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-03 16:26 [REGRESSION] NFSv4: open(O_TRUNC) hangs Miklos Szeredi
[not found] ` <87d37osrx2.fsf-d8RdFUjzFsbxNFs70CDYszOMxtEWgIxa@public.gmane.org>
2012-04-05 17:31 ` Myklebust, Trond [this message]
[not found] ` <1333647115.4573.3.camel-SyLVLa/KEI9HwK5hSS5vWB2eb7JE58TQ@public.gmane.org>
2012-04-06 9:43 ` Miklos Szeredi
[not found] ` <8762ddb3ge.fsf-d8RdFUjzFsbxNFs70CDYszOMxtEWgIxa@public.gmane.org>
2012-04-18 22:03 ` Myklebust, Trond
2012-04-19 11:27 ` Miklos Szeredi
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=1333647115.4573.3.camel@lade.trondhjem.org \
--to=trond.myklebust-hgovqubeegtqt0dzr+alfa@public.gmane.org \
--cc=bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org \
--cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=miklos-sUDqSbJrdHQHWmgEVkV9KA@public.gmane.org \
/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;
as well as URLs for NNTP newsgroup(s).