On Tue, Jul 22, 2025 at 01:45:53AM -0700, Christoph Hellwig wrote: > On Tue, Jul 22, 2025 at 01:49:11PM +0530, Anuj Gupta wrote: > > + switch (bi->csum_type) { > > + case BLK_INTEGRITY_CSUM_NONE: > > + meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_NONE; > > + break; > > + case BLK_INTEGRITY_CSUM_IP: > > + meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_IP; > > + break; > > + case BLK_INTEGRITY_CSUM_CRC: > > + meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_CRC16_T10DIF; > > + break; > > + case BLK_INTEGRITY_CSUM_CRC64: > > + meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_CRC64_NVME; > > + break; > > + default: > > + break; > > This should catch and reject invalid values. Otherwise the patch looks > fine. I guess reject is wrong, as the kernel is the source, but I think a bit of validation here still makes sense. I think if you just leave the default out, the compiler would complain if we added a new value to the union without handling it here, which should be enough.