mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-12-11 00:00:12 +03:00
Update bcachefs sources to caffe5f36f39 bcachefs: Compatibility with v6.18
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
87b7adc49b
commit
825b55e747
@ -1 +1 @@
|
|||||||
a3e0941d427cf4c0ae75f4afd5b525dddcf407a2
|
caffe5f36f39ef62d58383b77dfdce931104f8c2
|
||||||
|
|||||||
@ -135,15 +135,13 @@ struct bio {
|
|||||||
struct bio_vec *bi_io_vec; /* the actual vec list */
|
struct bio_vec *bi_io_vec; /* the actual vec list */
|
||||||
|
|
||||||
struct bio_set *bi_pool;
|
struct bio_set *bi_pool;
|
||||||
|
|
||||||
/*
|
|
||||||
* We can inline a number of vecs at the end of the bio, to avoid
|
|
||||||
* double allocations for a small number of bio_vecs. This member
|
|
||||||
* MUST obviously be kept at the very end of the bio.
|
|
||||||
*/
|
|
||||||
struct bio_vec bi_inline_vecs[0];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline struct bio_vec *bio_inline_vecs(struct bio *bio)
|
||||||
|
{
|
||||||
|
return (struct bio_vec *)(bio + 1);
|
||||||
|
}
|
||||||
|
|
||||||
#define BIO_RESET_BYTES offsetof(struct bio, bi_max_vecs)
|
#define BIO_RESET_BYTES offsetof(struct bio, bi_max_vecs)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -116,6 +116,7 @@ static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
|
|||||||
DEFINE_FREE(kfree, void *, if (!IS_ERR_OR_NULL(_T)) kfree(_T))
|
DEFINE_FREE(kfree, void *, if (!IS_ERR_OR_NULL(_T)) kfree(_T))
|
||||||
|
|
||||||
#define kvmalloc(size, flags) kmalloc(size, flags)
|
#define kvmalloc(size, flags) kmalloc(size, flags)
|
||||||
|
#define kvmalloc_node_align_noprof(size, align, flags, node) kmalloc(size, flags)
|
||||||
#define kvmalloc_noprof(size, flags) kmalloc(size, flags)
|
#define kvmalloc_noprof(size, flags) kmalloc(size, flags)
|
||||||
#define kvzalloc(size, flags) kzalloc(size, flags)
|
#define kvzalloc(size, flags) kzalloc(size, flags)
|
||||||
#define kvfree(p) kfree(p)
|
#define kvfree(p) kfree(p)
|
||||||
|
|||||||
@ -1227,6 +1227,7 @@ struct btree_node_scrub {
|
|||||||
|
|
||||||
struct work_struct work;
|
struct work_struct work;
|
||||||
struct bio bio;
|
struct bio bio;
|
||||||
|
struct bio_vec inline_vecs[];
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool btree_node_scrub_check(struct bch_fs *c, struct btree_node *data, unsigned ptr_written,
|
static bool btree_node_scrub_check(struct bch_fs *c, struct btree_node *data, unsigned ptr_written,
|
||||||
@ -1368,7 +1369,7 @@ int bch2_btree_node_scrub(struct btree_trans *trans,
|
|||||||
|
|
||||||
INIT_WORK(&scrub->work, btree_node_scrub_work);
|
INIT_WORK(&scrub->work, btree_node_scrub_work);
|
||||||
|
|
||||||
bio_init(&scrub->bio, ca->disk_sb.bdev, scrub->bio.bi_inline_vecs, vecs, REQ_OP_READ);
|
bio_init(&scrub->bio, ca->disk_sb.bdev, scrub->inline_vecs, vecs, REQ_OP_READ);
|
||||||
bch2_bio_map(&scrub->bio, scrub->buf, c->opts.btree_node_size);
|
bch2_bio_map(&scrub->bio, scrub->buf, c->opts.btree_node_size);
|
||||||
scrub->bio.bi_iter.bi_sector = pick.ptr.offset;
|
scrub->bio.bi_iter.bi_sector = pick.ptr.offset;
|
||||||
scrub->bio.bi_end_io = btree_node_scrub_endio;
|
scrub->bio.bi_end_io = btree_node_scrub_endio;
|
||||||
|
|||||||
@ -533,14 +533,14 @@ int bch2_dev_journal_init(struct bch_dev *ca, struct bch_sb *sb)
|
|||||||
* performance can be sensitive to anything that affects journal
|
* performance can be sensitive to anything that affects journal
|
||||||
* pipelining.
|
* pipelining.
|
||||||
*/
|
*/
|
||||||
ja->bio[i] = kvzalloc(struct_size(ja->bio[i], bio.bi_inline_vecs,
|
ja->bio[i] = kvzalloc(sizeof(struct bio) + sizeof(struct bio_vec) * nr_bvecs,
|
||||||
nr_bvecs), GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!ja->bio[i])
|
if (!ja->bio[i])
|
||||||
return bch_err_throw(c, ENOMEM_dev_journal_init);
|
return bch_err_throw(c, ENOMEM_dev_journal_init);
|
||||||
|
|
||||||
ja->bio[i]->ca = ca;
|
ja->bio[i]->ca = ca;
|
||||||
ja->bio[i]->buf_idx = i;
|
ja->bio[i]->buf_idx = i;
|
||||||
bio_init(&ja->bio[i]->bio, NULL, ja->bio[i]->bio.bi_inline_vecs, nr_bvecs, 0);
|
bio_init(&ja->bio[i]->bio, NULL, bio_inline_vecs(&ja->bio[i]->bio), nr_bvecs, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ja->buckets = kcalloc(ja->nr, sizeof(u64), GFP_KERNEL);
|
ja->buckets = kcalloc(ja->nr, sizeof(u64), GFP_KERNEL);
|
||||||
|
|||||||
@ -1080,7 +1080,7 @@ reread:
|
|||||||
bio = bio_kmalloc(nr_bvecs, GFP_KERNEL);
|
bio = bio_kmalloc(nr_bvecs, GFP_KERNEL);
|
||||||
if (!bio)
|
if (!bio)
|
||||||
return bch_err_throw(c, ENOMEM_journal_read_bucket);
|
return bch_err_throw(c, ENOMEM_journal_read_bucket);
|
||||||
bio_init(bio, ca->disk_sb.bdev, bio->bi_inline_vecs, nr_bvecs, REQ_OP_READ);
|
bio_init(bio, ca->disk_sb.bdev, bio_inline_vecs(bio), nr_bvecs, REQ_OP_READ);
|
||||||
|
|
||||||
bio->bi_iter.bi_sector = offset;
|
bio->bi_iter.bi_sector = offset;
|
||||||
bch2_bio_map(bio, buf->data, sectors_read << 9);
|
bch2_bio_map(bio, buf->data, sectors_read << 9);
|
||||||
|
|||||||
@ -235,7 +235,7 @@ int bch2_sb_realloc(struct bch_sb_handle *sb, unsigned u64s)
|
|||||||
if (!bio)
|
if (!bio)
|
||||||
return -BCH_ERR_ENOMEM_sb_bio_realloc;
|
return -BCH_ERR_ENOMEM_sb_bio_realloc;
|
||||||
|
|
||||||
bio_init(bio, NULL, bio->bi_inline_vecs, nr_bvecs, 0);
|
bio_init(bio, NULL, bio_inline_vecs(bio), nr_bvecs, 0);
|
||||||
|
|
||||||
kfree(sb->bio);
|
kfree(sb->bio);
|
||||||
sb->bio = bio;
|
sb->bio = bio;
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
#include <linux/ratelimit.h>
|
#include <linux/ratelimit.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/sort.h>
|
#include <linux/sort.h>
|
||||||
|
#include <linux/version.h>
|
||||||
#include <linux/vmalloc.h>
|
#include <linux/vmalloc.h>
|
||||||
#include <linux/workqueue.h>
|
#include <linux/workqueue.h>
|
||||||
|
|
||||||
@ -48,6 +49,13 @@ struct closure;
|
|||||||
(__builtin_types_compatible_p(typeof(_val), _type) || \
|
(__builtin_types_compatible_p(typeof(_val), _type) || \
|
||||||
__builtin_types_compatible_p(typeof(_val), const _type))
|
__builtin_types_compatible_p(typeof(_val), const _type))
|
||||||
|
|
||||||
|
#if defined(_KERNEL__) && LINUX_VERSION_CODE <= KERNEL_VERSION(6,17,0)
|
||||||
|
static inline struct bio_vec *bio_inline_vecs(struct bio *bio)
|
||||||
|
{
|
||||||
|
return (struct bio_vec *)(bio + 1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Userspace doesn't align allocations as nicely as the kernel allocators: */
|
/* Userspace doesn't align allocations as nicely as the kernel allocators: */
|
||||||
static inline size_t buf_pages(void *p, size_t len)
|
static inline size_t buf_pages(void *p, size_t len)
|
||||||
{
|
{
|
||||||
@ -58,9 +66,15 @@ static inline size_t buf_pages(void *p, size_t len)
|
|||||||
|
|
||||||
static inline void *bch2_kvmalloc_noprof(size_t n, gfp_t flags)
|
static inline void *bch2_kvmalloc_noprof(size_t n, gfp_t flags)
|
||||||
{
|
{
|
||||||
|
#if LINUX_VERSION_CODE <= KERNEL_VERSION(6,17,0)
|
||||||
void *p = unlikely(n >= INT_MAX)
|
void *p = unlikely(n >= INT_MAX)
|
||||||
? vmalloc_noprof(n)
|
? vmalloc_noprof(n)
|
||||||
: kvmalloc_noprof(n, flags & ~__GFP_ZERO);
|
: kvmalloc_noprof(n, flags & ~__GFP_ZERO);
|
||||||
|
#else
|
||||||
|
void *p = unlikely(n >= INT_MAX)
|
||||||
|
? vmalloc_noprof(n)
|
||||||
|
: kvmalloc_node_align_noprof(n, 1, flags & ~__GFP_ZERO, NUMA_NO_NODE);
|
||||||
|
#endif
|
||||||
if (p && (flags & __GFP_ZERO))
|
if (p && (flags & __GFP_ZERO))
|
||||||
memset(p, 0, n);
|
memset(p, 0, n);
|
||||||
return p;
|
return p;
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
#include <linux/fsnotify.h>
|
#include <linux/fsnotify.h>
|
||||||
#include <linux/mount.h>
|
#include <linux/mount.h>
|
||||||
#include <linux/namei.h>
|
#include <linux/namei.h>
|
||||||
|
#include <linux/version.h>
|
||||||
#include <linux/security.h>
|
#include <linux/security.h>
|
||||||
#include <linux/writeback.h>
|
#include <linux/writeback.h>
|
||||||
|
|
||||||
@ -25,6 +26,12 @@
|
|||||||
#define FSOP_GOING_FLAGS_LOGFLUSH 0x1 /* flush log but not data */
|
#define FSOP_GOING_FLAGS_LOGFLUSH 0x1 /* flush log but not data */
|
||||||
#define FSOP_GOING_FLAGS_NOLOGFLUSH 0x2 /* don't flush log nor data */
|
#define FSOP_GOING_FLAGS_NOLOGFLUSH 0x2 /* don't flush log nor data */
|
||||||
|
|
||||||
|
#if LINUX_VERSION_CODE <= KERNEL_VERSION(6,17,0)
|
||||||
|
#define start_creating_user_path user_path_create
|
||||||
|
#define end_creating_path done_path_create
|
||||||
|
#define start_removing_user_path_at user_path_locked_at
|
||||||
|
#endif
|
||||||
|
|
||||||
static int bch2_reinherit_attrs_fn(struct btree_trans *trans,
|
static int bch2_reinherit_attrs_fn(struct btree_trans *trans,
|
||||||
struct bch_inode_info *inode,
|
struct bch_inode_info *inode,
|
||||||
struct bch_inode_unpacked *bi,
|
struct bch_inode_unpacked *bi,
|
||||||
@ -257,7 +264,7 @@ static long __bch2_ioctl_subvolume_create(struct bch_fs *c, struct file *filp,
|
|||||||
snapshot_src = inode_inum(to_bch_ei(src_path.dentry->d_inode));
|
snapshot_src = inode_inum(to_bch_ei(src_path.dentry->d_inode));
|
||||||
}
|
}
|
||||||
|
|
||||||
dst_dentry = user_path_create(arg.dirfd,
|
dst_dentry = start_creating_user_path(arg.dirfd,
|
||||||
(const char __user *)(unsigned long)arg.dst_ptr,
|
(const char __user *)(unsigned long)arg.dst_ptr,
|
||||||
&dst_path, lookup_flags);
|
&dst_path, lookup_flags);
|
||||||
error = PTR_ERR_OR_ZERO(dst_dentry);
|
error = PTR_ERR_OR_ZERO(dst_dentry);
|
||||||
@ -316,7 +323,7 @@ static long __bch2_ioctl_subvolume_create(struct bch_fs *c, struct file *filp,
|
|||||||
d_instantiate(dst_dentry, &inode->v);
|
d_instantiate(dst_dentry, &inode->v);
|
||||||
fsnotify_mkdir(dir, dst_dentry);
|
fsnotify_mkdir(dir, dst_dentry);
|
||||||
err3:
|
err3:
|
||||||
done_path_create(&dst_path, dst_dentry);
|
end_creating_path(&dst_path, dst_dentry);
|
||||||
err2:
|
err2:
|
||||||
if (arg.src_ptr)
|
if (arg.src_ptr)
|
||||||
path_put(&src_path);
|
path_put(&src_path);
|
||||||
@ -363,7 +370,7 @@ static long __bch2_ioctl_subvolume_destroy(struct bch_fs *c, struct file *filp,
|
|||||||
if (arg.flags)
|
if (arg.flags)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
victim = user_path_locked_at(arg.dirfd, name, &path);
|
victim = start_removing_user_path_at(arg.dirfd, name, &path);
|
||||||
if (IS_ERR(victim))
|
if (IS_ERR(victim))
|
||||||
return PTR_ERR(victim);
|
return PTR_ERR(victim);
|
||||||
|
|
||||||
|
|||||||
@ -306,7 +306,7 @@ struct bio *bio_kmalloc(unsigned int nr_iovecs, gfp_t gfp_mask)
|
|||||||
sizeof(struct bio_vec) * nr_iovecs, gfp_mask);
|
sizeof(struct bio_vec) * nr_iovecs, gfp_mask);
|
||||||
if (unlikely(!bio))
|
if (unlikely(!bio))
|
||||||
return NULL;
|
return NULL;
|
||||||
bio_init(bio, NULL, nr_iovecs ? bio->bi_inline_vecs : NULL, nr_iovecs, 0);
|
bio_init(bio, NULL, nr_iovecs ? bio_inline_vecs(bio) : NULL, nr_iovecs, 0);
|
||||||
bio->bi_pool = NULL;
|
bio->bi_pool = NULL;
|
||||||
return bio;
|
return bio;
|
||||||
}
|
}
|
||||||
@ -320,7 +320,7 @@ struct bio *bio_alloc(struct block_device *bdev, unsigned nr_iovecs,
|
|||||||
sizeof(struct bio_vec) * nr_iovecs, gfp_mask);
|
sizeof(struct bio_vec) * nr_iovecs, gfp_mask);
|
||||||
if (unlikely(!bio))
|
if (unlikely(!bio))
|
||||||
return NULL;
|
return NULL;
|
||||||
bio_init(bio, bdev, nr_iovecs ? bio->bi_inline_vecs : NULL, nr_iovecs, opf);
|
bio_init(bio, NULL, nr_iovecs ? bio_inline_vecs(bio) : NULL, nr_iovecs, opf);
|
||||||
bio->bi_pool = NULL;
|
bio->bi_pool = NULL;
|
||||||
return bio;
|
return bio;
|
||||||
}
|
}
|
||||||
@ -372,7 +372,7 @@ struct bio *bio_alloc_bioset(struct block_device *bdev,
|
|||||||
|
|
||||||
bio_init(bio, bdev, bvl, nr_iovecs, opf);
|
bio_init(bio, bdev, bvl, nr_iovecs, opf);
|
||||||
} else if (nr_iovecs) {
|
} else if (nr_iovecs) {
|
||||||
bio_init(bio, bdev, bio->bi_inline_vecs, BIO_INLINE_VECS, opf);
|
bio_init(bio, bdev, bio_inline_vecs(bio), BIO_INLINE_VECS, opf);
|
||||||
} else {
|
} else {
|
||||||
bio_init(bio, bdev, NULL, 0, opf);
|
bio_init(bio, bdev, NULL, 0, opf);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user