Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5993094ybc; Wed, 27 Nov 2019 13:04:03 -0800 (PST) X-Google-Smtp-Source: APXvYqwLiMjKx83mr0C1Gpv6GzXS+PbYkTFXQEhjgsTs+E+LIy3Hda0e4mhwjtrsP+HK8SaeI2kd X-Received: by 2002:a17:906:da04:: with SMTP id fi4mr31823861ejb.24.1574888643636; Wed, 27 Nov 2019 13:04:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888643; cv=none; d=google.com; s=arc-20160816; b=rwqUXCSu43Q95UJ4dZwZGleT6HuGg4WCS8oDbFMNnIY25CI43a4vfb9z+fUhh3kUgp UYpHZoCNhHbvzVYDe4WMTZ2wTibNfMUtcKuAVTqiRb8kieiO7euuG/3BES0afeFrIHx3 aMYKdxICBh5tFThf6i4sd4ewGAQdXUibcn/qJ3WDucTzuLkgw3oqpLmO32TOxEfmIn60 Jk2lp4XivKeMkuosS08BY/tZDj2+V2XJTus03fnUSkH3YxYMD7eD+YAumaNyzcdh11UH z/S5SnV533oa2DEz4PmFDLKtXRZPOKWPOBhomgqhQXni7y7PVa0A1HhYxfZPfz5ssbzj 5QLA== 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=zodnBUiPQ1/0VMJYqA0CR2ZZU4a/wd9Klxh/E6e55Po=; b=p0l0ICZMN/pa82zq9rNu8ZI5MjVSCjsk8FZzqkl7fbYyAxHBYsMaFRrZS1c6m1Aq3x zS/Y9H2YyAMG68waLT7a3cQIUTWto7aFpKVeXuPJNkEXQNq1WpdYEWOmvpbT8a2AiYIn pycWbCFcdd0Qx+da6Ud+7ZeyKrqlLTsT++qw8y3ZlMFVZZMDoq4kI9zSXgHDyvIFPlZb BoucKDZ0NC5JSUvtq6zlXE3taGgnxCGbQS8EOPa8w6PFVDR30EG2vQRSvC0aqP2wN5jZ Oi2rxkh6TQo6e8cxt1EL/ZE8hkbKNFiLmT1TVZm/+DXXpgUWhNmVmPTIflr5zdmFaYiG 2Xvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P1fkTMiZ; 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 g6si13077106edk.210.2019.11.27.13.03.25; Wed, 27 Nov 2019 13:04:03 -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=P1fkTMiZ; 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 S1731888AbfK0VC2 (ORCPT + 99 others); Wed, 27 Nov 2019 16:02:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:55120 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731539AbfK0VCZ (ORCPT ); Wed, 27 Nov 2019 16:02:25 -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 867F121770; Wed, 27 Nov 2019 21:02:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888545; bh=2Kag3n177V4s373POaAsHKFOMafTS0FUlJuj+35TxYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P1fkTMiZ2hhEg4cPS0v3l24+XbhEFPQXR4Ju1hiA7VB2+K58UKROwpiBHi3XFdG70 poROZhtsA94DBfjiqpwZp6uaO7aNGNmqvMCuzyBOu6mzQYLSEiKo7h4BljFUgI1rcv nFaPN4DAtmOKnNTO4qPzp3bALZ+BHP/SB/4eU6Tg= 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.19 174/306] hfsplus: fix return value of hfsplus_get_block() Date: Wed, 27 Nov 2019 21:30:24 +0100 Message-Id: <20191127203128.083742112@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@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 8a8893d522ef3..a930ddd156819 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