]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
block: only zero non-PI metadata tuples in bio_integrity_prep
authorChristoph Hellwig <hch@lst.de>
Wed, 26 Jun 2024 04:59:34 +0000 (06:59 +0200)
committerJens Axboe <axboe@kernel.dk>
Fri, 28 Jun 2024 16:29:41 +0000 (10:29 -0600)
The PI generation helpers already zero the app tag, so relax the zeroing
to non-PI metadata.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20240626045950.189758-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio-integrity.c

index 356ca0d3d62f5ac1df92d75e63c435a559a8c588..4da003b86a1bbfae8cac5a38d85d691fea38a337 100644 (file)
@@ -456,11 +456,11 @@ bool bio_integrity_prep(struct bio *bio)
 
                /*
                 * Zero the memory allocated to not leak uninitialized kernel
-                * memory to disk.  For PI this only affects the app tag, but
-                * for non-integrity metadata it affects the entire metadata
-                * buffer.
+                * memory to disk for non-integrity metadata where nothing else
+                * initializes the memory.
                 */
-               gfp |= __GFP_ZERO;
+               if (bi->csum_type == BLK_INTEGRITY_CSUM_NONE)
+                       gfp |= __GFP_ZERO;
        }
 
        /* Allocate kernel buffer for protection data */