From patchwork Wed Feb 22 01:27:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Miller X-Patchwork-Id: 142388 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 548C9B6EEE for ; Wed, 22 Feb 2012 12:27:41 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753373Ab2BVB1k (ORCPT ); Tue, 21 Feb 2012 20:27:40 -0500 Received: from shards.monkeyblade.net ([198.137.202.13]:34404 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753016Ab2BVB1k (ORCPT ); Tue, 21 Feb 2012 20:27:40 -0500 Received: from localhost (nat-pool-rdu.redhat.com [66.187.233.202]) (authenticated bits=0) by shards.monkeyblade.net (8.14.4/8.14.4) with ESMTP id q1M1RYVT026015 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO); Tue, 21 Feb 2012 17:27:37 -0800 Date: Tue, 21 Feb 2012 20:27:33 -0500 (EST) Message-Id: <20120221.202733.1840554502153600636.davem@davemloft.net> To: jurij@wooyd.org Cc: mroos@linux.ee, sparclinux@vger.kernel.org Subject: Re: silo trouble with ext3 From: David Miller In-Reply-To: <20120221.183310.1245115002013195062.davem@davemloft.net> References: <20120221225108.GA4293@wooyd.org> <20120221.181007.225442485550765553.davem@davemloft.net> <20120221.183310.1245115002013195062.davem@davemloft.net> X-Mailer: Mew version 6.4 on Emacs 23.3 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (shards.monkeyblade.net [198.137.202.13]); Tue, 21 Feb 2012 17:27:37 -0800 (PST) Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org From: David Miller Date: Tue, 21 Feb 2012 18:33:10 -0500 (EST) > From: David Miller > Date: Tue, 21 Feb 2012 18:10:07 -0500 (EST) > >> For example, I just found a bug with symlink handling in path >> traversal fixed by the following patch. So if there are symlinks >> involved in Meelis's setup that would be the cause rather than not >> specifically using ext2 for the boot partition. >> >> -------------------- >> ext2: Fix symlink being overwritten. > > Ignore me, there is no bug. All callers specifically use a special > on-stack inode buffer to avoid this problem. Ok, while waiting for the debug dump from Meelis I think I found the problem. With my test harness I reproduced a case similar to what Meelis saw but it has nothing to do with ext3'ness or anything like that. The block group descriptors were having their location miscalculated. It only worked for the first block of group descriptors. So if an inode is outside of the first several block groups, things don't work. I guess for most /boot partitions, which are relatively small, most if not all of the files fit into the working range. Jurij, can you possibly build a test package for Meelis to see if this fixes the reported bug? It's pushed out to the silo GIT repo as well if that helps any. -------------------- ext2: Calculate group descriptor location properly. Calculate the block and offset correctly for group descriptors. The existing code would work properly only for the first block of descriptors. Signed-off-by: David S. Miller --- second/fs/ext2.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/second/fs/ext2.c b/second/fs/ext2.c index 710695a..7eb665f 100644 --- a/second/fs/ext2.c +++ b/second/fs/ext2.c @@ -57,6 +57,8 @@ struct silo_ext2_state { __u32 block_size; __u32 addr_per_block; __u32 addr_per_block_bits; + __u32 desc_per_block; + __u32 desc_per_block_bits; }; static struct silo_ext2_state *sstate; @@ -285,8 +287,8 @@ static void read_group(struct silo_ext2_state *s, __u32 grp_no, __u32 first = ext2_to_cpu_32(s->super->s_first_data_block); __u32 blk, offset; - blk = first + 1; - offset = grp_no * sizeof(*grp); + blk = first + 1 + (grp_no >> s->desc_per_block_bits); + offset = (grp_no & (s->desc_per_block - 1)) * sizeof(*grp); read_data(s, blk, offset, sizeof(*grp), grp); } @@ -371,6 +373,8 @@ static int open_ext2(char *device) s->addr_per_block = s->block_size / sizeof(__u32); s->addr_per_block_bits = calc_ilog2(s->addr_per_block); + s->desc_per_block = s->block_size / sizeof(struct ext2_group_desc); + s->desc_per_block_bits = calc_ilog2(s->desc_per_block); s->scratch_block[0] = malloc(s->block_size * 4); if (!s->scratch_block[0]) {