aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2012-11-07 12:21:12 -0500
committerBen Myers <bpm@sgi.com>2012-11-08 16:27:49 -0500
commit8ca149de80478441352a8622ea15fae7de703ced (patch)
treed98cd5200aa1180b01925a400fe6e4155e0e5a0b /fs/xfs
parent41176a68e3f710630feace536d0277a092e206b5 (diff)
xfs: add XFS_IOC_FREE_EOFBLOCKS ioctl
The XFS_IOC_FREE_EOFBLOCKS ioctl allows users to invoke an EOFBLOCKS scan. The xfs_eofblocks structure is defined to support the command parameters (scan mode). Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Mark Tinguely <tinguely@sgi.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_fs.h17
-rw-r--r--fs/xfs/xfs_icache.c10
-rw-r--r--fs/xfs/xfs_icache.h2
-rw-r--r--fs/xfs/xfs_ioctl.c20
4 files changed, 45 insertions, 4 deletions
diff --git a/fs/xfs/xfs_fs.h b/fs/xfs/xfs_fs.h
index 0948c043443..0cfa30813b1 100644
--- a/fs/xfs/xfs_fs.h
+++ b/fs/xfs/xfs_fs.h
@@ -340,6 +340,22 @@ typedef struct xfs_error_injection {
340 340
341 341
342/* 342/*
343 * Speculative preallocation trimming.
344 */
345#define XFS_EOFBLOCKS_VERSION 1
346struct xfs_eofblocks {
347 __u32 eof_version;
348 __u32 eof_flags;
349 __u64 pad[15];
350};
351
352/* eof_flags values */
353#define XFS_EOF_FLAGS_SYNC (1 << 0) /* sync/wait mode scan */
354#define XFS_EOF_FLAGS_VALID \
355 (XFS_EOF_FLAGS_SYNC)
356
357
358/*
343 * The user-level Handle Request interface structure. 359 * The user-level Handle Request interface structure.
344 */ 360 */
345typedef struct xfs_fsop_handlereq { 361typedef struct xfs_fsop_handlereq {
@@ -457,6 +473,7 @@ typedef struct xfs_handle {
457/* XFS_IOC_GETBIOSIZE ---- deprecated 47 */ 473/* XFS_IOC_GETBIOSIZE ---- deprecated 47 */
458#define XFS_IOC_GETBMAPX _IOWR('X', 56, struct getbmap) 474#define XFS_IOC_GETBMAPX _IOWR('X', 56, struct getbmap)
459#define XFS_IOC_ZERO_RANGE _IOW ('X', 57, struct xfs_flock64) 475#define XFS_IOC_ZERO_RANGE _IOW ('X', 57, struct xfs_flock64)
476#define XFS_IOC_FREE_EOFBLOCKS _IOR ('X', 58, struct xfs_eofblocks)
460 477
461/* 478/*
462 * ioctl commands that replace IRIX syssgi()'s 479 * ioctl commands that replace IRIX syssgi()'s
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index d115cb44b10..fbb74c71526 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -1206,11 +1206,15 @@ xfs_inode_free_eofblocks(
1206int 1206int
1207xfs_icache_free_eofblocks( 1207xfs_icache_free_eofblocks(
1208 struct xfs_mount *mp, 1208 struct xfs_mount *mp,
1209 int flags) 1209 struct xfs_eofblocks *eofb)
1210{ 1210{
1211 ASSERT((flags & ~(SYNC_TRYLOCK|SYNC_WAIT)) == 0); 1211 int flags = SYNC_TRYLOCK;
1212
1213 if (eofb && (eofb->eof_flags & XFS_EOF_FLAGS_SYNC))
1214 flags = SYNC_WAIT;
1215
1212 return xfs_inode_ag_iterator_tag(mp, xfs_inode_free_eofblocks, flags, 1216 return xfs_inode_ag_iterator_tag(mp, xfs_inode_free_eofblocks, flags,
1213 NULL, XFS_ICI_EOFBLOCKS_TAG); 1217 eofb, XFS_ICI_EOFBLOCKS_TAG);
1214} 1218}
1215 1219
1216void 1220void
diff --git a/fs/xfs/xfs_icache.h b/fs/xfs/xfs_icache.h
index cb6b8d0eee6..4934a77024c 100644
--- a/fs/xfs/xfs_icache.h
+++ b/fs/xfs/xfs_icache.h
@@ -37,7 +37,7 @@ void xfs_inode_set_reclaim_tag(struct xfs_inode *ip);
37 37
38void xfs_inode_set_eofblocks_tag(struct xfs_inode *ip); 38void xfs_inode_set_eofblocks_tag(struct xfs_inode *ip);
39void xfs_inode_clear_eofblocks_tag(struct xfs_inode *ip); 39void xfs_inode_clear_eofblocks_tag(struct xfs_inode *ip);
40int xfs_icache_free_eofblocks(struct xfs_mount *, int); 40int xfs_icache_free_eofblocks(struct xfs_mount *, struct xfs_eofblocks *);
41 41
42int xfs_sync_inode_grab(struct xfs_inode *ip); 42int xfs_sync_inode_grab(struct xfs_inode *ip);
43int xfs_inode_ag_iterator(struct xfs_mount *mp, 43int xfs_inode_ag_iterator(struct xfs_mount *mp,
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index c1df3c623de..5b20ab0b4f9 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -42,6 +42,7 @@
42#include "xfs_inode_item.h" 42#include "xfs_inode_item.h"
43#include "xfs_export.h" 43#include "xfs_export.h"
44#include "xfs_trace.h" 44#include "xfs_trace.h"
45#include "xfs_icache.h"
45 46
46#include <linux/capability.h> 47#include <linux/capability.h>
47#include <linux/dcache.h> 48#include <linux/dcache.h>
@@ -1602,6 +1603,25 @@ xfs_file_ioctl(
1602 error = xfs_errortag_clearall(mp, 1); 1603 error = xfs_errortag_clearall(mp, 1);
1603 return -error; 1604 return -error;
1604 1605
1606 case XFS_IOC_FREE_EOFBLOCKS: {
1607 struct xfs_eofblocks eofb;
1608
1609 if (copy_from_user(&eofb, arg, sizeof(eofb)))
1610 return -XFS_ERROR(EFAULT);
1611
1612 if (eofb.eof_version != XFS_EOFBLOCKS_VERSION)
1613 return -XFS_ERROR(EINVAL);
1614
1615 if (eofb.eof_flags & ~XFS_EOF_FLAGS_VALID)
1616 return -XFS_ERROR(EINVAL);
1617
1618 if (memchr_inv(eofb.pad, 0, sizeof(eofb.pad)))
1619 return -XFS_ERROR(EINVAL);
1620
1621 error = xfs_icache_free_eofblocks(mp, &eofb);
1622 return -error;
1623 }
1624
1605 default: 1625 default:
1606 return -ENOTTY; 1626 return -ENOTTY;
1607 } 1627 }