Skip to content

os/bluestore/bluestore_tool: compare retval stat() with -1#41433

Merged
tchaikov merged 3 commits intoceph:masterfrom
tchaikov:wip-50891
May 23, 2021
Merged

os/bluestore/bluestore_tool: compare retval stat() with -1#41433
tchaikov merged 3 commits intoceph:masterfrom
tchaikov:wip-50891

Conversation

@tchaikov
Copy link
Contributor

Fixes: https://tracker.ceph.com/issues/50891

Checklist

  • References tracker ticket
  • Updates documentation if necessary
  • Includes tests for new functionality or reproducer for bug

Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox

@tchaikov
Copy link
Contributor Author

changelog

  • add a space after if.

return {"", false};
}
std::error_code ec;
fs::path target_path = fs::weakly_canonical(dev_target, ec);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

-- The CXX compiler identification is GNU 7.5.0
-- The C compiler identification is GNU 7.5.0
...
/build/ceph-17.0.0-4436-g0a8ba2e2/src/os/bluestore/bluestore_tool.cc:789:34: error: 'weakly_canonical' is not a member of 'fs'
       fs::path target_path = fs::weakly_canonical(dev_target, ec);
                                  ^~~~~~~~~~~~~~~~

turns out libstdc++ shipped along with GCC 7.5.0 does not offer std::filesystem::weakly_canonical() yet. and we cannot drop bionic yet. see ceph/ceph-build#1794 (comment)

before this change, stat() is always called to check if the
file specified by --dev-target exists even if this option is not
specified. also, we compare the retval of stat() with ENOENT, while
state() returns -1 on error.

after this change, stat() is called only if --dev-target is specified,
and we compare the retval of stat() with -1 and 0 only, so if
--dev-target option is not specified, the tool still hehaves.

this change addresses a regression introduced by
94a91f5

Fixes: https://tracker.ceph.com/issues/50891
Signed-off-by: Kefu Chai <kchai@redhat.com>
@tchaikov
Copy link
Contributor Author

changelog

  • add a commit to use boost::filesystem as an alternative of std::filesystem

@tchaikov tchaikov force-pushed the wip-50891 branch 4 times, most recently from ba9960a to 35c7a1b Compare May 21, 2021 09:05
@ifed01
Copy link
Contributor

ifed01 commented May 21, 2021

@tchaikov - wouldn't it be better at this point to split this PR into two parts:

  1. proper stat() retval handling
  2. refactoring to start using filesystem

The rationale is that part 1) is definitely worth prompt backporting along with my ceph-volume migrate feature implementation.
Part 2) can keep living in master for a while (or even be not backported at all as this is rather a code cleanup)

What do you think?

tchaikov added 2 commits May 21, 2021 18:51
the libstdc++ shipped with GCC 7.5 does not have good support of
std::filesystem, among other things, it does not offer
std::filesystem::weakly_canonical(). but boost::filesystem does.
and boost::filesystem is compatible with std::filesystem to some
degree. so let's use it if <filesystem> is not available, we can
take it as a signal that std::filesystem is not quite ready yet.

Signed-off-by: Kefu Chai <kchai@redhat.com>
for better readability

Signed-off-by: Kefu Chai <kchai@redhat.com>
@tchaikov
Copy link
Contributor Author

@ifed01 but i do split the PR into separated commits.

@ifed01
Copy link
Contributor

ifed01 commented May 21, 2021

@ifed01 but i do split the PR into separated commits.

OK, nevermind

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants