From patchwork Wed Apr 15 14:16:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 6220921 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EBB229F2EC for ; Wed, 15 Apr 2015 14:16:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2A560202EB for ; Wed, 15 Apr 2015 14:16:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 38C0220154 for ; Wed, 15 Apr 2015 14:16:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753787AbbDOOQJ (ORCPT ); Wed, 15 Apr 2015 10:16:09 -0400 Received: from mail-lb0-f169.google.com ([209.85.217.169]:35703 "EHLO mail-lb0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753661AbbDOOQH (ORCPT ); Wed, 15 Apr 2015 10:16:07 -0400 Received: by lbbuc2 with SMTP id uc2so35088730lbb.2; Wed, 15 Apr 2015 07:16:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=b3o194kYZThC6S7uRq/WD0sruM4+EkDYtsexKo0ES10=; b=SADjmUjJiJo167bYR1fAUfsgeDYCpoh/x+66VNb+kkfA4m/b3RrbU4DJ9aJU+yxI3o 0ljqKvriZEGKdpGddgVtpXPADw9z3aa3Tiy1msSNqAgrGcY0P1Ohcl7nrI7AqYPxI7X+ KI7HRujckb0ralk0U8naQ7DVf4iK2mwFlh8zyu4G8XfyO0nzrvZ4Fhr3WCDJ8sBh+vmY JRO1AfBXn+SeB9c7m3/lkd3iLy70i1M+ryC6RifFvctqDhlmyG0dIgGOOw0hgGol8n/W z9sh71lyFkXgET37vkRd3WAhp0mGDgNcB9RWoqZ9hvOjWf7CB2HnygV36/WmtlbIqZsO gTiw== MIME-Version: 1.0 X-Received: by 10.152.203.201 with SMTP id ks9mr23428810lac.49.1429107365186; Wed, 15 Apr 2015 07:16:05 -0700 (PDT) Received: by 10.152.106.3 with HTTP; Wed, 15 Apr 2015 07:16:04 -0700 (PDT) In-Reply-To: <552E384F.3030203@dev.mellanox.co.il> References: <1428945575-30839-1-git-send-email-sagig@mellanox.com> <552D4C7B.9000402@dev.mellanox.co.il> <552E384F.3030203@dev.mellanox.co.il> Date: Wed, 15 Apr 2015 23:16:04 +0900 Message-ID: Subject: Re: [RFC] Simlify dif_verify routines and fixup fileio protection information code. From: Akinobu Mita To: Sagi Grimberg Cc: "Nicholas A. Bellinger" , target-devel@vger.kernel.org, "linux-scsi@vger.kernel.org" , "Martin K. Petersen" , Christoph Hellwig Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 2015-04-15 19:07 GMT+09:00 Sagi Grimberg : > On 4/15/2015 2:52 AM, Akinobu Mita wrote: > >>>> >>>> Looks good... >>>> >>>> I'll test with these patches and check if the problems I met >>>> disappear. >>> >>> >>> >>> Thanks Akinobu, >>> >>> Waiting to hear your verdict before sending a formal patchset. >> >> >> I hit a original bug in sbc_dif_verify() which is not introduced by >> your patch set, though. > > > What is this original bug? I meant to say about the problem I fixed by fix-sbc_dif_verify.patch. >> Please consider to include attached patch. > > > I'll include it. thanks. > >> I'm still seeing another problem and trying to find out a root cause, >> but it seems like it's caused by other change in -next. >> > > care to elaborate? When mounting ext4 filesystem at the first time after mkfs, a lot of WRITE_SAME commands are issued for lazy initialization or something. By the commit 436f4a0a ("loopback: Add fabric_prot_type attribute support"), When WRITE_SAME command with WRPROTECT=0 is executed, sbc_dif_generate() is called but cmd->t_prot_sg is NULL as block layer didn't allocate it for WRITE_SAME. I could work around with the attached patch, as the WRITE_SAME command will fail after all when protection info is enabled with FILEIO, we only need to avoid null pointer dereference. But I need to ask Nic about the right way to fix. For this patch set, please feel free to add: Tested-by: Akinobu Mita diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index 3d88c00..d8d6267 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -1183,6 +1183,9 @@ sbc_dif_generate(struct se_cmd *cmd) void *daddr, *paddr; int i, j, offset = 0; + if (!psg) + return; + for_each_sg(cmd->t_data_sg, dsg, cmd->t_data_nents, i) { daddr = kmap_atomic(sg_page(dsg)) + dsg->offset; paddr = kmap_atomic(sg_page(psg)) + psg->offset;