All of lore.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: "J. Bruce Fields" <bfields@redhat.com>
Subject: [PATCH 4/5] nfsd4: fix openmode checking on IO using lock stateid
Date: Thu, 29 Jul 2010 18:21:23 -0400	[thread overview]
Message-ID: <1280442084-17867-5-git-send-email-bfields@redhat.com> (raw)
In-Reply-To: <1280442084-17867-1-git-send-email-bfields@redhat.com>

It is legal to perform a write using the lock stateid that was
originally associated with a read lock, or with a file that was
originally opened for read, but has since been upgraded.

So, when checking the openmode, check the mode associated with the
open stateid from which the lock was derived.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
---
 fs/nfsd/nfs4state.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index d9c8232..b996a4b 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -2779,6 +2779,9 @@ __be32 nfs4_check_openmode(struct nfs4_stateid *stp, int flags)
 {
         __be32 status = nfserr_openmode;
 
+	/* For lock stateid's, we test the parent open, not the lock: */
+	if (stp->st_openstp)
+		stp = stp->st_openstp;
 	if ((flags & WR_STATE) && (!access_permit_write(stp->st_access_bmap)))
                 goto out;
 	if ((flags & RD_STATE) && (!access_permit_read(stp->st_access_bmap)))
@@ -3466,7 +3469,6 @@ alloc_init_lock_stateid(struct nfs4_stateowner *sop, struct nfs4_file *fp, struc
 	stp->st_stateid.si_fileid = fp->fi_id;
 	stp->st_stateid.si_generation = 0;
 	stp->st_vfs_file = open_stp->st_vfs_file; /* FIXME refcount?? */
-	stp->st_access_bmap = open_stp->st_access_bmap;
 	stp->st_deny_bmap = open_stp->st_deny_bmap;
 	stp->st_openstp = open_stp;
 
-- 
1.7.0.4


  parent reply	other threads:[~2010-07-29 22:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-29 22:21 nfsd fixes for 2.6.36 J. Bruce Fields
2010-07-29 22:21 ` [PATCH 1/5] nfsd: bypass readahead cache when have struct file J. Bruce Fields
2010-07-30  8:10   ` Christoph Hellwig
2010-07-30  8:19     ` Bian Naimeng
2010-07-30  8:25       ` Christoph Hellwig
2010-07-30 15:41     ` J. Bruce Fields
2010-07-30 18:30       ` J. Bruce Fields
2010-07-31 18:18     ` J. Bruce Fields
2010-07-29 22:21 ` [PATCH 2/5] nfsd4: don't pretend to support write delegations J. Bruce Fields
2010-07-29 22:21 ` [PATCH 3/5] nfsd4: miscellaneous process_open2 cleanup J. Bruce Fields
2010-07-29 22:21 ` J. Bruce Fields [this message]
2010-07-29 22:21 ` [PATCH 5/5] nfsd4: share file descriptors between stateid's J. Bruce Fields

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=1280442084-17867-5-git-send-email-bfields@redhat.com \
    --to=bfields@redhat.com \
    --cc=linux-nfs@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.