Repository navigation
blk/kernel: use open file description lock if available - #37153
Conversation
|
jenkins test make check |
There was a problem hiding this comment.
This looks good and addresses all my concerns from #34566 (comment), but https://github.com/X0Ken/ceph/blob/23f8c323d2ba9133c3ef5834ae93115425c862d1/src/common/options.cc#L3998 now needs to mention that negative means unlimited, e.g.
.set_long_description(
"The number of times to retry on getting the block device lock. "
"Programs such as systemd-udevd may compete with Ceph for this lock. "
"A negative number means 'unlimited'."),Independent question: Is 3 still the best default, should it be longer, or should it loop forever without configurable max retry value (perhaps logging a warning instead)? It seems sensible to me in a situation like this where we know that the lock will eventually make progress.
thank you. i split the wait-forever change into a separate commit, as it's not related to the OFD lock change. and incorporated your suggestion into that commit.
i cannot tell what is the best default. but by inspecting https://github.com/systemd/systemd/blob/ee0b9e721a368742ac6fa9c3d9a33e45dc3203a2/src/shared/lockfile-util.c#L45-L72 . i think 0.3 second should be enough for and after a second thought, i don't think to loop forever is a good default. a small number for the max retry times is like assert(systemd_should_finish_its_job_in_a_short_time)where short time is, well, a magic number. if, systemd cannot finish in 0.3 second, we should be aware of this right away. as it very likely indicates a serious issue in system. a warning in log is not enough for this signal, IMHO. |
ifed01
left a comment
There was a problem hiding this comment.
LGTM. Just one nit - may be more straightforward processing when bdev_flock_retry is set to 0. Currently this means MAX_INT retries which isn't obvious for users...
|
@ifed01 i don't follow you. do you mean we should retry forever if |
Given prefix form for (++nr_tries) and initial setting nr_tries=0 it looks like the current behavior when bdev_flock_retry == 0 is to to repeat MAX_UINT times and stop. This is neither a "forever" loop nor "meaningful" behavior for such a setting. |
max_retry > 0 && ++nr_tries == max_retryif the setting ( but yeah, the setting is not retry anymore, it is actually |
instead of relying on utime_t, use standard library directly. Signed-off-by: Kefu Chai <[email protected]>
also drop bdev_flock_retry and bdev_flock_retry_interval from legacy_config_opts.h, as `KernelDevice::_lock()` is not in the critical path, there is no need to access these settings via member variables -- get_val<> would just suffice. Signed-off-by: Kefu Chai <[email protected]>
* use OFD lock if available. OFD is Linux specific, and only available
on 3.15 kernels. OFD is able to synchronize both threads and
processes. and has simpler semantics. this is just a cleanup.
as we don't create threads for acquiring the flock.
* use BSD flock(2) as a fallback
* return the errno right away, without printing logging messages.
for two reasons:
- writing logging messages would reset the errno.
- the caller of _lock() also prints the logging messages along
with strerror(errno)
Fixes: https://tracker.ceph.com/issues/46124
Signed-off-by: Kefu Chai <[email protected]>
|
@ifed01 fixed and repushed. |
retry forever if cct->_conf->bdev_flock_retry is 0. systemd-udevd is most likely the reason why ceph-osd fails to acquire the flock when "mkfs", because systemd-udevd probes all block devices when the device changes in the system using libblkid, and when systemd-udevd starts looking at the device it takes a `LOCK_SH|LOCK_NB` lock. and it releases the lock right after done with it. so normally, it only takes a jiffy, see https://github.com/systemd/systemd/blob/ee0b9e721a368742ac6fa9c3d9a33e45dc3203a2/src/shared/lockfile-util.c#L18 so, we just need to retry couple times before acquiring the lock. Fixes: https://tracker.ceph.com/issues/46124 Signed-off-by: Kefu Chai <[email protected]>
Checklist
Show available Jenkins commands
jenkins retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test apijenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume tox