mirror of
https://github.com/systemd/systemd.git
synced 2025-03-08 08:58:27 +03:00
Merge pull request #10164 from poettering/btrfs-resize-fix
btrfs resize fix
This commit is contained in:
commit
d00de84373
@ -877,7 +877,7 @@ int btrfs_subvol_set_subtree_quota_limit(const char *path, uint64_t subvol_id, u
|
||||
|
||||
int btrfs_resize_loopback_fd(int fd, uint64_t new_size, bool grow_only) {
|
||||
struct btrfs_ioctl_vol_args args = {};
|
||||
char p[SYS_BLOCK_PATH_MAX("/loop/backing_file")];
|
||||
char p[SYS_BLOCK_PATH_MAX("/loop/backing_file")], q[DEV_NUM_PATH_MAX];
|
||||
_cleanup_free_ char *backing = NULL;
|
||||
_cleanup_close_ int loop_fd = -1, backing_fd = -1;
|
||||
struct stat st;
|
||||
@ -922,8 +922,8 @@ int btrfs_resize_loopback_fd(int fd, uint64_t new_size, bool grow_only) {
|
||||
if (grow_only && new_size < (uint64_t) st.st_size)
|
||||
return -EINVAL;
|
||||
|
||||
xsprintf_sys_block_path(p, NULL, dev);
|
||||
loop_fd = open(p, O_RDWR|O_CLOEXEC|O_NOCTTY);
|
||||
xsprintf_dev_num_path(q, "block", dev);
|
||||
loop_fd = open(q, O_RDWR|O_CLOEXEC|O_NOCTTY);
|
||||
if (loop_fd < 0)
|
||||
return -errno;
|
||||
|
||||
|
@ -378,14 +378,21 @@ int grow_machine_directory(void) {
|
||||
new_size = old_size + max_add;
|
||||
|
||||
r = btrfs_resize_loopback("/var/lib/machines", new_size, true);
|
||||
if (r <= 0)
|
||||
return r;
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to resize loopback: %m");
|
||||
if (r == 0)
|
||||
return 0;
|
||||
|
||||
/* Also bump the quota, of both the subvolume leaf qgroup, as
|
||||
* well as of any subtree quota group by the same id but a
|
||||
* higher level, if it exists. */
|
||||
(void) btrfs_qgroup_set_limit("/var/lib/machines", 0, new_size);
|
||||
(void) btrfs_subvol_set_subtree_quota_limit("/var/lib/machines", 0, new_size);
|
||||
r = btrfs_qgroup_set_limit("/var/lib/machines", 0, new_size);
|
||||
if (r < 0)
|
||||
log_debug_errno(r, "Failed to set btrfs limit: %m");
|
||||
|
||||
r = btrfs_subvol_set_subtree_quota_limit("/var/lib/machines", 0, new_size);
|
||||
if (r < 0)
|
||||
log_debug_errno(r, "Failed to set btrfs subtree limit: %m");
|
||||
|
||||
log_info("Grew /var/lib/machines btrfs loopback file system to %s.", format_bytes(buf, sizeof(buf), new_size));
|
||||
return 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user