public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] xfs: don't serialise direct IO reads on page cache checks
  2011-08-25  7:17 [PATCH 0/6] xfs: patch queue for Linux 3.2 Dave Chinner
@ 2011-08-25  7:17 ` Dave Chinner
  0 siblings, 0 replies; 20+ messages in thread
From: Dave Chinner @ 2011-08-25  7:17 UTC (permalink / raw)
  To: xfs

From: Dave Chinner <dchinner@redhat.com>

There is no need to grab the i_mutex of the IO lock in exclusive
mode if we don't need to invalidate the page cache. Taking these
locks on every direct IO effective serialises them as taking the IO
lock in exclusive mode has to wait for all shared holders to drop
the lock. That only happens when IO is complete, so effective it
prevents dispatch of concurrent direct IO reads to the same inode.

Fix this by taking the IO lock shared to check the page cache state,
and only then drop it and take the IO lock exclusively if there is
work to be done. Hence for the normal direct IO case, no exclusive
locking will occur.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Tested-by: Joern Engel <joern@logfs.org>
Reviewed-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_file.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 2fdc6d1..a1dea10 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -317,7 +317,19 @@ xfs_file_aio_read(
 	if (XFS_FORCED_SHUTDOWN(mp))
 		return -EIO;
 
-	if (unlikely(ioflags & IO_ISDIRECT)) {
+	/*
+	 * Locking is a bit tricky here. If we take an exclusive lock
+	 * for direct IO, we effectively serialise all new concurrent
+	 * read IO to this file and block it behind IO that is currently in
+	 * progress because IO in progress holds the IO lock shared. We only
+	 * need to hold the lock exclusive to blow away the page cache, so
+	 * only take lock exclusively if the page cache needs invalidation.
+	 * This allows the normal direct IO case of no page cache pages to
+	 * proceeed concurrently without serialisation.
+	 */
+	xfs_rw_ilock(ip, XFS_IOLOCK_SHARED);
+	if ((ioflags & IO_ISDIRECT) && inode->i_mapping->nrpages) {
+		xfs_rw_iunlock(ip, XFS_IOLOCK_SHARED);
 		xfs_rw_ilock(ip, XFS_IOLOCK_EXCL);
 
 		if (inode->i_mapping->nrpages) {
@@ -330,8 +342,7 @@ xfs_file_aio_read(
 			}
 		}
 		xfs_rw_ilock_demote(ip, XFS_IOLOCK_EXCL);
-	} else
-		xfs_rw_ilock(ip, XFS_IOLOCK_SHARED);
+	}
 
 	trace_xfs_file_read(ip, size, iocb->ki_pos, ioflags);
 
-- 
1.7.5.4

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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 0/6] XFS update for 3.1-stable
@ 2011-11-23 21:38 Ben Myers
  2011-11-23 21:38 ` [PATCH 1/6] xfs: don't serialise direct IO reads on page cache checks Ben Myers
                   ` (6 more replies)
  0 siblings, 7 replies; 20+ messages in thread
From: Ben Myers @ 2011-11-23 21:38 UTC (permalink / raw)
  To: stable; +Cc: xfs

This is a series of XFS fixes from current mainline which is important for
3.1-stable.  Note that it is the same patch set that Christoph submitted for
3.0-stable, minus the first three patches which are already included in 3.1.

My QA came out ok with these six patches atop 3.1.y.  Apologies to those who
got this mail twice. 

Thanks,
	Ben



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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/6] xfs: don't serialise direct IO reads on page cache checks
  2011-11-23 21:38 [PATCH 0/6] XFS update for 3.1-stable Ben Myers
@ 2011-11-23 21:38 ` Ben Myers
  2011-11-23 21:38 ` [PATCH 2/6] xfs: avoid direct I/O write vs buffered I/O race Ben Myers
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Ben Myers @ 2011-11-23 21:38 UTC (permalink / raw)
  To: stable; +Cc: Alex Elder, Dave Chinner, xfs

From: Dave Chinner <dchinner@redhat.com>

>From c83a4e86f777d08e247592291de429d827c1287a

There is no need to grab the i_mutex of the IO lock in exclusive
mode if we don't need to invalidate the page cache. Taking these
locks on every direct IO effective serialises them as taking the IO
lock in exclusive mode has to wait for all shared holders to drop
the lock. That only happens when IO is complete, so effective it
prevents dispatch of concurrent direct IO reads to the same inode.

Fix this by taking the IO lock shared to check the page cache state,
and only then drop it and take the IO lock exclusively if there is
work to be done. Hence for the normal direct IO case, no exclusive
locking will occur.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Tested-by: Joern Engel <joern@logfs.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Elder <aelder@sgi.com>
---
 fs/xfs/xfs_file.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 7f7b424..8fd4a07 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -317,7 +317,19 @@ xfs_file_aio_read(
 	if (XFS_FORCED_SHUTDOWN(mp))
 		return -EIO;
 
-	if (unlikely(ioflags & IO_ISDIRECT)) {
+	/*
+	 * Locking is a bit tricky here. If we take an exclusive lock
+	 * for direct IO, we effectively serialise all new concurrent
+	 * read IO to this file and block it behind IO that is currently in
+	 * progress because IO in progress holds the IO lock shared. We only
+	 * need to hold the lock exclusive to blow away the page cache, so
+	 * only take lock exclusively if the page cache needs invalidation.
+	 * This allows the normal direct IO case of no page cache pages to
+	 * proceeed concurrently without serialisation.
+	 */
+	xfs_rw_ilock(ip, XFS_IOLOCK_SHARED);
+	if ((ioflags & IO_ISDIRECT) && inode->i_mapping->nrpages) {
+		xfs_rw_iunlock(ip, XFS_IOLOCK_SHARED);
 		xfs_rw_ilock(ip, XFS_IOLOCK_EXCL);
 
 		if (inode->i_mapping->nrpages) {
@@ -330,8 +342,7 @@ xfs_file_aio_read(
 			}
 		}
 		xfs_rw_ilock_demote(ip, XFS_IOLOCK_EXCL);
-	} else
-		xfs_rw_ilock(ip, XFS_IOLOCK_SHARED);
+	}
 
 	trace_xfs_file_read(ip, size, iocb->ki_pos, ioflags);
 
-- 
1.7.8.rc0.46.g5ae0f

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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/6] xfs: avoid direct I/O write vs buffered I/O race
  2011-11-23 21:38 [PATCH 0/6] XFS update for 3.1-stable Ben Myers
  2011-11-23 21:38 ` [PATCH 1/6] xfs: don't serialise direct IO reads on page cache checks Ben Myers
@ 2011-11-23 21:38 ` Ben Myers
  2011-11-23 21:38 ` [PATCH 3/6] xfs: Return -EIO when xfs_vn_getattr() failed Ben Myers
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Ben Myers @ 2011-11-23 21:38 UTC (permalink / raw)
  To: stable; +Cc: Christoph Hellwig, Alex Elder, Christoph Hellwig, xfs

From: Christoph Hellwig <hch@infradead.org>

>From 1d443d87fbda3b1e01d3dba07008ad0064fd8c59

Currently a buffered reader or writer can add pages to the pagecache
while we are waiting for the iolock in xfs_file_dio_aio_write.  Prevent
this by re-checking mapping->nrpages after we got the iolock, and if
nessecary upgrade the lock to exclusive mode.  To simplify this a bit
only take the ilock inside of xfs_file_aio_write_checks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Alex Elder <aelder@sgi.com>
---
 fs/xfs/xfs_file.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 8fd4a07..b7e75c6 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -677,6 +677,7 @@ xfs_file_aio_write_checks(
 	xfs_fsize_t		new_size;
 	int			error = 0;
 
+	xfs_rw_ilock(ip, XFS_ILOCK_EXCL);
 	error = generic_write_checks(file, pos, count, S_ISBLK(inode->i_mode));
 	if (error) {
 		xfs_rw_iunlock(ip, XFS_ILOCK_EXCL | *iolock);
@@ -768,14 +769,24 @@ xfs_file_dio_aio_write(
 		*iolock = XFS_IOLOCK_EXCL;
 	else
 		*iolock = XFS_IOLOCK_SHARED;
-	xfs_rw_ilock(ip, XFS_ILOCK_EXCL | *iolock);
+	xfs_rw_ilock(ip, *iolock);
 
 	ret = xfs_file_aio_write_checks(file, &pos, &count, iolock);
 	if (ret)
 		return ret;
 
+	/*
+	 * Recheck if there are cached pages that need invalidate after we got
+	 * the iolock to protect against other threads adding new pages while
+	 * we were waiting for the iolock.
+	 */
+	if (mapping->nrpages && *iolock == XFS_IOLOCK_SHARED) {
+		xfs_rw_iunlock(ip, *iolock);
+		*iolock = XFS_IOLOCK_EXCL;
+		xfs_rw_ilock(ip, *iolock);
+	}
+
 	if (mapping->nrpages) {
-		WARN_ON(*iolock != XFS_IOLOCK_EXCL);
 		ret = -xfs_flushinval_pages(ip, (pos & PAGE_CACHE_MASK), -1,
 							FI_REMAPF_LOCKED);
 		if (ret)
@@ -820,7 +831,7 @@ xfs_file_buffered_aio_write(
 	size_t			count = ocount;
 
 	*iolock = XFS_IOLOCK_EXCL;
-	xfs_rw_ilock(ip, XFS_ILOCK_EXCL | *iolock);
+	xfs_rw_ilock(ip, *iolock);
 
 	ret = xfs_file_aio_write_checks(file, &pos, &count, iolock);
 	if (ret)
-- 
1.7.8.rc0.46.g5ae0f

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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/6] xfs: Return -EIO when xfs_vn_getattr() failed
  2011-11-23 21:38 [PATCH 0/6] XFS update for 3.1-stable Ben Myers
  2011-11-23 21:38 ` [PATCH 1/6] xfs: don't serialise direct IO reads on page cache checks Ben Myers
  2011-11-23 21:38 ` [PATCH 2/6] xfs: avoid direct I/O write vs buffered I/O race Ben Myers
@ 2011-11-23 21:38 ` Ben Myers
  2011-11-23 21:38 ` [PATCH 4/6] xfs: fix buffer flushing during unmount Ben Myers
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Ben Myers @ 2011-11-23 21:38 UTC (permalink / raw)
  To: stable; +Cc: Alex Elder, Mitsuo Hayasaka, xfs

From: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>

>From 65ed79f5114ca0bad494e5b858f47615c337c492

An attribute of inode can be fetched via xfs_vn_getattr() in XFS.
Currently it returns EIO, not negative value, when it failed.  As a
result, the system call returns not negative value even though an
error occured. The stat(2), ls and mv commands cannot handle this
error and do not work correctly.

This patch fixes this bug, and returns -EIO, not EIO when an error
is detected in xfs_vn_getattr().

Signed-off-by: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Elder <aelder@sgi.com>
---
 fs/xfs/xfs_iops.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 673704f..474920b 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -465,7 +465,7 @@ xfs_vn_getattr(
 	trace_xfs_getattr(ip);
 
 	if (XFS_FORCED_SHUTDOWN(mp))
-		return XFS_ERROR(EIO);
+		return -XFS_ERROR(EIO);
 
 	stat->size = XFS_ISIZE(ip);
 	stat->dev = inode->i_sb->s_dev;
-- 
1.7.8.rc0.46.g5ae0f

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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 4/6] xfs: fix buffer flushing during unmount
  2011-11-23 21:38 [PATCH 0/6] XFS update for 3.1-stable Ben Myers
                   ` (2 preceding siblings ...)
  2011-11-23 21:38 ` [PATCH 3/6] xfs: Return -EIO when xfs_vn_getattr() failed Ben Myers
@ 2011-11-23 21:38 ` Ben Myers
  2011-11-23 21:38 ` [PATCH 5/6] xfs: Fix possible memory corruption in xfs_readlink Ben Myers
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Ben Myers @ 2011-11-23 21:38 UTC (permalink / raw)
  To: stable; +Cc: Christoph Hellwig, Alex Elder, Christoph Hellwig, xfs

From: Christoph Hellwig <hch@infradead.org>

>From a063aff275e3c514da54b293e0f86c7c9c5b3ec2

The code to flush buffers in the umount code is a bit iffy: we first
flush all delwri buffers out, but then might be able to queue up a
new one when logging the sb counts.  On a normal shutdown that one
would get flushed out when doing the synchronous superblock write in
xfs_unmountfs_writesb, but we skip that one if the filesystem has
been shut down.

Fix this by moving the delwri list flushing until just before unmounting
the log, and while we're at it also remove the superflous delwri list
and buffer lru flusing for the rt and log device that can never have
cached or delwri buffers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reported-by: Amit Sahrawat <amit.sahrawat83@gmail.com>
Tested-by: Amit Sahrawat <amit.sahrawat83@gmail.com>
Signed-off-by: Alex Elder <aelder@sgi.com>
---
 fs/xfs/xfs_buf.h   |    1 -
 fs/xfs/xfs_mount.c |   29 ++++++++++-------------------
 2 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index 620972b..8e8b06b 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -320,7 +320,6 @@ extern struct list_head *xfs_get_buftarg_list(void);
 #define xfs_getsize_buftarg(buftarg)	block_size((buftarg)->bt_bdev)
 #define xfs_readonly_buftarg(buftarg)	bdev_read_only((buftarg)->bt_bdev)
 
-#define xfs_binval(buftarg)		xfs_flush_buftarg(buftarg, 1)
 #define XFS_bflush(buftarg)		xfs_flush_buftarg(buftarg, 1)
 
 #endif	/* __XFS_BUF_H__ */
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 0081657..d4d5775 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -44,9 +44,6 @@
 #include "xfs_trace.h"
 
 
-STATIC void	xfs_unmountfs_wait(xfs_mount_t *);
-
-
 #ifdef HAVE_PERCPU_SB
 STATIC void	xfs_icsb_balance_counter(xfs_mount_t *, xfs_sb_field_t,
 						int);
@@ -1496,11 +1493,6 @@ xfs_unmountfs(
 	 */
 	xfs_log_force(mp, XFS_LOG_SYNC);
 
-	xfs_binval(mp->m_ddev_targp);
-	if (mp->m_rtdev_targp) {
-		xfs_binval(mp->m_rtdev_targp);
-	}
-
 	/*
 	 * Unreserve any blocks we have so that when we unmount we don't account
 	 * the reserved free space as used. This is really only necessary for
@@ -1526,7 +1518,16 @@ xfs_unmountfs(
 		xfs_warn(mp, "Unable to update superblock counters. "
 				"Freespace may not be correct on next mount.");
 	xfs_unmountfs_writesb(mp);
-	xfs_unmountfs_wait(mp); 		/* wait for async bufs */
+
+	/*
+	 * Make sure all buffers have been flushed and completed before
+	 * unmounting the log.
+	 */
+	error = xfs_flush_buftarg(mp->m_ddev_targp, 1);
+	if (error)
+		xfs_warn(mp, "%d busy buffers during unmount.", error);
+	xfs_wait_buftarg(mp->m_ddev_targp);
+
 	xfs_log_unmount_write(mp);
 	xfs_log_unmount(mp);
 	xfs_uuid_unmount(mp);
@@ -1537,16 +1538,6 @@ xfs_unmountfs(
 	xfs_free_perag(mp);
 }
 
-STATIC void
-xfs_unmountfs_wait(xfs_mount_t *mp)
-{
-	if (mp->m_logdev_targp != mp->m_ddev_targp)
-		xfs_wait_buftarg(mp->m_logdev_targp);
-	if (mp->m_rtdev_targp)
-		xfs_wait_buftarg(mp->m_rtdev_targp);
-	xfs_wait_buftarg(mp->m_ddev_targp);
-}
-
 int
 xfs_fs_writable(xfs_mount_t *mp)
 {
-- 
1.7.8.rc0.46.g5ae0f

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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 5/6] xfs: Fix possible memory corruption in xfs_readlink
  2011-11-23 21:38 [PATCH 0/6] XFS update for 3.1-stable Ben Myers
                   ` (3 preceding siblings ...)
  2011-11-23 21:38 ` [PATCH 4/6] xfs: fix buffer flushing during unmount Ben Myers
@ 2011-11-23 21:38 ` Ben Myers
  2011-11-23 21:38 ` [PATCH 6/6] xfs: use doalloc flag in xfs_qm_dqattach_one() Ben Myers
  2011-11-28 11:00 ` [PATCH 0/6] XFS update for 3.1-stable Christoph Hellwig
  6 siblings, 0 replies; 20+ messages in thread
From: Ben Myers @ 2011-11-23 21:38 UTC (permalink / raw)
  To: stable; +Cc: Alex Elder, Carlos Maiolino, xfs

From: Carlos Maiolino <cmaiolino@redhat.com>

>From 13072258732bcf349649caa162f34c8d37b4f134

Fixes a possible memory corruption when the link is larger than
MAXPATHLEN and XFS_DEBUG is not enabled. This also remove the
S_ISLNK assert, since the inode mode is checked previously in
xfs_readlink_by_handle() and via VFS.

Updated to address concerns raised by Ben Hutchings about the loose
attention paid to 32- vs 64-bit values, and the lack of handling a
potentially negative pathlen value:
 - Changed type of "pathlen" to be xfs_fsize_t, to match that of
   ip->i_d.di_size
 - Added checking for a negative pathlen to the too-long pathlen
   test, and generalized the message that gets reported in that case
   to reflect the change
As a result, if a negative pathlen were encountered, this function
would return EFSCORRUPTED (and would fail an assertion for a debug
build)--just as would a too-long pathlen.

Signed-off-by: Alex Elder <aelder@sgi.com>
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_vnodeops.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 51fc429..b9e2873 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -113,7 +113,7 @@ xfs_readlink(
 	char		*link)
 {
 	xfs_mount_t	*mp = ip->i_mount;
-	int		pathlen;
+	xfs_fsize_t	pathlen;
 	int		error = 0;
 
 	trace_xfs_readlink(ip);
@@ -123,13 +123,19 @@ xfs_readlink(
 
 	xfs_ilock(ip, XFS_ILOCK_SHARED);
 
-	ASSERT(S_ISLNK(ip->i_d.di_mode));
-	ASSERT(ip->i_d.di_size <= MAXPATHLEN);
-
 	pathlen = ip->i_d.di_size;
 	if (!pathlen)
 		goto out;
 
+	if (pathlen < 0 || pathlen > MAXPATHLEN) {
+		xfs_alert(mp, "%s: inode (%llu) bad symlink length (%lld)",
+			 __func__, (unsigned long long) ip->i_ino,
+			 (long long) pathlen);
+		ASSERT(0);
+		return XFS_ERROR(EFSCORRUPTED);
+	}
+
+
 	if (ip->i_df.if_flags & XFS_IFINLINE) {
 		memcpy(link, ip->i_df.if_u1.if_data, pathlen);
 		link[pathlen] = '\0';
-- 
1.7.8.rc0.46.g5ae0f

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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 6/6] xfs: use doalloc flag in xfs_qm_dqattach_one()
  2011-11-23 21:38 [PATCH 0/6] XFS update for 3.1-stable Ben Myers
                   ` (4 preceding siblings ...)
  2011-11-23 21:38 ` [PATCH 5/6] xfs: Fix possible memory corruption in xfs_readlink Ben Myers
@ 2011-11-23 21:38 ` Ben Myers
  2011-11-28 11:00 ` [PATCH 0/6] XFS update for 3.1-stable Christoph Hellwig
  6 siblings, 0 replies; 20+ messages in thread
From: Ben Myers @ 2011-11-23 21:38 UTC (permalink / raw)
  To: stable; +Cc: Christoph Hellwig, Ben Myers, Alex Elder, Mitsuo Hayasaka, xfs

From: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>

>From bc957c9c7fd2e2c7bc2f3a9d3d2785e27984f01c

The doalloc arg in xfs_qm_dqattach_one() is a flag that indicates
whether a new area to handle quota information will be allocated
if needed. Originally, it was passed to xfs_qm_dqget(), but has
been removed by the following commit (probably by mistake):

	commit 8e9b6e7fa4544ea8a0e030c8987b918509c8ff47
	Author: Christoph Hellwig <hch@lst.de>
	Date:   Sun Feb 8 21:51:42 2009 +0100

	xfs: remove the unused XFS_QMOPT_DQLOCK flag

As the result, xfs_qm_dqget() called from xfs_qm_dqattach_one()
never allocates the new area even if it is needed.

This patch gives the doalloc arg to xfs_qm_dqget() in
xfs_qm_dqattach_one() to fix this problem.

Signed-off-by: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>
Cc: Alex Elder <aelder@sgi.com>
Cc: Christoph Hellwig <hch@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ben Myers <bpm@sgi.com>
---
 fs/xfs/xfs_qm.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 9a0aa76..95ba6dc 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -674,7 +674,8 @@ xfs_qm_dqattach_one(
 	 * disk and we didn't ask it to allocate;
 	 * ESRCH if quotas got turned off suddenly.
 	 */
-	error = xfs_qm_dqget(ip->i_mount, ip, id, type, XFS_QMOPT_DOWARN, &dqp);
+	error = xfs_qm_dqget(ip->i_mount, ip, id, type,
+			     doalloc | XFS_QMOPT_DOWARN, &dqp);
 	if (error)
 		return error;
 
-- 
1.7.8.rc0.46.g5ae0f

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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/6] XFS update for 3.1-stable
  2011-11-23 21:38 [PATCH 0/6] XFS update for 3.1-stable Ben Myers
                   ` (5 preceding siblings ...)
  2011-11-23 21:38 ` [PATCH 6/6] xfs: use doalloc flag in xfs_qm_dqattach_one() Ben Myers
@ 2011-11-28 11:00 ` Christoph Hellwig
  2011-11-28 13:48   ` Greg KH
  6 siblings, 1 reply; 20+ messages in thread
From: Christoph Hellwig @ 2011-11-28 11:00 UTC (permalink / raw)
  To: Ben Myers; +Cc: stable, xfs

On Wed, Nov 23, 2011 at 03:38:07PM -0600, Ben Myers wrote:
> This is a series of XFS fixes from current mainline which is important for
> 3.1-stable.  Note that it is the same patch set that Christoph submitted for
> 3.0-stable, minus the first three patches which are already included in 3.1.
> 
> My QA came out ok with these six patches atop 3.1.y.  Apologies to those who
> got this mail twice. 

The updates looks good to me.

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/6] XFS update for 3.1-stable
  2011-11-28 11:00 ` [PATCH 0/6] XFS update for 3.1-stable Christoph Hellwig
@ 2011-11-28 13:48   ` Greg KH
  2011-11-28 16:54     ` Ben Myers
  0 siblings, 1 reply; 20+ messages in thread
From: Greg KH @ 2011-11-28 13:48 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Ben Myers, stable, xfs

On Mon, Nov 28, 2011 at 06:00:43AM -0500, Christoph Hellwig wrote:
> On Wed, Nov 23, 2011 at 03:38:07PM -0600, Ben Myers wrote:
> > This is a series of XFS fixes from current mainline which is important for
> > 3.1-stable.  Note that it is the same patch set that Christoph submitted for
> > 3.0-stable, minus the first three patches which are already included in 3.1.
> > 
> > My QA came out ok with these six patches atop 3.1.y.  Apologies to those who
> > got this mail twice. 
> 
> The updates looks good to me.

I never saw this series once, can someone please resend them as I don't
see them anywhere.

confused,

greg k-h

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/6] XFS update for 3.1-stable
  2011-11-28 13:48   ` Greg KH
@ 2011-11-28 16:54     ` Ben Myers
  2011-11-28 21:40       ` Greg KH
  0 siblings, 1 reply; 20+ messages in thread
From: Ben Myers @ 2011-11-28 16:54 UTC (permalink / raw)
  To: Greg KH; +Cc: Christoph Hellwig, stable, xfs

Hey Greg,

On Mon, Nov 28, 2011 at 10:48:29PM +0900, Greg KH wrote:
> On Mon, Nov 28, 2011 at 06:00:43AM -0500, Christoph Hellwig wrote:
> > On Wed, Nov 23, 2011 at 03:38:07PM -0600, Ben Myers wrote:
> > > This is a series of XFS fixes from current mainline which is important for
> > > 3.1-stable.  Note that it is the same patch set that Christoph submitted for
> > > 3.0-stable, minus the first three patches which are already included in 3.1.
> > > 
> > > My QA came out ok with these six patches atop 3.1.y.  Apologies to those who
> > > got this mail twice. 
> > 
> > The updates looks good to me.
> 
> I never saw this series once, can someone please resend them as I don't
> see them anywhere.

The first time I sent this 3.1.y series you were not on the --to=, which
is why some people got the series twice but you didn't.  Sorry for the
confusion. 

Do you need the series for 3.0 to be resubmitted?

Thanks,
	Ben

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/6] XFS update for 3.1-stable
  2011-11-28 16:54     ` Ben Myers
@ 2011-11-28 21:40       ` Greg KH
  2011-11-30 18:10         ` XFS update for 3.1-stable (resent) Ben Myers
  0 siblings, 1 reply; 20+ messages in thread
From: Greg KH @ 2011-11-28 21:40 UTC (permalink / raw)
  To: Ben Myers; +Cc: Christoph Hellwig, stable, xfs

On Mon, Nov 28, 2011 at 10:54:18AM -0600, Ben Myers wrote:
> Hey Greg,
> 
> On Mon, Nov 28, 2011 at 10:48:29PM +0900, Greg KH wrote:
> > On Mon, Nov 28, 2011 at 06:00:43AM -0500, Christoph Hellwig wrote:
> > > On Wed, Nov 23, 2011 at 03:38:07PM -0600, Ben Myers wrote:
> > > > This is a series of XFS fixes from current mainline which is important for
> > > > 3.1-stable.  Note that it is the same patch set that Christoph submitted for
> > > > 3.0-stable, minus the first three patches which are already included in 3.1.
> > > > 
> > > > My QA came out ok with these six patches atop 3.1.y.  Apologies to those who
> > > > got this mail twice. 
> > > 
> > > The updates looks good to me.
> > 
> > I never saw this series once, can someone please resend them as I don't
> > see them anywhere.
> 
> The first time I sent this 3.1.y series you were not on the --to=, which
> is why some people got the series twice but you didn't.  Sorry for the
> confusion. 

Was stable@vger.kernel.org on the to: line?  If so, I should have seen
them through that, but I don't, which is worrysome to me.

> Do you need the series for 3.0 to be resubmitted?

The 3.0 series is already in the last 3.0.11 release, so I don't need
them, I think I need the 3.1 patches, right?

thanks,

greg k-h

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* XFS update for 3.1-stable (resent)
  2011-11-28 21:40       ` Greg KH
@ 2011-11-30 18:10         ` Ben Myers
  2011-11-30 18:10           ` [PATCH 1/6] xfs: don't serialise direct IO reads on page cache checks Ben Myers
                             ` (5 more replies)
  0 siblings, 6 replies; 20+ messages in thread
From: Ben Myers @ 2011-11-30 18:10 UTC (permalink / raw)
  To: greg, stable; +Cc: bpm, xfs

Hey Greg,

The last mailing of this patch set went AWOL.  Here's another whirl.

Greg K-H wrote:
> Was stable@vger.kernel.org on the to: line?   If so, I should have seen them
> through that, but I don't, which is worrysome to me.

I thought so.

> The 3.0 series is already in the last 3.0.11 release, so I don't need them, I
> think I need the 3.1 patches, right? 

Affirmative.  You only need the 3.1 patches, here they are:

---

This is a series of XFS fixes from current mainline which are important for
3.1-stable.  Note that it is the same patch set that Christoph submitted for
3.0-stable, minus the first three patches which are already included in 3.1.

My QA came out ok with these six patches atop 3.1.y.

Thanks!
Ben

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/6] xfs: don't serialise direct IO reads on page cache checks
  2011-11-30 18:10         ` XFS update for 3.1-stable (resent) Ben Myers
@ 2011-11-30 18:10           ` Ben Myers
  2011-11-30 18:10           ` [PATCH 2/6] xfs: avoid direct I/O write vs buffered I/O race Ben Myers
                             ` (4 subsequent siblings)
  5 siblings, 0 replies; 20+ messages in thread
From: Ben Myers @ 2011-11-30 18:10 UTC (permalink / raw)
  To: greg, stable; +Cc: Alex Elder, bpm, Dave Chinner, xfs

From: Dave Chinner <dchinner@redhat.com>

commit 0c38a2512df272b14ef4238b476a2e4f70da1479 upstream.

There is no need to grab the i_mutex of the IO lock in exclusive
mode if we don't need to invalidate the page cache. Taking these
locks on every direct IO effective serialises them as taking the IO
lock in exclusive mode has to wait for all shared holders to drop
the lock. That only happens when IO is complete, so effective it
prevents dispatch of concurrent direct IO reads to the same inode.

Fix this by taking the IO lock shared to check the page cache state,
and only then drop it and take the IO lock exclusively if there is
work to be done. Hence for the normal direct IO case, no exclusive
locking will occur.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Tested-by: Joern Engel <joern@logfs.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Elder <aelder@sgi.com>
---
 fs/xfs/xfs_file.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 7f7b424..8fd4a07 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -317,7 +317,19 @@ xfs_file_aio_read(
 	if (XFS_FORCED_SHUTDOWN(mp))
 		return -EIO;
 
-	if (unlikely(ioflags & IO_ISDIRECT)) {
+	/*
+	 * Locking is a bit tricky here. If we take an exclusive lock
+	 * for direct IO, we effectively serialise all new concurrent
+	 * read IO to this file and block it behind IO that is currently in
+	 * progress because IO in progress holds the IO lock shared. We only
+	 * need to hold the lock exclusive to blow away the page cache, so
+	 * only take lock exclusively if the page cache needs invalidation.
+	 * This allows the normal direct IO case of no page cache pages to
+	 * proceeed concurrently without serialisation.
+	 */
+	xfs_rw_ilock(ip, XFS_IOLOCK_SHARED);
+	if ((ioflags & IO_ISDIRECT) && inode->i_mapping->nrpages) {
+		xfs_rw_iunlock(ip, XFS_IOLOCK_SHARED);
 		xfs_rw_ilock(ip, XFS_IOLOCK_EXCL);
 
 		if (inode->i_mapping->nrpages) {
@@ -330,8 +342,7 @@ xfs_file_aio_read(
 			}
 		}
 		xfs_rw_ilock_demote(ip, XFS_IOLOCK_EXCL);
-	} else
-		xfs_rw_ilock(ip, XFS_IOLOCK_SHARED);
+	}
 
 	trace_xfs_file_read(ip, size, iocb->ki_pos, ioflags);
 
-- 
1.7.8.rc0.46.g5ae0f

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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/6] xfs: avoid direct I/O write vs buffered I/O race
  2011-11-30 18:10         ` XFS update for 3.1-stable (resent) Ben Myers
  2011-11-30 18:10           ` [PATCH 1/6] xfs: don't serialise direct IO reads on page cache checks Ben Myers
@ 2011-11-30 18:10           ` Ben Myers
  2011-11-30 18:10           ` [PATCH 3/6] xfs: Return -EIO when xfs_vn_getattr() failed Ben Myers
                             ` (3 subsequent siblings)
  5 siblings, 0 replies; 20+ messages in thread
From: Ben Myers @ 2011-11-30 18:10 UTC (permalink / raw)
  To: greg, stable; +Cc: Christoph Hellwig, bpm, Alex Elder, Christoph Hellwig, xfs

From: Christoph Hellwig <hch@infradead.org>

commit c58cb165bd44de8aaee9755a144136ae743be116 upstream.

Currently a buffered reader or writer can add pages to the pagecache
while we are waiting for the iolock in xfs_file_dio_aio_write.  Prevent
this by re-checking mapping->nrpages after we got the iolock, and if
nessecary upgrade the lock to exclusive mode.  To simplify this a bit
only take the ilock inside of xfs_file_aio_write_checks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Alex Elder <aelder@sgi.com>
---
 fs/xfs/xfs_file.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 8fd4a07..b7e75c6 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -677,6 +677,7 @@ xfs_file_aio_write_checks(
 	xfs_fsize_t		new_size;
 	int			error = 0;
 
+	xfs_rw_ilock(ip, XFS_ILOCK_EXCL);
 	error = generic_write_checks(file, pos, count, S_ISBLK(inode->i_mode));
 	if (error) {
 		xfs_rw_iunlock(ip, XFS_ILOCK_EXCL | *iolock);
@@ -768,14 +769,24 @@ xfs_file_dio_aio_write(
 		*iolock = XFS_IOLOCK_EXCL;
 	else
 		*iolock = XFS_IOLOCK_SHARED;
-	xfs_rw_ilock(ip, XFS_ILOCK_EXCL | *iolock);
+	xfs_rw_ilock(ip, *iolock);
 
 	ret = xfs_file_aio_write_checks(file, &pos, &count, iolock);
 	if (ret)
 		return ret;
 
+	/*
+	 * Recheck if there are cached pages that need invalidate after we got
+	 * the iolock to protect against other threads adding new pages while
+	 * we were waiting for the iolock.
+	 */
+	if (mapping->nrpages && *iolock == XFS_IOLOCK_SHARED) {
+		xfs_rw_iunlock(ip, *iolock);
+		*iolock = XFS_IOLOCK_EXCL;
+		xfs_rw_ilock(ip, *iolock);
+	}
+
 	if (mapping->nrpages) {
-		WARN_ON(*iolock != XFS_IOLOCK_EXCL);
 		ret = -xfs_flushinval_pages(ip, (pos & PAGE_CACHE_MASK), -1,
 							FI_REMAPF_LOCKED);
 		if (ret)
@@ -820,7 +831,7 @@ xfs_file_buffered_aio_write(
 	size_t			count = ocount;
 
 	*iolock = XFS_IOLOCK_EXCL;
-	xfs_rw_ilock(ip, XFS_ILOCK_EXCL | *iolock);
+	xfs_rw_ilock(ip, *iolock);
 
 	ret = xfs_file_aio_write_checks(file, &pos, &count, iolock);
 	if (ret)
-- 
1.7.8.rc0.46.g5ae0f

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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/6] xfs: Return -EIO when xfs_vn_getattr() failed
  2011-11-30 18:10         ` XFS update for 3.1-stable (resent) Ben Myers
  2011-11-30 18:10           ` [PATCH 1/6] xfs: don't serialise direct IO reads on page cache checks Ben Myers
  2011-11-30 18:10           ` [PATCH 2/6] xfs: avoid direct I/O write vs buffered I/O race Ben Myers
@ 2011-11-30 18:10           ` Ben Myers
  2011-11-30 18:10           ` [PATCH 4/6] xfs: fix buffer flushing during unmount Ben Myers
                             ` (2 subsequent siblings)
  5 siblings, 0 replies; 20+ messages in thread
From: Ben Myers @ 2011-11-30 18:10 UTC (permalink / raw)
  To: greg, stable; +Cc: bpm, Alex Elder, Mitsuo Hayasaka, xfs

From: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>

commit ed32201e65e15f3e6955cb84cbb544b08f81e5a5 upstream.

An attribute of inode can be fetched via xfs_vn_getattr() in XFS.
Currently it returns EIO, not negative value, when it failed.  As a
result, the system call returns not negative value even though an
error occured. The stat(2), ls and mv commands cannot handle this
error and do not work correctly.

This patch fixes this bug, and returns -EIO, not EIO when an error
is detected in xfs_vn_getattr().

Signed-off-by: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Elder <aelder@sgi.com>
---
 fs/xfs/xfs_iops.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 673704f..474920b 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -465,7 +465,7 @@ xfs_vn_getattr(
 	trace_xfs_getattr(ip);
 
 	if (XFS_FORCED_SHUTDOWN(mp))
-		return XFS_ERROR(EIO);
+		return -XFS_ERROR(EIO);
 
 	stat->size = XFS_ISIZE(ip);
 	stat->dev = inode->i_sb->s_dev;
-- 
1.7.8.rc0.46.g5ae0f

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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 4/6] xfs: fix buffer flushing during unmount
  2011-11-30 18:10         ` XFS update for 3.1-stable (resent) Ben Myers
                             ` (2 preceding siblings ...)
  2011-11-30 18:10           ` [PATCH 3/6] xfs: Return -EIO when xfs_vn_getattr() failed Ben Myers
@ 2011-11-30 18:10           ` Ben Myers
  2011-11-30 18:10           ` [PATCH 5/6] xfs: Fix possible memory corruption in xfs_readlink Ben Myers
  2011-11-30 18:11           ` [PATCH 6/6] xfs: use doalloc flag in xfs_qm_dqattach_one() Ben Myers
  5 siblings, 0 replies; 20+ messages in thread
From: Ben Myers @ 2011-11-30 18:10 UTC (permalink / raw)
  To: greg, stable; +Cc: Christoph Hellwig, bpm, Alex Elder, Christoph Hellwig, xfs

From: Christoph Hellwig <hch@infradead.org>

commit 87c7bec7fc3377b3873eb3a0f4b603981ea16ebb upstream.

The code to flush buffers in the umount code is a bit iffy: we first
flush all delwri buffers out, but then might be able to queue up a
new one when logging the sb counts.  On a normal shutdown that one
would get flushed out when doing the synchronous superblock write in
xfs_unmountfs_writesb, but we skip that one if the filesystem has
been shut down.

Fix this by moving the delwri list flushing until just before unmounting
the log, and while we're at it also remove the superflous delwri list
and buffer lru flusing for the rt and log device that can never have
cached or delwri buffers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reported-by: Amit Sahrawat <amit.sahrawat83@gmail.com>
Tested-by: Amit Sahrawat <amit.sahrawat83@gmail.com>
Signed-off-by: Alex Elder <aelder@sgi.com>
---
 fs/xfs/xfs_buf.h   |    1 -
 fs/xfs/xfs_mount.c |   29 ++++++++++-------------------
 2 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index 620972b..8e8b06b 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -320,7 +320,6 @@ extern struct list_head *xfs_get_buftarg_list(void);
 #define xfs_getsize_buftarg(buftarg)	block_size((buftarg)->bt_bdev)
 #define xfs_readonly_buftarg(buftarg)	bdev_read_only((buftarg)->bt_bdev)
 
-#define xfs_binval(buftarg)		xfs_flush_buftarg(buftarg, 1)
 #define XFS_bflush(buftarg)		xfs_flush_buftarg(buftarg, 1)
 
 #endif	/* __XFS_BUF_H__ */
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 0081657..d4d5775 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -44,9 +44,6 @@
 #include "xfs_trace.h"
 
 
-STATIC void	xfs_unmountfs_wait(xfs_mount_t *);
-
-
 #ifdef HAVE_PERCPU_SB
 STATIC void	xfs_icsb_balance_counter(xfs_mount_t *, xfs_sb_field_t,
 						int);
@@ -1496,11 +1493,6 @@ xfs_unmountfs(
 	 */
 	xfs_log_force(mp, XFS_LOG_SYNC);
 
-	xfs_binval(mp->m_ddev_targp);
-	if (mp->m_rtdev_targp) {
-		xfs_binval(mp->m_rtdev_targp);
-	}
-
 	/*
 	 * Unreserve any blocks we have so that when we unmount we don't account
 	 * the reserved free space as used. This is really only necessary for
@@ -1526,7 +1518,16 @@ xfs_unmountfs(
 		xfs_warn(mp, "Unable to update superblock counters. "
 				"Freespace may not be correct on next mount.");
 	xfs_unmountfs_writesb(mp);
-	xfs_unmountfs_wait(mp); 		/* wait for async bufs */
+
+	/*
+	 * Make sure all buffers have been flushed and completed before
+	 * unmounting the log.
+	 */
+	error = xfs_flush_buftarg(mp->m_ddev_targp, 1);
+	if (error)
+		xfs_warn(mp, "%d busy buffers during unmount.", error);
+	xfs_wait_buftarg(mp->m_ddev_targp);
+
 	xfs_log_unmount_write(mp);
 	xfs_log_unmount(mp);
 	xfs_uuid_unmount(mp);
@@ -1537,16 +1538,6 @@ xfs_unmountfs(
 	xfs_free_perag(mp);
 }
 
-STATIC void
-xfs_unmountfs_wait(xfs_mount_t *mp)
-{
-	if (mp->m_logdev_targp != mp->m_ddev_targp)
-		xfs_wait_buftarg(mp->m_logdev_targp);
-	if (mp->m_rtdev_targp)
-		xfs_wait_buftarg(mp->m_rtdev_targp);
-	xfs_wait_buftarg(mp->m_ddev_targp);
-}
-
 int
 xfs_fs_writable(xfs_mount_t *mp)
 {
-- 
1.7.8.rc0.46.g5ae0f

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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 5/6] xfs: Fix possible memory corruption in xfs_readlink
  2011-11-30 18:10         ` XFS update for 3.1-stable (resent) Ben Myers
                             ` (3 preceding siblings ...)
  2011-11-30 18:10           ` [PATCH 4/6] xfs: fix buffer flushing during unmount Ben Myers
@ 2011-11-30 18:10           ` Ben Myers
  2011-11-30 18:11           ` [PATCH 6/6] xfs: use doalloc flag in xfs_qm_dqattach_one() Ben Myers
  5 siblings, 0 replies; 20+ messages in thread
From: Ben Myers @ 2011-11-30 18:10 UTC (permalink / raw)
  To: greg, stable; +Cc: bpm, Alex Elder, Carlos Maiolino, xfs

From: Carlos Maiolino <cmaiolino@redhat.com>

commit b52a360b2aa1c59ba9970fb0f52bbb093fcc7a24 upstream.

Fixes a possible memory corruption when the link is larger than
MAXPATHLEN and XFS_DEBUG is not enabled. This also remove the
S_ISLNK assert, since the inode mode is checked previously in
xfs_readlink_by_handle() and via VFS.

Updated to address concerns raised by Ben Hutchings about the loose
attention paid to 32- vs 64-bit values, and the lack of handling a
potentially negative pathlen value:
 - Changed type of "pathlen" to be xfs_fsize_t, to match that of
   ip->i_d.di_size
 - Added checking for a negative pathlen to the too-long pathlen
   test, and generalized the message that gets reported in that case
   to reflect the change
As a result, if a negative pathlen were encountered, this function
would return EFSCORRUPTED (and would fail an assertion for a debug
build)--just as would a too-long pathlen.

Signed-off-by: Alex Elder <aelder@sgi.com>
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_vnodeops.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 51fc429..b9e2873 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -113,7 +113,7 @@ xfs_readlink(
 	char		*link)
 {
 	xfs_mount_t	*mp = ip->i_mount;
-	int		pathlen;
+	xfs_fsize_t	pathlen;
 	int		error = 0;
 
 	trace_xfs_readlink(ip);
@@ -123,13 +123,19 @@ xfs_readlink(
 
 	xfs_ilock(ip, XFS_ILOCK_SHARED);
 
-	ASSERT(S_ISLNK(ip->i_d.di_mode));
-	ASSERT(ip->i_d.di_size <= MAXPATHLEN);
-
 	pathlen = ip->i_d.di_size;
 	if (!pathlen)
 		goto out;
 
+	if (pathlen < 0 || pathlen > MAXPATHLEN) {
+		xfs_alert(mp, "%s: inode (%llu) bad symlink length (%lld)",
+			 __func__, (unsigned long long) ip->i_ino,
+			 (long long) pathlen);
+		ASSERT(0);
+		return XFS_ERROR(EFSCORRUPTED);
+	}
+
+
 	if (ip->i_df.if_flags & XFS_IFINLINE) {
 		memcpy(link, ip->i_df.if_u1.if_data, pathlen);
 		link[pathlen] = '\0';
-- 
1.7.8.rc0.46.g5ae0f

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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 6/6] xfs: use doalloc flag in xfs_qm_dqattach_one()
  2011-11-30 18:10         ` XFS update for 3.1-stable (resent) Ben Myers
                             ` (4 preceding siblings ...)
  2011-11-30 18:10           ` [PATCH 5/6] xfs: Fix possible memory corruption in xfs_readlink Ben Myers
@ 2011-11-30 18:11           ` Ben Myers
  5 siblings, 0 replies; 20+ messages in thread
From: Ben Myers @ 2011-11-30 18:11 UTC (permalink / raw)
  To: greg, stable; +Cc: Christoph Hellwig, bpm, Alex Elder, Mitsuo Hayasaka, xfs

From: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>

commit db3e74b582915d66e10b0c73a62763418f54c340 upstream.

The doalloc arg in xfs_qm_dqattach_one() is a flag that indicates
whether a new area to handle quota information will be allocated
if needed. Originally, it was passed to xfs_qm_dqget(), but has
been removed by the following commit (probably by mistake):

	commit 8e9b6e7fa4544ea8a0e030c8987b918509c8ff47
	Author: Christoph Hellwig <hch@lst.de>
	Date:   Sun Feb 8 21:51:42 2009 +0100

	xfs: remove the unused XFS_QMOPT_DQLOCK flag

As the result, xfs_qm_dqget() called from xfs_qm_dqattach_one()
never allocates the new area even if it is needed.

This patch gives the doalloc arg to xfs_qm_dqget() in
xfs_qm_dqattach_one() to fix this problem.

Signed-off-by: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>
Cc: Alex Elder <aelder@sgi.com>
Cc: Christoph Hellwig <hch@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ben Myers <bpm@sgi.com>
---
 fs/xfs/xfs_qm.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 9a0aa76..95ba6dc 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -674,7 +674,8 @@ xfs_qm_dqattach_one(
 	 * disk and we didn't ask it to allocate;
 	 * ESRCH if quotas got turned off suddenly.
 	 */
-	error = xfs_qm_dqget(ip->i_mount, ip, id, type, XFS_QMOPT_DOWARN, &dqp);
+	error = xfs_qm_dqget(ip->i_mount, ip, id, type,
+			     doalloc | XFS_QMOPT_DOWARN, &dqp);
 	if (error)
 		return error;
 
-- 
1.7.8.rc0.46.g5ae0f

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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 1/6] xfs: don't serialise direct IO reads on page cache checks
  2011-12-01 23:27 [PATCH 0/6] XFS update for 3.1-stable (again) Ben Myers
@ 2011-12-01 23:27 ` Ben Myers
  0 siblings, 0 replies; 20+ messages in thread
From: Ben Myers @ 2011-12-01 23:27 UTC (permalink / raw)
  To: stable, greg; +Cc: Alex Elder, bpm, Dave Chinner, xfs

From: Dave Chinner <dchinner@redhat.com>

commit 0c38a2512df272b14ef4238b476a2e4f70da1479 upstream.

There is no need to grab the i_mutex of the IO lock in exclusive
mode if we don't need to invalidate the page cache. Taking these
locks on every direct IO effective serialises them as taking the IO
lock in exclusive mode has to wait for all shared holders to drop
the lock. That only happens when IO is complete, so effective it
prevents dispatch of concurrent direct IO reads to the same inode.

Fix this by taking the IO lock shared to check the page cache state,
and only then drop it and take the IO lock exclusively if there is
work to be done. Hence for the normal direct IO case, no exclusive
locking will occur.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Tested-by: Joern Engel <joern@logfs.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Elder <aelder@sgi.com>
---
 fs/xfs/xfs_file.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 7f7b424..8fd4a07 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -317,7 +317,19 @@ xfs_file_aio_read(
 	if (XFS_FORCED_SHUTDOWN(mp))
 		return -EIO;
 
-	if (unlikely(ioflags & IO_ISDIRECT)) {
+	/*
+	 * Locking is a bit tricky here. If we take an exclusive lock
+	 * for direct IO, we effectively serialise all new concurrent
+	 * read IO to this file and block it behind IO that is currently in
+	 * progress because IO in progress holds the IO lock shared. We only
+	 * need to hold the lock exclusive to blow away the page cache, so
+	 * only take lock exclusively if the page cache needs invalidation.
+	 * This allows the normal direct IO case of no page cache pages to
+	 * proceeed concurrently without serialisation.
+	 */
+	xfs_rw_ilock(ip, XFS_IOLOCK_SHARED);
+	if ((ioflags & IO_ISDIRECT) && inode->i_mapping->nrpages) {
+		xfs_rw_iunlock(ip, XFS_IOLOCK_SHARED);
 		xfs_rw_ilock(ip, XFS_IOLOCK_EXCL);
 
 		if (inode->i_mapping->nrpages) {
@@ -330,8 +342,7 @@ xfs_file_aio_read(
 			}
 		}
 		xfs_rw_ilock_demote(ip, XFS_IOLOCK_EXCL);
-	} else
-		xfs_rw_ilock(ip, XFS_IOLOCK_SHARED);
+	}
 
 	trace_xfs_file_read(ip, size, iocb->ki_pos, ioflags);
 
-- 
1.7.8.rc4

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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2011-12-01 23:27 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-23 21:38 [PATCH 0/6] XFS update for 3.1-stable Ben Myers
2011-11-23 21:38 ` [PATCH 1/6] xfs: don't serialise direct IO reads on page cache checks Ben Myers
2011-11-23 21:38 ` [PATCH 2/6] xfs: avoid direct I/O write vs buffered I/O race Ben Myers
2011-11-23 21:38 ` [PATCH 3/6] xfs: Return -EIO when xfs_vn_getattr() failed Ben Myers
2011-11-23 21:38 ` [PATCH 4/6] xfs: fix buffer flushing during unmount Ben Myers
2011-11-23 21:38 ` [PATCH 5/6] xfs: Fix possible memory corruption in xfs_readlink Ben Myers
2011-11-23 21:38 ` [PATCH 6/6] xfs: use doalloc flag in xfs_qm_dqattach_one() Ben Myers
2011-11-28 11:00 ` [PATCH 0/6] XFS update for 3.1-stable Christoph Hellwig
2011-11-28 13:48   ` Greg KH
2011-11-28 16:54     ` Ben Myers
2011-11-28 21:40       ` Greg KH
2011-11-30 18:10         ` XFS update for 3.1-stable (resent) Ben Myers
2011-11-30 18:10           ` [PATCH 1/6] xfs: don't serialise direct IO reads on page cache checks Ben Myers
2011-11-30 18:10           ` [PATCH 2/6] xfs: avoid direct I/O write vs buffered I/O race Ben Myers
2011-11-30 18:10           ` [PATCH 3/6] xfs: Return -EIO when xfs_vn_getattr() failed Ben Myers
2011-11-30 18:10           ` [PATCH 4/6] xfs: fix buffer flushing during unmount Ben Myers
2011-11-30 18:10           ` [PATCH 5/6] xfs: Fix possible memory corruption in xfs_readlink Ben Myers
2011-11-30 18:11           ` [PATCH 6/6] xfs: use doalloc flag in xfs_qm_dqattach_one() Ben Myers
  -- strict thread matches above, loose matches on Subject: below --
2011-12-01 23:27 [PATCH 0/6] XFS update for 3.1-stable (again) Ben Myers
2011-12-01 23:27 ` [PATCH 1/6] xfs: don't serialise direct IO reads on page cache checks Ben Myers
2011-08-25  7:17 [PATCH 0/6] xfs: patch queue for Linux 3.2 Dave Chinner
2011-08-25  7:17 ` [PATCH 1/6] xfs: don't serialise direct IO reads on page cache checks Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox