From patchwork Thu Feb 9 21:28:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 726335 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vKB6b075Bz9s7D for ; Fri, 10 Feb 2017 08:29:27 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="OMnveWC9"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=ymP93q2wybdDA++lD1nV1D5iHg9y1BlcV7nRxZfeK/s=; b=OMn veWC96Yzf4X6fmyvI4DFtuKiOQF0i5aO/P2/GbIRQLPANZxO0QYpmCBp2wsW95mdiWAUBsJjlQFLS KEB2LTgVVz4Z+3WCv7EKm0gfx8GoM6nfG5M7u9YcATaWvSKd3Y9jEsC6tZn5tP2CRK+BYGhfCY9DY 4J+iGbP9sylVaNBbJsDqEebikXAm2SkQuJ7fAmS/hyoNrnuFI9ypgMCQxV87luQs/tvjZo3Bp6w0A QkEOpcmP+A/r0J+9BRGKIaSooAzeC9qOybvOZAWW+fHLiis9aNrVnJdd/4YhxK1s7QJU4L5DCvYaQ IW6DWrjS/N2/eqX4SucOhS5gvqxwY8A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cbwHM-0006RF-LZ; Thu, 09 Feb 2017 21:29:24 +0000 Received: from mail.sigma-star.at ([95.130.255.111]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cbwH3-0006As-SZ for linux-mtd@lists.infradead.org; Thu, 09 Feb 2017 21:29:09 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.sigma-star.at (Postfix) with ESMTP id 08A6D24E0005; Thu, 9 Feb 2017 22:28:42 +0100 (CET) Received: from spankyham.sigmapriv.at (unknown [82.150.214.13]) by mail.sigma-star.at (Postfix) with ESMTPSA id 676BC24E0001; Thu, 9 Feb 2017 22:28:41 +0100 (CET) From: Richard Weinberger To: linux-mtd@lists.infradead.org Subject: [PATCH 1/4] ubifs: Fix data node size for truncating uncompressed nodes Date: Thu, 9 Feb 2017 22:28:34 +0100 Message-Id: <20170209212837.14197-1-richard@nod.at> X-Mailer: git-send-email 2.10.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170209_132906_123238_9F2DE185 X-CRM114-Status: GOOD ( 12.70 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Weinberger , david.oberhollenzer@sigma-star.at, linux-kernel@vger.kernel.org, dedekind1@gmail.com MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: David Oberhollenzer Currently, the function truncate_data_node only updates the destination data node size if compression is used. For uncompressed nodes, the old length is incorrectly retained. This patch makes sure that the length is correctly set when compression is disabled. Signed-off-by: David Oberhollenzer Signed-off-by: Richard Weinberger --- fs/ubifs/journal.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c index 294519b98874..f3b620cbdda4 100644 --- a/fs/ubifs/journal.c +++ b/fs/ubifs/journal.c @@ -1298,7 +1298,9 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in goto out; } - if (compr_type != UBIFS_COMPR_NONE) { + if (compr_type == UBIFS_COMPR_NONE) { + out_len = *new_len; + } else { err = ubifs_decompress(c, &dn->data, dlen, buf, &out_len, compr_type); if (err) goto out;