From patchwork Wed Oct 10 18:24:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ernesto_A=2E_Fern=C3=A1ndez?= X-Patchwork-Id: 10635075 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3220914BD for ; Wed, 10 Oct 2018 18:25:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25A2029750 for ; Wed, 10 Oct 2018 18:25:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19CA329B39; Wed, 10 Oct 2018 18:25:04 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 C1CC829750 for ; Wed, 10 Oct 2018 18:25:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727034AbeJKBsV (ORCPT ); Wed, 10 Oct 2018 21:48:21 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:40537 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727031AbeJKBsV (ORCPT ); Wed, 10 Oct 2018 21:48:21 -0400 Received: by mail-qk1-f195.google.com with SMTP id a13-v6so3786810qkc.7 for ; Wed, 10 Oct 2018 11:25:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=M9apPidjilpe/f3slHn9NgfIhXAr5pvH7eValgFfcjI=; b=BPp49gz3kwxlPWp/YGwI8PBSZDVKAlS4K5Xjbl+/6CRxanUh8qx+Bhzd+Fzik5bALF H+JJaTaWfyLJ0ko3GJmAJcYGFb1uyGhr1PcAoJiEaSA8pvAD1B3Ec/5Z1OFJePo+clnR o5DfRdUSbLaX4JKT8tjzZgcJ+17v1ceLBWksjaLpjAINh89YlaLi+KskA9BuFUNaYJ5v Yv6kYS5AwPPyfPkQIKkalJlRbfaX7lVQW1xwGESDO2Vasjv9eNVlR4p5C23nqnMmx1AN +51SAuclCn5x0kmAgpIb1GS7cBRPKNrJt0YFtc3OdXRH1VCW7DwIDy9Q78MXX6nR4a1v ZTIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=M9apPidjilpe/f3slHn9NgfIhXAr5pvH7eValgFfcjI=; b=quxpVRaCNYbWslQXa86hEbiQ/cf643pv3wTr7WipZeiCu6rt2oqEBSO1A4YwJ5U7/b lVgw+b99kNuIOCXAwn8nnYMmpq/bOF0tVl0ejDyg3Pb0TTB0FTRu1O0TPMYArXC7eWBb J2OVUCcFYPMP7PbQFhga1AY2jHawplDCEO8XCXx2UMK69EaEPFK9VbHGr1SWrUE0BDYG hPVjrR/0XfBDx4ep1ydBRPs2CWRvj726OgwLnEZZ6VsewAyy59x4rzPr7LMq60jXp1qg 2TucY0pettr2NqQUwEeqkRGRXL+zBWCBkNE9EtlBrvQJ/wSCafBBNnDq5jZKRUzwocia n4ug== X-Gm-Message-State: ABuFfohwrptyCr7IJbqMtDCVzvvSdeVmsy0eVlg2i44BIDeTf3biWK3J oNSU0VQ9DsF6OqQyC2m7kNlk05oM X-Google-Smtp-Source: ACcGV62iheygGGLFNM+c5X90URYa3hOfxcxWBH3u0ndlmSuOLVpxpv/aJEiMugBCfY6+NwobCH3sWg== X-Received: by 2002:a37:1519:: with SMTP id f25-v6mr28238390qkh.268.1539195900067; Wed, 10 Oct 2018 11:25:00 -0700 (PDT) Received: from eaf ([181.47.179.0]) by smtp.gmail.com with ESMTPSA id r18-v6sm13438794qtj.54.2018.10.10.11.24.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Oct 2018 11:24:59 -0700 (PDT) Date: Wed, 10 Oct 2018 15:24:55 -0300 From: Ernesto =?utf-8?q?A=2E_Fern=C3=A1ndez?= To: linux-fsdevel@vger.kernel.org Cc: Andrew Morton Subject: [PATCH 2/2] hfs: fix return value of hfs_get_block() Message-ID: <4538ab8c35ea37338490525f0f24cbc37227528c.1539195310.git.ernesto.mnd.fernandez@gmail.com> References: <2cd1301404ec7cf1e39c8f11a01a4302f1460ad6.1539195310.git.ernesto.mnd.fernandez@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2cd1301404ec7cf1e39c8f11a01a4302f1460ad6.1539195310.git.ernesto.mnd.fernandez@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Direct writes to empty inodes fail with EIO. The generic direct-io code is in part to blame (a patch has been submitted as "direct-io: allow direct writes to empty inodes"), but hfs is worse affected than the other filesystems because the fallback to buffered I/O doesn't happen. The problem is the return value of hfs_get_block() when called with !create. Change it to be more consistent with the other modules. Signed-off-by: Ernesto A. Fernández Reviewed-by: Vyacheslav Dubeyko --- fs/hfs/extent.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c index 0c638c612152..5f1ff97a3b98 100644 --- a/fs/hfs/extent.c +++ b/fs/hfs/extent.c @@ -345,7 +345,9 @@ int hfs_get_block(struct inode *inode, sector_t block, ablock = (u32)block / HFS_SB(sb)->fs_div; if (block >= HFS_I(inode)->fs_blocks) { - if (block > HFS_I(inode)->fs_blocks || !create) + if (!create) + return 0; + if (block > HFS_I(inode)->fs_blocks) return -EIO; if (ablock >= HFS_I(inode)->alloc_blocks) { res = hfs_extend_file(inode);