Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5994197ybc; Wed, 27 Nov 2019 13:04:55 -0800 (PST) X-Google-Smtp-Source: APXvYqwYam7KbBImlnqRq9pIjNgMykJvPcaTEqtD7NW4e49fijF1yok3+Y0ieaqVklBVjwqwq/BT X-Received: by 2002:a05:6402:54a:: with SMTP id i10mr33709910edx.230.1574888695843; Wed, 27 Nov 2019 13:04:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888695; cv=none; d=google.com; s=arc-20160816; b=bJoH2C5jZbaU15EIzr+PYuah6Aw1tBJ1wUmP7al4WfZk1z/1wtOgKab6AdT1nISJOr GCU70v3T0+MFgKNWGZeQSJ5ACkXxh4pIeS4y9UntU274i3luG72ED2FXGiGSLHxovp1Q nVhLyG/6pO+NYkkwXYHS7NZHwrD67AggZd26KTEk+OFAeNCaehHyeJsl4qN6O6Lq28LK 7y44bst36FIPEN9ryk9pZuJCXXrLi/SKq/VDQzQZbXDLpT90QYtYcq3xfl1HpqQZkFT+ 2lhE3jSGyJ+JWUZTWfNIA+5sTY1xPbaGLgxqLR2fzu6QhGPthmXsiYavNw4KM62J/aJ1 e6uQ== 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=KdV4sz5cNZeG0o/KaO3cno8R/Lzipfqkfnkg5wbREqQ=; b=FT+Bc1qzvaOm/5AczxbYZHqWLUM/yinwgkN/fAOaU1YWP9Z5qW2KoXQSn7HJxM24B9 SAR/IlBqFZVCOqwcSAQg1ehKRDF/VM9l/uyrVuA3dkur6y+JkwuDfB0VW9rdLVVM4HKo wZiuf1whAr5F1TJHp8Myoi5Ekw4UZYPCdiYRTxhjdorbJpzT3NVZYTcI2TLnK4Zbr9rw XqrebQV8s36//u7nFMxc1WH6kv/A+wjy444PZN5DwTZLcoiZs+h4sAYrk8Dd5+beXrB8 iJiIoq5c5Jdv1GZiFAcnCnJ81R8F6kGUt/mdmRnAvtCVbDMfMCyA/BsjCxiIK7FC0bJA e41Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=07kHggHg; 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 w10si10636148eja.116.2019.11.27.13.04.20; Wed, 27 Nov 2019 13:04:55 -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=07kHggHg; 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 S1731899AbfK0VCa (ORCPT + 99 others); Wed, 27 Nov 2019 16:02:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:55178 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731038AbfK0VC2 (ORCPT ); Wed, 27 Nov 2019 16:02:28 -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 0143821770; Wed, 27 Nov 2019 21:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888547; bh=VNgWXYD8e+4U8yiObGoH66hb1GrtXm1uHaPUEKGL4xg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=07kHggHgsfOzoxd/NK6y5yNRhLRwRxsHGeLZl8+lD/DtZYxmHuJSlpNe0WWM7Tda5 p+By0jnS+Db+0w8p8E4rOHK0edFn+NxC+kkIkNMCdFdAx9XMKKXUXbcer+7EM+pObd k1c2Ro1jbIa/7gZQuczN4XK00QVQLRRtK6ehRAas= 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 175/306] hfs: fix return value of hfs_get_block() Date: Wed, 27 Nov 2019 21:30:25 +0100 Message-Id: <20191127203128.147157857@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 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