From: Sage Weil Date: Tue, 18 Jun 2013 03:54:15 +0000 (-0700) Subject: ceph-disk: make is_held() smarter about full disks X-Git-Tag: v0.67-rc1~164^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e082f1247fb6ddfb36c4223cbfdf500d6b45c978;p=ceph.git ceph-disk: make is_held() smarter about full disks Handle the case where the device is a full disk. Make the partition check a bit more robust (don't make assumptions about naming aside from the device being a prefix of the partition). Signed-off-by: Sage Weil --- diff --git a/src/ceph-disk b/src/ceph-disk index e77a8560ec20..13f434882c8d 100755 --- a/src/ceph-disk +++ b/src/ceph-disk @@ -289,13 +289,20 @@ def is_held(dev): assert os.path.exists(dev) dev = os.path.realpath(dev) base = dev[5:] - disk = base - while disk[-1].isdigit(): - disk = disk[:-1] - directory = '/sys/block/{disk}/{base}/holders'.format(disk=disk, base=base) - if not os.path.exists(directory): - return [] - return os.listdir(directory) + + # full disk? + directory = '/sys/block/{base}/holders'.format(base=base) + if os.path.exists(directory): + return os.listdir(directory) + + # partition? + part = base + while len(base): + directory = '/sys/block/{base}/{part}/holders'.format(part=part, base=base) + if os.path.exists(directory): + return os.listdir(directory) + base = base[:-1] + return [] def verify_not_in_use(dev):