[Ocfs2-commits] mfasheh commits r2456 - in trunk/fs/ocfs2: . dlm

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Jul 1 19:18:32 CDT 2005


Author: mfasheh
Signed-off-by: manish
Date: 2005-07-01 19:18:30 -0500 (Fri, 01 Jul 2005)
New Revision: 2456

Modified:
   trunk/fs/ocfs2/dlm/dlmdomain.c
   trunk/fs/ocfs2/dlm/dlmfs.c
   trunk/fs/ocfs2/dlm/userdlm.c
   trunk/fs/ocfs2/dlmglue.c
Log:
* Have register_domain return an ERR_PTR - this will hopefully bubble up
  more meaningful errors to userspace.

Signed-off-by: manish



Modified: trunk/fs/ocfs2/dlm/dlmdomain.c
===================================================================
--- trunk/fs/ocfs2/dlm/dlmdomain.c	2005-07-02 00:12:02 UTC (rev 2455)
+++ trunk/fs/ocfs2/dlm/dlmdomain.c	2005-07-02 00:18:30 UTC (rev 2456)
@@ -32,6 +32,7 @@
 #include <linux/init.h>
 #include <linux/spinlock.h>
 #include <linux/delay.h>
+#include <linux/err.h>
 
 #include "cluster/heartbeat.h"
 #include "cluster/nodemanager.h"
@@ -1266,6 +1267,7 @@
 	struct dlm_ctxt *new_ctxt = NULL;
 
 	if (strlen(domain) > O2NM_MAX_NAME_LEN) {
+		ret = -ENAMETOOLONG;
 		mlog(ML_ERROR, "domain name length too long\n");
 		goto leave;
 	}
@@ -1273,6 +1275,7 @@
 	if (!o2hb_check_local_node_heartbeating()) {
 		mlog(ML_ERROR, "the local node has not been configured, or is "
 		     "not heartbeating\n");
+		ret = -EPROTO;
 		goto leave;
 	}
 
@@ -1280,8 +1283,11 @@
 
 retry:
 	dlm = NULL;
-	if (signal_pending(current))
+	if (signal_pending(current)) {
+		ret = -ERESTARTSYS;
+		mlog_errno(ret);
 		goto leave;
+	}
 
 	spin_lock(&dlm_domain_lock);
 
@@ -1301,6 +1307,8 @@
 		dlm->num_joins++;
 
 		spin_unlock(&dlm_domain_lock);
+
+		ret = 0;
 		goto leave;
 	}
 
@@ -1311,6 +1319,9 @@
 		new_ctxt = dlm_alloc_ctxt(domain, key);
 		if (new_ctxt)
 			goto retry;
+
+		ret = -ENOMEM;
+		mlog_errno(ret);
 		goto leave;
 	}
 
@@ -1326,13 +1337,17 @@
 	if (ret) {
 		mlog_errno(ret);
 		dlm_put(dlm);
-		dlm = NULL;
+		goto leave;
 	}
 
+	ret = 0;
 leave:
 	if (new_ctxt)
 		dlm_free_ctxt_mem(new_ctxt);
 
+	if (ret < 0)
+		dlm = ERR_PTR(ret);
+
 	return dlm;
 }
 EXPORT_SYMBOL_GPL(dlm_register_domain);

Modified: trunk/fs/ocfs2/dlm/dlmfs.c
===================================================================
--- trunk/fs/ocfs2/dlm/dlmfs.c	2005-07-02 00:12:02 UTC (rev 2455)
+++ trunk/fs/ocfs2/dlm/dlmfs.c	2005-07-02 00:18:30 UTC (rev 2456)
@@ -419,13 +419,14 @@
  */
 /* SMP-safe */
 static int dlmfs_mkdir(struct inode * dir,
-			    struct dentry * dentry,
-			    int mode)
+		       struct dentry * dentry,
+		       int mode)
 {
 	int status;
 	struct inode *inode = NULL;
 	struct qstr *domain = &dentry->d_name;
 	struct dlmfs_inode_private *ip;
+	struct dlm_ctxt *dlm;
 
 	mlog(0, "mkdir %.*s\n", domain->len, domain->name);
 
@@ -445,13 +446,14 @@
 
 	ip = DLMFS_I(inode);
 
-	ip->ip_dlm = user_dlm_register_context(domain);
-	if (!ip->ip_dlm) {
-		status = -ENOMEM;
-		mlog(ML_ERROR, "could not register domain \"%.*s\"\n",
-		     domain->len, domain->name);
+	dlm = user_dlm_register_context(domain);
+	if (IS_ERR(dlm)) {
+		status = PTR_ERR(dlm);
+		mlog(ML_ERROR, "Error %d could not register domain \"%.*s\"\n",
+		     status, domain->len, domain->name);
 		goto bail;
 	}
+	ip->ip_dlm = dlm;
 
 	dir->i_nlink++;
 	d_instantiate(dentry, inode);

Modified: trunk/fs/ocfs2/dlm/userdlm.c
===================================================================
--- trunk/fs/ocfs2/dlm/userdlm.c	2005-07-02 00:12:02 UTC (rev 2455)
+++ trunk/fs/ocfs2/dlm/userdlm.c	2005-07-02 00:18:30 UTC (rev 2456)
@@ -637,7 +637,7 @@
 	domain = kmalloc(name->len + 1, GFP_KERNEL);
 	if (!domain) {
 		mlog_errno(-ENOMEM);
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 	}
 
 	dlm_key = crc32(0, name->name, name->len);
@@ -645,6 +645,8 @@
 	snprintf(domain, name->len + 1, "%.*s", name->len, name->name);
 
 	dlm = dlm_register_domain(domain, dlm_key);
+	if (IS_ERR(dlm))
+		mlog_errno(PTR_ERR(dlm));
 
 	kfree(domain);
 	return dlm;

Modified: trunk/fs/ocfs2/dlmglue.c
===================================================================
--- trunk/fs/ocfs2/dlmglue.c	2005-07-02 00:12:02 UTC (rev 2455)
+++ trunk/fs/ocfs2/dlmglue.c	2005-07-02 00:18:30 UTC (rev 2456)
@@ -1745,7 +1745,7 @@
 {
 	int status;
 	u32 dlm_key;
-	struct dlm_ctxt *dlm = NULL;
+	struct dlm_ctxt *dlm;
 
 	mlog_entry_void();
 
@@ -1765,9 +1765,8 @@
 
 	/* for now, uuid == domain */
 	dlm = dlm_register_domain(osb->uuid_str, dlm_key);
-	if (!dlm) {
-		/* This is a best guess on return value... */
-		status = -ENOMEM;
+	if (IS_ERR(dlm)) {
+		status = PTR_ERR(dlm);
 		mlog_errno(status);
 		goto bail;
 	}



More information about the Ocfs2-commits mailing list