Skip to content

some block device handling fixes#9255

Merged
keszybz merged 6 commits intosystemd:masterfrom
poettering:block-dev-fixes
Jun 12, 2018
Merged

some block device handling fixes#9255
keszybz merged 6 commits intosystemd:masterfrom
poettering:block-dev-fixes

Conversation

@poettering
Copy link
Member

I noticed these while reviewing #9247. I figure that PR should be rebased on this as soon as it is merged.

if (r <= 0)
return r;
/* For the specified block device tries to chase it down the layers, in case LUKS-style DM stacking is used,
* trying to find the next upper layer. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

down the layers to go up?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

up, down, potato, potato ;-)

return -ENODEV;
}
if (r < 0)
return log_warning_errno(r, "Failed to determine block device backing btrfs file system '%s': %m", p);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message assumes that p must be a btrfs device. I think it'd be better to reorder this and report the more specific case of failing to determine btrfs backing device first:

                r = btrfs_get_block_device(p, ret);
                if (r < 0 && r != -ENOTTY)
                        return log_warning_errno(r, "Failed to determine if path '%s' is backed by a btrfs file system: %m", p);

                if (r == -ENOTTY) {
                        log_warning("'%s' is not a block device node, and file system block device cannot be determined or is not local.", p);
                        return -ENODEV;
                }

We document the rule that return values >= 0 of functions are supposed
to indicate success, and that in case of success all return parameters
should be initialized. Let's actually do so.

Just a tiny coding style fix-up.
… into function of its own

That way we can use it in code that already acquired a dev_t from some
source.
Let's chase block devices through btrfs and LUKS like we do elsewhere.
This drops needless safety checks that ensure we only reference block
devices for blockio/io settings. The backing code was already able to
accept regular file system paths too, in which case the backing device
node of that file system would be used. Hence, let's drop the artificial
restrictions and open up this underlying functionality.
Let's make sure we don't validate "char-*" and "block-*" expressions as
paths.
@poettering
Copy link
Member Author

Force pushed a new version now. PTAL. Only changes are the points you raised

@keszybz
Copy link
Member

keszybz commented Jun 12, 2018

LGTM.

@keszybz keszybz merged commit 24d169e into systemd:master Jun 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants