xfs: add FITRIM support
PATCH v3 1/1 xfs: add FITRIM support
Allow manual discards from userspace using the FITRIM ioctl. This is not intended to be run during normal workloads, as the freepsace btree walks can cause large performance degradation.
Signed-off-by Christoph Hellwig <[email protected]>
fs/xfs/xfs_alloc.c +3 -7
@@ -41,10 +41,6 @@#define XFSA_FIXUP_BNO_OK 1#define XFSA_FIXUP_CNT_OK 2 -static int -xfs_alloc_busy_search (struct xfs_mount *mp,xfs_agnumber_t agno, -xfs_agblock_t bno,xfs_extlen_t len); -/* * Prototypes for per-ag allocation routines */
@@ -94,7 +90,7 @@ xfs_alloc_lookup_ge(* Lookup the first record less than or equal to [bno, len] * in the btree given by cur. */ -STATIC int /* error */ +int /* error */ xfs_alloc_lookup_le( struct xfs_btree_cur *cur, /* btree cursor */ xfs_agblock_t bno, /* starting block of extent */
@@ -127,7 +123,7 @@ xfs_alloc_update(/* * Get the data from the pointed-to record. */ -STATIC int /* error */ +int /* error */ xfs_alloc_get_rec( struct xfs_btree_cur *cur, /* btree cursor */ xfs_agblock_t *bno, /* output: starting block of extent */
@@ -2615,7 +2611,7 @@ restart:* will require a synchronous transaction, but it can still be * used to distinguish between a partial or exact match. */ -static int +int xfs_alloc_busy_search( struct xfs_mount *mp, xfs_agnumber_t agno,
fs/xfs/xfs_alloc.h +20 -5
@@ -19,6 +19,7 @@#define __XFS_ALLOC_H__struct xfs_buf ; +struct xfs_btree_cur ;struct xfs_mount ;struct xfs_perag ;struct xfs_trans ;
@@ -118,16 +119,16 @@ xfs_alloc_longest_free_extent(struct xfs struct xfs_perag *pag);#ifdef __KERNEL__ -void -xfs_alloc_busy_insert (xfs_trans_t *tp, -xfs_agnumber_t agno, -xfs_agblock_t bno, -xfs_extlen_t len); +xfs_alloc_busy_insert (struct xfs_trans *tp,xfs_agnumber_t agno, +xfs_agblock_t bno,xfs_extlen_t len);void xfs_alloc_busy_clear (struct xfs_mount *mp,struct xfs_busy_extent *busyp); +int +xfs_alloc_busy_search (struct xfs_mount *mp,xfs_agnumber_t agno, +xfs_agblock_t bno,xfs_extlen_t len);#endif /* __KERNEL__ */ /*
@@ -205,4 +206,18 @@ xfs_free_extent(xfs_fsblock_t bno,/* starting block number of extent */ xfs_extlen_t len); /* length of extent */ +int /* error */ +xfs_alloc_lookup_le ( +struct xfs_btree_cur *cur,/* btree cursor */ +xfs_agblock_t bno,/* starting block of extent */ +xfs_extlen_t len,/* length of extent */ +int *stat);/* success/failure */ + +int /* error */ +xfs_alloc_get_rec ( +struct xfs_btree_cur *cur,/* btree cursor */ +xfs_agblock_t *bno,/* output: starting block of extent */ +xfs_extlen_t *len,/* output: length of extent */ +int *stat);/* output: success/failure */ +#endif /* __XFS_ALLOC_H__ */
fs/xfs/Makefile +1 -0
@@ -98,6 +98,7 @@ xfs-y += $(addprefix $(XFS_LINUX)/, \ kmem.o \ xfs_aops.o \ xfs_buf.o \ + xfs_discard.o \ xfs_export.o \ xfs_file.o \ xfs_fs_subr.o \
fs/xfs/linux-2.6/xfs_discard.c new file +191 -0
191 lines not on this page · raw message
fs/xfs/linux-2.6/xfs_discard.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef XFS_DISCARD_H +#define XFS_DISCARD_H 1 + +struct fstrim_range ; + +extern int xfs_ioc_trim (struct xfs_mount *,struct fstrim_range __user *); + +#endif /* XFS_DISCARD_H */
fs/xfs/linux-2.6/xfs_trace.h +33 -0
@@ -1759,6 +1759,39 @@ DEFINE_LOG_RECOVER_INO_ITEM(xfs_log_recoDEFINE_LOG_RECOVER_INO_ITEM (xfs_log_recover_inode_cancel);DEFINE_LOG_RECOVER_INO_ITEM (xfs_log_recover_inode_skip); +DECLARE_EVENT_CLASS (xfs_discard_class, + TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, + xfs_agblock_t agbno, xfs_extlen_t len), +TP_ARGS (mp, agno, agbno, len), +TP_STRUCT__entry ( + __field(dev_t, dev) + __field(xfs_agnumber_t, agno) + __field(xfs_agblock_t, agbno) +__field (xfs_extlen_t, len) + ), +TP_fast_assign ( + __entry->dev = mp->m_super->s_dev; + __entry->agno = agno; + __entry->agbno = agbno; + __entry->len = len; + ), +TP_printk ("dev %d:%d agno %u agbno %u len %u\n" , +MAJOR (__entry->dev),MINOR (__entry->dev), + __entry->agno, + __entry->agbno, + __entry->len) +) + +#define DEFINE_DISCARD_EVENT (name) \ +DEFINE_EVENT(xfs_discard_class, name, \ + TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \ + xfs_agblock_t agbno, xfs_extlen_t len), \ + TP_ARGS(mp, agno, agbno, len)) +DEFINE_DISCARD_EVENT (xfs_discard_extent); +DEFINE_DISCARD_EVENT (xfs_discard_toosmall); +DEFINE_DISCARD_EVENT (xfs_discard_exclude); +DEFINE_DISCARD_EVENT (xfs_discard_busy); +#endif /* _TRACE_XFS_H */ #undef TRACE_INCLUDE_PATH
fs/xfs/linux-2.6/xfs_ioctl.c +3 -0
@@ -39,6 +39,7 @@#include "xfs_dfrag.h" #include "xfs_fsops.h" #include "xfs_vnodeops.h" +#include "xfs_discard.h" #include "xfs_quota.h" #include "xfs_inode_item.h" #include "xfs_export.h"
@@ -1294,6 +1295,8 @@ xfs_file_ioctl(trace_xfs_file_ioctl (ip);switch (cmd) { +case FITRIM : +return xfs_ioc_trim (mp, arg);case XFS_IOC_ALLOCSP :case XFS_IOC_FREESP :case XFS_IOC_RESVSP :
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 5 lines · Christoph Hellwig
Allow manual discards from userspace using the FITRIM ioctl. This is not intended to be run during normal workloads, as the freepsace btree walks can cause large performance degradation.
Signed-off-by Christoph Hellwig <[email protected]>
Looks good.
Reviewed-by Dave Chinner <[email protected]>
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs