* [PATCH 1/6] vfs: fix return type of ioctl_file_dedupe_range
2016-08-25 23:30 [PATCH v8 0/6] vfs: help support reflink for XFS Darrick J. Wong
@ 2016-08-25 23:30 ` Darrick J. Wong
2016-08-25 23:30 ` [PATCH 2/6] vfs: cap dedupe request structure size at PAGE_SIZE Darrick J. Wong
` (4 subsequent siblings)
5 siblings, 0 replies; 19+ messages in thread
From: Darrick J. Wong @ 2016-08-25 23:30 UTC (permalink / raw)
To: david, viro, darrick.wong; +Cc: linux-xfs, linux-fsdevel, xfs, linux-api
All the VFS functions in the dedupe ioctl path return int status, so
the ioctl handler ought to as well.
Found by Coverity, CID 1350952.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
fs/ioctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 0f56deb..26aba09 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -568,7 +568,7 @@ static int ioctl_fsthaw(struct file *filp)
return thaw_super(sb);
}
-static long ioctl_file_dedupe_range(struct file *file, void __user *arg)
+static int ioctl_file_dedupe_range(struct file *file, void __user *arg)
{
struct file_dedupe_range __user *argp = arg;
struct file_dedupe_range *same = NULL;
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 2/6] vfs: cap dedupe request structure size at PAGE_SIZE
2016-08-25 23:30 [PATCH v8 0/6] vfs: help support reflink for XFS Darrick J. Wong
2016-08-25 23:30 ` [PATCH 1/6] vfs: fix return type of ioctl_file_dedupe_range Darrick J. Wong
@ 2016-08-25 23:30 ` Darrick J. Wong
[not found] ` <147216785429.525.1965983896010934181.stgit-PTl6brltDGh4DFYR7WNSRA@public.gmane.org>
2016-08-25 23:31 ` [PATCH 3/6] vfs: support FS_XFLAG_REFLINK and FS_XFLAG_COWEXTSIZE Darrick J. Wong
` (3 subsequent siblings)
5 siblings, 1 reply; 19+ messages in thread
From: Darrick J. Wong @ 2016-08-25 23:30 UTC (permalink / raw)
To: david, viro, darrick.wong
Cc: linux-xfs, Kirill A. Shutemov, xfs, linux-fsdevel, linux-api
Kirill A. Shutemov reports that the kernel doesn't try to cap dest_count
in any way, and uses the number to allocate kernel memory. This causes
high order allocation warnings in the kernel log if someone passes in a
big enough value. We should clamp the allocation at PAGE_SIZE to avoid
stressing the VM.
The two existing users of the dedupe ioctl never send more than 120
requests, so we can safely clamp dest_range at PAGE_SIZE, because with
4k pages we can handle up to 127 dedupe candidates. Given the max
extent length of 16MB, we can end up doing 2GB of IO which is plenty.
Reported-by: "Kirill A. Shutemov" <kirill@shutemov.name>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
fs/ioctl.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 26aba09..c415668 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -582,6 +582,10 @@ static int ioctl_file_dedupe_range(struct file *file, void __user *arg)
}
size = offsetof(struct file_dedupe_range __user, info[count]);
+ if (size > PAGE_SIZE) {
+ ret = -ENOMEM;
+ goto out;
+ }
same = memdup_user(argp, size);
if (IS_ERR(same)) {
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 3/6] vfs: support FS_XFLAG_REFLINK and FS_XFLAG_COWEXTSIZE
2016-08-25 23:30 [PATCH v8 0/6] vfs: help support reflink for XFS Darrick J. Wong
2016-08-25 23:30 ` [PATCH 1/6] vfs: fix return type of ioctl_file_dedupe_range Darrick J. Wong
2016-08-25 23:30 ` [PATCH 2/6] vfs: cap dedupe request structure size at PAGE_SIZE Darrick J. Wong
@ 2016-08-25 23:31 ` Darrick J. Wong
[not found] ` <147216786073.525.16014208838990530622.stgit-PTl6brltDGh4DFYR7WNSRA@public.gmane.org>
2016-08-25 23:31 ` [PATCH 4/6] fs: add iomap_file_dirty Christoph Hellwig
` (2 subsequent siblings)
5 siblings, 1 reply; 19+ messages in thread
From: Darrick J. Wong @ 2016-08-25 23:31 UTC (permalink / raw)
To: david, viro, darrick.wong; +Cc: linux-xfs, linux-fsdevel, xfs, linux-api
Introduce XFLAGs for the new XFS reflink inode flag and the CoW extent
size hint, and actually plumb the CoW extent size hint into the fsxattr
structure.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
include/uapi/linux/fs.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index 3b00f7c..fb371a5 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -157,7 +157,8 @@ struct fsxattr {
__u32 fsx_extsize; /* extsize field value (get/set)*/
__u32 fsx_nextents; /* nextents field value (get) */
__u32 fsx_projid; /* project identifier (get/set) */
- unsigned char fsx_pad[12];
+ __u32 fsx_cowextsize; /* CoW extsize field value (get/set)*/
+ unsigned char fsx_pad[8];
};
/*
@@ -178,6 +179,8 @@ struct fsxattr {
#define FS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
#define FS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
#define FS_XFLAG_DAX 0x00008000 /* use DAX for IO */
+#define FS_XFLAG_REFLINK 0x00010000 /* file is reflinked */
+#define FS_XFLAG_COWEXTSIZE 0x00020000 /* CoW extent size allocator hint */
#define FS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
/* the read-only stuff doesn't really belong here, but any other place is
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 4/6] fs: add iomap_file_dirty
2016-08-25 23:30 [PATCH v8 0/6] vfs: help support reflink for XFS Darrick J. Wong
` (2 preceding siblings ...)
2016-08-25 23:31 ` [PATCH 3/6] vfs: support FS_XFLAG_REFLINK and FS_XFLAG_COWEXTSIZE Darrick J. Wong
@ 2016-08-25 23:31 ` Christoph Hellwig
2016-09-05 14:57 ` Christoph Hellwig
2016-08-25 23:31 ` [PATCH 5/6] iomap: don't set FIEMAP_EXTENT_MERGED for extent based filesystems Darrick J. Wong
[not found] ` <147216784041.525.7722906502172299465.stgit-PTl6brltDGh4DFYR7WNSRA@public.gmane.org>
5 siblings, 1 reply; 19+ messages in thread
From: Christoph Hellwig @ 2016-08-25 23:31 UTC (permalink / raw)
To: david, viro, darrick.wong; +Cc: linux-xfs, linux-fsdevel, xfs, linux-api
Originally-from: Christoph Hellwig <hch@lst.de>
This function uses the iomap infrastructure to re-write all pages
in a given range. This is useful for doing a copy-up of COW ranges,
and might be useful for scrubbing in the future.
XXX: might want a bigger name, and possible a better implementation
that doesn't require two lookups in the radix tree.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/iomap.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/iomap.h | 2 +
2 files changed, 84 insertions(+)
diff --git a/fs/iomap.c b/fs/iomap.c
index 0342254..7b295d5 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -252,6 +252,88 @@ iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *iter,
}
EXPORT_SYMBOL_GPL(iomap_file_buffered_write);
+static struct page *
+__iomap_read_page(struct inode *inode, loff_t offset)
+{
+ struct address_space *mapping = inode->i_mapping;
+ struct page *page;
+
+ page = read_mapping_page(mapping, offset >> PAGE_SHIFT, NULL);
+ if (IS_ERR(page))
+ return page;
+ if (!PageUptodate(page)) {
+ put_page(page);
+ return ERR_PTR(-EIO);
+ }
+ return page;
+}
+
+static loff_t
+iomap_dirty_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
+ struct iomap *iomap)
+{
+ long status = 0;
+ ssize_t written = 0;
+
+ do {
+ struct page *page, *rpage;
+ unsigned long offset; /* Offset into pagecache page */
+ unsigned long bytes; /* Bytes to write to page */
+
+ offset = (pos & (PAGE_SIZE - 1));
+ bytes = min_t(unsigned long, PAGE_SIZE - offset, length);
+
+ rpage = __iomap_read_page(inode, pos);
+ if (IS_ERR(rpage))
+ return PTR_ERR(rpage);
+
+ status = iomap_write_begin(inode, pos, bytes,
+ AOP_FLAG_NOFS | AOP_FLAG_UNINTERRUPTIBLE,
+ &page, iomap);
+ put_page(rpage);
+ if (unlikely(status))
+ return status;
+
+ WARN_ON_ONCE(!PageUptodate(page));
+
+ status = iomap_write_end(inode, pos, bytes, bytes, page);
+ if (unlikely(status <= 0)) {
+ if (WARN_ON_ONCE(status == 0))
+ return -EIO;
+ return status;
+ }
+
+ cond_resched();
+
+ pos += status;
+ written += status;
+ length -= status;
+
+ balance_dirty_pages_ratelimited(inode->i_mapping);
+ } while (length);
+
+ return written;
+}
+
+int
+iomap_file_dirty(struct inode *inode, loff_t pos, loff_t len,
+ struct iomap_ops *ops)
+{
+ loff_t ret;
+
+ while (len) {
+ ret = iomap_apply(inode, pos, len, IOMAP_WRITE, ops, NULL,
+ iomap_dirty_actor);
+ if (ret <= 0)
+ return ret;
+ pos += ret;
+ len -= ret;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(iomap_file_dirty);
+
static int iomap_zero(struct inode *inode, loff_t pos, unsigned offset,
unsigned bytes, struct iomap *iomap)
{
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index 3267df4..b2e30e5 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -58,6 +58,8 @@ struct iomap_ops {
ssize_t iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *from,
struct iomap_ops *ops);
+int iomap_file_dirty(struct inode *inode, loff_t pos, loff_t len,
+ struct iomap_ops *ops);
int iomap_zero_range(struct inode *inode, loff_t pos, loff_t len,
bool *did_zero, struct iomap_ops *ops);
int iomap_truncate_page(struct inode *inode, loff_t pos, bool *did_zero,
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH 4/6] fs: add iomap_file_dirty
2016-08-25 23:31 ` [PATCH 4/6] fs: add iomap_file_dirty Christoph Hellwig
@ 2016-09-05 14:57 ` Christoph Hellwig
2016-09-06 17:34 ` Darrick J. Wong
[not found] ` <20160905145751.GC7662-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
0 siblings, 2 replies; 19+ messages in thread
From: Christoph Hellwig @ 2016-09-05 14:57 UTC (permalink / raw)
To: Christoph Hellwig
Cc: darrick.wong, linux-api, xfs, linux-xfs, viro, linux-fsdevel
On Thu, Aug 25, 2016 at 04:31:07PM -0700, Christoph Hellwig wrote:
> Originally-from: Christoph Hellwig <hch@lst.de>
This should be a
From: Christoph Hellwig <hch@lst.de>
so that git picks up authorship information correctly.
> XXX: might want a bigger name, and possible a better implementation
> that doesn't require two lookups in the radix tree.
And these need to be looked into. I can take a stab at it, but I need
to get a few other things off my plate first.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 4/6] fs: add iomap_file_dirty
2016-09-05 14:57 ` Christoph Hellwig
@ 2016-09-06 17:34 ` Darrick J. Wong
2016-09-11 12:58 ` Christoph Hellwig
[not found] ` <20160905145751.GC7662-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
1 sibling, 1 reply; 19+ messages in thread
From: Darrick J. Wong @ 2016-09-06 17:34 UTC (permalink / raw)
To: Christoph Hellwig
Cc: linux-api, xfs, linux-xfs, viro, linux-fsdevel, Christoph Hellwig
On Mon, Sep 05, 2016 at 07:57:51AM -0700, Christoph Hellwig wrote:
> On Thu, Aug 25, 2016 at 04:31:07PM -0700, Christoph Hellwig wrote:
> > Originally-from: Christoph Hellwig <hch@lst.de>
>
> This should be a
>
> From: Christoph Hellwig <hch@lst.de>
>
> so that git picks up authorship information correctly.
>
> > XXX: might want a bigger name, and possible a better implementation
> > that doesn't require two lookups in the radix tree.
>
> And these need to be looked into. I can take a stab at it, but I need
> to get a few other things off my plate first.
Yeah. It works well enough for unsharing blocks, if inefficiently.
Not sure what "a bigger name" means, though. I tried feeding the
function prototype through figlet but gcc didn't like that. ;)
--D
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 4/6] fs: add iomap_file_dirty
2016-09-06 17:34 ` Darrick J. Wong
@ 2016-09-11 12:58 ` Christoph Hellwig
0 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2016-09-11 12:58 UTC (permalink / raw)
To: Darrick J. Wong
Cc: Christoph Hellwig, Christoph Hellwig, david, viro, linux-xfs,
linux-fsdevel, xfs, linux-api
On Tue, Sep 06, 2016 at 10:34:28AM -0700, Darrick J. Wong wrote:
> > > XXX: might want a bigger name, and possible a better implementation
> > > that doesn't require two lookups in the radix tree.
> >
> > And these need to be looked into. I can take a stab at it, but I need
> > to get a few other things off my plate first.
>
> Yeah. It works well enough for unsharing blocks, if inefficiently.
>
> Not sure what "a bigger name" means, though. I tried feeding the
> function prototype through figlet but gcc didn't like that. ;)
That should have been "better", sorry.
^ permalink raw reply [flat|nested] 19+ messages in thread
[parent not found: <20160905145751.GC7662-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>]
* Re: [PATCH 4/6] fs: add iomap_file_dirty
[not found] ` <20160905145751.GC7662-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
@ 2016-09-19 0:11 ` Dave Chinner
0 siblings, 0 replies; 19+ messages in thread
From: Dave Chinner @ 2016-09-19 0:11 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Christoph Hellwig, viro-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn,
darrick.wong-QHcLZuEGTsvQT0dZR+AlfA,
linux-xfs-u79uwXL29TY76Z2rM5mHXA,
linux-fsdevel-u79uwXL29TY76Z2rM5mHXA, xfs-VZNHf3L845pBDgjK7y7TUQ,
linux-api-u79uwXL29TY76Z2rM5mHXA
On Mon, Sep 05, 2016 at 07:57:51AM -0700, Christoph Hellwig wrote:
> On Thu, Aug 25, 2016 at 04:31:07PM -0700, Christoph Hellwig wrote:
> > Originally-from: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
>
> This should be a
>
> From: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
>
> so that git picks up authorship information correctly.
>
> > XXX: might want a bigger name, and possible a better implementation
> > that doesn't require two lookups in the radix tree.
>
> And these need to be looked into. I can take a stab at it, but I need
> to get a few other things off my plate first.
Seeing as it works and isn't too ugly to live, I think I'm going to
merge this as is. When a better implementation comes along we
can replace it with that...
Cheers,
Dave.
--
Dave Chinner
david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 5/6] iomap: don't set FIEMAP_EXTENT_MERGED for extent based filesystems
2016-08-25 23:30 [PATCH v8 0/6] vfs: help support reflink for XFS Darrick J. Wong
` (3 preceding siblings ...)
2016-08-25 23:31 ` [PATCH 4/6] fs: add iomap_file_dirty Christoph Hellwig
@ 2016-08-25 23:31 ` Darrick J. Wong
[not found] ` <147216784041.525.7722906502172299465.stgit-PTl6brltDGh4DFYR7WNSRA@public.gmane.org>
5 siblings, 0 replies; 19+ messages in thread
From: Darrick J. Wong @ 2016-08-25 23:31 UTC (permalink / raw)
To: david, viro, darrick.wong
Cc: Andreas Gruenbacher, linux-api, xfs, linux-xfs, linux-fsdevel,
Christoph Hellwig
From: Christoph Hellwig <hch@lst.de>
Filesystems like XFS that use extents should not set the
FIEMAP_EXTENT_MERGED flag in the fiemap extent structures. To allow
for both behaviors for the upcoming gfs2 usage split the iomap
type field into type and flags, and only set FIEMAP_EXTENT_MERGED if
the IOMAP_F_MERGED flag is set. The flags field will also come in
handy for future features such as shared extents on reflink-enabled
file systems.
Reported-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/iomap.c | 5 ++++-
include/linux/iomap.h | 8 +++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/fs/iomap.c b/fs/iomap.c
index 7b295d5..e9b3f99 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -510,9 +510,12 @@ static int iomap_to_fiemap(struct fiemap_extent_info *fi,
break;
}
+ if (iomap->flags & IOMAP_F_MERGED)
+ flags |= FIEMAP_EXTENT_MERGED;
+
return fiemap_fill_next_extent(fi, iomap->offset,
iomap->blkno != IOMAP_NULL_BLOCK ? iomap->blkno << 9: 0,
- iomap->length, flags | FIEMAP_EXTENT_MERGED);
+ iomap->length, flags);
}
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index b2e30e5..3a56212 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -19,6 +19,11 @@ struct vm_fault;
#define IOMAP_UNWRITTEN 0x04 /* blocks allocated @blkno in unwritten state */
/*
+ * Flags for iomap mappings:
+ */
+#define IOMAP_F_MERGED 0x01 /* contains multiple blocks/extents */
+
+/*
* Magic value for blkno:
*/
#define IOMAP_NULL_BLOCK -1LL /* blkno is not valid */
@@ -27,7 +32,8 @@ struct iomap {
sector_t blkno; /* 1st sector of mapping, 512b units */
loff_t offset; /* file offset of mapping, bytes */
u64 length; /* length of mapping, bytes */
- int type; /* type of mapping */
+ u16 type; /* type of mapping */
+ u16 flags; /* flags for mapping */
struct block_device *bdev; /* block device for I/O */
};
^ permalink raw reply related [flat|nested] 19+ messages in thread
[parent not found: <147216784041.525.7722906502172299465.stgit-PTl6brltDGh4DFYR7WNSRA@public.gmane.org>]
* [PATCH 6/6] iomap: add a flag to report shared extents
[not found] ` <147216784041.525.7722906502172299465.stgit-PTl6brltDGh4DFYR7WNSRA@public.gmane.org>
@ 2016-08-25 23:31 ` Darrick J. Wong
2016-09-05 14:58 ` Christoph Hellwig
0 siblings, 1 reply; 19+ messages in thread
From: Darrick J. Wong @ 2016-08-25 23:31 UTC (permalink / raw)
To: david-FqsqvQoI3Ljby3iVrkZq2A,
viro-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn,
darrick.wong-QHcLZuEGTsvQT0dZR+AlfA
Cc: linux-xfs-u79uwXL29TY76Z2rM5mHXA,
linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
linux-api-u79uwXL29TY76Z2rM5mHXA, xfs-VZNHf3L845pBDgjK7y7TUQ
Signed-off-by: Darrick J. Wong <darrick.wong-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
fs/iomap.c | 2 ++
include/linux/iomap.h | 1 +
2 files changed, 3 insertions(+)
diff --git a/fs/iomap.c b/fs/iomap.c
index e9b3f99..ec411a6 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -512,6 +512,8 @@ static int iomap_to_fiemap(struct fiemap_extent_info *fi,
if (iomap->flags & IOMAP_F_MERGED)
flags |= FIEMAP_EXTENT_MERGED;
+ if (iomap->flags & IOMAP_F_SHARED)
+ flags |= FIEMAP_EXTENT_SHARED;
return fiemap_fill_next_extent(fi, iomap->offset,
iomap->blkno != IOMAP_NULL_BLOCK ? iomap->blkno << 9: 0,
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index 3a56212..c74226a 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -22,6 +22,7 @@ struct vm_fault;
* Flags for iomap mappings:
*/
#define IOMAP_F_MERGED 0x01 /* contains multiple blocks/extents */
+#define IOMAP_F_SHARED 0x02 /* block shared with another file */
/*
* Magic value for blkno:
^ permalink raw reply related [flat|nested] 19+ messages in thread