mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-23 00:00:02 +03:00
Update bcachefs sources to b1107114ca bcachefs: Add an ioctl for resizing journal on a device
This commit is contained in:
parent
13f53aa228
commit
9225f81a49
@ -1 +1 @@
|
||||
d1fd47183051729471bce1c9f84fa63cb84dc557
|
||||
b1107114caf6aa6f725170f3d75b072badcfa573
|
||||
|
@ -73,6 +73,7 @@ struct bch_ioctl_incremental {
|
||||
#define BCH_IOCTL_READ_SUPER _IOW(0xbc, 12, struct bch_ioctl_read_super)
|
||||
#define BCH_IOCTL_DISK_GET_IDX _IOW(0xbc, 13, struct bch_ioctl_disk_get_idx)
|
||||
#define BCH_IOCTL_DISK_RESIZE _IOW(0xbc, 14, struct bch_ioctl_disk_resize)
|
||||
#define BCH_IOCTL_DISK_RESIZE_JOURNAL _IOW(0xbc,15, struct bch_ioctl_disk_resize_journal)
|
||||
|
||||
/* ioctl below act on a particular file, not the filesystem as a whole: */
|
||||
|
||||
@ -329,4 +330,17 @@ struct bch_ioctl_disk_resize {
|
||||
__u64 nbuckets;
|
||||
};
|
||||
|
||||
/*
|
||||
* BCH_IOCTL_DISK_RESIZE_JOURNAL: resize journal on a device
|
||||
*
|
||||
* @dev - member to resize
|
||||
* @nbuckets - new number of buckets
|
||||
*/
|
||||
struct bch_ioctl_disk_resize_journal {
|
||||
__u32 flags;
|
||||
__u32 pad;
|
||||
__u64 dev;
|
||||
__u64 nbuckets;
|
||||
};
|
||||
|
||||
#endif /* _BCACHEFS_IOCTL_H */
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "bcachefs_ioctl.h"
|
||||
#include "buckets.h"
|
||||
#include "chardev.h"
|
||||
#include "journal.h"
|
||||
#include "move.h"
|
||||
#include "replicas.h"
|
||||
#include "super.h"
|
||||
@ -563,6 +564,26 @@ static long bch2_ioctl_disk_resize(struct bch_fs *c,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long bch2_ioctl_disk_resize_journal(struct bch_fs *c,
|
||||
struct bch_ioctl_disk_resize_journal arg)
|
||||
{
|
||||
struct bch_dev *ca;
|
||||
int ret;
|
||||
|
||||
if ((arg.flags & ~BCH_BY_INDEX) ||
|
||||
arg.pad)
|
||||
return -EINVAL;
|
||||
|
||||
ca = bch2_device_lookup(c, arg.dev, arg.flags);
|
||||
if (IS_ERR(ca))
|
||||
return PTR_ERR(ca);
|
||||
|
||||
ret = bch2_set_nr_journal_buckets(c, ca, arg.nbuckets);
|
||||
|
||||
percpu_ref_put(&ca->ref);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define BCH_IOCTL(_name, _argtype) \
|
||||
do { \
|
||||
_argtype i; \
|
||||
@ -619,6 +640,8 @@ long bch2_fs_ioctl(struct bch_fs *c, unsigned cmd, void __user *arg)
|
||||
BCH_IOCTL(data, struct bch_ioctl_data);
|
||||
case BCH_IOCTL_DISK_RESIZE:
|
||||
BCH_IOCTL(disk_resize, struct bch_ioctl_disk_resize);
|
||||
case BCH_IOCTL_DISK_RESIZE_JOURNAL:
|
||||
BCH_IOCTL(disk_resize_journal, struct bch_ioctl_disk_resize_journal);
|
||||
|
||||
default:
|
||||
return -ENOTTY;
|
||||
|
@ -731,6 +731,12 @@ static int __bch2_set_nr_journal_buckets(struct bch_dev *ca, unsigned nr,
|
||||
spin_lock(&c->journal.lock);
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX
|
||||
* For resize at runtime, we should be writing the new
|
||||
* superblock before inserting into the journal array
|
||||
*/
|
||||
|
||||
pos = ja->nr ? (ja->cur_idx + 1) % ja->nr : 0;
|
||||
__array_insert_item(ja->buckets, ja->nr, pos);
|
||||
__array_insert_item(ja->bucket_seq, ja->nr, pos);
|
||||
@ -766,6 +772,8 @@ static int __bch2_set_nr_journal_buckets(struct bch_dev *ca, unsigned nr,
|
||||
|
||||
ret = 0;
|
||||
err:
|
||||
bch2_sb_resize_journal(&ca->disk_sb,
|
||||
ja->nr + sizeof(*journal_buckets) / sizeof(u64));
|
||||
kfree(new_bucket_seq);
|
||||
kfree(new_buckets);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user