From patchwork Mon Mar 23 02:53:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Antonov X-Patchwork-Id: 6069021 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F1B79BF90F for ; Mon, 23 Mar 2015 02:57:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 122232011B for ; Mon, 23 Mar 2015 02:57:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A96C1200DF for ; Mon, 23 Mar 2015 02:57:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752062AbbCWC5u (ORCPT ); Sun, 22 Mar 2015 22:57:50 -0400 Received: from mail-wg0-f45.google.com ([74.125.82.45]:33321 "EHLO mail-wg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752052AbbCWC5r (ORCPT ); Sun, 22 Mar 2015 22:57:47 -0400 Received: by wgbcc7 with SMTP id cc7so135060296wgb.0 for ; Sun, 22 Mar 2015 19:57:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=bvKhmOOIlJ8Qlx8ZekLXsclPCu9n8CzLKe8QNZj4bkI=; b=vjofchGFjW3jZ2Zf2wwiBveFt7u6zPkBSEBFso9wpQu7CK2rLHMniIYMXizpBO04JF XAkE3gcCZTy+tAC4xeMby/9/KGLiCmAOBEG/ZWQdXmeC27Bcm8V70BQ5ox/NzACAtehG AYIkmAQImOxLH1blFe4MC3fg62Q5wFGNlDIp/TD+m0oHqaoVH74wlOZ/tUYgfct++UtJ VnWmBomWLPxG2c9/cgYwyxebv3q5w/E1Bas139wgwJJ97TurAS8Dcoy5wCkCJoGU0urM GuDJs9YgIDQPs5Ek3br+kky0qfA8nayKcCZ//wjPsur8YAH76rERot3xD0hiLrnAqEjx rHjQ== X-Received: by 10.194.89.195 with SMTP id bq3mr158386326wjb.123.1427079465977; Sun, 22 Mar 2015 19:57:45 -0700 (PDT) Received: from localhost.localdomain (HSI-KBW-046-005-223-100.hsi8.kabel-badenwuerttemberg.de. [46.5.223.100]) by mx.google.com with ESMTPSA id hl15sm9138013wib.3.2015.03.22.19.57.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 22 Mar 2015 19:57:44 -0700 (PDT) From: Sergei Antonov To: linux-fsdevel@vger.kernel.org Cc: Andrew Morton , Vyacheslav Dubeyko , Hin-Tak Leung , Anton Altaparmakov , Al Viro , Christoph Hellwig , Sougata Santra , Sergei Antonov Subject: [PATCH] hfsplus: fix expand when not enough available space Date: Mon, 23 Mar 2015 03:53:20 +0100 Message-Id: <1427079200-1041-1-git-send-email-saproj@gmail.com> X-Mailer: git-send-email 2.3.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP HFS+ does not support file size > allocated size, therefore the following command should fail: truncate --size= However, it ends successfully. The driver returns success despite having been unable to allocate the requested space for the file. Also filesystem check finds an error: Checking catalog file. Incorrect size for file test_file (It should be 469094400 instead of 1000000000) Add a piece of code analogous to code in the fat driver. Now a proper error is returned and filesystem remains consistent. Cc: Andrew Morton Cc: Vyacheslav Dubeyko Cc: Hin-Tak Leung Cc: Anton Altaparmakov Cc: Al Viro Cc: Christoph Hellwig Cc: Sougata Santra Signed-off-by: Sergei Antonov --- fs/hfsplus/inode.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c index 0cf786f..7691cc1 100644 --- a/fs/hfsplus/inode.c +++ b/fs/hfsplus/inode.c @@ -254,6 +254,12 @@ static int hfsplus_setattr(struct dentry *dentry, struct iattr *attr) if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size != i_size_read(inode)) { inode_dio_wait(inode); + if (attr->ia_size > inode->i_size) { + error = generic_cont_expand_simple(inode, + attr->ia_size); + if (error) + return error; + } truncate_setsize(inode, attr->ia_size); hfsplus_file_truncate(inode); }