From: Alex Zhuravlev Date: Mon, 13 Jul 2015 20:36:10 +0000 (+0300) Subject: LU-6768 osd: unmap reallocated blocks X-Git-Tag: 2.7.58~43 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=bcef61a80ab4fa6cee847722184738ba4deeb971 LU-6768 osd: unmap reallocated blocks call unmap_underlying_metadata() on every allocated block. otherwise metadata blocks released in a previous transaction can be written by the kernel corrupting user's data. pblock != 0 should be a good sign of that. Change-Id: I0d06611feb384a3f7ef5d8e5b34951822369ed0f Signed-off-by: Alex Zhuravlev Reviewed-on: http://review.whamcloud.com/15593 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Bobi Jam Reviewed-by: Niu Yawei Reviewed-by: Oleg Drokin --- diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index 065f2e4..3939ae9 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -619,7 +619,7 @@ static int ldiskfs_ext_new_extent_cb(struct inode *inode, { struct bpointers *bp = cbdata; struct ldiskfs_extent nex; - unsigned long pblock; + unsigned long pblock = 0; unsigned long tgen; int err, i; unsigned long count; @@ -745,11 +745,7 @@ map: i, cex->ec_len); for (; i < cex->ec_len && bp->num; i++) { *(bp->blocks) = cex->ec_start + i; -#ifdef LDISKFS_EXT_CACHE_EXTENT /* until kernel 2.6.37 */ - if (cex->ec_type != LDISKFS_EXT_CACHE_EXTENT) { -#else - if ((cex->ec_len == 0) || (cex->ec_start == 0)) { -#endif + if (pblock != 0) { /* unmap any possible underlying metadata from * the block device mapping. bug 6998. */ unmap_underlying_metadata(inode->i_sb->s_bdev,