From patchwork Tue May 27 12:28:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 352908 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9EAF3140098 for ; Tue, 27 May 2014 22:36:26 +1000 (EST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WpGax-0001xB-Kl; Tue, 27 May 2014 12:35:07 +0000 Received: from mga14.intel.com ([192.55.52.115]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WpGav-0000rg-Tz for linux-mtd@lists.infradead.org; Tue, 27 May 2014 12:35:06 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 27 May 2014 05:24:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.98,918,1392192000"; d="scan'208";a="538112585" Received: from linux.jf.intel.com (HELO linux.intel.com) ([10.23.219.25]) by fmsmga001.fm.intel.com with ESMTP; 27 May 2014 05:28:23 -0700 Received: from [10.237.72.81] (sauron.fi.intel.com [10.237.72.81]) by linux.intel.com (Postfix) with ESMTP id 8412F6A4087; Tue, 27 May 2014 05:27:57 -0700 (PDT) Message-ID: <1401193701.1304.135.camel@sauron.fi.intel.com> Subject: Re: [PATCH] ubifs: add missing ui pointer in debugging code From: Artem Bityutskiy To: hujianyang Date: Tue, 27 May 2014 15:28:21 +0300 In-Reply-To: <53731C00.1020203@huawei.com> References: <20140513202750.GA27516@earthship.olsr.leipzig.freifunk.net> <53731C00.1020203@huawei.com> X-Mailer: Evolution 3.10.4 (3.10.4-2.fc20) Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140527_053506_018585_1821F434 X-CRM114-Status: GOOD ( 18.06 ) X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (dedekind1[at]gmail.com) 0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is CUSTOM_MED 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (dedekind1[at]gmail.com) 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 1.2 NML_ADSP_CUSTOM_MED ADSP custom_med hit, and not from a mailing list Cc: linux-mtd , Daniel Golle X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: dedekind1@gmail.com List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org On Wed, 2014-05-14 at 15:32 +0800, hujianyang wrote: > On 2014/5/14 4:27, Daniel Golle wrote: > > If UBIFS_DEBUG is defined an additional assertion of the ui_lock > > spinlock in do_writepage cannot compile because the ui pointer has not > > been previously declared. > > > > Fix this by declaring and initializing the ui pointer in case > > UBIFS_DEBUG is defined. > > > > Signed-off-by: Daniel Golle > > --- > > fs/ubifs/file.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c > > index 4f34dba..e13ec5e 100644 > > --- a/fs/ubifs/file.c > > +++ b/fs/ubifs/file.c > > @@ -903,6 +903,7 @@ static int do_writepage(struct page *page, int len) > > struct ubifs_info *c = inode->i_sb->s_fs_info; > > > > #ifdef UBIFS_DEBUG > > + struct ubifs_inode *ui = ubifs_inode(inode); > > spin_lock(&ui->ui_lock); > > ubifs_assert(page->index <= ui->synced_i_size << PAGE_CACHE_SIZE); > > I think here should be: > ubifs_assert(page->index <= ui->synced_i_size >> PAGE_CACHE_SHIFT); I think you are right, thanks. I've just applied this patch: Author: Artem Bityutskiy Date: Tue May 27 15:24:39 2014 +0300 UBIFS: fix debugging check The debugging check which verifies that we never write outside of the file length was incorrect, since it was multiplying file length by the page size, instead of dividing. Fix this. Spotted-by: hujianyang Signed-off-by: Artem Bityutskiy diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index 727506b..2767ffb 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c @@ -905,7 +905,7 @@ static int do_writepage(struct page *page, int len) #ifdef UBIFS_DEBUG struct ubifs_inode *ui = ubifs_inode(inode); spin_lock(&ui->ui_lock); - ubifs_assert(page->index <= ui->synced_i_size << PAGE_CACHE_SIZE); + ubifs_assert(page->index <= ui->synced_i_size >> PAGE_CACHE_SIZE); spin_unlock(&ui->ui_lock); #endif