From patchwork Sat May 31 08:51:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Chen X-Patchwork-Id: 4275081 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F0D179F1D6 for ; Sat, 31 May 2014 08:56:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0649420397 for ; Sat, 31 May 2014 08:56:33 +0000 (UTC) Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mail.kernel.org (Postfix) with ESMTP id D3A7C2038F for ; Sat, 31 May 2014 08:56:30 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s4V8pvve032511; Sat, 31 May 2014 04:51:58 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s4V8psxn013741 for ; Sat, 31 May 2014 04:51:54 -0400 Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.20]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4V8prB2021647; Sat, 31 May 2014 04:51:54 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [119.145.14.66]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4V8pnme019080; Sat, 31 May 2014 04:51:50 -0400 Received: from 172.24.2.119 (EHLO szxeml214-edg.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id APJ47057; Sat, 31 May 2014 16:51:45 +0800 (CST) Received: from SZXEML403-HUB.china.huawei.com (10.82.67.35) by szxeml214-edg.china.huawei.com (172.24.2.29) with Microsoft SMTP Server (TLS) id 14.3.158.1; Sat, 31 May 2014 16:51:40 +0800 Received: from [127.0.0.1] (10.177.23.53) by szxeml403-hub.china.huawei.com (10.82.67.35) with Microsoft SMTP Server id 14.3.158.1; Sat, 31 May 2014 16:51:36 +0800 Message-ID: <53899812.50403@huawei.com> Date: Sat, 31 May 2014 16:51:30 +0800 From: alex chen User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: Mike Snitzer References: <53042F91.4050201@huawei.com> In-Reply-To: <53042F91.4050201@huawei.com> X-Forwarded-Message-Id: <53042F91.4050201@huawei.com> X-Originating-IP: [10.177.23.53] X-CFilter-Loop: Reflected X-RedHat-Spam-Score: -3.651 (BAYES_00, DCC_REPUT_00_12, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS, URIBL_BLOCKED) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.20 X-loop: dm-devel@redhat.com Cc: Kiyoshi Ueda , Milan Broz , Mike Anderson , Joseph Qi , christophe varoqui , dm-devel@redhat.com, "Jun'ichi Nomura" , Alasdair Kergon Subject: [dm-devel] [PATCH] dm linear: disable WRITE SAME if it fails X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 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 X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The original commit f84cb8a46a771f36a04a02c61ea635c968ed5f6a("dm mpath: disable WRITE SAME if it fails") disables WRITE SAME in the DM multipath device if it fails, but when the DM linear device stacks ontop of the multipath device it doesn't help. this patch adds DM linear end_io method to catch WRITE SAME errors and disables WRITE SAME in the DM linear device's queue_limits if an underlying device disables it. Before this patch: dm linear device(dm-20): ocfs2-fs; multipath device(dm-6); scsi device(sdt,sdu); After a WRITE SAME bio fails, the DM linear device does not disable the WRITE SAME, although the underlying device(DM multipath device) has disabled WRITE SAME. cat /sys/block/dm-20/queue/write_same_max_bytes 33553920 cat /sys/block/dm-6/queue/write_same_max_bytes 0 cat /sys/block/sdt/queue/write_same_max_bytes 0 cat /sys/block/sdu/queue/write_same_max_bytes 0 After this patch: dm linear device(dm-20): ocfs2-fs; multipath device(dm-6); scsi device(sdt,sdu); After a WRITE SAME bio fails, the underlying device(DM multipath device) disables WRITE SAME and then the DM linear device also disables WRITE SAME. cat /sys/block/dm-20/queue/write_same_max_bytes 0 cat /sys/block/dm-6/queue/write_same_max_bytes 0 cat /sys/block/sdt/queue/write_same_max_bytes 0 cat /sys/block/sdu/queue/write_same_max_bytes 0 Signed-off-by: alex.chen --- drivers/md/dm-linear.c | 26 +++++++++++++++++++++++++- drivers/md/dm.c | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index 53e848c..eaf86a5 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md/dm-linear.c @@ -96,6 +96,29 @@ static int linear_map(struct dm_target *ti, struct bio *bio) return DM_MAPIO_REMAPPED; } +static int linear_end_io(struct dm_target *ti, struct bio *bio, int error) +{ + struct linear_c *lc = ti->private; + struct block_device *bdev; + struct queue_limits *limits; + struct queue_limits *bdev_limits; + + if (!error) + return error; + + if (unlikely(bio->bi_rw & REQ_WRITE_SAME)) { + bdev = lc->dev->bdev; + bdev_limits = &bdev->bd_disk->queue->limits; + + limits = dm_get_queue_limits(dm_table_get_md(ti->table)); + + if ((!bdev_limits->max_write_same_sectors) && + limits->max_write_same_sectors) + limits->max_write_same_sectors = 0; + } + + return error; +} static void linear_status(struct dm_target *ti, status_type_t type, unsigned status_flags, char *result, unsigned maxlen) { @@ -155,11 +178,12 @@ static int linear_iterate_devices(struct dm_target *ti, static struct target_type linear_target = { .name = "linear", - .version = {1, 2, 1}, + .version = {1, 2, 2}, .module = THIS_MODULE, .ctr = linear_ctr, .dtr = linear_dtr, .map = linear_map, + .end_io = linear_end_io, .status = linear_status, .ioctl = linear_ioctl, .merge = linear_merge, diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 8c53b09..4337025 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -770,7 +770,7 @@ static void clone_endio(struct bio *bio, int error) if (endio) { r = endio(tio->ti, bio, error); - if (r < 0 || r == DM_ENDIO_REQUEUE) + if (r <= 0 || r == DM_ENDIO_REQUEUE) /* * error and requeue request are handled * in dec_pending().