New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ceph-disk: fix signed integer is greater than maximum when call major #19196
Conversation
|
src/ceph-disk/ceph_disk/main.py
Outdated
@@ -603,7 +603,8 @@ def block_path(dev): | |||
return dev | |||
path = os.path.realpath(dev) | |||
rdev = os.stat(path).st_rdev | |||
(M, m) = (os.major(rdev), os.minor(rdev)) | |||
M = ((rdev >> 8) & 0xfff) | ((rdev >> 32) & ~0xfff) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd suggest monkey patching os.major()
and os.minor()
. in other words, add following code snippet at the beginning of main.py
, right before class Ptype(object)
try:
# see https://bugs.python.org/issue23098
os.major(0x80002b00)
except OverflowError:
os.major = lambda devid: ((devid >> 8) & 0xfff) | ((devid >> 32) & ~0xfff)
os.minor = lambda devid: (devid & 0xff) | ((devid >> 12) & ~0xff)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tchaikov , thanks your detailed instruction. ^^
i've done with above monkey patch, please review again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please drop this change. as it is not necessary anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, you reverted the change i suggested.
0805e8d
to
61294ef
Compare
src/ceph-disk/ceph_disk/main.py
Outdated
@@ -603,7 +603,8 @@ def block_path(dev): | |||
return dev | |||
path = os.path.realpath(dev) | |||
rdev = os.stat(path).st_rdev | |||
(M, m) = (os.major(rdev), os.minor(rdev)) | |||
M = ((rdev >> 8) & 0xfff) | ((rdev >> 32) & ~0xfff) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please drop this change. as it is not necessary anymore.
35775eb
to
f77934b
Compare
fix signed integer is greater than maximum when call os.major using python 2.7.5 in Centos 7 Signed-off-by: Song Shun <song.shun3@zte.com.cn>
@tchaikov , i think this time i totally get what you mean, please review. |
fix signed integer is greater than maximum when call os.major
using python 2.7.5 in Centos 7
when calling os.major in block_path, it may broken due to already exist bugs in python 2.7.5 [1].
As you see, this bug has been fixed in python after 2.7.14 (also teseted in my enviroment), just upgradeing python is Ok.
but when i think 2.7.5 is largely used in Centos 7, upgrading could have influenced to other applications.
so i think implementing os.major and os.minor like major and minor in glibc [2] mayb be a good idea.
but i'm not sure that if there is any other problems? please take a review, thanks
[1] Dan MacDonald told me that "os.mknod()" should accept devices >32 bits.
https://bugs.python.org/issue23098
[2] https://github.com/lattera/glibc/blob/master/sysdeps/unix/sysv/linux/sys/sysmacros.h
Signed-off-by: Song Shun song.shun3@zte.com.cn