diff options
author | Chris Mason <chris.mason@oracle.com> | 2011-05-24 15:35:30 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-05-26 17:52:15 -0400 |
commit | 4cb5300bc839b8a943eb19c9f27f25470e22d0ca (patch) | |
tree | ac0f2fb481c7aa6af08a624d276fa6d580c94c9b /fs/btrfs/ctree.h | |
parent | d6c0cb379c5198487e4ac124728cbb2346d63b1f (diff) |
Btrfs: add mount -o auto_defrag
This will detect small random writes into files and
queue the up for an auto defrag process. It isn't well suited to
database workloads yet, but works for smaller files such as rpm, sqlite
or bdb databases.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 026fc47b42cf..332323e19dd1 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -1074,6 +1074,11 @@ struct btrfs_fs_info { | |||
1074 | /* all metadata allocations go through this cluster */ | 1074 | /* all metadata allocations go through this cluster */ |
1075 | struct btrfs_free_cluster meta_alloc_cluster; | 1075 | struct btrfs_free_cluster meta_alloc_cluster; |
1076 | 1076 | ||
1077 | /* auto defrag inodes go here */ | ||
1078 | spinlock_t defrag_inodes_lock; | ||
1079 | struct rb_root defrag_inodes; | ||
1080 | atomic_t defrag_running; | ||
1081 | |||
1077 | spinlock_t ref_cache_lock; | 1082 | spinlock_t ref_cache_lock; |
1078 | u64 total_ref_cache_size; | 1083 | u64 total_ref_cache_size; |
1079 | 1084 | ||
@@ -1205,6 +1210,38 @@ struct btrfs_root { | |||
1205 | struct super_block anon_super; | 1210 | struct super_block anon_super; |
1206 | }; | 1211 | }; |
1207 | 1212 | ||
1213 | struct btrfs_ioctl_defrag_range_args { | ||
1214 | /* start of the defrag operation */ | ||
1215 | __u64 start; | ||
1216 | |||
1217 | /* number of bytes to defrag, use (u64)-1 to say all */ | ||
1218 | __u64 len; | ||
1219 | |||
1220 | /* | ||
1221 | * flags for the operation, which can include turning | ||
1222 | * on compression for this one defrag | ||
1223 | */ | ||
1224 | __u64 flags; | ||
1225 | |||
1226 | /* | ||
1227 | * any extent bigger than this will be considered | ||
1228 | * already defragged. Use 0 to take the kernel default | ||
1229 | * Use 1 to say every single extent must be rewritten | ||
1230 | */ | ||
1231 | __u32 extent_thresh; | ||
1232 | |||
1233 | /* | ||
1234 | * which compression method to use if turning on compression | ||
1235 | * for this defrag operation. If unspecified, zlib will | ||
1236 | * be used | ||
1237 | */ | ||
1238 | __u32 compress_type; | ||
1239 | |||
1240 | /* spare for later */ | ||
1241 | __u32 unused[4]; | ||
1242 | }; | ||
1243 | |||
1244 | |||
1208 | /* | 1245 | /* |
1209 | * inode items have the data typically returned from stat and store other | 1246 | * inode items have the data typically returned from stat and store other |
1210 | * info about object characteristics. There is one for every file and dir in | 1247 | * info about object characteristics. There is one for every file and dir in |
@@ -1302,6 +1339,7 @@ struct btrfs_root { | |||
1302 | #define BTRFS_MOUNT_CLEAR_CACHE (1 << 13) | 1339 | #define BTRFS_MOUNT_CLEAR_CACHE (1 << 13) |
1303 | #define BTRFS_MOUNT_USER_SUBVOL_RM_ALLOWED (1 << 14) | 1340 | #define BTRFS_MOUNT_USER_SUBVOL_RM_ALLOWED (1 << 14) |
1304 | #define BTRFS_MOUNT_ENOSPC_DEBUG (1 << 15) | 1341 | #define BTRFS_MOUNT_ENOSPC_DEBUG (1 << 15) |
1342 | #define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16) | ||
1305 | 1343 | ||
1306 | #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt) | 1344 | #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt) |
1307 | #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt) | 1345 | #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt) |
@@ -2528,8 +2566,13 @@ extern const struct dentry_operations btrfs_dentry_operations; | |||
2528 | long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg); | 2566 | long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg); |
2529 | void btrfs_update_iflags(struct inode *inode); | 2567 | void btrfs_update_iflags(struct inode *inode); |
2530 | void btrfs_inherit_iflags(struct inode *inode, struct inode *dir); | 2568 | void btrfs_inherit_iflags(struct inode *inode, struct inode *dir); |
2531 | 2569 | int btrfs_defrag_file(struct inode *inode, struct file *file, | |
2570 | struct btrfs_ioctl_defrag_range_args *range, | ||
2571 | u64 newer_than, unsigned long max_pages); | ||
2532 | /* file.c */ | 2572 | /* file.c */ |
2573 | int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans, | ||
2574 | struct inode *inode); | ||
2575 | int btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info); | ||
2533 | int btrfs_sync_file(struct file *file, int datasync); | 2576 | int btrfs_sync_file(struct file *file, int datasync); |
2534 | int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end, | 2577 | int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end, |
2535 | int skip_pinned); | 2578 | int skip_pinned); |