[PATCH 2/2] nfsd: don't allocate odstates unless pNFS is enabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
 fs/nfsd/nfs4state.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index f417362..9072964 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -475,8 +475,10 @@ static void nfs4_file_put_access(struct nfs4_file *fp, u32 access)
 
 /*
  * Allocate a new open/delegation state counter. This is needed for
- * pNFS for proper return on close semantics. For v4.0 however, it's
- * not needed.
+ * pNFS for proper return on close semantics.
+ *
+ * Note that we only allocate it for pNFS-enabled exports, otherwise
+ * all pointers to struct nfs4_clnt_odstate are always NULL.
  */
 static struct nfs4_clnt_odstate *
 alloc_clnt_odstate(struct nfs4_client *clp)
@@ -503,7 +505,6 @@ hash_clnt_odstate_locked(struct nfs4_clnt_odstate *co)
 static inline void
 get_clnt_odstate(struct nfs4_clnt_odstate *co)
 {
-	/* This is always NULL in v4.0 */
 	if (co)
 		atomic_inc(&co->co_odcount);
 }
@@ -513,7 +514,6 @@ put_clnt_odstate(struct nfs4_clnt_odstate *co)
 {
 	struct nfs4_file *fp;
 
-	/* This is always NULL in v4.0 */
 	if (!co)
 		return;
 
@@ -533,7 +533,6 @@ find_or_hash_clnt_odstate(struct nfs4_file *fp, struct nfs4_clnt_odstate *new)
 	struct nfs4_clnt_odstate *co;
 	struct nfs4_client *cl;
 
-	/* This is always NULL in v4.0 */
 	if (!new)
 		return NULL;
 
@@ -3680,7 +3679,8 @@ alloc_stateid:
 	if (!open->op_stp)
 		return nfserr_jukebox;
 
-	if (nfsd4_has_session(cstate)) {
+	if (nfsd4_has_session(cstate) &&
+	    (cstate->current_fh.fh_export->ex_flags & NFSEXP_PNFS)) {
 		open->op_odstate = alloc_clnt_odstate(clp);
 		if (!open->op_odstate)
 			return nfserr_jukebox;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux