Skip to content

Commit bbf65cf

Browse files
author
Chris Mason
committed
Merge branch 'cleanup/misc-for-3.18' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into for-linus
Signed-off-by: Chris Mason <clm@fb.com> Conflicts: fs/btrfs/extent_io.c
2 parents bf8e8ca + fccb84c commit bbf65cf

17 files changed

Lines changed: 130 additions & 135 deletions

‎fs/btrfs/compression.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
388388
* freed before we're done setting it up
389389
*/
390390
atomic_inc(&cb->pending_bios);
391-
ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0);
391+
ret = btrfs_bio_wq_end_io(root->fs_info, bio,
392+
BTRFS_WQ_ENDIO_DATA);
392393
BUG_ON(ret); /* -ENOMEM */
393394

394395
if (!skip_sum) {
@@ -419,7 +420,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
419420
}
420421
bio_get(bio);
421422

422-
ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0);
423+
ret = btrfs_bio_wq_end_io(root->fs_info, bio, BTRFS_WQ_ENDIO_DATA);
423424
BUG_ON(ret); /* -ENOMEM */
424425

425426
if (!skip_sum) {
@@ -668,7 +669,8 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
668669
PAGE_CACHE_SIZE) {
669670
bio_get(comp_bio);
670671

671-
ret = btrfs_bio_wq_end_io(root->fs_info, comp_bio, 0);
672+
ret = btrfs_bio_wq_end_io(root->fs_info, comp_bio,
673+
BTRFS_WQ_ENDIO_DATA);
672674
BUG_ON(ret); /* -ENOMEM */
673675

674676
/*
@@ -706,7 +708,8 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
706708
}
707709
bio_get(comp_bio);
708710

709-
ret = btrfs_bio_wq_end_io(root->fs_info, comp_bio, 0);
711+
ret = btrfs_bio_wq_end_io(root->fs_info, comp_bio,
712+
BTRFS_WQ_ENDIO_DATA);
710713
BUG_ON(ret); /* -ENOMEM */
711714

712715
if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {

‎fs/btrfs/ctree.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,10 +1506,9 @@ static inline int should_cow_block(struct btrfs_trans_handle *trans,
15061506
struct btrfs_root *root,
15071507
struct extent_buffer *buf)
15081508
{
1509-
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
1510-
if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state)))
1509+
if (btrfs_test_is_dummy_root(root))
15111510
return 0;
1512-
#endif
1511+
15131512
/* ensure we can see the force_cow */
15141513
smp_rmb();
15151514

@@ -4625,8 +4624,7 @@ void btrfs_truncate_item(struct btrfs_root *root, struct btrfs_path *path,
46254624
ptr = btrfs_item_ptr_offset(leaf, slot);
46264625
memmove_extent_buffer(leaf, ptr,
46274626
(unsigned long)fi,
4628-
offsetof(struct btrfs_file_extent_item,
4629-
disk_bytenr));
4627+
BTRFS_FILE_EXTENT_INLINE_DATA_START);
46304628
}
46314629
}
46324630

‎fs/btrfs/ctree.h‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,11 @@ struct btrfs_header {
385385
sizeof(struct btrfs_key_ptr))
386386
#define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header))
387387
#define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->nodesize))
388+
#define BTRFS_FILE_EXTENT_INLINE_DATA_START \
389+
(offsetof(struct btrfs_file_extent_item, disk_bytenr))
388390
#define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
389391
sizeof(struct btrfs_item) - \
390-
offsetof(struct btrfs_file_extent_item, disk_bytenr))
392+
BTRFS_FILE_EXTENT_INLINE_DATA_START)
391393
#define BTRFS_MAX_XATTR_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
392394
sizeof(struct btrfs_item) -\
393395
sizeof(struct btrfs_dir_item))
@@ -896,6 +898,8 @@ struct btrfs_file_extent_item {
896898
/*
897899
* disk space consumed by the extent, checksum blocks are included
898900
* in these numbers
901+
*
902+
* At this offset in the structure, the inline extent data start.
899903
*/
900904
__le64 disk_bytenr;
901905
__le64 disk_num_bytes;
@@ -2089,6 +2093,7 @@ struct btrfs_ioctl_defrag_range_args {
20892093
#define BTRFS_MOUNT_CHANGE_INODE_CACHE (1 << 24)
20902094

20912095
#define BTRFS_DEFAULT_COMMIT_INTERVAL (30)
2096+
#define BTRFS_DEFAULT_MAX_INLINE (8192)
20922097

20932098
#define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
20942099
#define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
@@ -3042,14 +3047,12 @@ BTRFS_SETGET_STACK_FUNCS(stack_file_extent_compression,
30423047
static inline unsigned long
30433048
btrfs_file_extent_inline_start(struct btrfs_file_extent_item *e)
30443049
{
3045-
unsigned long offset = (unsigned long)e;
3046-
offset += offsetof(struct btrfs_file_extent_item, disk_bytenr);
3047-
return offset;
3050+
return (unsigned long)e + BTRFS_FILE_EXTENT_INLINE_DATA_START;
30483051
}
30493052

30503053
static inline u32 btrfs_file_extent_calc_inline_size(u32 datasize)
30513054
{
3052-
return offsetof(struct btrfs_file_extent_item, disk_bytenr) + datasize;
3055+
return BTRFS_FILE_EXTENT_INLINE_DATA_START + datasize;
30533056
}
30543057

30553058
BTRFS_SETGET_FUNCS(file_extent_disk_bytenr, struct btrfs_file_extent_item,
@@ -3079,9 +3082,7 @@ BTRFS_SETGET_FUNCS(file_extent_other_encoding, struct btrfs_file_extent_item,
30793082
static inline u32 btrfs_file_extent_inline_item_len(struct extent_buffer *eb,
30803083
struct btrfs_item *e)
30813084
{
3082-
unsigned long offset;
3083-
offset = offsetof(struct btrfs_file_extent_item, disk_bytenr);
3084-
return btrfs_item_size(eb, e) - offset;
3085+
return btrfs_item_size(eb, e) - BTRFS_FILE_EXTENT_INLINE_DATA_START;
30853086
}
30863087

30873088
/* this returns the number of file bytes represented by the inline item.
@@ -4128,4 +4129,13 @@ static inline int btrfs_defrag_cancelled(struct btrfs_fs_info *fs_info)
41284129
void btrfs_test_destroy_inode(struct inode *inode);
41294130
#endif
41304131

4132+
static inline int btrfs_test_is_dummy_root(struct btrfs_root *root)
4133+
{
4134+
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
4135+
if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state)))
4136+
return 1;
4137+
#endif
4138+
return 0;
4139+
}
4140+
41314141
#endif

‎fs/btrfs/disk-io.c‎

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,41 @@ static int btrfs_cleanup_transaction(struct btrfs_root *root);
7272
static void btrfs_error_commit_super(struct btrfs_root *root);
7373

7474
/*
75-
* end_io_wq structs are used to do processing in task context when an IO is
76-
* complete. This is used during reads to verify checksums, and it is used
75+
* btrfs_end_io_wq structs are used to do processing in task context when an IO
76+
* is complete. This is used during reads to verify checksums, and it is used
7777
* by writes to insert metadata for new file extents after IO is complete.
7878
*/
79-
struct end_io_wq {
79+
struct btrfs_end_io_wq {
8080
struct bio *bio;
8181
bio_end_io_t *end_io;
8282
void *private;
8383
struct btrfs_fs_info *info;
8484
int error;
85-
int metadata;
85+
enum btrfs_wq_endio_type metadata;
8686
struct list_head list;
8787
struct btrfs_work work;
8888
};
8989

90+
static struct kmem_cache *btrfs_end_io_wq_cache;
91+
92+
int __init btrfs_end_io_wq_init(void)
93+
{
94+
btrfs_end_io_wq_cache = kmem_cache_create("btrfs_end_io_wq",
95+
sizeof(struct btrfs_end_io_wq),
96+
0,
97+
SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD,
98+
NULL);
99+
if (!btrfs_end_io_wq_cache)
100+
return -ENOMEM;
101+
return 0;
102+
}
103+
104+
void btrfs_end_io_wq_exit(void)
105+
{
106+
if (btrfs_end_io_wq_cache)
107+
kmem_cache_destroy(btrfs_end_io_wq_cache);
108+
}
109+
90110
/*
91111
* async submit bios are used to offload expensive checksumming
92112
* onto the worker threads. They checksum file and metadata bios
@@ -327,8 +347,7 @@ static int verify_parent_transid(struct extent_io_tree *io_tree,
327347
{
328348
struct extent_state *cached_state = NULL;
329349
int ret;
330-
bool need_lock = (current->journal_info ==
331-
(void *)BTRFS_SEND_TRANS_STUB);
350+
bool need_lock = (current->journal_info == BTRFS_SEND_TRANS_STUB);
332351

333352
if (!parent_transid || btrfs_header_generation(eb) == parent_transid)
334353
return 0;
@@ -690,7 +709,7 @@ static int btree_io_failed_hook(struct page *page, int failed_mirror)
690709

691710
static void end_workqueue_bio(struct bio *bio, int err)
692711
{
693-
struct end_io_wq *end_io_wq = bio->bi_private;
712+
struct btrfs_end_io_wq *end_io_wq = bio->bi_private;
694713
struct btrfs_fs_info *fs_info;
695714
struct btrfs_workqueue *wq;
696715
btrfs_work_func_t func;
@@ -733,20 +752,12 @@ static void end_workqueue_bio(struct bio *bio, int err)
733752
btrfs_queue_work(wq, &end_io_wq->work);
734753
}
735754

736-
/*
737-
* For the metadata arg you want
738-
*
739-
* 0 - if data
740-
* 1 - if normal metadta
741-
* 2 - if writing to the free space cache area
742-
* 3 - raid parity work
743-
*/
744755
int btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio,
745-
int metadata)
756+
enum btrfs_wq_endio_type metadata)
746757
{
747-
struct end_io_wq *end_io_wq;
758+
struct btrfs_end_io_wq *end_io_wq;
748759

749-
end_io_wq = kmalloc(sizeof(*end_io_wq), GFP_NOFS);
760+
end_io_wq = kmem_cache_alloc(btrfs_end_io_wq_cache, GFP_NOFS);
750761
if (!end_io_wq)
751762
return -ENOMEM;
752763

@@ -930,7 +941,7 @@ static int btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
930941
* can happen in the async kernel threads
931942
*/
932943
ret = btrfs_bio_wq_end_io(BTRFS_I(inode)->root->fs_info,
933-
bio, 1);
944+
bio, BTRFS_WQ_ENDIO_METADATA);
934945
if (ret)
935946
goto out_w_error;
936947
ret = btrfs_map_bio(BTRFS_I(inode)->root, rw, bio,
@@ -1119,11 +1130,9 @@ struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root,
11191130
struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root,
11201131
u64 bytenr, u32 blocksize)
11211132
{
1122-
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
1123-
if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state)))
1133+
if (btrfs_test_is_dummy_root(root))
11241134
return alloc_test_extent_buffer(root->fs_info, bytenr,
11251135
blocksize);
1126-
#endif
11271136
return alloc_extent_buffer(root->fs_info, bytenr, blocksize);
11281137
}
11291138

@@ -1731,16 +1740,16 @@ static int setup_bdi(struct btrfs_fs_info *info, struct backing_dev_info *bdi)
17311740
static void end_workqueue_fn(struct btrfs_work *work)
17321741
{
17331742
struct bio *bio;
1734-
struct end_io_wq *end_io_wq;
1743+
struct btrfs_end_io_wq *end_io_wq;
17351744
int error;
17361745

1737-
end_io_wq = container_of(work, struct end_io_wq, work);
1746+
end_io_wq = container_of(work, struct btrfs_end_io_wq, work);
17381747
bio = end_io_wq->bio;
17391748

17401749
error = end_io_wq->error;
17411750
bio->bi_private = end_io_wq->private;
17421751
bio->bi_end_io = end_io_wq->end_io;
1743-
kfree(end_io_wq);
1752+
kmem_cache_free(btrfs_end_io_wq_cache, end_io_wq);
17441753
bio_endio_nodec(bio, error);
17451754
}
17461755

@@ -2260,7 +2269,7 @@ int open_ctree(struct super_block *sb,
22602269
atomic_set(&fs_info->qgroup_op_seq, 0);
22612270
atomic64_set(&fs_info->tree_mod_seq, 0);
22622271
fs_info->sb = sb;
2263-
fs_info->max_inline = 8192 * 1024;
2272+
fs_info->max_inline = BTRFS_DEFAULT_MAX_INLINE;
22642273
fs_info->metadata_ratio = 0;
22652274
fs_info->defrag_inodes = RB_ROOT;
22662275
fs_info->free_chunk_space = 0;

‎fs/btrfs/disk-io.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#define BTRFS_SUPER_MIRROR_MAX 3
2626
#define BTRFS_SUPER_MIRROR_SHIFT 12
2727

28-
enum {
28+
enum btrfs_wq_endio_type {
2929
BTRFS_WQ_ENDIO_DATA = 0,
3030
BTRFS_WQ_ENDIO_METADATA = 1,
3131
BTRFS_WQ_ENDIO_FREE_SPACE = 2,
@@ -120,7 +120,7 @@ int btrfs_read_buffer(struct extent_buffer *buf, u64 parent_transid);
120120
u32 btrfs_csum_data(char *data, u32 seed, size_t len);
121121
void btrfs_csum_final(u32 crc, char *result);
122122
int btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio,
123-
int metadata);
123+
enum btrfs_wq_endio_type metadata);
124124
int btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct inode *inode,
125125
int rw, struct bio *bio, int mirror_num,
126126
unsigned long bio_flags, u64 bio_offset,
@@ -142,6 +142,8 @@ int btree_lock_page_hook(struct page *page, void *data,
142142
void (*flush_fn)(void *));
143143
int btrfs_calc_num_tolerated_disk_barrier_failures(
144144
struct btrfs_fs_info *fs_info);
145+
int __init btrfs_end_io_wq_init(void);
146+
void btrfs_end_io_wq_exit(void);
145147

146148
#ifdef CONFIG_DEBUG_LOCK_ALLOC
147149
void btrfs_init_lockdep(void);

‎fs/btrfs/extent-tree.c‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3073,10 +3073,10 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
30733073
int (*process_func)(struct btrfs_trans_handle *, struct btrfs_root *,
30743074
u64, u64, u64, u64, u64, u64, int);
30753075

3076-
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
3077-
if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state)))
3076+
3077+
if (btrfs_test_is_dummy_root(root))
30783078
return 0;
3079-
#endif
3079+
30803080
ref_root = btrfs_header_owner(buf);
30813081
nritems = btrfs_header_nritems(buf);
30823082
level = btrfs_header_level(buf);
@@ -6264,10 +6264,9 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root *root,
62646264
int ret;
62656265
struct btrfs_fs_info *fs_info = root->fs_info;
62666266

6267-
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
6268-
if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state)))
6267+
if (btrfs_test_is_dummy_root(root))
62696268
return 0;
6270-
#endif
6269+
62716270
add_pinned_bytes(root->fs_info, num_bytes, owner, root_objectid);
62726271

62736272
/*
@@ -7338,15 +7337,14 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
73387337
bool skinny_metadata = btrfs_fs_incompat(root->fs_info,
73397338
SKINNY_METADATA);
73407339

7341-
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
7342-
if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state))) {
7340+
if (btrfs_test_is_dummy_root(root)) {
73437341
buf = btrfs_init_new_buffer(trans, root, root->alloc_bytenr,
73447342
blocksize, level);
73457343
if (!IS_ERR(buf))
73467344
root->alloc_bytenr += blocksize;
73477345
return buf;
73487346
}
7349-
#endif
7347+
73507348
block_rsv = use_block_rsv(trans, root, blocksize);
73517349
if (IS_ERR(block_rsv))
73527350
return ERR_CAST(block_rsv);

0 commit comments

Comments
 (0)