aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/rbd.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index bb7f436b1765..ae65fac2c42b 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -481,6 +481,12 @@ static void rbd_coll_release(struct kref *kref)
481 kfree(coll); 481 kfree(coll);
482} 482}
483 483
484static bool rbd_dev_ondisk_valid(struct rbd_image_header_ondisk *ondisk)
485{
486 return !memcmp(&ondisk->text,
487 RBD_HEADER_TEXT, sizeof (RBD_HEADER_TEXT));
488}
489
484/* 490/*
485 * Create a new header structure, translate header format from the on-disk 491 * Create a new header structure, translate header format from the on-disk
486 * header. 492 * header.
@@ -492,7 +498,7 @@ static int rbd_header_from_disk(struct rbd_image_header *header,
492{ 498{
493 u32 i, snap_count; 499 u32 i, snap_count;
494 500
495 if (memcmp(ondisk, RBD_HEADER_TEXT, sizeof(RBD_HEADER_TEXT))) 501 if (!rbd_dev_ondisk_valid(ondisk))
496 return -ENXIO; 502 return -ENXIO;
497 503
498 snap_count = le32_to_cpu(ondisk->snap_count); 504 snap_count = le32_to_cpu(ondisk->snap_count);