From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9AACC43331 for ; Mon, 11 Nov 2019 08:38:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C11BA214DB for ; Mon, 11 Nov 2019 08:38:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="OQc6TyHs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726819AbfKKIi1 (ORCPT ); Mon, 11 Nov 2019 03:38:27 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:46014 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726770AbfKKIi1 (ORCPT ); Mon, 11 Nov 2019 03:38:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=hcAOVMZPSzZPhTPxN9VZMB0WgNghvQiZWyp0y9X3270=; b=OQc6TyHsOO3L0MFE2gFIEh/2u TF2lL1nyj+yTZMLy5mmv5imhXqE+V+8CXMch6bDvBXSksYLErJMKs5UeQ299wYUd9B8nHIxHEVJto oIAaICc3N5bh9KCeyuArOpH+2jkFiZs3my+rlzQoh446mRASerHynRsMEjNNr3jEEOmhUJm77cUgX wk/FlQ4IjZqmfgKz4BAlXdBOaKD/Bw70ADeDWNlkwloksFnyzKrdKRUWu6hTiiyiq0/QgBnvofuRt kUcVgQa3G0wvszDfsT+5HqIATdK3Fs68wZIq3NNrDx2qPcxNvMxtjzaP7pFw5NA9ZvA4lCmVMZHAN a9vF33p3g==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1iU5DD-0007mS-4J; Mon, 11 Nov 2019 08:38:15 +0000 Date: Mon, 11 Nov 2019 00:38:15 -0800 From: Christoph Hellwig To: Jan Stancek Cc: "Darrick J. Wong" , Naresh Kamboju , LTP List , Linux-Next Mailing List , linux-fsdevel@vger.kernel.org, chrubis , open list , Al Viro , Mark Brown , Arnd Bergmann , lkft-triage@lists.linaro.org, Christoph Hellwig , linux-ext4 , Theodore Ts'o Subject: Re: LTP: diotest4.c:476: read to read-only space. returns 0: Success Message-ID: <20191111083815.GA29540@infradead.org> References: <852514139.11036267.1573172443439.JavaMail.zimbra@redhat.com> <20191111012614.GC6235@magnolia> <1751469294.11431533.1573460380206.JavaMail.zimbra@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1751469294.11431533.1573460380206.JavaMail.zimbra@redhat.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Mon, Nov 11, 2019 at 03:19:40AM -0500, Jan Stancek wrote: > > > loff_t length, > > > if (pad) > > > iomap_dio_zero(dio, iomap, pos, fs_block_size - > > > pad); > > > } > > > - return copied ? copied : ret; > > > + return copied ? (loff_t) copied : ret; > > > > I'm a little confused on this proposed fix -- why does casting size_t > > (aka unsigned long) to loff_t (long long) on a 32-bit system change the > > test outcome? > > Ternary operator has a return type and an attempt is made to convert > each of operands to the type of the other. So, in this case "ret" > appears to be converted to type of "copied" first. Both have size of > 4 bytes on 32-bit x86: Sounds like we should use a good old if here to avoid that whole problem spacE: if (copied) return copied; return ret; > size_t copied = 0; > int ret = -14; > long long actor_ret = copied ? copied : ret; > > On x86_64: actor_ret == -14; > On x86 : actor_ret == 4294967282 > > > Does this same diotest4 failure happen with XFS? I ask > > because XFS has been using iomap for directio for ages. > > Yes, it fails on XFS too. Is this a new test? If not why was this never reported? Sounds like we should add this test case to xfstests.