Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5983724ybc; Wed, 27 Nov 2019 12:53:42 -0800 (PST) X-Google-Smtp-Source: APXvYqx2v6P925ea0WePv6JF066nV+utf0M3j51Keqeorlna+Q1pSzlMHiZXEJXgy1rBR6d7HBNO X-Received: by 2002:aa7:d60e:: with SMTP id c14mr34412253edr.174.1574888022533; Wed, 27 Nov 2019 12:53:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888022; cv=none; d=google.com; s=arc-20160816; b=OYU8hriXiUWEd+J/uhhcs0ctFKFuW6TzSHc8KiU47ejLqZmxnEIFlfDbte6WIG1Txy Iqga07TPy/aU3BtRUwGCp0PAEnW/CYfinC1dH1p+Y2qp3YlwYkGb5NkpEswJ0mmFxiiT yBjigbiCEkm5+zJTUP1ha43vuQEUNf1dwio7c8UiKfnVJs+VKVIe1mkvxNbTs1Zs0pz/ ZitY5TqcBg5+ewYN19nEavVZ20JFBvxddvf8QFlppzNm2KInH74CZFB0MDtDp+Xpl2Uj 39EcfFNWAeLj6+K9H3rUEdt8V2AljSbcrt5GPgu82arDaBvxdSX7Ar/dFmt3OYMJo1Vt ElaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZQN1/g5GZkq3z0BYe0IlsVsgSkxxSWxse9ve71JzOvE=; b=KA7o2orcZ4k1zGy52llXtr5sWEepGJHwU1JM96Zp8JYeqL51D9e2H4dOsvhNIzyVUE /XDrrtVK/dB+z0T1rA3xniLmPMtYeqcscOQF7bbRSv6dOFXiO6M7oOuZZEfDt8imm6De ETb90tPbMruYLVhjNhG29Iqrw7DvvclhPER65ezG4m1zVNJuU6FwnBrvJnLAc5yMKP/C wV48Z3U8j5AKNHLl7P5LT2jHRLeu6M6qghAaju7he/QDmVL/hcHKwYnVu2RP56j3vFeN QzBCprkfaNr2tXHcro+/PCM5QmXs9qgNpZRLWnUs1Uvhn57O96wsC3dDdCpQqqanoYk/ GFdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xyevuFZK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j19si10866069edt.451.2019.11.27.12.53.18; Wed, 27 Nov 2019 12:53:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xyevuFZK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728338AbfK0Uul (ORCPT + 99 others); Wed, 27 Nov 2019 15:50:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:36670 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730373AbfK0Uuh (ORCPT ); Wed, 27 Nov 2019 15:50:37 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AE49C2184C; Wed, 27 Nov 2019 20:50:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574887836; bh=UuqkYwaEdKSFRzNCtzmdbILIkT501RlWETeJr5f1rEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xyevuFZK5/wiFOT6DUldiEEW3CykJVJOf1jXzSs5mUUGkaY32lynmK3SYi8vC95aV B4asNMeXM29O3u1P6nckuWMAZDK70GuvAJ2XyzIhw7KDli0QIh2vD9z0WiR/V3Qi8C sMlQ/djhbwT1IpHz49QgG+T3p+I9XyqtgR8Egvuo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "=?UTF-8?q?Ernesto=20A . =20Fern=C3=A1ndez?=" , Vyacheslav Dubeyko , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.14 113/211] hfsplus: fix return value of hfsplus_get_block() Date: Wed, 27 Nov 2019 21:30:46 +0100 Message-Id: <20191127203104.699181119@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203049.431810767@linuxfoundation.org> References: <20191127203049.431810767@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ernesto A. Fernández [ Upstream commit 839c3a6a5e1fbc8542d581911b35b2cb5cd29304 ] 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 hfsplus is worse affected than the other filesystems because the fallback to buffered I/O doesn't happen. The problem is the return value of hfsplus_get_block() when called with !create. Change it to be more consistent with the other modules. Link: http://lkml.kernel.org/r/2cd1301404ec7cf1e39c8f11a01a4302f1460ad6.1539195310.git.ernesto.mnd.fernandez@gmail.com Signed-off-by: Ernesto A. Fernández Reviewed-by: Vyacheslav Dubeyko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/hfsplus/extents.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c index 284d7fb73e863..58f296bfd4380 100644 --- a/fs/hfsplus/extents.c +++ b/fs/hfsplus/extents.c @@ -237,7 +237,9 @@ int hfsplus_get_block(struct inode *inode, sector_t iblock, ablock = iblock >> sbi->fs_shift; if (iblock >= hip->fs_blocks) { - if (iblock > hip->fs_blocks || !create) + if (!create) + return 0; + if (iblock > hip->fs_blocks) return -EIO; if (ablock >= hip->alloc_blocks) { res = hfsplus_file_extend(inode, false); -- 2.20.1