[SSI] openssi/kernel/cluster/ssi/vproc as_xscribe.c, 1.18, 1.19 dvp_pvpops.c, 1.43, 1.44 nd_carelist.c, 1.10, 1.11 procfs_mount.c, 1.13, 1.14 reopen.c, 1.33, 1.34 rproc_cli_pproc.c, 1.24, 1.25 rproc_svr_pproc.c, 1.27, 1.28

Roger Tsang <[email protected]>
Newsgroups gmane.linux.cluster.ssic.cvs
Message-ID <[email protected]>
Update of /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/vproc
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv1388/cluster/ssi/vproc

Modified Files:
      Tag: OPENSSI-FC
	as_xscribe.c dvp_pvpops.c nd_carelist.c procfs_mount.c 
	reopen.c rproc_cli_pproc.c rproc_svr_pproc.c 
Log Message:
Multiple bug fixes. See ChangeLog.


Index: rproc_cli_pproc.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/vproc/rproc_cli_pproc.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- rproc_cli_pproc.c	18 Nov 2009 06:16:53 -0000	1.24
+++ rproc_cli_pproc.c	17 Dec 2009 06:43:51 -0000	1.25
@@ -485,13 +485,14 @@
 	comm_datap->comm_p_cdir = NULL;
 
 	read_lock(&current->fs->lock);
-	rootmnt = mntget(current->fs->rootmnt);
+
+	comm_datap->comm_umask = current->fs->umask;
 	root = dget(current->fs->root);
-	altrootmnt = mntget(current->fs->altrootmnt);
+	pwd = dget(current->fs->pwd);
 	altroot = dget(current->fs->altroot);
+	rootmnt = mntget(current->fs->rootmnt);
 	pwdmnt = mntget(current->fs->pwdmnt);
-	pwd = dget(current->fs->pwd);
-	comm_datap->comm_umask=current->fs->umask;
+	altrootmnt = mntget(current->fs->altrootmnt);
 	read_unlock(&current->fs->lock);
 
 	error = reop_export_path(root, rootmnt, optype,

Index: procfs_mount.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/vproc/procfs_mount.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- procfs_mount.c	27 Oct 2009 03:18:30 -0000	1.13
+++ procfs_mount.c	17 Dec 2009 06:43:51 -0000	1.14
@@ -402,6 +402,7 @@
 	const int cmap_len = 128;
 	int p_len;
 
+	*type = NULL;
 	*payload = NULL;
 
 	/* Ignore local only vfsmount */
@@ -422,6 +423,7 @@
 	*payload = kmalloc(*payload_len, GFP_KERNEL);
 	if (*payload == NULL) {
 		kfree(*type);
+		*type = NULL;
 		return -ENOMEM;
 	}
 
@@ -444,8 +446,13 @@
 		*flags |= MS_NOEXEC;
 
 	if (snprintf(cmap, cmap_len, "uid=%d,gid=%d",
-		     root->i_uid, root->i_gid) >= cmap_len)
+		     root->i_uid, root->i_gid) >= cmap_len) {
+		kfree(*payload);
+		*payload = NULL;
+		kfree(*type);
+		*type = NULL;
 		return -E2BIG;
+	}
 
 	return 0;
 }

Index: reopen.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/vproc/reopen.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- reopen.c	27 Oct 2009 03:18:30 -0000	1.33
+++ reopen.c	17 Dec 2009 06:43:51 -0000	1.34
@@ -585,7 +585,7 @@
  * cases, it simulates the behavior of path_init().
  */
 #ifdef REOP_EXPORT_PATH_SVRNODE
-static inline int
+static int
 reop_import_pathinit(
 	char **name,
 	struct nameidata *nd,
@@ -681,8 +681,10 @@
 		printk(KERN_DEBUG "reop_import_pathinit: d_lookup() dentry=%p name=%s hash=%d\n",
 					dentry, pathname, (int)ino);
 #endif
-		if (!dentry)
+		if (!dentry) {
+			path_release(nd);
 			return -ENOENT;
+		}
 		dput(nd->dentry);
 		nd->dentry = dentry;
 		return 0;
@@ -701,11 +703,13 @@
 		printk(KERN_DEBUG "reop_import_pathinit: do_lookup() ret=%d name=%s hash=%d\n",
 				ret, pathname, (int)ino);
 #endif
-		if (!ret) {
-			dput(nd->dentry);
-			nd->dentry = next.dentry;
+		if (ret) {
+			path_release(nd);
+			return ret;
 		}
-		return ret;
+		dput(nd->dentry);
+		nd->dentry = next.dentry;
+		return 0;
 	}
 	/* not reached */
 	BUG();
@@ -1119,12 +1123,13 @@
 	 * the base code expects the lock to be there, so we oblige.
 	 */
 	error = reop_import_locks(filp, &path->lckdata_info,
-		*(ctv_t *)&path->ctv);
-
-	if (!error)
-		return filp;
+				  *(ctv_t *)&path->ctv);
+	if (error) {
+		fput(filp);
+		return ERR_PTR(error);
+	}
 
-	return ERR_PTR(error);
+	return filp;
 }
 
 int
@@ -1143,9 +1148,10 @@
 			fb_datap->ino, fb_datap->fileid};
 		struct rmtfb_svr *svr =
 			rmtfb_getsvr_handle(&svrhandle);
-		error = PTR_ERR(svr);
-		if (IS_ERR(svr))
+		if (IS_ERR(svr)) {
+			error = PTR_ERR(svr);
 			goto out;
+		}
 		file = svr->common.rfb_file;
 		get_file(file);
 		rmtfb_putsvr(svr);
@@ -1161,17 +1167,19 @@
 						,fb_datap->fb_svrnode
 #endif
 						);
-		error = PTR_ERR(cli);
-		if (IS_ERR(cli))
+		if (IS_ERR(cli)) {
+			error = PTR_ERR(cli);
 			goto out;
+		}
 		file = cli->common.rfb_file;
 		rmtfb_putcli(cli);
 	}
 	else {
 		file = reop_make_file(fb_datap->path, fb_datap->flags, svrnode);
-		error = PTR_ERR(file);
-		if (IS_ERR(file))
+		if (IS_ERR(file)) {
+			error = PTR_ERR(file);
 			goto out;
+		}
 		file->f_pos = fb_datap->pos;
 		set_f_owner(file, fb_datap->f_owner.pid,
 			    fb_datap->f_owner.uid, fb_datap->f_owner.euid);

Index: rproc_svr_pproc.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/vproc/rproc_svr_pproc.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- rproc_svr_pproc.c	18 Nov 2009 06:16:53 -0000	1.27
+++ rproc_svr_pproc.c	17 Dec 2009 06:43:51 -0000	1.28
@@ -273,8 +273,8 @@
 	struct vfsmount *rootmnt, *oldmnt, *lastrootmnt;
 
 	read_lock(&current->fs->lock);
-	oldmnt = mntget(current->fs->rootmnt);
 	old = dget(current->fs->root);
+	oldmnt = mntget(current->fs->rootmnt);
 	read_unlock(&current->fs->lock);
 
 	/* Find top-of-tree; don't use "rootfs" filesystem. */
@@ -336,34 +336,43 @@
 		goto rap_fail;
 
 	write_lock(&current->fs->lock);
-	mntput(current->fs->pwdmnt);
+
+	current->fs->umask = comm_datap->comm_umask;
+
+	dput(current->fs->root);
+	current->fs->root = root;
+
 	dput(current->fs->pwd);
-	current->fs->pwdmnt = pwdmnt;
 	current->fs->pwd = pwd;
+
 	if (altroot) {
-		mntput(current->fs->altrootmnt);
 		dput(current->fs->altroot);
-		current->fs->altrootmnt = altrootmnt;
 		current->fs->altroot = altroot;
 	}
+
 	mntput(current->fs->rootmnt);
-	dput(current->fs->root);
 	current->fs->rootmnt = rootmnt;
-	current->fs->root = root;
-	current->fs->umask = comm_datap->comm_umask;
+
+	mntput(current->fs->pwdmnt);
+	current->fs->pwdmnt = pwdmnt;
+
+	if (altroot) {
+		mntput(current->fs->altrootmnt);
+		current->fs->altrootmnt = altrootmnt;
+	}
 	write_unlock(&current->fs->lock);
 
 	return 0;
 
 rap_fail:
-	mntput(rootmnt);
 	dput(root);
+	mntput(rootmnt);
 ap_fail:
-	mntput(altrootmnt);
 	dput(altroot);
+	mntput(altrootmnt);
 p_fail:
-	mntput(pwdmnt);
 	dput(pwd);
+	mntput(pwdmnt);
 fail:
 	return error;
 }

Index: dvp_pvpops.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/vproc/dvp_pvpops.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- dvp_pvpops.c	17 Dec 2009 05:46:50 -0000	1.43
+++ dvp_pvpops.c	17 Dec 2009 06:43:51 -0000	1.44
@@ -4356,7 +4356,7 @@
 {
 	struct pvproc *pvp = PVP(v);
 	struct rpvpop_args rargs;
-	int ret, error = -ENOENT;
+	int ret, error;
 	ssi_procstate_t pstate;
 	char *path = NULL;
 	int pathlen = PATH_MAX + 1;
@@ -4415,8 +4415,10 @@
 	 * Perform operation locally.
 	 */
 #ifdef VPROC_HOLD_ZERO_GET_TASK
-	if (!PV_IS_ALIVE(pvp))
+	if (!PV_IS_ALIVE(pvp)) {
+		error = -ENOENT;
 		goto out;
+	}
 #else
 #ifdef VPROC_RW_LOCK
 	VPROC_LOCK_SHARED(v, "pvpop_proc_readlink");
@@ -4429,6 +4431,7 @@
 #else
 		VPROC_UNLOCK_EXCL(v, "pvpop_proc_readlink");
 #endif
+		error = -ENOENT;
 		goto out;
 	}
 	get_task_struct(pvp->pvp_pproc);
@@ -4519,7 +4522,7 @@
 {
 	struct pvproc *pvp = PVP(v);
 	struct rpvpop_args rargs;
-	int ret, error = 0;
+	int ret, error;
 	int fd, num;
 	struct files_struct *files;
 	struct task_struct *task;
@@ -4565,8 +4568,10 @@
 	*buflen = 0;
 	num = 0;
 #ifdef VPROC_HOLD_ZERO_GET_TASK
-	if (!PV_IS_ALIVE(pvp))
+	if (!PV_IS_ALIVE(pvp)) {
+		error = -ENOENT;
 		goto out;
+	}
 	task = pvp->pvp_pproc;
 #else
 #ifdef VPROC_RW_LOCK
@@ -4581,6 +4586,7 @@
 #else
 		VPROC_UNLOCK_EXCL(v, "pvpop_proc_readfd");
 #endif
+		error = -ENOENT;
 		goto out;
 	}
 #endif
@@ -4887,8 +4893,7 @@
 {
 	struct rpvpop_args rargs;
 	ssi_procstate_t pstate;
-	int ret = 0;
-	int error = 0;
+	int ret = 0, error;
 
 	/*
 	 * Take the movement lock to prevent migration while this

Index: nd_carelist.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/vproc/nd_carelist.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- nd_carelist.c	17 Dec 2009 05:46:50 -0000	1.10
+++ nd_carelist.c	17 Dec 2009 06:43:51 -0000	1.11
@@ -125,9 +125,10 @@
 	vproc_caredata_t *dest_vcdp,
 	vproc_caredata_t *src_vcdp)
 {
-	*dest_vcdp = *src_vcdp;
 #ifdef VPROC_ND_CARELIST_RACE_FIX
-	wmb();
+	memcpy(dest_vcdp, src_vcdp, sizeof(vproc_caredata_t));
+#else
+	*dest_vcdp = *src_vcdp;
 #endif
 	dest_vcdp->vcd_next = NULL;
 	dest_vcdp->vcd_prev = NULL;
@@ -195,14 +196,13 @@
 		vchp->vch_caredatap = vcdp->vcd_next;
 	if (vcdp->vcd_next)
 		vcdp->vcd_next->vcd_prev = vcdp->vcd_prev;
-
-	vchp->vch_carecount--;
-
 #ifdef VPROC_ND_CARELIST_RACE_FIX
-	mb();
+	rmb();
 #endif
 	vcdp->vcd_prev = NULL;
 	vcdp->vcd_next = NULL;
+
+	vchp->vch_carecount--;
 }
 
 /* Caller holds vproc_objhash_lock or
@@ -372,7 +372,7 @@
 		vchp->vch_next->vch_prev = vchp->vch_prev;
 
 #ifdef VPROC_ND_CARELIST_RACE_FIX
-	mb();
+	rmb();
 #endif
 	vchp->vch_prev = NULL;
 	vchp->vch_next = NULL;

Index: as_xscribe.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/vproc/as_xscribe.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- as_xscribe.c	27 Oct 2009 03:18:29 -0000	1.18
+++ as_xscribe.c	17 Dec 2009 06:43:51 -0000	1.19
@@ -593,7 +593,7 @@
 {
 	u_long datasize;
 	u_long newsize;
-	struct mm_struct *mm;
+	struct mm_struct *mm = NULL;
 	struct vm_area_struct *vma;
 	struct task_struct *p;
 	struct vproc *v = NULL;
@@ -602,7 +602,6 @@
 	int i;
 
 	reopen_op = ASX_TO_REOP_OP(op);
-	*error = 0;
 	avap->ava_data.ava_data_len = 0;
 	avap->ava_data.ava_data_val = kmalloc(AS_VMA_MAX * sizeof(as_vma_info),
 					      GFP_USER);
@@ -611,14 +610,32 @@
 		goto out;
 	}
 	v = VPROCPTR(pid);
+#ifdef TASK_HOLD_VPROC
+	if (unlikely(v == NULL)) {
+		*error = -ESRCH;
+		goto out;
+	}
+	VPROC_LOCK_FLAG(v, "ras_pull_vma_info");
+	if (unlikely(!(PVP(v)->pvp_flag & PV_IS_LOCAL))) {
+		/* Process migrated */
+		VPROC_UNLOCK_FLAG(v, "ras_pull_vma_info");
+		*error = -ESRCH;
+		goto out;
+	}
+	p = PVP(v)->pvp_pproc;
+	get_task_struct(p);
+	VPROC_UNLOCK_FLAG(v, "ras_pull_vma_info");
+	mm = get_task_mm(p);
+	put_task_struct(p);
+	if (!mm) {
+		*error = -EAGAIN;
+		goto out;
+	}
+#else
 	SSI_ASSERT(v);
 	if (v) {
 		p = PVP(v)->pvp_pproc;
-#ifdef TASK_HOLD_VPROC
-		SSI_ASSERT(PVP(v)->pvp_flag & PV_IS_LOCAL);
-#else
 		SSI_ASSERT(p);
-#endif
 	} else
 		p = NULL;
 	if (!p) {
@@ -626,6 +643,8 @@
 		goto out;
 	}
 	mm = p->mm;
+#endif /* !TASK_HOLD_VPROC */
+	*error = 0;
 	down_read(&mm->mmap_sem);
 	datasize = 0;
 	for (vma = mm->mmap;
@@ -670,6 +689,10 @@
  out_unlock:
 	up_read(&mm->mmap_sem);
  out:
+#ifdef TASK_HOLD_VPROC
+	if (mm)
+		mmput(mm);
+#endif
 #ifdef VPROC_RELEASE__REFCNT_RACE_FIX
 	if (v)
 		VPROC_RELE(v, "ras_pull_vma_info");
@@ -774,7 +797,7 @@
 		 enum asx_op op, u_long *addr, as_pg_info **apipp,
 		 int *apipp_len)
 {
-	struct mm_struct *mm;
+	struct mm_struct *mm = NULL;
 	struct vm_area_struct *vma;
 	struct task_struct *p;
 	struct vproc *v = NULL;
@@ -789,7 +812,6 @@
 	int i;
 
 	asx_hist2(7, pid, (short)__LINE__,  *addr, 0, 0, 0, 0);
-	*error = 0;
 	*apipp_len = 0;
 	apip = *apipp = kmalloc(AS_PAGE_MAX * sizeof(as_pg_info), GFP_USER);
 	if (!apip) {
@@ -798,14 +820,32 @@
 	}
 	apip->api_deactivate = (op == ASX_MIGRATE);
 	v = VPROCPTR(pid);
+#ifdef TASK_HOLD_VPROC
+	if (unlikely(v == NULL)) {
+		*error = -ESRCH;
+		goto out;
+	}
+	VPROC_LOCK_FLAG(v, "ras_pull_pg_info");
+	if (unlikely(!(PVP(v)->pvp_flag & PV_IS_LOCAL))) {
+		/* Process migrated */
+		VPROC_UNLOCK_FLAG(v, "ras_pull_pg_info");
+		*error = -ESRCH;
+		goto out;
+	}
+	p = PVP(v)->pvp_pproc;
+	get_task_struct(p);
+	VPROC_UNLOCK_FLAG(v, "ras_pull_pg_info");
+	mm = get_task_mm(p);
+	put_task_struct(p);
+	if (!mm) {
+		*error = -EAGAIN;
+		goto out;
+	}
+#else
 	SSI_ASSERT(v);
 	if (v) {
 		p = PVP(v)->pvp_pproc;
-#ifdef TASK_HOLD_VPROC
-		SSI_ASSERT(PVP(v)->pvp_flag & PV_IS_LOCAL);
-#else
 		SSI_ASSERT(p);
-#endif
 	} else
 		p = NULL;
 	if (!p) {
@@ -813,11 +853,13 @@
 		goto out;
 	}
 	mm = p->mm;
+#endif /* !TASK_HOLD_VPROC */
+	*error = 0;
 	start = 0;
  loop:
 	let_go = run_over_maxchunk;
 	down_read(&mm->mmap_sem);
-	spin_lock(&mm->page_table_lock);
+	//spin_lock(&mm->page_table_lock);
 	for (vma = mm->mmap; vma; vma = vma->vm_next) {
 		if (*addr >= vma->vm_end)
 			continue;
@@ -832,6 +874,8 @@
 			*error = -EBUSY;
 			goto out_unlock;
 		}
+
+		spin_lock(&mm->page_table_lock);
 		pgdir = pgd_offset(mm, start);
 		for (*addr = start; *addr < vma->vm_end;
 		     *addr = pgd_end, pgdir++) {
@@ -850,14 +894,21 @@
 			*error = as_pull_pgdir(pid, apip, apipp_len,
 					       mm, vma, isprivate,
 					       addr, pgdir, pgd_end);
-			if (*error)
+			if (*error) {
+				spin_unlock(&mm->page_table_lock);
 				goto out_unlock;
+			}
 		}
+		spin_unlock(&mm->page_table_lock);
 	}
  out_unlock:
-	spin_unlock(&mm->page_table_lock);
+	//spin_unlock(&mm->page_table_lock);
 	up_read(&mm->mmap_sem);
  out:
+#ifdef TASK_HOLD_VPROC
+	if (mm)
+		mmput(mm);
+#endif
 #ifdef VPROC_RELEASE__REFCNT_RACE_FIX
 	if (v)
 		VPROC_RELE(v, "ras_pull_pg_info");


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.