Skip to content

mds: use parse_filesystem in parse_role to handle exceptions and reuse parsing code#11357

Merged
jcsp merged 4 commits intoceph:masterfrom
batrick:i17518
Oct 14, 2016
Merged

mds: use parse_filesystem in parse_role to handle exceptions and reuse parsing code#11357
jcsp merged 4 commits intoceph:masterfrom
batrick:i17518

Conversation

@batrick
Copy link
Member

@batrick batrick commented Oct 6, 2016

get_filesystem may fail in parse_role if the fscid does not exist. This
would result in the program (mon) aborting due to the uncaught
exception.

Fixes: http://tracker.ceph.com/issues/17518

Signed-off-by: Patrick Donnelly pdonnell@redhat.com

@batrick batrick added bug-fix cephfs Ceph File System labels Oct 6, 2016
@jcsp
Copy link
Contributor

jcsp commented Oct 7, 2016

iirc it was intentional that this would throw if the filesystem didn't exist (otherwise we open the door to segfaults if the callers don't rigorously check nullness of the return value) -- I'd rather have the caller check for existence (and get an exception if they forget to do it) than have the caller check for null returns (and get a segfault if they forget to do it). I don't claim all the existing code necessarily sticks to that principle though!

Clearly this is a bit inconsistent wrt the name-based get_filesystem call. The number-based one is for use internally whereas the name based one is always used for handling user input. I wonder if the name based one should get renamed to "resolve_filesystem" or something to make it less weird.

@batrick batrick changed the title mds: use find to avoid exception mds: use parse_filesystem in parse_role to handle exceptions and reuse parsing code Oct 10, 2016
@batrick
Copy link
Member Author

batrick commented Oct 10, 2016

@jcsp please take another look.

Copy link
Contributor

@jcsp jcsp left a comment

Choose a reason for hiding this comment

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

This is nice, just need to back out the use of refs for output arguments (one of the more debatable parts of the style guide but nevertheless it's in there)

src/mds/FSMap.cc Outdated
int FSMap::parse_filesystem(
std::string const &ns_str,
std::shared_ptr<const Filesystem> *result
std::shared_ptr<const Filesystem> &result
Copy link
Contributor

Choose a reason for hiding this comment

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

Using pointers for output arguments is a style guide thing (https://github.com/ceph/ceph/blob/master/CodingStyle#L127)

@batrick
Copy link
Member Author

batrick commented Oct 11, 2016

@jcsp, thanks for pointing that out. I've removed that commit.

@batrick
Copy link
Member Author

batrick commented Oct 11, 2016

retest

@batrick
Copy link
Member Author

batrick commented Oct 11, 2016

retest this please

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
This allows us to reuse code in parse_filesystem and avoid
get_filesystem which may fail if the fscid does not exist. This would
result in the program (mon) aborting due to the uncaught exception.

Fixes: http://tracker.ceph.com/issues/17518

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
@jcsp jcsp merged commit 9aacef4 into ceph:master Oct 14, 2016
@batrick batrick deleted the i17518 branch October 14, 2016 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants