Skip to content

Commit

Permalink
storage: Always resize filesystems and LUKS to the maximum possible
Browse files Browse the repository at this point in the history
This is always the right thing to do, since Cockpit will first resize
the block device (which is a logical volume or partition) and then
resize the content to match.  This will cover the case where the block
device resizing ended up with something different from what we asked
for.
  • Loading branch information
mvollmer committed Oct 25, 2023
1 parent 1a903b4 commit e1aa8e1
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions pkg/storaged/resize.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ function lvol_or_part_and_fsys_resize(client, lvol_or_part, size, offline, passp

function fsys_resize() {
if (fsys) {
// When growing a filesystem, always grow it to fill its
// block device. This is always the right thing to do in
// Cockpit.
//
const resize_size = (size > orig_size) ? 0 : size - crypto_overhead;

// HACK - https://bugzilla.redhat.com/show_bug.cgi?id=1934567
//
// block_fsys.MountedAt might be out of synch with reality
Expand All @@ -87,9 +93,9 @@ function lvol_or_part_and_fsys_resize(client, lvol_or_part, size, offline, passp
// When doing an offline resize, we need to first repair the filesystem.
if (!is_mounted) {
return (fsys.Repair({ })
.then(function () { return fsys.Resize(size - crypto_overhead, { }) }));
.then(() => fsys.Resize(resize_size, { })));
} else {
return fsys.Resize(size - crypto_overhead, { });
return fsys.Resize(resize_size, { });
}
}));
} else if (vdo) {
Expand Down Expand Up @@ -119,11 +125,17 @@ function lvol_or_part_and_fsys_resize(client, lvol_or_part, size, offline, passp
}

function crypto_resize() {
// When growing a LUKS device, always grow it to fill its
// block device. This is always the right thing to do in
// Cockpit.
//
const resize_size = (size > orig_size) ? 0 : size - crypto_overhead;

if (crypto) {
const opts = { };
if (passphrase)
opts.passphrase = { t: "s", v: passphrase };
return crypto.Resize(size - crypto_overhead, opts);
return crypto.Resize(resize_size, opts);
} else {
return Promise.resolve();
}
Expand Down

0 comments on commit e1aa8e1

Please sign in to comment.