public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* first set of iomap fix
@ 2016-08-13 23:42 Christoph Hellwig
  2016-08-13 23:42 ` [PATCH 1/7] iomap: remove superflous mark_page_accessed from iomap_write_actor Christoph Hellwig
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Christoph Hellwig @ 2016-08-13 23:42 UTC (permalink / raw)
  To: xfs

This contains various fixes for the iomap path for 4.8, but it skips
the changes to the delalloc path (which aren't really about the iomap
path itself anyway).

Two fixes to make the iomap buffered write path catch up with changes
to the filemap one.  Then I've cherry picked the FIEMAP_FLAG_SYNC patch
from Dave, and added my version of re-implementing FIEMAP_FLAG_XATTR
as well.

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

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

* [PATCH 1/7] iomap: remove superflous mark_page_accessed from iomap_write_actor
  2016-08-13 23:42 first set of iomap fix Christoph Hellwig
@ 2016-08-13 23:42 ` Christoph Hellwig
  2016-08-13 23:42 ` [PATCH 2/7] iomap: remove superflous pagefault_disable " Christoph Hellwig
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2016-08-13 23:42 UTC (permalink / raw)
  To: xfs

This catches up with commit  2457ae ("mm: non-atomically mark page
accessed during page cache allocation where possible"), which
moved the initial access marking into the pagecache allocator.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/iomap.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/iomap.c b/fs/iomap.c
index 48141b8..f39c318 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -199,7 +199,6 @@ again:
 		pagefault_enable();
 
 		flush_dcache_page(page);
-		mark_page_accessed(page);
 
 		status = iomap_write_end(inode, pos, bytes, copied, page);
 		if (unlikely(status < 0))
-- 
2.1.4

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

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

* [PATCH 2/7] iomap: remove superflous pagefault_disable from iomap_write_actor
  2016-08-13 23:42 first set of iomap fix Christoph Hellwig
  2016-08-13 23:42 ` [PATCH 1/7] iomap: remove superflous mark_page_accessed from iomap_write_actor Christoph Hellwig
@ 2016-08-13 23:42 ` Christoph Hellwig
  2016-08-13 23:42 ` [PATCH 3/7] iomap: fiemap should honor the FIEMAP_FLAG_SYNC flag Christoph Hellwig
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2016-08-13 23:42 UTC (permalink / raw)
  To: xfs

iov_iter_copy_from_user_atomic disableѕ page fauls internal, no need to
do it around the call.  This also brings the iomap code in line with
the original filemap version.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/iomap.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/iomap.c b/fs/iomap.c
index f39c318..74712e2 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -194,9 +194,7 @@ again:
 		if (mapping_writably_mapped(inode->i_mapping))
 			flush_dcache_page(page);
 
-		pagefault_disable();
 		copied = iov_iter_copy_from_user_atomic(page, i, offset, bytes);
-		pagefault_enable();
 
 		flush_dcache_page(page);
 
-- 
2.1.4

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

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

* [PATCH 3/7] iomap: fiemap should honor the FIEMAP_FLAG_SYNC flag
  2016-08-13 23:42 first set of iomap fix Christoph Hellwig
  2016-08-13 23:42 ` [PATCH 1/7] iomap: remove superflous mark_page_accessed from iomap_write_actor Christoph Hellwig
  2016-08-13 23:42 ` [PATCH 2/7] iomap: remove superflous pagefault_disable " Christoph Hellwig
@ 2016-08-13 23:42 ` Christoph Hellwig
  2016-08-13 23:42 ` [PATCH 4/7] iomap: prepare iomap_fiemap for attribute mappings Christoph Hellwig
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2016-08-13 23:42 UTC (permalink / raw)
  To: xfs; +Cc: Dave Chinner

From: Dave Chinner <dchinner@redhat.com>

The flag is checked as supported, but then we do an unconditional
sync of the file, regardless of whether the flag is set or not. Make
the sync conditional on having the FIEMAP_FLAG_SYNC flag set.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 fs/iomap.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/iomap.c b/fs/iomap.c
index 74712e2..56c19e6 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -467,9 +467,11 @@ int iomap_fiemap(struct inode *inode, struct fiemap_extent_info *fi,
 	if (ret)
 		return ret;
 
-	ret = filemap_write_and_wait(inode->i_mapping);
-	if (ret)
-		return ret;
+	if (fi->fi_flags & FIEMAP_FLAG_SYNC) {
+		ret = filemap_write_and_wait(inode->i_mapping);
+		if (ret)
+			return ret;
+	}
 
 	while (len > 0) {
 		ret = iomap_apply(inode, start, len, 0, ops, &ctx,
-- 
2.1.4

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

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

* [PATCH 4/7] iomap: prepare iomap_fiemap for attribute mappings
  2016-08-13 23:42 first set of iomap fix Christoph Hellwig
                   ` (2 preceding siblings ...)
  2016-08-13 23:42 ` [PATCH 3/7] iomap: fiemap should honor the FIEMAP_FLAG_SYNC flag Christoph Hellwig
@ 2016-08-13 23:42 ` Christoph Hellwig
  2016-08-13 23:42 ` [PATCH 5/7] iomap: mark ->iomap_end as optional Christoph Hellwig
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2016-08-13 23:42 UTC (permalink / raw)
  To: xfs; +Cc: Dave Chinner

From: Dave Chinner <dchinner@redhat.com>

By bassing through an -ENOENT, similar to the old XFS implementation of
FIEMAP_FLAG_XATTR.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
[hch: split from a larger patch]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/iomap.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/iomap.c b/fs/iomap.c
index 56c19e6..d9d1f50 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -476,6 +476,9 @@ int iomap_fiemap(struct inode *inode, struct fiemap_extent_info *fi,
 	while (len > 0) {
 		ret = iomap_apply(inode, start, len, 0, ops, &ctx,
 				iomap_fiemap_actor);
+		/* inode with no (attribute) mapping will give ENOENT */
+		if (ret == -ENOENT)
+			break;
 		if (ret < 0)
 			return ret;
 		if (ret == 0)
-- 
2.1.4

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

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

* [PATCH 5/7] iomap: mark ->iomap_end as optional
  2016-08-13 23:42 first set of iomap fix Christoph Hellwig
                   ` (3 preceding siblings ...)
  2016-08-13 23:42 ` [PATCH 4/7] iomap: prepare iomap_fiemap for attribute mappings Christoph Hellwig
@ 2016-08-13 23:42 ` Christoph Hellwig
  2016-08-13 23:43 ` [PATCH 6/7] xfs: simplify xfs_file_iomap_begin Christoph Hellwig
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2016-08-13 23:42 UTC (permalink / raw)
  To: xfs

No need to implement it for read-only mappings.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/iomap.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/iomap.c b/fs/iomap.c
index d9d1f50..0342254 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -84,8 +84,11 @@ iomap_apply(struct inode *inode, loff_t pos, loff_t length, unsigned flags,
 	 * Now the data has been copied, commit the range we've copied.  This
 	 * should not fail unless the filesystem has had a fatal error.
 	 */
-	ret = ops->iomap_end(inode, pos, length, written > 0 ? written : 0,
-			flags, &iomap);
+	if (ops->iomap_end) {
+		ret = ops->iomap_end(inode, pos, length,
+				     written > 0 ? written : 0,
+				     flags, &iomap);
+	}
 
 	return written ? written : ret;
 }
-- 
2.1.4

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

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

* [PATCH 6/7] xfs: simplify xfs_file_iomap_begin
  2016-08-13 23:42 first set of iomap fix Christoph Hellwig
                   ` (4 preceding siblings ...)
  2016-08-13 23:42 ` [PATCH 5/7] iomap: mark ->iomap_end as optional Christoph Hellwig
@ 2016-08-13 23:43 ` Christoph Hellwig
  2016-08-13 23:43 ` [PATCH 7/7] xfs: (re-)implement FIEMAP_FLAG_XATTR Christoph Hellwig
  2016-08-14  6:33 ` first set of iomap fix Dave Chinner
  7 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2016-08-13 23:43 UTC (permalink / raw)
  To: xfs

We'll never get nimap == 0 for a successful return from xfs_bmapi_read,
so don't try to handle it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_iomap.c | 14 ++++----------
 fs/xfs/xfs_trace.h |  1 -
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 2114d53..1cce760 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -1037,20 +1037,14 @@ xfs_file_iomap_begin(
 			return error;
 
 		trace_xfs_iomap_alloc(ip, offset, length, 0, &imap);
-		xfs_bmbt_to_iomap(ip, iomap, &imap);
-	} else if (nimaps) {
-		xfs_iunlock(ip, XFS_ILOCK_EXCL);
-		trace_xfs_iomap_found(ip, offset, length, 0, &imap);
-		xfs_bmbt_to_iomap(ip, iomap, &imap);
 	} else {
+		ASSERT(nimaps);
+
 		xfs_iunlock(ip, XFS_ILOCK_EXCL);
-		trace_xfs_iomap_not_found(ip, offset, length, 0, &imap);
-		iomap->blkno = IOMAP_NULL_BLOCK;
-		iomap->type = IOMAP_HOLE;
-		iomap->offset = offset;
-		iomap->length = length;
+		trace_xfs_iomap_found(ip, offset, length, 0, &imap);
 	}
 
+	xfs_bmbt_to_iomap(ip, iomap, &imap);
 	return 0;
 }
 
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index 551b7e2..7e88bec 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -1298,7 +1298,6 @@ DEFINE_IOMAP_EVENT(xfs_get_blocks_alloc);
 DEFINE_IOMAP_EVENT(xfs_get_blocks_map_direct);
 DEFINE_IOMAP_EVENT(xfs_iomap_alloc);
 DEFINE_IOMAP_EVENT(xfs_iomap_found);
-DEFINE_IOMAP_EVENT(xfs_iomap_not_found);
 
 DECLARE_EVENT_CLASS(xfs_simple_io_class,
 	TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count),
-- 
2.1.4

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

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

* [PATCH 7/7] xfs: (re-)implement FIEMAP_FLAG_XATTR
  2016-08-13 23:42 first set of iomap fix Christoph Hellwig
                   ` (5 preceding siblings ...)
  2016-08-13 23:43 ` [PATCH 6/7] xfs: simplify xfs_file_iomap_begin Christoph Hellwig
@ 2016-08-13 23:43 ` Christoph Hellwig
  2016-08-14  6:33 ` first set of iomap fix Dave Chinner
  7 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2016-08-13 23:43 UTC (permalink / raw)
  To: xfs

Use a special read-only iomap_ops implementation to support fiemap on
the attr fork.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_iomap.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 fs/xfs/xfs_iomap.h |  1 +
 fs/xfs/xfs_iops.c  |  9 ++++++++-
 3 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 1cce760..697c8fd 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -1106,3 +1106,48 @@ struct iomap_ops xfs_iomap_ops = {
 	.iomap_begin		= xfs_file_iomap_begin,
 	.iomap_end		= xfs_file_iomap_end,
 };
+
+static int
+xfs_xattr_iomap_begin(
+	struct inode		*inode,
+	loff_t			offset,
+	loff_t			length,
+	unsigned		flags,
+	struct iomap		*iomap)
+{
+	struct xfs_inode	*ip = XFS_I(inode);
+	struct xfs_mount	*mp = ip->i_mount;
+	xfs_fileoff_t		offset_fsb = XFS_B_TO_FSBT(mp, offset);
+	xfs_fileoff_t		end_fsb = XFS_B_TO_FSB(mp, offset + length);
+	struct xfs_bmbt_irec	imap;
+	int			nimaps = 1, error = 0;
+	unsigned		lockmode;
+
+	if (XFS_FORCED_SHUTDOWN(mp))
+		return -EIO;
+
+	lockmode = xfs_ilock_data_map_shared(ip);
+
+	/* if there are no attribute fork or extents, return ENOENT */
+	if (XFS_IFORK_Q(ip) || !ip->i_d.di_anextents) {
+		error = -ENOENT;
+		goto out_unlock;
+	}
+
+	ASSERT(ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL);
+	error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb, &imap,
+			       &nimaps, XFS_BMAPI_ENTIRE | XFS_BMAPI_ATTRFORK);
+out_unlock:
+	xfs_iunlock(ip, lockmode);
+
+	if (!error) {
+		ASSERT(nimaps);
+		xfs_bmbt_to_iomap(ip, iomap, &imap);
+	}
+
+	return error;
+}
+
+struct iomap_ops xfs_xattr_iomap_ops = {
+	.iomap_begin		= xfs_xattr_iomap_begin,
+};
diff --git a/fs/xfs/xfs_iomap.h b/fs/xfs/xfs_iomap.h
index e066d04..fb8aca3 100644
--- a/fs/xfs/xfs_iomap.h
+++ b/fs/xfs/xfs_iomap.h
@@ -35,5 +35,6 @@ void xfs_bmbt_to_iomap(struct xfs_inode *, struct iomap *,
 		struct xfs_bmbt_irec *);
 
 extern struct iomap_ops xfs_iomap_ops;
+extern struct iomap_ops xfs_xattr_iomap_ops;
 
 #endif /* __XFS_IOMAP_H__*/
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index ab820f8..b24c310 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -1009,7 +1009,14 @@ xfs_vn_fiemap(
 	int			error;
 
 	xfs_ilock(XFS_I(inode), XFS_IOLOCK_SHARED);
-	error = iomap_fiemap(inode, fieinfo, start, length, &xfs_iomap_ops);
+	if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) {
+		fieinfo->fi_flags &= ~FIEMAP_FLAG_XATTR;
+		error = iomap_fiemap(inode, fieinfo, start, length,
+				&xfs_xattr_iomap_ops);
+	} else {
+		error = iomap_fiemap(inode, fieinfo, start, length,
+				&xfs_iomap_ops);
+	}
 	xfs_iunlock(XFS_I(inode), XFS_IOLOCK_SHARED);
 
 	return error;
-- 
2.1.4

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

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

* Re: first set of iomap fix
  2016-08-13 23:42 first set of iomap fix Christoph Hellwig
                   ` (6 preceding siblings ...)
  2016-08-13 23:43 ` [PATCH 7/7] xfs: (re-)implement FIEMAP_FLAG_XATTR Christoph Hellwig
@ 2016-08-14  6:33 ` Dave Chinner
  7 siblings, 0 replies; 9+ messages in thread
From: Dave Chinner @ 2016-08-14  6:33 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

On Sat, Aug 13, 2016 at 04:42:54PM -0700, Christoph Hellwig wrote:
> This contains various fixes for the iomap path for 4.8, but it skips
> the changes to the delalloc path (which aren't really about the iomap
> path itself anyway).
> 
> Two fixes to make the iomap buffered write path catch up with changes
> to the filemap one.  Then I've cherry picked the FIEMAP_FLAG_SYNC patch
> from Dave, and added my version of re-implementing FIEMAP_FLAG_XATTR
> as well.

Thanks for the quick turnaround on these, Christoph.  Your change
for handling xattr mappings is simpler than the one I have - the
optional ioend handling is definitely an improvement.  At first
glance I can't see anything obvious wrong with the patches - I'll
give them a spin through QA and see what falls out...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

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

end of thread, other threads:[~2016-08-14  6:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-13 23:42 first set of iomap fix Christoph Hellwig
2016-08-13 23:42 ` [PATCH 1/7] iomap: remove superflous mark_page_accessed from iomap_write_actor Christoph Hellwig
2016-08-13 23:42 ` [PATCH 2/7] iomap: remove superflous pagefault_disable " Christoph Hellwig
2016-08-13 23:42 ` [PATCH 3/7] iomap: fiemap should honor the FIEMAP_FLAG_SYNC flag Christoph Hellwig
2016-08-13 23:42 ` [PATCH 4/7] iomap: prepare iomap_fiemap for attribute mappings Christoph Hellwig
2016-08-13 23:42 ` [PATCH 5/7] iomap: mark ->iomap_end as optional Christoph Hellwig
2016-08-13 23:43 ` [PATCH 6/7] xfs: simplify xfs_file_iomap_begin Christoph Hellwig
2016-08-13 23:43 ` [PATCH 7/7] xfs: (re-)implement FIEMAP_FLAG_XATTR Christoph Hellwig
2016-08-14  6:33 ` first set of iomap fix Dave Chinner

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