Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp737542ybc; Sat, 16 Nov 2019 07:50:16 -0800 (PST) X-Google-Smtp-Source: APXvYqybBqCtnGwjV9RyHnIFutUF/KMoNwkDUQlRRoesMZtMRoXvRmPsg5+0AlFes17eNspW8jCr X-Received: by 2002:a17:906:4910:: with SMTP id b16mr10591580ejq.133.1573919416698; Sat, 16 Nov 2019 07:50:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573919416; cv=none; d=google.com; s=arc-20160816; b=IyDNVpMcbSss3WGyxHNS3CPPSOHMVZTC18WvUlW4HJhzMrFZlsVPEyuuIr7Aed8jy/ jMRfgeoRWkW+zDfu3GChjS7f85RV3G6JsrB33IYMTfz6zpIZDJQkcVLxJj7MMtcoy3/V u4/i8yeWVCZV2y/3rleCLR652EbcLL/oSDJp158cfFNXWnllEGip4zKV6a5py0dCsfpA w90JUYI0kI/+U6ekqgsAVqCkUxS0bk0F4PaWJ4MtJ12REJSVWhW5pgz7i3cARydw5OAK bqt2Z63L3gfcljpou1jTpj++bAv0BDoknNn8U5T/qt552mkaiUL/gVZKhICP03N0CJ30 mkvg== 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=KdV4sz5cNZeG0o/KaO3cno8R/Lzipfqkfnkg5wbREqQ=; b=ZEEo81fMPiMegVkaDcKaveZNHEFZZF6/dFSmO0m/pQEvagoJjw2NObpuLIRLh+Nw5R cl6DEkdmJSFdvXVWUfwYe2L7yxzptNSh8YXhL+Ue7hc4yv0KgdHzCLpqINmRT7EO7UpY FgR0gPgknuy81Iz/kpwn3nznNWR/beiJTk6iSrRJHmhC8CeB5le+tAZ9A/1RATiBMTLZ 4wgW9wN+1DJX+JgGLjH1udNMuPAkPR7W3yN8CNFet+pL+t1hr7YFedQPoVklxlaAh9ce bwz6tlILda0L+J1axpfHnqvQTNRmsxGnT4xW+Hb8zKCew8I2FqCUSw8N9/jcNM3haWvn ri4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TtLyAckF; 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 o19si7805381ejc.315.2019.11.16.07.49.52; Sat, 16 Nov 2019 07:50:16 -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=TtLyAckF; 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 S1729182AbfKPPpa (ORCPT + 99 others); Sat, 16 Nov 2019 10:45:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:50936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729173AbfKPPp0 (ORCPT ); Sat, 16 Nov 2019 10:45:26 -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 0195E20803; Sat, 16 Nov 2019 15:45:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573919126; bh=VNgWXYD8e+4U8yiObGoH66hb1GrtXm1uHaPUEKGL4xg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TtLyAckFlUUminmJcJzqsSPWiCA2aIekspgpnvl32XTT9hzdf+RrZBVrt0y99hhzW NvUhuEgrnqiBS9Q1PTLkvSQu6ROJCxvDos+NEmWY9PznVq569sKZmXAVrs6CBDL9EQ PqBgtmwHmLmieErESasAkVb5RLSmqflj5p4CVgWQ= 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 158/237] hfs: fix return value of hfs_get_block() Date: Sat, 16 Nov 2019 10:39:53 -0500 Message-Id: <20191116154113.7417-158-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 1267a07be5ebbff2d2739290f3d043ae137c15b4 ] 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. Link: http://lkml.kernel.org/r/4538ab8c35ea37338490525f0f24cbc37227528c.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/hfs/extent.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c index 0c638c6121526..5f1ff97a3b987 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); -- 2.20.1