-
Bug
-
Resolution: Unresolved
-
Medium
-
None
-
None
-
None
-
3
-
9223372036854775807
LL_IOC_MDC_GETINFO_V2 and IOC_MDC_GETFILEINFO_V2 return a wrong device number for a character or block device.
The client sends the device number in the old 16-bit encoding (old_encode_dev() in ll_mknod()), and the MDT returns it the same way in mbo_rdev. ll_update_inode() decodes it with old_decode_dev(), so stat(2) is right. The V2 arm in ll_dir_ioctl() calls MAJOR() and MINOR() on the raw value:
stx.stx_rdev_major = MAJOR(body->mbo_rdev); stx.stx_rdev_minor = MINOR(body->mbo_rdev);
So every device node has major 0 and a wrong minor.
Measured on 2.17.57, ldiskfs, 2 MDTs. Stock lustre.ko and fixed lustre.ko run one after the other, twice each:
mknod stat(2) V1 (raw st_rdev) V2 stock V2 fixed c 10 200 10:200 10:200 0:2760 10:200 b 8 1 8:1 8:1 0:2049 8:1 c 300 5 44:5 44:5 0:11269 44:5 c 4 1048000 253:192 253:192 0:64960 253:192
The V1 arm is correct: it copies the raw value into st_rdev, and userspace major() and minor() read the same bits. (c 300 5 shows as 44:5 everywhere, because the old encoding has 8 bits each. That is a separate limit, not this bug.)
Who sees it: llapi callers of the V2 ioctls, for example a find that reads stx_rdev_major/stx_rdev_minor. No tool in master prints this field today.
Fix: decode with old_decode_dev() first, as ll_update_inode() does.