Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5984689ybc; Wed, 27 Nov 2019 12:54:59 -0800 (PST) X-Google-Smtp-Source: APXvYqx+XGrm6PQ6JjnJnQGuRuFt3MCr1H7BabV0F+bd2k/Zcu/GykNfqOw6qjibKR3jlFrsSCwd X-Received: by 2002:a50:8ada:: with SMTP id k26mr2898185edk.100.1574888098957; Wed, 27 Nov 2019 12:54:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888098; cv=none; d=google.com; s=arc-20160816; b=AvlYegzCzZ8y+OZtZf9vg2kyhIOwTF3kpr2ClXCbZBlz4ZibxYo00qJRfpJdTjpx8p +d19I57jQk6+dX/zG2mWYpnBTiU7pvR65LknO87UuQ0hMOxU3/Xoj0jSePtAoutLdW68 c1kYdn8KT9SCozbqzIo9gObcGrvhOH98oGCEOTnPJ+3TFY+JvCmgF8Mwr21RdvBt0E6Q rFhNmeuNpujCgEfCJQkAbmyQeAntUikNIwVT15M+zmEgAv04hCFl4/WUh1WcAP6uUM8Z 0BainWUsbBDVFxMouTnJWHMpmlC9mVK3aGgaXzLFsmw/IH3iQc3Mv1lZ44SGK7htbYeb h4Fw== 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=qkG6ZwHSfN50+WQUUMLE6FJBkLw2ZK6OBjG/pxHyb9miEwOCuHJRuN4/jRj5oW8nf9 XqRitFROy+0T3DJZ4ZsMRBzJm0okEAohq5cs2Qn3dD8ARN4C8G6fYznV8MiV5vsy2vc6 hDrNGnn6z0jn1/UagNIrNLQn8hXfTjsJ7MoClrRJ8IiHHQGf4j6IOgW8pxsVny1nLqfA Q9Rug5pzh3VDA5F+kaAd3ht5m+nN0RC3a1f+PfCmoyQGzxGBvrb2cKs6o3L70x+mEFr6 Egs4KesTVcZh3rwIFsMXu0SO/qkY5LoQORGCKMixx2DZxioJITbxXNrHR2Xou8rtP+Oo mDMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KBzyh5BG; 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 p20si10761236ejn.273.2019.11.27.12.54.35; Wed, 27 Nov 2019 12:54:58 -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=KBzyh5BG; 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 S1730384AbfK0Uuo (ORCPT + 99 others); Wed, 27 Nov 2019 15:50:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:36750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730378AbfK0Uuj (ORCPT ); Wed, 27 Nov 2019 15:50:39 -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 C0B492184C; Wed, 27 Nov 2019 20:50:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574887839; bh=VNgWXYD8e+4U8yiObGoH66hb1GrtXm1uHaPUEKGL4xg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KBzyh5BGayQxBvaxHkiJAwtXKp9/1DjyJlMHn/EvpCRxgLfzAbRnfCjlXWPK7m6dz FZMElM7R751PnW4QQtxkdQzZ5pmWjOyh9l+IM0/s7oBzYEtym/QXuVLwC2jHEWOWHe SrLzW2LvShWE8a9AHzlP6WWSeAP3n/1LCK6Scw74= 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.14 114/211] hfs: fix return value of hfs_get_block() Date: Wed, 27 Nov 2019 21:30:47 +0100 Message-Id: <20191127203104.767292820@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203049.431810767@linuxfoundation.org> References: <20191127203049.431810767@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