* [PATCH] nfsd: nfs4_file_get_access: need to be more careful with O_RDWR
@ 2013-07-23 4:05 Harshula Jayasuriya
2013-07-23 16:28 ` J.Bruce Fields
0 siblings, 1 reply; 2+ messages in thread
From: Harshula Jayasuriya @ 2013-07-23 4:05 UTC (permalink / raw)
To: J.Bruce Fields; +Cc: linux-nfs, NeilBrown
If fi_fds = {non-NULL, NULL, non-NULL} and oflag = O_WRONLY
the WARN_ON_ONCE(!(fp->fi_fds[oflag] || fp->fi_fds[O_RDWR]))
doesn't trigger when it should.
Signed-off-by: Harshula Jayasuriya <harshula@redhat.com>
---
fs/nfsd/nfs4state.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 280acef..1cb6211 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -282,19 +282,14 @@ static unsigned int file_hashval(struct inode *ino)
static struct hlist_head file_hashtbl[FILE_HASH_SIZE];
-static void __nfs4_file_get_access(struct nfs4_file *fp, int oflag)
-{
- WARN_ON_ONCE(!(fp->fi_fds[oflag] || fp->fi_fds[O_RDWR]));
- atomic_inc(&fp->fi_access[oflag]);
-}
-
static void nfs4_file_get_access(struct nfs4_file *fp, int oflag)
{
+ WARN_ON_ONCE(!fp->fi_fds[oflag]);
if (oflag == O_RDWR) {
- __nfs4_file_get_access(fp, O_RDONLY);
- __nfs4_file_get_access(fp, O_WRONLY);
+ atomic_inc(&fp->fi_access[O_RDONLY]);
+ atomic_inc(&fp->fi_access[O_WRONLY]);
} else
- __nfs4_file_get_access(fp, oflag);
+ atomic_inc(&fp->fi_access[oflag]);
}
static void nfs4_file_put_fd(struct nfs4_file *fp, int oflag)
--
1.8.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] nfsd: nfs4_file_get_access: need to be more careful with O_RDWR
2013-07-23 4:05 [PATCH] nfsd: nfs4_file_get_access: need to be more careful with O_RDWR Harshula Jayasuriya
@ 2013-07-23 16:28 ` J.Bruce Fields
0 siblings, 0 replies; 2+ messages in thread
From: J.Bruce Fields @ 2013-07-23 16:28 UTC (permalink / raw)
To: Harshula Jayasuriya; +Cc: linux-nfs, NeilBrown
Thanks, applying for 3.12.--b.
On Tue, Jul 23, 2013 at 02:05:14PM +1000, Harshula Jayasuriya wrote:
> If fi_fds = {non-NULL, NULL, non-NULL} and oflag = O_WRONLY
> the WARN_ON_ONCE(!(fp->fi_fds[oflag] || fp->fi_fds[O_RDWR]))
> doesn't trigger when it should.
>
> Signed-off-by: Harshula Jayasuriya <harshula@redhat.com>
> ---
> fs/nfsd/nfs4state.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 280acef..1cb6211 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -282,19 +282,14 @@ static unsigned int file_hashval(struct inode *ino)
>
> static struct hlist_head file_hashtbl[FILE_HASH_SIZE];
>
> -static void __nfs4_file_get_access(struct nfs4_file *fp, int oflag)
> -{
> - WARN_ON_ONCE(!(fp->fi_fds[oflag] || fp->fi_fds[O_RDWR]));
> - atomic_inc(&fp->fi_access[oflag]);
> -}
> -
> static void nfs4_file_get_access(struct nfs4_file *fp, int oflag)
> {
> + WARN_ON_ONCE(!fp->fi_fds[oflag]);
> if (oflag == O_RDWR) {
> - __nfs4_file_get_access(fp, O_RDONLY);
> - __nfs4_file_get_access(fp, O_WRONLY);
> + atomic_inc(&fp->fi_access[O_RDONLY]);
> + atomic_inc(&fp->fi_access[O_WRONLY]);
> } else
> - __nfs4_file_get_access(fp, oflag);
> + atomic_inc(&fp->fi_access[oflag]);
> }
>
> static void nfs4_file_put_fd(struct nfs4_file *fp, int oflag)
> --
> 1.8.1.4
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-07-23 16:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-23 4:05 [PATCH] nfsd: nfs4_file_get_access: need to be more careful with O_RDWR Harshula Jayasuriya
2013-07-23 16:28 ` J.Bruce Fields
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).