From patchwork Fri Feb 3 07:55:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junichi Nomura X-Patchwork-Id: 9553563 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 8E21B60405 for ; Fri, 3 Feb 2017 07:56:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EE11284F0 for ; Fri, 3 Feb 2017 07:56:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7373F284EF; Fri, 3 Feb 2017 07:56:50 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 2B8FE284EF for ; Fri, 3 Feb 2017 07:56:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752807AbdBCH4t convert rfc822-to-8bit (ORCPT ); Fri, 3 Feb 2017 02:56:49 -0500 Received: from tyo162.gate.nec.co.jp ([114.179.232.162]:38535 "EHLO tyo162.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752800AbdBCH4s (ORCPT ); Fri, 3 Feb 2017 02:56:48 -0500 Received: from mailgate01.nec.co.jp ([114.179.233.122]) by tyo162.gate.nec.co.jp (8.15.1/8.15.1) with ESMTPS id v137ukqc029293 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 3 Feb 2017 16:56:46 +0900 Received: from mailsv01.nec.co.jp (mailgate-v.nec.co.jp [10.204.236.94]) by mailgate01.nec.co.jp (8.15.1/8.15.1) with ESMTP id v137uklR031110; Fri, 3 Feb 2017 16:56:46 +0900 Received: from mail01b.kamome.nec.co.jp (mail01b.kamome.nec.co.jp [10.25.43.2]) by mailsv01.nec.co.jp (8.15.1/8.15.1) with ESMTP id v137ukbR015117; Fri, 3 Feb 2017 16:56:46 +0900 Received: from bpxc99gp.gisp.nec.co.jp ([10.38.151.140] [10.38.151.140]) by mail02.kamome.nec.co.jp with ESMTP id BT-MMP-1287868; Fri, 3 Feb 2017 16:55:39 +0900 Received: from BPXM12GP.gisp.nec.co.jp ([10.38.151.204]) by BPXC12GP.gisp.nec.co.jp ([10.38.151.140]) with mapi id 14.03.0319.002; Fri, 3 Feb 2017 16:55:38 +0900 From: Junichi Nomura To: "linux-block@vger.kernel.org" , linux-scsi Subject: [REGRESSION v4.10-rc1] blkdev_issue_zeroout() returns -EREMOTEIO on the first call for SCSI device that doesn't support WRITE SAME Thread-Topic: [REGRESSION v4.10-rc1] blkdev_issue_zeroout() returns -EREMOTEIO on the first call for SCSI device that doesn't support WRITE SAME Thread-Index: AQHSffLogVXR+DvfE0u/pBTub4Ht6A== Date: Fri, 3 Feb 2017 07:55:38 +0000 Message-ID: Accept-Language: en-US, ja-JP Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.34.125.85] Content-ID: MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP I found following ext4 error occurs on a certain storage since v4.10-rc1: EXT4-fs (sdc1): Delayed block allocation failed for inode 12 at logical offset 100 with max blocks 2 with error 121 EXT4-fs (sdc1): This should not happen!! Data will be lost Error 121 (EREMOTEIO) was returned from blkdev_issue_zeroout(). That came from sd driver because WRITE SAME was sent to the device which didn't support it. The problem was introduced by commit e73c23ff736e ("block: add async variant of blkdev_issue_zeroout"). Before the commit, blkdev_issue_zeroout fell back to normal zero writing when WRITE SAME failed and it seems sd driver's heuristics depends on that behaviour. Below is a band-aid fix to restore the fallback behaviour for sd. Although there should be better fix as retrying blindly is not a good idea... v4.10-rc6: # cat /sys/block/sdc/queue/write_same_max_bytes 33553920 # fallocate -v -z -l 512 /dev/sdc1 fallocate: fallocate failed: Remote I/O error # cat /sys/block/sdc/queue/write_same_max_bytes 0 # fallocate -v -z -l 512 /dev/sdc1 # echo $? 0 v4.9 or v4.10-rc6 + this patch: # grep . /sys/block/sdc/queue/write_same_max_bytes 33553920 # fallocate -v -z -l 512 /dev/sdc1 # echo $? 0 # grep . /sys/block/sdc/queue/write_same_max_bytes 0 diff --git a/block/blk-lib.c b/block/blk-lib.c index f8c82a9..8e53474 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c @@ -360,6 +360,7 @@ int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, sector_t nr_sects, gfp_t gfp_mask, bool discard) { int ret; + int pass = 0; struct bio *bio = NULL; struct blk_plug plug; @@ -369,6 +370,7 @@ int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, return 0; } + retry_other_method: blk_start_plug(&plug); ret = __blkdev_issue_zeroout(bdev, sector, nr_sects, gfp_mask, &bio, discard); @@ -378,6 +380,11 @@ int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, } blk_finish_plug(&plug); + if (ret && pass++ == 0) { + bio = NULL; + goto retry_other_method; + } + return ret; } EXPORT_SYMBOL(blkdev_issue_zeroout);