Skip to contentSkip to conversation

ocfs2: Add missing iput() during error handling in ocfs2_dentry_attach_lock()

PATCH New Sunil Mushran 1 participant 3 messages May 4, 2009 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 ocfs2: Add missing iput() during error handling in ocfs2_dentry_attach_lock()

Mainline commit a5a0a630922a2f6a774b6dac19f70cb5abd86bb0

In ocfs2_dentry_attach_lock(), if unable to get the dentry lock, we need to call iput(inode) because a failure here means no d_instantiate(), which means the normally matching iput() will not be called during dput(dentry).

This patch fixes the oops that accompanies the following message:
(3996,1):dlm_empty_lockres:2708 ERROR: lockres W00000000000000000a1046b06a4382 still has local locks! kernel BUG in dlm_empty_lockres at /rpmbuild/smushran/BUILD/ocfs2-1.4.2/fs/ocfs2/dlm/dlmmaster.c:2709!

---
 fs/ocfs2/dcache.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
fs/ocfs2/dcache.c +15 -0
index fab4911..6bf070a 100644
@@ -289,6 +289,21 @@ out_attach:
 	else
 		mlog_errno(ret);
 
+	/*
+	 * In case of error, manually free the allocation and do the iput().
+	 * We need to do this because error here means no d_instantiate(),
+	 * which means iput() will not be called during dput(dentry).
+	 */
+	if (ret < 0 && !alias) {
+		ocfs2_lock_res_free(&dl->dl_lockres);
+		BUG_ON(dl->dl_count != 1);
+		spin_lock(&dentry_attach_lock);
+		dentry->d_fsdata = NULL;
+		spin_unlock(&dentry_attach_lock);
+		kfree(dl);
+		iput(inode);
+	}
+
 	dput(alias);
 
 	return ret;
Signature · 1 line
1.5.6.3
#1 lore raw

PATCH 2/3 ocfs2: Hold mmap_sem while calling get_user_pages()

From: Kurt Garloff <[email protected]>

This patch adds locking around get_user_pages() in ocfs2_get_write_source() so as to prevent the vmas from changing underneath.

Fixes Novell bugzilla# 485827

---
 fs/ocfs2/file.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/ocfs2/file.c +2 -0
index 0c8e03a..267389c 100644
@@ -1967,9 +1967,11 @@ static struct page * ocfs2_get_write_source(char **ret_src_buf,
 		 * of the meta data locks in order to preserve locking
 		 * order in case of page fault.
 		 */
+		down_read(&current->mm->mmap_sem);
 		ret = get_user_pages(current, current->mm,
 				     (unsigned long)buf & PAGE_CACHE_MASK, 1,
 				     0, 0, &src_page, NULL);
+		up_read(&current->mm->mmap_sem);
 		if (ret == 1)
 			*ret_src_buf = kmap(src_page) + off;
 		else
Signature · 1 line
1.5.6.3
#2 lore raw

PATCH 3/3 ocfs2: Up version to 1.4.2

In reply to Sunil Mushran

Up version to 1.4.2. Also increase the required tools version to 1.4.2 as it includes some fixes for inline data.

---
 configure.in |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
configure.in +2 -2
index b7efa1b..34d6e74 100644
@@ -9,11 +9,11 @@ AC_SUBST(PACKAGE)
 # Adjust these for the software version.
 MAJOR_VERSION=1
 MINOR_VERSION=4
-MICRO_VERSION=1
+MICRO_VERSION=2
 EXTRA_VERSION=
 
 # Required version of ocfs-tools
-TOOLS_REQUIRED_VERSION=1.4.1
+TOOLS_REQUIRED_VERSION=1.4.2
 
 DIST_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
 if test -z "$EXTRA_VERSION"; then
Signature · 1 line
1.5.6.3