From patchwork Wed May 10 15:20:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Monakhov X-Patchwork-Id: 9720079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 50A3560236 for ; Wed, 10 May 2017 15:21:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4392C28608 for ; Wed, 10 May 2017 15:21:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 389BE28610; Wed, 10 May 2017 15:21:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D063E28608 for ; Wed, 10 May 2017 15:21:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753710AbdEJPVi (ORCPT ); Wed, 10 May 2017 11:21:38 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35531 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753526AbdEJPVE (ORCPT ); Wed, 10 May 2017 11:21:04 -0400 Received: by mail-wm0-f67.google.com with SMTP id v4so535299wmb.2; Wed, 10 May 2017 08:21:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=8fSY5W6PtnDVdRntJj9ptFbvG95+RUv33qr6/Y/kww0=; b=cKJe8XIEbtrq2xZIeWpESwI537KI0ZZA/kXKrIpmWw06Vkc5kp9j0892ivQLO/E9NA IrDyAOTW1Q5UjmOwTL04dxljQiAZHkzGtciPSUuelPFqtJYarE5FHN2seo80YFdn344W egNSKNKXe0OT/0ADTab6foKjUrJ/GFHktdLxVGnd9PTiAuv/5wXWkJRxsnYqs85NsAYl J7boGCyPf+1gSCUaV6cX1oEgc/zjB1JhvY3KjeMI+qRDvplyTFGaaat+oMycV6Fy2Hfq XEo8rlKj5gK+OoL+k1cxAi38a9UB2bQARgPezqzmYiiFepWiTLWy749u+R5AWqS79ow8 k+AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=8fSY5W6PtnDVdRntJj9ptFbvG95+RUv33qr6/Y/kww0=; b=oDXZ0z5GIE537302uSRT8tSX8E8FcJxikdzjbfcv0wqeEZzSbkVY5yuC4V9Cp2AmVE N86VCPw1d4SdZV9nMFuo4sdRQZL123alrgUai6Ud8yaGZ3j48dwBA7zbt0gHAa4W92bY ti2eoxBoCcFfXJqwY1/RvW8sUQchGL70sDtUi3Q2TF48YzNVOBxNawmsrFpUT/bbqpa4 vRHeEJk1CTfvZ1dCCPZ1gRzP3ofMc7NBAv4oY+p+pFOFBA/6Ilqf4h4Lg1y08LqsO5oU 0mfGIRky+HxOVEanZg6QJ9ziUkMMe1k3VUaWoyvd5XbWlI2EWefhMKsnknevq5n3VFBH 4Qng== X-Gm-Message-State: AODbwcAxNSnYbcCQSidIjkX+COwEQcpewcZTN70c3yqdO7z11gMXyB+3 JtJHYipKWrkwNVGQWkw= X-Received: by 10.25.19.85 with SMTP id j82mr3156359lfi.16.1494429661918; Wed, 10 May 2017 08:21:01 -0700 (PDT) Received: from smtp.gmail.com (msk-vpn.virtuozzo.com. [195.214.232.6]) by smtp.gmail.com with ESMTPSA id 139sm602939ljj.16.2017.05.10.08.21.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 May 2017 08:21:01 -0700 (PDT) From: Dmitry Monakhov To: fstests@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, Dmitry Monakhov Subject: [PATCH 4/9] bio-integrity: fix interface for bio_integrity_trim Date: Wed, 10 May 2017 19:20:47 +0400 Message-Id: <1494429652-9488-5-git-send-email-dmonakhov@openvz.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1494429652-9488-1-git-send-email-dmonakhov@openvz.org> References: <1494429652-9488-1-git-send-email-dmonakhov@openvz.org> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP bio_integrity_trim inherent it's interface from bio_trim and accept offset and size, but this API is error prone because data offset must always be insync with bio's data offset. That is why we have integrity update hook in bio_advance() So only meaningful values are: offset == 0, sectors == bio_sectors(bio) Let's just remove them completely. Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Reviewed-by: Martin K. Petersen Signed-off-by: Dmitry Monakhov --- block/bio-integrity.c | 11 ++--------- block/bio.c | 4 ++-- drivers/md/dm.c | 2 +- include/linux/bio.h | 5 ++--- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 82a6ffb..6170dad 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -433,22 +433,15 @@ EXPORT_SYMBOL(bio_integrity_advance); /** * bio_integrity_trim - Trim integrity vector * @bio: bio whose integrity vector to update - * @offset: offset to first data sector - * @sectors: number of data sectors * * Description: Used to trim the integrity vector in a cloned bio. - * The ivec will be advanced corresponding to 'offset' data sectors - * and the length will be truncated corresponding to 'len' data - * sectors. */ -void bio_integrity_trim(struct bio *bio, unsigned int offset, - unsigned int sectors) +void bio_integrity_trim(struct bio *bio) { struct bio_integrity_payload *bip = bio_integrity(bio); struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev); - bio_integrity_advance(bio, offset << 9); - bip->bip_iter.bi_size = bio_integrity_bytes(bi, sectors); + bip->bip_iter.bi_size = bio_integrity_bytes(bi, bio_sectors(bio)); } EXPORT_SYMBOL(bio_integrity_trim); diff --git a/block/bio.c b/block/bio.c index 2f01f1b..d42e602 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1857,7 +1857,7 @@ struct bio *bio_split(struct bio *bio, int sectors, split->bi_iter.bi_size = sectors << 9; if (bio_integrity(split)) - bio_integrity_trim(split, 0, sectors); + bio_integrity_trim(split); bio_advance(bio, split->bi_iter.bi_size); @@ -1891,7 +1891,7 @@ void bio_trim(struct bio *bio, int offset, int size) bio->bi_iter.bi_size = size; if (bio_integrity(bio)) - bio_integrity_trim(bio, 0, size); + bio_integrity_trim(bio); } EXPORT_SYMBOL_GPL(bio_trim); diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 6ef9500..35e5f57 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1146,7 +1146,7 @@ static int clone_bio(struct dm_target_io *tio, struct bio *bio, clone->bi_iter.bi_size = to_bytes(len); if (unlikely(bio_integrity(bio) != NULL)) - bio_integrity_trim(clone, 0, len); + bio_integrity_trim(clone); return 0; } diff --git a/include/linux/bio.h b/include/linux/bio.h index d1b04b0..5834186 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -724,7 +724,7 @@ extern bool bio_integrity_enabled(struct bio *bio); extern int bio_integrity_prep(struct bio *); extern void bio_integrity_endio(struct bio *); extern void bio_integrity_advance(struct bio *, unsigned int); -extern void bio_integrity_trim(struct bio *, unsigned int, unsigned int); +extern void bio_integrity_trim(struct bio *); extern int bio_integrity_clone(struct bio *, struct bio *, gfp_t); extern int bioset_integrity_create(struct bio_set *, int); extern void bioset_integrity_free(struct bio_set *); @@ -774,8 +774,7 @@ static inline void bio_integrity_advance(struct bio *bio, return; } -static inline void bio_integrity_trim(struct bio *bio, unsigned int offset, - unsigned int sectors) +static inline void bio_integrity_trim(struct bio *bio) { return; }