public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Waiman Long <Waiman.Long@hp.com>
To: Dave Chinner <david@fromorbit.com>, xfs@oss.sgi.com
Cc: Waiman Long <Waiman.Long@hp.com>, linux-kernel@vger.kernel.org
Subject: [PATCH] xfs: call xfs_idestroy_fork() in xfs_ilock() critical section
Date: Wed, 22 Apr 2015 13:33:41 -0400	[thread overview]
Message-ID: <1429724021-7675-1-git-send-email-Waiman.Long@hp.com> (raw)

The commit f7be2d7f594cbc ("xfs: push down inactive transaction
mgmt for truncate") refactored the xfs_inactive() function
in fs/xfs/xfs_inode.c.  However, it also moved the call to
xfs_idestroy_fork() from inside the xfs_ilock() critical section to
outside. That was causing memory corruption and strange failures like
deferencing NULL pointers in some circumstances.

This patch moves the xfs_idestroy_fork() call back into an xfs_ilock()
critical section to avoid memory corruption problem.

Signed-off-by: Waiman Long <Waiman.Long@hp.com>
---
 fs/xfs/xfs_inode.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 6163767..31850fb 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1900,8 +1900,11 @@ xfs_inactive(
 			return;
 	}
 
-	if (ip->i_afp)
+	if (ip->i_afp) {
+		xfs_ilock(ip, XFS_ILOCK_EXCL);
 		xfs_idestroy_fork(ip, XFS_ATTR_FORK);
+		xfs_iunlock(ip, XFS_ILOCK_EXCL);
+	}
 
 	ASSERT(ip->i_d.di_anextents == 0);
 
-- 
1.7.1

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

             reply	other threads:[~2015-04-22 17:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-22 17:33 Waiman Long [this message]
2015-04-22 19:11 ` [PATCH] xfs: call xfs_idestroy_fork() in xfs_ilock() critical section Brian Foster
2015-04-22 20:28   ` Waiman Long
2015-04-22 23:17 ` Dave Chinner
2015-04-23 12:21   ` Brian Foster
2015-04-23 22:08     ` Dave Chinner
2015-04-24 11:57       ` Brian Foster
2015-04-26 22:56         ` Dave Chinner
2015-04-23 17:14   ` Waiman Long

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1429724021-7675-1-git-send-email-Waiman.Long@hp.com \
    --to=waiman.long@hp.com \
    --cc=david@fromorbit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox