From patchwork Mon Apr 25 10:36:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 8925201 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BFA48BF29F for ; Mon, 25 Apr 2016 10:36:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 95E1820166 for ; Mon, 25 Apr 2016 10:36:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3DA4F2015A for ; Mon, 25 Apr 2016 10:36:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754167AbcDYKgd (ORCPT ); Mon, 25 Apr 2016 06:36:33 -0400 Received: from mail-oi0-f53.google.com ([209.85.218.53]:34975 "EHLO mail-oi0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752299AbcDYKgc (ORCPT ); Mon, 25 Apr 2016 06:36:32 -0400 Received: by mail-oi0-f53.google.com with SMTP id x19so38100605oix.2 for ; Mon, 25 Apr 2016 03:36:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=profitbricks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to:cc; bh=N4cui0HqHaXo1m0wdEKbspcxlFqkRjJEl9YkLoFnw0k=; b=W8TwrqwkClj2KdHiYvKBOHoyP59RkDL5AvvtQzF/ImP7Bv9J7q1K91/REQQA7G2Blu tgiw2G1cqjMHzRHMxPqN+hIxv28nJZqWehce1hjvX1qGPFXYTTSg6w+vhIKg4EQ8GGvG nZm2Bms6N9WRn06FITXbnAh4PKWhhowR5SChp0fT0v/5qO0i6F5Jqzq76XSO/3rIQ8io Etn7EWzEs1V3kHZB7jalhkIMD2O0OVrdN8GktXOUgaEBxmIgYkkbdlbhBcSDzq9Iu7fA KtSnkXrpUWaxX1tHOdWexraP6uWrhD5NHk58gspgzJGw+vxU1IXjO6O7H94cY//YZP4n lt8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=N4cui0HqHaXo1m0wdEKbspcxlFqkRjJEl9YkLoFnw0k=; b=ZVT1q/UjtFdeF3O9tSQG7Bns89Vdqbb7UmiUKJ3nHBQU0yOSHV9wOmEt7yzGrx05Yf tJmjM3onKNtB1KrmujR6/IB+7Q4uUCMUifeIQQmHIbZ649FqxX55AsqcusTEZMPU8U12 rAxKYZIC/noon9F/by95afmFzCYNtQCn8sNWRtmSw5oFyYwumOYlIuUeRMvRGXTL++A4 x+rW3W0PSY1yueQ7eTURVkt8slPP9qipZj2mWIpk9hcV9517D8X9NbzqLpTkQhsm8TWQ BKkXOqPL8soyZ749fQFeodqZ4jfDqIIf5IzAG5VZq6PhsmS5Oy+pJu1yDPQiIbh16iGL 3V3w== X-Gm-Message-State: AOPr4FXNLd+n1M1S8KGm+GlnBdaQvhiXSeuHKPJdxAdULrFAXPP11nPsjhwFRzHCY4cLC+SNRwkCykXyPMPmGEeI X-Received: by 10.202.183.7 with SMTP id h7mr216361oif.118.1461580591847; Mon, 25 Apr 2016 03:36:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.87.5 with HTTP; Mon, 25 Apr 2016 03:36:12 -0700 (PDT) From: Jinpu Wang Date: Mon, 25 Apr 2016 12:36:12 +0200 Message-ID: Subject: [PATCH]sd: Don't treat succeeded SYNC as error To: linux-scsi@vger.kernel.org, "Martin K. Petersen" , "James E.J. Bottomley" , Christoph Hellwig Cc: s.parschauer@gmx.de Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=ham 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 Hi, all We hit IO error on fsync, it turns out was because sd treat succeeded SYNC as error. From what I checked in SBC spec there is no indication we should fail IO in this case, so we create this patch. Best Regards, Jack Wang From 5d1f72d9643ce61cd9f3d312377378c43f171d0c Mon Sep 17 00:00:00 2001 From: Jack Wang Date: Mon, 25 Apr 2016 12:05:22 +0200 Subject: [PATCH] sd: Don't treat succeeded SYNC as error We hit IO error in our production on multipath devices during resize device on target side, the problem turns out sd driver passes up as IO error when sense data is UNIT_ATTENTION and ASC && ASCQ indicate Capacity data has changed, even storage side sync the data properly. In order to fix this check in sd_done, report success if condition matches. Sebastian Parschauer report/analyze the bug here: https://sourceforge.net/p/scst/mailman/message/34953416/ Signed-off-by: Sebastian Parschauer Signed-off-by: Jack Wang --- drivers/scsi/sd.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 5a5457a..e9bfe01 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1833,6 +1833,19 @@ static int sd_done(struct scsi_cmnd *SCpnt) } } break; + case UNIT_ATTENTION: + /* Capacity data has changed */ + if (sshdr.asc == 0x2a && sshdr.ascq == 0x09) { + switch (op) { + /* don't treat succeeded fsync() as error */ + case SYNCHRONIZE_CACHE: + case SYNCHRONIZE_CACHE_16: + if (good_bytes == scsi_bufflen(SCpnt)) + SCpnt->result = 0; + break; + } + } + break; default: break; } -- 1.9.1