From patchwork Sun Jan 4 08:01:24 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Martin K. Petersen" X-Patchwork-Id: 1164 Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n07DVhKi009327 for ; Wed, 7 Jan 2009 05:31:43 -0800 Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id A6122618859; Wed, 7 Jan 2009 08:35:16 -0500 (EST) Received: from int-mx2.corp.redhat.com (nat-pool.util.phx.redhat.com [10.8.5.200]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n07DZFsw008607 for ; Wed, 7 Jan 2009 08:35:15 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n07DZFLG014201 for ; Wed, 7 Jan 2009 08:35:16 -0500 Received: from agk.fab.redhat.com (agk.fab.redhat.com [10.33.0.19]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n07DZEE3006004 for ; Wed, 7 Jan 2009 08:35:15 -0500 Received: from agk by agk.fab.redhat.com with local (Exim 4.34) id 1LKYYz-0006kR-Kz for dm-devel@redhat.com; Wed, 07 Jan 2009 13:35:13 +0000 Received: from zmta01.collab.prod.int.phx2.redhat.com (LHLO zmta01.collab.prod.int.phx2.redhat.com) (10.5.5.31) by mail01.corp.redhat.com with LMTP; Sun, 4 Jan 2009 03:01:49 -0500 (EST) Received: from localhost (localhost.localdomain [127.0.0.1]) by zmta01.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id D5A8E9047E for ; Sun, 4 Jan 2009 03:01:49 -0500 (EST) Received: from zmta01.collab.prod.int.phx2.redhat.com ([127.0.0.1]) by localhost (zmta01.collab.prod.int.phx2.redhat.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 04WOcfEsVBxl for ; Sun, 4 Jan 2009 03:01:49 -0500 (EST) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by zmta01.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id 8F46590267 for ; Sun, 4 Jan 2009 03:01:49 -0500 (EST) Received: from mx3.redhat.com (mx3.redhat.com [172.16.48.32]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n0481mVe022644; Sun, 4 Jan 2009 03:01:48 -0500 Received: from acsinet12.oracle.com (acsinet12.oracle.com [141.146.126.234]) by mx3.redhat.com (8.13.8/8.13.8) with ESMTP id n0481W9m007411; Sun, 4 Jan 2009 03:01:33 -0500 Received: from acsinet13.oracle.com (acsinet13.oracle.com [141.146.126.235]) by acsinet12.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id n04811xV024737 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 4 Jan 2009 08:01:02 GMT Received: from acsmt702.oracle.com (acsmt702.oracle.com [141.146.40.80]) by acsinet13.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id n04822r6006972; Sun, 4 Jan 2009 08:02:04 GMT Received: from groovelator.mkp.net (/209.217.122.111) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 04 Jan 2009 08:01:26 +0000 To: "Alasdair G. Kergon" , jens.axboe@oracle.com, device-mapper development From: "Martin K. Petersen" Organization: Oracle Date: Sun, 04 Jan 2009 03:01:24 -0500 Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) MIME-Version: 1.0 X-Source-IP: acsmt702.oracle.com [141.146.40.80] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A010207.49606CD8.0008:SCFSTAT928724,ss=1,fgs=0 X-RedHat-Spam-Score: -103.861 X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Scanned-By: MIMEDefang 2.63 on 172.16.48.32 Resent-From: agk@redhat.com Resent-Date: Wed, 7 Jan 2009 13:35:13 +0000 Resent-To: dm-devel@redhat.com Resent-Message-Id: X-loop: dm-devel@redhat.com Cc: Subject: [dm-devel] [PATCH] DM Block integrity support X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com This patch provides support for data integrity passthrough in the device mapper. - If one or more component devices support integrity an integrity profile is preallocated for the DM device. - If all component devices have compatible profiles the DM device is flagged as capable. - Handle integrity metadata when splitting and cloning bios. Signed-off-by: Martin K. Petersen --- -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -1048,6 +1048,19 @@ static int populate_table(struct dm_tabl return dm_table_complete(table); } +static int table_prealloc_integrity(struct dm_table *t, struct mapped_device *md) +{ + struct list_head *devices = dm_table_get_devices(t); + struct dm_dev_internal *ddi; + + list_for_each_entry(ddi, devices, list) { + if (bdev_get_integrity(ddi->dm_dev.bdev)) + return blk_integrity_register(dm_disk(md), NULL); + } + + return 0; +} + static int table_load(struct dm_ioctl *param, size_t param_size) { int r; @@ -1065,6 +1078,14 @@ static int table_load(struct dm_ioctl *p r = populate_table(t, param, param_size); if (r) { + dm_table_put(t); + goto out; + } + + r = table_prealloc_integrity(t, md); + if (r) { + DMERR("could not register integrity profile for %s.", + dm_disk(md)->disk_name); dm_table_put(t); goto out; } diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -865,7 +865,43 @@ void dm_table_set_restrictions(struct dm queue_flag_clear_unlocked(QUEUE_FLAG_CLUSTER, q); else queue_flag_set_unlocked(QUEUE_FLAG_CLUSTER, q); +} +void dm_table_set_integrity(struct dm_table *t, struct mapped_device *md) +{ + struct list_head *devices = dm_table_get_devices(t); + struct dm_dev_internal *prev, *cur; + + /* + * Run through all devices to ensure they have matching + * integrity profile + */ + cur = prev = NULL; + + list_for_each_entry(cur, devices, list) { + + if (prev && + blk_integrity_compare(prev->dm_dev.bdev->bd_disk, + cur->dm_dev.bdev->bd_disk) < 0) { + printk(KERN_ERR "%s: %s %s integrity mismatch!\n", + __func__, prev->dm_dev.bdev->bd_disk->disk_name, + cur->dm_dev.bdev->bd_disk->disk_name); + return; + } + prev = cur; + } + + if (!prev || !bdev_get_integrity(prev->dm_dev.bdev)) + return; + + /* Register dm device as being integrity capable */ + if (blk_integrity_register(dm_disk(md), + bdev_get_integrity(prev->dm_dev.bdev))) + printk(KERN_ERR "%s: %s Could not register integrity!\n", + __func__, dm_disk(md)->disk_name); + else + printk(KERN_INFO "Enabling data integrity on %s\n", + dm_disk(md)->disk_name); } unsigned int dm_table_get_num_targets(struct dm_table *t) diff --git a/drivers/md/dm.c b/drivers/md/dm.c --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -661,6 +661,12 @@ static struct bio *split_bvec(struct bio clone->bi_io_vec->bv_len = clone->bi_size; clone->bi_flags |= 1 << BIO_CLONED; + if (bio_integrity(bio)) { + bio_integrity_clone(clone, bio, bs); + bio_integrity_trim(clone, + bio_sector_offset(bio, idx, offset), len); + } + return clone; } @@ -681,6 +687,14 @@ static struct bio *clone_bio(struct bio clone->bi_vcnt = idx + bv_count; clone->bi_size = to_bytes(len); clone->bi_flags &= ~(1 << BIO_SEG_VALID); + + if (bio_integrity(bio)) { + bio_integrity_clone(clone, bio, bs); + + if (idx != bio->bi_idx || clone->bi_size < bio->bi_size) + bio_integrity_trim(clone, + bio_sector_offset(bio, idx, 0), len); + } return clone; } @@ -1160,6 +1174,7 @@ static void free_dev(struct mapped_devic mempool_destroy(md->tio_pool); mempool_destroy(md->io_pool); bioset_free(md->bs); + blk_integrity_unregister(md->disk); del_gendisk(md->disk); free_minor(minor); @@ -1225,6 +1240,7 @@ static int __bind(struct mapped_device * write_lock(&md->map_lock); md->map = t; dm_table_set_restrictions(t, q); + dm_table_set_integrity(t, md); write_unlock(&md->map_lock); return 0; diff --git a/drivers/md/dm.h b/drivers/md/dm.h --- a/drivers/md/dm.h +++ b/drivers/md/dm.h @@ -41,6 +41,7 @@ struct dm_target *dm_table_get_target(st struct dm_target *dm_table_get_target(struct dm_table *t, unsigned int index); struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector); void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q); +void dm_table_set_integrity(struct dm_table *t, struct mapped_device *md); struct list_head *dm_table_get_devices(struct dm_table *t); void dm_table_presuspend_targets(struct dm_table *t); void dm_table_postsuspend_targets(struct dm_table *t);