From patchwork Fri Dec 26 04:14:11 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 15666 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.176.167]) by ozlabs.org (Postfix) with ESMTP id E0E5ADDDCA for ; Fri, 26 Dec 2008 15:14:26 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752711AbYLZEOQ (ORCPT ); Thu, 25 Dec 2008 23:14:16 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752712AbYLZEOQ (ORCPT ); Thu, 25 Dec 2008 23:14:16 -0500 Received: from BISCAYNE-ONE-STATION.MIT.EDU ([18.7.7.80]:53692 "EHLO biscayne-one-station.mit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752711AbYLZEOP (ORCPT ); Thu, 25 Dec 2008 23:14:15 -0500 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by biscayne-one-station.mit.edu (8.13.6/8.9.2) with ESMTP id mBQ4ECPf007421; Thu, 25 Dec 2008 23:14:12 -0500 (EST) Received: from closure.thunk.org (c-98-216-98-217.hsd1.ma.comcast.net [98.216.98.217]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id mBQ4EBxD023903 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 25 Dec 2008 23:14:11 -0500 (EST) Received: from tytso by closure.thunk.org with local (Exim 4.69) (envelope-from ) id 1LG45T-0002lT-6S; Thu, 25 Dec 2008 23:14:11 -0500 Date: Thu, 25 Dec 2008 23:14:11 -0500 From: Theodore Tso To: Paul Collins Cc: linux-ext4@vger.kernel.org Subject: Re: (resend) extent header problems following shrink with resize2fs Message-ID: <20081226041411.GM9871@mit.edu> References: <87abanbfvo.fsf@burly.wgtn.ondioline.org> <20081223061833.GQ23723@mit.edu> <877i5ozprb.fsf@burly.wgtn.ondioline.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <877i5ozprb.fsf@burly.wgtn.ondioline.org> User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Scanned-By: MIMEDefang 2.42 X-Spam-Flag: NO X-Spam-Score: 0.00 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu, Dec 25, 2008 at 08:18:48PM +1300, Paul Collins wrote: > Theodore Tso writes: > > Yeah, resize2fs needs to be fixed to handle extents correctly. At the > > moment it can screw them up pretty badly. > > In the meantime, perhaps something like the patch below is appropriate? Actually, I think the following patch should fix things up nicely. I need to create a test case so I can be sure this fixes the problem, but I think this should address the root cause of theproblem you reported. - Ted --- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/resize/resize2fs.c b/resize/resize2fs.c index abe05f5..65398a6 100644 --- a/resize/resize2fs.c +++ b/resize/resize2fs.c @@ -1188,6 +1188,16 @@ static int process_block(ext2_filsys fs, blk_t *block_nr, return ret; } +static int process_block_ind(ext2_filsys fs, blk_t *block_nr, + e2_blkcnt_t blockcnt, blk_t ref_block, + int ref_offset, void *priv_data) +{ + if (blockcnt >= 0) + return 0; + return process_block(fs, block_nr, blockcnt, ref_block, ref_offset, + priv_data); +} + /* * Progress callback */ @@ -1302,6 +1312,18 @@ static errcode_t inode_scan_and_fix(ext2_resize_t rfs) if (ext2fs_inode_has_valid_blocks(inode) && (rfs->bmap || pb.is_dir)) { pb.ino = ino; + if (inode->i_flags & EXT4_EXTENTS_FL) { + /* + * With extent-based files, we have + * to translate all of the interior + * node blocks first. + */ + retval = ext2fs_block_iterate2(rfs->old_fs, + ino, 0, block_buf, + process_block_ind, &pb); + if (retval) + goto errout; + } retval = ext2fs_block_iterate2(rfs->old_fs, ino, 0, block_buf, process_block, &pb);