Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750908AbXACQXu (ORCPT ); Wed, 3 Jan 2007 11:23:50 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750911AbXACQXu (ORCPT ); Wed, 3 Jan 2007 11:23:50 -0500 Received: from nf-out-0910.google.com ([64.233.182.185]:4001 "EHLO nf-out-0910.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750908AbXACQXr (ORCPT ); Wed, 3 Jan 2007 11:23:47 -0500 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:mime-version:content-type; b=CLJzG3sV9LTs1ztIQzmFqvr+McbsRaG7lCISYG8RO0sWTPUOhJbWMuvNMIVM7QUj/VuOXQth4cHBL7h3lM/+B7tt9832fC0NRl+3nIJ+n20hXPz+9/kwJV5Ixkr0/7eF95HFM3vvOsyXlSVAR94tEuLkQGCWvQqSqycbVaGbaPc= Message-ID: Date: Wed, 3 Jan 2007 11:23:45 -0500 From: "Ming Zhao" To: "device-mapper development" Subject: [dm-devel] [RFC][PATCH] dm-cache (block level disk cache target): UPDATE Cc: linux-kernel@vger.kernel.org, ming@acis.ufl.edu, ericvh@gmail.com MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_221821_3510469.1167841425577" Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 71430 Lines: 942 ------=_Part_221821_3510469.1167841425577 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Made several updates on the dm-cache code. The major ones include, * The change on handling of reads: cache insertions are now performed in background for read bio requests, so the reads would appear faster. * The feature of persistent metadata: cache metadata is automatically dumped onto cache disk before a cache is removed, and it can be loaded again when creating a cache so that the existing data on the cache disk can be reused. * The handling of status ioctl is also added, so on dmsetup status, the cache outputs the cache stats, and on dmsetup table, it outputs the cache configuration. Signed-off-by: Ming Zhao ------=_Part_221821_3510469.1167841425577 Content-Type: text/plain; name=patch-2.6.19.1; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: base64 X-Attachment-Id: f_ewhyciz6 Content-Disposition: attachment; filename="patch-2.6.19.1" ZGlmZiAtTmF1ciBsaW51eC0yLjYuMTkuMS1vcmlnL2RyaXZlcnMvbWQvZG0tY2FjaGUuYyBsaW51 eC0yLjYuMTkuMS1kbWNhY2hlL2RyaXZlcnMvbWQvZG0tY2FjaGUuYwotLS0gbGludXgtMi42LjE5 LjEtb3JpZy9kcml2ZXJzL21kL2RtLWNhY2hlLmMJMTk2OS0xMi0zMSAxOTowMDowMC4wMDAwMDAw MDAgLTA1MDAKKysrIGxpbnV4LTIuNi4xOS4xLWRtY2FjaGUvZHJpdmVycy9tZC9kbS1jYWNoZS5j CTIwMDctMDEtMDEgMTg6MjY6MDYuMDAwMDAwMDAwIC0wNTAwCkBAIC0wLDAgKzEsMTc1NSBAQAor LyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioKKyAqICBkbS1jYWNoZS5jCisgKiAgRGV2aWNlIG1hcHBlciB0 YXJnZXQgZm9yIGJsb2NrLWxldmVsIGRpc2sgY2FjaGluZworICoKKyAqICBDb3B5cmlnaHQgKEMp IEludGVybmF0aW9uYWwgQnVzaW5lc3MgTWFjaGluZXMgQ29ycC4sIDIwMDYKKyAqICBBdXRob3I6 IE1pbmcgWmhhbyAobWluZ3poYW9AdWZsLmVkdSkKKyAqCisgKiAgVGhpcyBwcm9ncmFtIGlzIGZy ZWUgc29mdHdhcmU7IHlvdSBjYW4gcmVkaXN0cmlidXRlIGl0IGFuZC9vciBtb2RpZnkKKyAqICBp dCB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEdOVSBHZW5lcmFsIFB1YmxpYyBMaWNlbnNlIGFzIHB1 Ymxpc2hlZCBieQorICogIHRoZSBGcmVlIF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gbGlzdF9oZWFkICpq b2JzKQoreworCXN0cnVjdCBrY2FjaGVkX2pvYiAqam9iID0gTlVMTDsKKwl1bnNpZ25lZCBsb25n IGZsYWdzOworCisJc3Bpbl9sb2NrX2lycXNhdmUoJl9qb2JfbG9jaywgZmxhZ3MpOworCisJaWYg KCFsaXN0X2VtcHR5KGpvYnMpKSB7CisJCWpvYiA9IGxpc3RfZW50cnkoam9icy0+bmV4dCwgc3Ry dWN0IGtjYWNoZWRfam9iLCBsaXN0KTsKKwkJbGlzdF9kZWwoJmpvYi0+bGlzdCk7CisJfQorCXNw aW5fdW5sb2NrX2lycXJlc3RvcmUoJl9qb2JfbG9jaywgZmxhZ3MpOworCisJcmV0dXJuIGpvYjsK K30KKworc3RhdGljIGlubGluZSB2b2lkIHB1c2goc3RydWN0IGxpc3RfaGVhZCAqam9icywgc3Ry dWN0IGtjYWNoZWRfam9iICpqb2IpCit7CisJdW5zaWduZWQgbG9uZyBmbGFnczsKKworCXNwaW5f bG9ja19pcnFzYXZlKCZfam9iX2xvY2ssIGZsYWdzKTsKKwlsaXN0X2FkZF90YWlsKCZqb2ItPmxp c3QsIGpvYnMpOworCXNwaW5fdW5sb2NrX2lycXJlc3RvcmUoJl9qb2JfbG9jaywgZmxhZ3MpOwor fQorCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBGdW5jdGlvbnMgZm9yIGFzeW5jaHJvbm91 c2x5IGZldGNoaW5nIGRhdGEgZnJvbSBzb3VyY2UgZGV2aWNlIGFuZCBzdG9yaW5nCisgKiBkYXRh IGluIGNhY2hlIGRldmljZS4gQmVjYXVzZSB0aGUgcmVxdWVzdGVkIGRhdGEgbWF5IG5vdCBhbGln biB3aXRoIHRoZQorICogY2FjaGUgYmxvY2tzLCBleHRyYSBoYW5kbGluZyBpcyByZXF1aXJlZCB0 byBwYWQgYSBibG9jayByZXF1ZXN0IGFuZC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Y2sgKi8KKwkJCXIgPSBkbV9pb19hc3luY19idmVjKDEsICZqb2ItPnNyYywgUkVB RCwKKwkJCSAgICAgICAgICAgICAgICAgICAgIGJpby0+YmlfaW9fdmVjICsgYmlvLT5iaV9pZHgs CisJCQkgICAgICAgICAgICAgICAgICAgICBpb19jYWxsYmFjaywgam9iKTsKKwkJCXJldHVybiBy OworCQl9CisKKwkJbnJfdmVjcyA9IGJpby0+YmlfdmNudCAtIGJpby0+YmlfaWR4ICsgam9iLT5u cl9wYWdlczsKKwkJYnZlYyA9IGttYWxsb2MobnJfdmVjcyAqIHNpemVvZigqYnZlYyksIEdGUF9O T0lPKTsKKwkJaWYgKCFidmVjKSB7CisJCQlETUVSUigiZG9fZmV0Y2g6IE5vIG1lbW9yeSIpOwor CQkJcmV0dXJuIDE7CisJCX0KKworCQlwbCA9IGpvYi0+cGFnZXM7CisJCWkgPSAwOworCQl3aGls ZSAoaGVhZCkgeworCQkJYnZlY1tpXS5idl9sZW4gPSBtaW4oaGVhZCwgKHVuc2lnbmVkIGludClQ QUdFX1NJWkUpOworCQkJYnZlY1tpXS5idl9vZmZzZXQgPSAwOworCQkJYnZlY1tpXS5idl9wYWdl ID0gcGwtPnBhZ2U7CisJCQloZWFkIC09IGJ2ZWNbaV0uYnZfbGVuOworCQkJcGwgPSBwbC0+bmV4 dDsKKwkJCWkrKzsKKwkJfQorCisJCXJlbWFpbmluZyA9IGJpby0+Ymlfc2l6ZTsKKwkJaiA9IGJp by0+YmlfaWR4OworCQl3aGlsZSAocmVtYWluaW5nKSB7CisJCQlidmVjW2ldID0gYmlvLT5iaV9p b192ZWNbal07CisJCQlyZW1haW5pbmcgLT0gYnZlY1tpXS5idl9sZW47CisJCQlpKys7IGorKzsK KwkJfQorCisJCXdoaWxlICh0YWlsKSB7CisJCQlidmVjW2ldLmJ2X2xlbiA9IG1pbih0YWlsLCAo dW5zaWduZWQgaW50KVBBR0VfU0laRSk7CisJCQlidmVjW2ldLmJ2X29mZnNldCA9I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gaW50 IGxlbmd0aCkKK3sKKwlzdHJ1Y3QgaW9fcmVnaW9uIHNyYywgZGVzdDsKKwlzdHJ1Y3QgY2FjaGVi bG9jayAqY2FjaGVibG9jayA9ICZkbWMtPmNhY2hlW2luZGV4XTsKKwl1bnNpZ25lZCBpbnQgaTsK KworCURQUklOVEsoIldyaXRlIGJhY2sgYmxvY2sgJWxsdSglbGx1LCAldSkiLAorCSAgICAgICAg aW5kZXgsIGNhY2hlYmxvY2stPmJsb2NrLCBsZW5ndGgpOworCXNyYy5iZGV2ID0gZG1jLT5jYWNo ZV9kZXYtPmJkZXY7CisJc3JjLnNlY3RvciA9IGluZGV4IDw8IGRtYy0+YmxvY2tfc2hpZnQ7CisJ c3JjLmNvdW50ID0gZG1jLT5ibG9ja19zaXplICogbGVuZ3RoOworCWRlc3QuYmRldiA9IGRtYy0+ c3JjX2Rldi0+YmRldjsKKwlkZXN0LnNlY3RvciA9IGNhY2hlYmxvY2stPmJsb2NrOworCWRlc3Qu Y291bnQgPSBkbWMtPmJsb2NrX3NpemUgKiBsZW5ndGg7CisKKwlmb3IgKGk9MDsgaTxsZW5ndGg7 IGkrKykKKwkJc2V0X3N0YXRlKGRtYy0+Y2FjaGVbaW5kZXgraV0uc3RhdGUsIFdSSVRFQkFDSyk7 CisJZG1jLT5kaXJ0eV9ibG9ja3MgLT0gbGVuZ3RoOworCWNvcHlfYmxvY2soZG1jLCBzcmMsIGRl c3QsIGNhY2hlYmxvY2spOworfQorCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiAgRnVuY3Rp b25zIGZvciBpbXBsZW1lbnRpbmcgdGhlIHZhcmlvdXMgY2FjaGUgb3BlcmF0aW9ucy4KKyAqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqLworCisvKgorICogTWFwIGEgYmx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iKGpvYik7CisKKwlyZXR1cm4gMDsKK30KKworLyogSGFuZGxlIGNhY2hlIG1pc3NlcyAqLwor c3RhdGljIGludCBjYWNoZV9taXNzKHN0cnVjdCBjYWNoZV9jICpkbWMsIHN0cnVjdCBiaW8qIGJp bywgc2VjdG9yX3QgY2FjaGVfYmxvY2spIHsKKwlpZiAoYmlvX2RhdGFfZGlyKGJpbykgPT0gUkVB RCkKKwkJcmV0dXJuIGNhY2hlX3JlYWRfbWlzcyhkbWMsIGJpbywgY2FjaGVfYmxvY2spOworCWVs c2UKKwkJcmV0dXJuIGNhY2hlX3dyaXRlX21pc3MoZG1jLCBiaW8sIGNhY2hlX2Jsb2NrKTsKK30K KworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKgorICogIEZ1bmN0aW9ucyBmb3IgaW1wbGVtZW50aW5n IHRoZSBvcGVyYXRpb25zIG9uIGEgY2FjaGUgbWFwcGluZy4KKyAqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq LworCisvKgorICogRGVjaWRlIHRoZSBtYXBwaW5nIGFuZCBwZXJmb3JtIG5lY2Vzc2FyeSBjYWNo ZSBvcGVyYXRpb25zIGZvciBhIGJpbyByZXF1ZXN0LgorICovCitzdGF0aWMgaW50IGNhY2hlX21h cChzdHJ1Y3QgZG1fdGFyZ2V0ICp0aSwgc3RydWN0IGJpbyAqYmlvLAorCQkgICAgICB1bmlvbiBt YXBfaW5mbyAqbWFwX2NvbnRleHQpCit7CisJc3RydWN0IGNhY2hlX2MgKmRtYyA9IChzdHJ1Y3Qg Y2FjaGVfYyAqKSB0aS0+cHJpdmF0ZTsKKwlzZWN0b3JfdCByZXF1ZXN0X2Jsb2NrLCBjYWNoZV9i bG9jayA9IDAsIG9mZnNldDsKKwlpbnQgcmVzOworCisJb2Zmc2V0ID0gYm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KHN0 cnVjdCBkbV90YXJnZXQgKnRpLCBzdGF0dXNfdHlwZV90IHR5cGUsCisJCQkgY2hhciAqcmVzdWx0 LCB1bnNpZ25lZCBpbnQgbWF4bGVuKQoreworCXN0cnVjdCBjYWNoZV9jICpkbWMgPSAoc3RydWN0 IGNhY2hlX2MgKikgdGktPnByaXZhdGU7CisJaW50IHN6ID0gMDsKKworCXN3aXRjaCAodHlwZSkg eworCWNhc2UgU1RBVFVTVFlQRV9JTkZPOgorCQlETUVNSVQoInN0YXRzOiByZWFkcyglbHUpLCB3 cml0ZXMoJWx1KSwgY2FjaGUgaGl0cyglbHUsIDAuJWx1KSwiIFwKKwkgICAgICAgICAgICJyZXBs YWNlbWVudCglbHUpLCByZXBsYWNlZCBkaXJ0eSBibG9ja3MoJWx1KSIsCisJICAgICAgICAgICBk bWMtPnJlYWRzLCBkbWMtPndyaXRlcywgZG1jLT5jYWNoZV9oaXRzLAorCSAgICAgICAgICAgZG1j LT5jYWNoZV9oaXRzICogMTAwIC8gKGRtYy0+cmVhZHMgKyBkbWMtPndyaXRlcyksCisJICAgICAg ICAgICBkbWMtPnJlcGxhY2UsIGRtYy0+d3JpdGViYWNrKTsKKwkJYnJlYWs7CisJY2FzZSBTVEFU VVNUWVBFX1RBQkxFOgorCQlETUVNSVQoImNvbmY6IGNhcGFjaXR5KCVsbHVNKSwgYXNzb2NpYXRp dml0eSgldSksIGJsb2NrIHNpemUoJXVLKSwgJXMiLAorCSAgICAgICAgICAgZG1jLT5zaXplKmRt Yy0+YmxvY2tfc2l6ZT4+MTEsIGRtYy0+YXNzb2MsCisJICAgICAgICAgICBkbWMtPmJsb2NrX3Np emU+PigxMC1TRUNUT1JfU0hJRlQpLAorCSAgICAgICAgICAgZG1jLT53cml0ZV9wb2xpY3kgPyAi d3JpdGUtYmFjayI6IndyaXRlLXRocm91Z2giKTsKKwkJYnJlYWs7CisJfQorCXJldHVybiAwOwor fQorCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiAgRnVuY3Rpb25zIGZvciBtYW5pcHVsYXRp bmcgYSBjYWNoZSB0YXJnZXQuCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworc3RhdGljIHN0cnVj dCB0YXJnZXRfdHlwZSBjYWNoZV90YXJnZXQgPSB7CisJLm5hbWUgICA9ICJjYWNoZSIsCisJLnZl cnNpb249IHsxLCAwLCAxfSwKKwkubW9kdWxlID0gVEhJU19NT0RVTEUsCisJLmN0ciAgICA9IGNh Y2hlX2N0ciwKKwkuZHRyICAgID0gY2FjaGVfZHRyLAorCS5tYXAgICAgPSBjYWNoZV9tYXAsCisJ LnN0YXR1cyA9IGNhY2hlX3N0YXR1cywKK307CisKKy8qCisgKiBJbml0aWF0ZSBhIGNhY2hlIHRh cmdldC4KKyAqLworaW50IF9faW5pdCBkbV9jYWNoZV9pbml0KHZvaWQpCit7CisJaW50IHI7CisK KwlyID0gam9ic19pbml0KCk7CisJaWYgKHIpCisJCXJldHVybiByOworCisJX2tjYWNoZWRfd3Eg PSBjcmVhdGVfc2luZ2xldGhyZWFkX3dvcmtxdWV1ZSgia2NhY2hlZCIpOworCWlmICghX2tjYWNo ZWRfd3EpIHsKKwkJRE1FUlIoImZhaWxlZCB0byBzdGFydCBrY2FjaGVkIik7CisJCXJldHVybiAt RU5PTUVNOworCX0KKwlJTklUX1dPUksoJl9rY2FjaGVkX3dvcmssIGRvX3dvcmssIE5VTEwpOwor CisJciA9IGRtX3JlZ2lzdGVyX3RhcmdldCgmY2FjaGVfdGFyZ2V0KTsKKwlpZiAociA8IDApIHsK KwkJRE1FUlIoImNhY2hlOiByZWdpc3RlciBmYWlsZWQgJWQiLCByKTsKKwkJZGVzdHJveV93b3Jr cXVldWUoX2tjYWNoZWRfd3EpOworCX0KKworCXJldHVybiByOworfQor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mJiBFWFBFUklNRU5UQUwKKwktLS1oZWxwLS0tCisJICBTdXBwb3J0IGZvciBnZW5lcmljIGNh Y2hlIHRhcmdldCBmb3IgZGV2aWNlLW1hcHBlci4KKwogZW5kbWVudQogCiBlbmRpZgpkaWZmIC1O YXVyIGxpbnV4LTIuNi4xOS4xLW9yaWcvZHJpdmVycy9tZC9NYWtlZmlsZSBsaW51eC0yLjYuMTku MS1kbWNhY2hlL2RyaXZlcnMvbWQvTWFrZWZpbGUKLS0tIGxpbnV4LTIuNi4xOS4xLW9yaWcvZHJp dmVycy9tZC9NYWtlZmlsZQkyMDA2LTEyLTMxIDEyOjE4OjIwLjAwMDAwMDAwMCAtMDUwMAorKysg bGludXgtMi42LjE5LjEtZG1jYWNoZS9kcml2ZXJzL21kL01ha2VmaWxlCTIwMDYtMTItMzEgMTM6 MjI6MjcuMDAwMDAwMDAwIC0wNTAwCkBAIC0zNiw2ICszNiw3IEBACiBvYmotJChDT05GSUdfRE1f U05BUFNIT1QpCSs9IGRtLXNuYXBzaG90Lm8KIG9iai0kKENPTkZJR19ETV9NSVJST1IpCQkrPSBk bS1taXJyb3Iubwogb2JqLSQoQ09ORklHX0RNX1pFUk8pCQkrPSBkbS16ZXJvLm8KK29iai0kKENP TkZJR19ETV9DQUNIRSkJCSs9IGRtLWNhY2hlLm8KIAogcXVpZXRfY21kX3Vucm9sbCA9IFVOUk9M TCAgJEAKICAgICAgIGNtZF91bnJvbGwgPSAkKFBFUkwpICQoc3JjdHJlZSkvJChzcmMpL3Vucm9s bC5wbCAkKFVOUk9MTCkgXAo= ------=_Part_221821_3510469.1167841425577-- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/