Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp737455ybc; Sat, 16 Nov 2019 07:50:11 -0800 (PST) X-Google-Smtp-Source: APXvYqxoJDji0nbD4o23JUFWzqMH/XatPAC9bcHOgu3dlBo4JV3ukirp2Hamf/lUi2U+re1AU+BN X-Received: by 2002:a17:906:3ec2:: with SMTP id d2mr10990671ejj.251.1573919411022; Sat, 16 Nov 2019 07:50:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573919411; cv=none; d=google.com; s=arc-20160816; b=wHcCM12MVKaTkDKsLe5zZ8T3OJu+1M4IQ5j6ggLlVv/1kKHjdoGA8sGklCbgf67Ks1 vXOCYEzez1rDEN3e9WghgcMFPvECWpR0TXNWlTLEdF49GUvc/wLYhRGGn7DCuwfq/1L6 MA0RMYa4vtAlc583v9TVUUU5C1V6PNOp0V740rU5t0IUERzC7XP2chM7/wn8eGGSO3Lq xtx76IvUYTs1g/uGZu+N0uyzz9b5QiKHvmffEyjSV+GLrFdvK3xexbXwRAt+rBVNtkic DaRu3Ha5CMQYXWirQzv2ejLRfg/Yr8eQDe2p4ROSGnq/dqkfj1fN1CEmnhxj8rsjW1eQ kSBw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zodnBUiPQ1/0VMJYqA0CR2ZZU4a/wd9Klxh/E6e55Po=; b=ZYhjnJF2HjrvJO/DYTfQVsah61xpLurnrRTGfjhUoAIDwuYm/yszCPk2IiY8skJPth HeB107yaieDXj1DXPmo0qbauPZM3bjnAl50NxNY/Uu/f3K9c7FNQThs8t5NroAa5o/pJ Em6MMA6IlORsnzZ+q+F9fo8g4M5XhPIcH7Eh0hz2DFzymmxobMROADB67nG7N1wMjRsp J8dA6scRnvhELiTE7mI2lh+ogIQQXeGb2fsOUuvbbXDtTv+dGsFKQU7miEOndtXTmMZU +R98sltn5cPrjJG9+cozIfIhmQKRR6sH7910Q9Y3RuaIK/XDUYosivRLZqAD6ADMKZ1c aDvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yocb3d2P; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c24si7655929ejs.366.2019.11.16.07.49.46; Sat, 16 Nov 2019 07:50:11 -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=yocb3d2P; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729172AbfKPPp0 (ORCPT + 99 others); Sat, 16 Nov 2019 10:45:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:50870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729158AbfKPPpY (ORCPT ); Sat, 16 Nov 2019 10:45:24 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1955320803; Sat, 16 Nov 2019 15:45:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573919123; bh=2Kag3n177V4s373POaAsHKFOMafTS0FUlJuj+35TxYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yocb3d2PBr0mFH0JRr1OVXwBcXU390JlN2doximdqdzaC4QkeiVQMtbl4pnAvXJUw kbIfmppy05UcqCiqmgwRYP8pUBlPaNPFPGXnZQk0RCZha4XR31W1cAgCN+UDB46gmQ 8Li6NdnQWhsNo2Lh2Hybxlv6zK2sORE8JI3IPgb4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?Ernesto=20A=2E=20Fern=C3=A1ndez?= , Vyacheslav Dubeyko , Andrew Morton , Linus Torvalds , Sasha Levin , linux-fsdevel@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 157/237] hfsplus: fix return value of hfsplus_get_block() Date: Sat, 16 Nov 2019 10:39:52 -0500 Message-Id: <20191116154113.7417-157-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore 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