Re: [PATCH 3/3] block: implement (some of) fallocate for block devices

From
Christoph Hellwig <hidden>
Date
2016-03-21 15:38:30
Also in
linux-fsdevel, lkml
Reply to
Darrick J. Wong, 2016-03-15
On Tue, Mar 15, 2016 at 12:42:44PM -0700, Darrick J. Wong wrote:
quoted hunk ↗ jump to hunk
 #include <linux/cleancache.h>
 #include <linux/dax.h>
 #include <asm/uaccess.h>
+#include <linux/falloc.h>
Maybe keep this before asm/uaccess.h
+long blkdev_fallocate(struct file *file, int mode, loff_t start, loff_t len)
should be marked static.
quoted hunk ↗ jump to hunk
+	/* We haven't a primitive for "ensure space exists" right now. */
+	if (!(mode & ~FALLOC_FL_KEEP_SIZE))
+		return -EOPNOTSUPP;
I don't really understand the comment.  But I think you'd be much
better off with having blkdev_fallocate as just a tiny wrapper that has
a switch for the supported modes, e.g.

	switch (mode) {
	case FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE:
		return blkdev_punch_hole();
	case FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE::
		return blkdev_zero_range();
	default:
		return -EOPNOTSUPP;
	}
+EXPORT_SYMBOL_GPL(blkdev_fallocate);
and no need to export it either..
Thread (11 messages) 11 messages, 4 authors, 2016-03-21
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help