Skip to contentSkip to conversation

block: change blk_get_meta_cap() stub return -ENOIOCTLCMD

PATCH In review Klara Modin 4 participants 4 messages Jul 25, 2025 – Jul 29, 2025 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: change blk_get_meta_cap() stub return -ENOIOCTLCMD

When introduced in commit 9eb22f7fedfc ("fs: add ioctl to query metadata and protection info capabilities") the stub of blk_get_meta_cap() for !BLK_DEV_INTEGRITY always returns -EOPNOTSUPP. The motivation was that while the command was unsupported in that configuration it was still recognized.

A later change instead assumed -ENOIOCTLCMD as is required for unknown ioctl commands per Documentation/driver-api/ioctl.rst. The result being that on !BLK_DEV_INTEGRITY configs, any ioctl which reaches blkdev_common_ioctl() will return -EOPNOTSUPP.

Change the stub to return -ENOIOCTLCMD, fixing the issue and better matching with expectations.

Fixes 42b0ef01e6b5 ("block: fix FS_IOC_GETLBMD_CAP parsing in blkdev_common_ioctl()")
---
 include/linux/blk-integrity.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/blk-integrity.h +1 -1
index e04c6e5bf1c6..e67a2b6e8f11 100644
@@ -97,7 +97,7 @@ static inline struct bio_vec rq_integrity_vec(struct request *rq)
 static inline int blk_get_meta_cap(struct block_device *bdev, unsigned int cmd,
 				   struct logical_block_metadata_cap __user *argp)
 {
-	return -EOPNOTSUPP;
+	return -ENOIOCTLCMD;
 }
 static inline int blk_rq_count_integrity_sg(struct request_queue *q,
 					    struct bio *b)

base-commit: bc5b0c8febccbeabfefc9b59083b223ec7c7b53a

Signature · 1 line
2.50.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Klara Modin

When introduced in commit 9eb22f7fedfc ("fs: add ioctl to query metadata and protection info capabilities") the stub of blk_get_meta_cap() for !BLK_DEV_INTEGRITY always returns -EOPNOTSUPP. The motivation was that while the command was unsupported in that configuration it was still recognized.

A later change instead assumed -ENOIOCTLCMD as is required for unknown ioctl commands per Documentation/driver-api/ioctl.rst. The result being that on !BLK_DEV_INTEGRITY configs, any ioctl which reaches blkdev_common_ioctl() will return -EOPNOTSUPP.

Quoted 8 lines

Change the stub to return -ENOIOCTLCMD, fixing the issue and better matching with expectations.

Link:
https://lore.kernel.org/lkml/CACzX3AsRd__fXb9=CJPTTJC494SDnYAtYrN2=+bZgMCvM6UQDg@mail.gmail.com

Fixes 42b0ef01e6b5 ("block: fix FS_IOC_GETLBMD_CAP parsing in

blkdev_common_ioctl()")

Thanks for the fix!

#2 lore raw
In reply to Klara Modin
Quoted 10 lines · Klara Modin

When introduced in commit 9eb22f7fedfc ("fs: add ioctl to query metadata and protection info capabilities") the stub of blk_get_meta_cap() for !BLK_DEV_INTEGRITY always returns -EOPNOTSUPP. The motivation was that while the command was unsupported in that configuration it was still recognized.

A later change instead assumed -ENOIOCTLCMD as is required for unknown ioctl commands per Documentation/driver-api/ioctl.rst. The result being that on !BLK_DEV_INTEGRITY configs, any ioctl which reaches blkdev_common_ioctl() will return -EOPNOTSUPP.

FYI, I still think we should not fail the command for !BLK_DEV_INTEGRITY, but just report no capabilities.

#3 lore raw

Christoph,

Quoted 2 lines

FYI, I still think we should not fail the command for !BLK_DEV_INTEGRITY, but just report no capabilities.

I agree.

Signature · 1 line
Martin K. Petersen