Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6032006ybc; Wed, 27 Nov 2019 13:45:19 -0800 (PST) X-Google-Smtp-Source: APXvYqzr8McwKyxyWe83zD442LQtc/uML0kL3dyR95XeH2xl4srUop2peADUly8sa913T48zNQ5B X-Received: by 2002:a05:6402:70e:: with SMTP id w14mr34411209edx.95.1574891119741; Wed, 27 Nov 2019 13:45:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574891119; cv=none; d=google.com; s=arc-20160816; b=pembnOp4VC0ot1xAmGkBCFvYDSMKDVQraP5x5lcO0GwUx/K2q+y+ZJRq2IdQ3+gKmt dZuDrCj/eEzVfAjtP6LEcP8f/3m2VasuhuJAUldzV3HZdmBQiZKfIBCSjG2KGTPSxmvT rk9MPAoZ5OFmDGpsq53oKDvR1Bv+DB/wnAnzBkZKg6BdvFQ3NuQNkNJTTPTBCp8DDeAE bWvzvRP58cKY4jpaz/7dXh/06T1kH7HZS0Si7aq8ycJ/EhBIwD0dbRVccl+ETOnTuj9G fWe/VXTHySgjg0y6QZ6BUxzulw6AHVWEfAbmdOh8v4ZkXFSk9UcsL40Eb0QurfTD38l0 m2Qw== 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=HVDq0rul1yyuIBkaPsmr02iEZArWGD2C0UYE6dytE+U=; b=qFf85HhHfkasOjXEg0Cbc8QcX1JOPq0XDhj81sgTqSzWRcqFk75IRpuUwFNo1a5+M6 ZUd5RpxyMqkP0XqxM0jHxoppAk71GZ+KA4Q8IMT8AqX7om3dMERK8lb5kmkyT4t7DkXh famWNaQZy7KA7PtuONPJOSgghCjO/w2q6OytzfBnspqIaKeuSJLZINqf83gZQUP4OItu fV4gnDNYA8H2zuNT1pNHYi0nE3tPY5LlGBfOlHwnmcFxud4OYL8cXFoeh07J1xlKL9Gt acDC/mf2F1TznssOyZj7XiRLB+O7D6AdvP3RbX9wSDsUbdqFOV0Fe8F3OhgGyT6BsXcv V/JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MoiMO41f; 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 w17si4628198edu.267.2019.11.27.13.44.56; Wed, 27 Nov 2019 13:45:19 -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=MoiMO41f; 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 S1728845AbfK0Um1 (ORCPT + 99 others); Wed, 27 Nov 2019 15:42:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:48652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729319AbfK0UmY (ORCPT ); Wed, 27 Nov 2019 15:42:24 -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 089D421783; Wed, 27 Nov 2019 20:42:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574887343; bh=QTntiOm27ELfX+4pHEMJoOCTT0p1VFvY5sE0aEjOdi0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MoiMO41fOt+S2hMGehRuc5J6zIUAFIGDEKjqg11ATGukbff5D5mM0BaxmMLvl3DnU j83RKmxBeMF60pz9dBj7Pc5QivZkCDprjaLDzNLjgJnqPLg2A1/MjMpevX/1buihHQ sYNzmx1u56MBZLFElKUjnEbUndNBmMqHFW7whKFo= 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.9 075/151] hfsplus: fix return value of hfsplus_get_block() Date: Wed, 27 Nov 2019 21:30:58 +0100 Message-Id: <20191127203035.132076789@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203000.773542911@linuxfoundation.org> References: <20191127203000.773542911@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 ce0b8f8374081..d93c051559cb8 100644 --- a/fs/hfsplus/extents.c +++ b/fs/hfsplus/extents.c @@ -236,7 +236,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