Skip to contentSkip to conversation

pnfsd: Update the reference of nfs4_layout_state properly

PATCH In review [email protected] 2 participants 2 messages Jan 15, 2013 – Jan 21, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pnfsd: Update the reference of nfs4_layout_state properly

From: Yanchuan Nian <[email protected]>

The reference of nfs4_layout_state is set to 1 when creating. it isn't necessary to increase the reference again in nfs4_process_layout_stateid(), otherwise it will lead to a memory leak.

---
 fs/nfsd/nfs4pnfsd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/nfsd/nfs4pnfsd.c +1 -1
index 2211b50..dd7856c 100644
@@ -248,10 +248,10 @@ nfs4_process_layout_stateid(struct nfs4_client *clp, struct nfs4_file *fp,
 			status = nfserr_bad_stateid;
 			goto out;
 		}
+		get_layout_state(ls);
 	}
 	status = 0;
 
-	get_layout_state(ls);
 	*lsp = ls;
 	dprintk("%s: layout stateid=" STATEID_FMT " ref=%d\n", __func__,
 		STATEID_VAL(&ls->ls_stid.sc_stateid), atomic_read(&ls->ls_ref.refcount));
Signature · 1 line
1.7.4.4
#1 lore raw
Quoted 8 lines · On 2013-01-15 04:37, [email protected] wrote:

From: Yanchuan Nian <[email protected]>

The reference of nfs4_layout_state is set to 1 when creating. it isn't necessary to increase the reference again in nfs4_process_layout_stateid(), otherwise it will lead to a memory leak.

Thanks. Committing for pnfs-all-3.7 and latest.

Benny

Quoted 21 lines
---
 fs/nfsd/nfs4pnfsd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/nfsd/nfs4pnfsd.c +1 -1
index 2211b50..dd7856c 100644
@@ -248,10 +248,10 @@ nfs4_process_layout_stateid(struct nfs4_client *clp, struct nfs4_file *fp,
 			status = nfserr_bad_stateid;
 			goto out;
 		}
+		get_layout_state(ls);
 	}
 	status = 0;
 
-	get_layout_state(ls);
 	*lsp = ls;
 	dprintk("%s: layout stateid=" STATEID_FMT " ref=%d\n", __func__,
 		STATEID_VAL(&ls->ls_stid.sc_stateid), atomic_read(&ls->ls_ref.refcount));