Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp90372rwb; Fri, 30 Sep 2022 18:00:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5DkruHmePFMJtgQfXULoxAU73dSEu6kmPHNvCqyB25ub2Fp6Z6BTP2Wasbcn8vwDKeCQWC X-Received: by 2002:a62:ea0d:0:b0:55f:8624:4d8b with SMTP id t13-20020a62ea0d000000b0055f86244d8bmr596007pfh.74.1664586056106; Fri, 30 Sep 2022 18:00:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664586056; cv=none; d=google.com; s=arc-20160816; b=iljb03kjeJr3xjqzB/sRwXz0IdQFnERqLE8FVmUpnw53ObnRnfmC9bl3BCC7GUn9TP E4VUU7XrFdtd5lu8tdQQJtuvAiJb3VAQ3Pgc0UIZuE85iKhYQuiOXk4+4Up1wmifhBr9 ji+p+KyN5/hJk2GMQsRQlT20d+is3iSWW5QxUQ8rgam3ZBVgdTk9WKtok2zJyAVhENvK V05ldg3b+o+PgFYqTXszG10rdte1H2Uk6Bx/NFZOnMO+AGOH4MKfCx5pqkBKBDooBb3D uoEfK4MBUomuT4A2NOpeYyMoyOfIxH++tK/kBWgCKIkodkc6kscKhWNBG5pnlYIhuwLD YqeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature:wdcironportexception :ironport-sdr:ironport-sdr:dkim-signature; bh=Mxj5moVJccrmhdt1aNjcSe3sLBRoUareQ11JOXgiNcw=; b=fAJTYBhpnIYv+hVpsqXwq5vnHURyuS26wO/cwVX0dGAuSx75oKH6i7rEMWGk8qWYQm Ko3Hvtk+ZdQgcJ2x+R869iiuDx3NZO+e1m4SuPtCeifCyIkhCBsDCu9QTDFGP8l1inxI 6GDrEotySSBULkNPIC8TWbGkmg99hdWicBeMnBgStN6cOveFoHlqcF65Cyq0cjO70tTX 3OT9JQrEY9CmFlI47yNlXf7aZvK88NGNWdzHa7dz2tpPdyZkqqmYniK/tGuN3dPiR+Hn ecKWTC3u+etlwct7qQdp+rTybGucsj1OxYKYXF9D4eE8ffdSpLLTUelfrvjMSPIJyMpk 7OSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=kQsWDdAp; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=h0NMvYe8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l5-20020a17090a408500b001fad0e954cesi3733828pjg.32.2022.09.30.18.00.43; Fri, 30 Sep 2022 18:00:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=kQsWDdAp; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=h0NMvYe8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=opensource.wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229547AbiJAAu2 (ORCPT + 99 others); Fri, 30 Sep 2022 20:50:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232072AbiJAAuY (ORCPT ); Fri, 30 Sep 2022 20:50:24 -0400 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD7241005EB for ; Fri, 30 Sep 2022 17:50:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1664585420; x=1696121420; h=message-id:date:mime-version:subject:to:references:from: in-reply-to:content-transfer-encoding; bh=GzapoAx1yyETlTo9s+u64ZXimE4706mEDDvom0JArvo=; b=kQsWDdAp/4+bb2PmUqv804DEx0Z92xqgBGrDIMiNyeB/W+ZXVKHQTBIX JwTMiP6UM0UINHwFm8drYtoq6v7qNgFUgmoceXt8IlDYB2k1tzO522GJH GGFT+aOuW+l4KTn5o0MGD+fxXSwyIHoLjckeGJb+sCpbAyjEqih20FdVB zWJGI3jLVKkqD6wIMWPMW4bvwYtB/0U3nb/LqQadwiaMNOjt7tSe7c2dc RnqwZkKN/V1P18a6uuVvDoJh9HlEOnwLGDeXUkqOQaur+xDHKcuxmsjwu /YT9XIqobRG1p3Y4RjT22CCFN5RxNcSuTy6I1pMcPmPQOqYPsruZUlkI2 g==; X-IronPort-AV: E=Sophos;i="5.93,359,1654531200"; d="scan'208";a="212712831" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 01 Oct 2022 08:50:18 +0800 IronPort-SDR: Bko5uJdeLAWWrCX/dTKQXGuCqhOyEDZB5rF+9QesaL5TsPC6DIrq8khQOIekMDC8bpaZZ1A4wZ ubY78L//+j1yDyyrG9k3BWpn3gK4eS255UnNVNgNUmuBvArx5o6nguwTWjc6J2QZlIsM8+mZfB +Qnj4rc4Z9XwnT51FWuG/VyFoBu20FSggI8Ghq5SbbloQUp/dBG2NigUXeOXdI3r3oHooQ+dyM 7MvY+9eQyfJJpOi1F6Ust9ui4KkhzFFVoIms7k5J/pewvHeAb7+XbxB3/X2XOvGahKqcQC9tKK bJOJYMBDe0peLE76mtv0uTTy Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 30 Sep 2022 17:04:38 -0700 IronPort-SDR: n12wYzXvaW4cdqUHdQBWFd/Pgr0TdRh7vACspb5WlB4DVBO0aSfpnsTjisgzwlvLMzztrpIJJm Jv+MflgcxmDqoq084SGYIvSFlyFxNiGRrT4nyZIKy1r+S+3viM2sVt3BaIPzqSLAkuA+dARfA3 mqSG56KV35be5WAKW1piYL5IfP4AnWADL76Fbidks8QfPb4uFdKpBn8Xez3VEwkb0RrxRRodQv DaVEM2GYMKghCEm02szhYSujg/80tTr5VMgECqVXZYPfp/Crl7dkIIANuHUIytXYMgsWlL7SHX /xU= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 30 Sep 2022 17:50:19 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4MfT621JTNz1RvTp for ; Fri, 30 Sep 2022 17:50:18 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :in-reply-to:organization:from:references:to:content-language :subject:user-agent:mime-version:date:message-id; s=dkim; t= 1664585417; x=1667177418; bh=GzapoAx1yyETlTo9s+u64ZXimE4706mEDDv om0JArvo=; b=h0NMvYe8gVC4DRidCFZQZfOluWYBomEst7HZUcZGnIdW6TtaT0E g7s4/SLonH5tK12LSokZWrniSr1NV/MB6VhSWSMO8lWfLHTpu7fSH9MfCY5tG/qn BIAeQcU+isdpCHCG4IHheJuX5AG7hESunecmj7CKID2TmrtUAqVaPRHgedRpIinY bwUz1Lv0HQOrbpWuCCKnlLOmV3NDeyriCB8OFAw25kPFpUtXQpH9nlT+JaYRmA+d mbHEQjrwJn4vMffL7v80fRfIdnwpwyRmRgf8HW4jocjc1/bulknJ5zYVeJLY7Z83 MvqHQ4wLUpALCkOj2RjV1+NboWNC50zehdw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id xH4lzNeuHWl8 for ; Fri, 30 Sep 2022 17:50:17 -0700 (PDT) Received: from [10.225.163.96] (unknown [10.225.163.96]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4MfT5y5FD4z1RvLy; Fri, 30 Sep 2022 17:50:14 -0700 (PDT) Message-ID: <8d5ffebe-39dc-b811-ce7c-9df4b5d061c1@opensource.wdc.com> Date: Sat, 1 Oct 2022 09:50:13 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: block: wrong return value by bio_end_sector? Content-Language: en-US To: Paolo Valente , Arie van der Hoeven , Tyler Erickson , Muhammad Ahmad , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Jan Kara , "andrea.righi@canonical.com" , "glen.valante@linaro.org" , "axboe@kernel.dk" , Michael English , Andrew Ring , Varun Boddu , Damien Le Moal References: From: Damien Le Moal Organization: Western Digital Research In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/1/22 00:59, Paolo Valente wrote: > Hi Jens, Damien, all other possibly interested people, this is to raise > attention on a mistake that has emerged in a thread on a bfq extension > for multi-actuary drives [1]. > > The mistake is apparently in the macro bio_end_sector (defined in > include/linux/bio.h), which seems to be translated (incorrectly) as > sector+size, and not as sector+size-1. This has been like this for a long time, I think. > > For your convenience, I'm pasting a detailed description of the > problem, by Tyler (description taken from the above thread [1]). > > The drive reports the actuator ranges as a starting LBA and a count of > LBAs for the range. If the code reading the reported values simply does > startingLBA + range, this is an incorrect ending LBA for that actuator. Well, yes. LBA 0 + drive capacity is also an incorrect LBA. If the code assumes that it is, you have a classic off-by-one bug. > This is because LBAs are zero indexed and this simple addition is not > taking that into account. The proper way to get the endingLBA is > startingLBA + range - 1 to get the last LBA value for where to issue a > final IO read/write to account for LBA values starting at zero rather > than one. Yes. And ? Where is the issue ? > > Here is an example from the output in SeaChest/openSeaChest: > ====Concurrent Positioning Ranges==== > > Range# #Elements Lowest LBA # of LBAs 0 > 1 0 > 17578328064 1 1 17578328064 > 17578328064 > > If using the incorrect formula to get the final LBA for actuator 0, you > would get 17578328064, but this is the starting LBA reported by the > drive for actuator 1. So to be consistent for all ranges, the final LBA > for a given actuator should be calculated as starting LBA + range - 1. > > I had reached out to Seagate's T10 and T13 representatives for > clarification and verification and this is most likely what is causing > the error is a missing - 1 somewhere after getting the information > reported by the device. They agreed that the reporting from the drive > and the SCSI to ATA translation is correct. > > I'm not sure where this is being read and calculated, but it is not an > error in the low-level libata or sd level of the kernel. It may be in > bfq, or it may be in some other place after the sd layer. I know there > were some additions to read this and report it up the stack, but I did > not think those were wrong as they seemed to pass the drive reported > information up the stack. > > Jens, Damien, can you shed a light on this? I am not clear on what the problem is exactly. This all sound like a simple off-by-one issue if bfq support code. No ? > > Thanks, Paolo > > [1] https://www.spinics.net/lists/kernel/msg4507408.html -- Damien Le Moal Western Digital Research