From owner-freebsd-fs@FreeBSD.ORG Wed Feb 23 14:02:46 2011 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B6E9C106566C for ; Wed, 23 Feb 2011 14:02:46 +0000 (UTC) (envelope-from gnehzuil@gmail.com) Received: from mail-pz0-f54.google.com (mail-pz0-f54.google.com [209.85.210.54]) by mx1.freebsd.org (Postfix) with ESMTP id 87A3A8FC18 for ; Wed, 23 Feb 2011 14:02:46 +0000 (UTC) Received: by pzk32 with SMTP id 32so535829pzk.13 for ; Wed, 23 Feb 2011 06:02:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=fTvUWDpzDE5VUEXIanIqJqkfkvIbMtlzDpJNV+z8mgE=; b=kFMayIhQt1YIIQdc88P1U+xSVy/6JFiCQ4hOtITsUeIer9Wv0GqVGT5zV3he2gUPJN CDRW9bF8uhO8STOIKKx3DAC3J28jEaYjIeuh9pscDC1qhtYrZjmVGaR0HV9C2WDPehu5 wBahO3BGHX7cTe2ucTZSQlH9WJI8Gua+dFrF0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=TKcVQtRpMXVwtCGMTFXKQv8NsCk5Qnr889kucQKCG3TPvKWUiAK5cNenp/YqAl7q5U ywJW+aj91IrxJOeWJ1Gw3mICG3zid+OmFZrho9GtFpgOPqxeZbcdVXdSlM9mQldKu/Q3 3nYZDFmIgn9ML7h3hwb8+VF1T+0oQQaT49idA= Received: by 10.142.178.7 with SMTP id a7mr3198965wff.386.1298468014597; Wed, 23 Feb 2011 05:33:34 -0800 (PST) Received: from [192.168.1.157] ([166.111.68.197]) by mx.google.com with ESMTPS id z8sm5318886wfj.13.2011.02.23.05.33.32 (version=SSLv3 cipher=OTHER); Wed, 23 Feb 2011 05:33:33 -0800 (PST) Message-ID: <4D650CA5.4030603@gmail.com> Date: Wed, 23 Feb 2011 21:33:25 +0800 From: gnehzuil User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 MIME-Version: 1.0 To: John Baldwin References: <201102230811.32864.jhb@freebsd.org> In-Reply-To: <201102230811.32864.jhb@freebsd.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-fs@freebsd.org Subject: Re: Simple ext2fs allocation routine cleanups X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Feb 2011 14:02:46 -0000 Hi John, I can try to do some tests. :-) Best regards, lz On 02/23/2011 09:11 PM, John Baldwin wrote: > I have some small changes to ext2fs to use ffs() to simplify some of the > allocation routines. The changes compile, but I have not had time to generate > a test ext2fs file system to run-test them. If someone has some spare cycles > to setup a test file system and try them out I would appreciate it. Otherwise > I will get to it eventually. Given that this hasn't been run-tested yet, I > would not recommend using it for a production ext2fs since it may completely > trash the filesystem. > > Index: ext2_alloc.c > =================================================================== > --- ext2_alloc.c (revision 218951) > +++ ext2_alloc.c (working copy) > @@ -815,16 +815,12 @@ > } > } > i = start + len - loc; > - map = ibp[i]; > - ipref = i * NBBY; > - for (i = 1; i< (1<< NBBY); i<<= 1, ipref++) { > - if ((map& i) == 0) { > - goto gotit; > - } > + map = ibp[i] ^ 0xff; > + if (map == 0) { > + printf("fs = %s\n", fs->e2fs_fsmnt); > + panic("ext2fs_nodealloccg: block not in map"); > } > - printf("fs = %s\n", fs->e2fs_fsmnt); > - panic("ext2fs_nodealloccg: block not in map"); > - /* NOTREACHED */ > + ipref = i * NBBY + ffs(map); > gotit: > setbit(ibp, ipref); > EXT2_LOCK(ump); > @@ -952,7 +948,6 @@ > static daddr_t > ext2_mapsearch(struct m_ext2fs *fs, char *bbp, daddr_t bpref) > { > - daddr_t bno; > int start, len, loc, i, map; > > /* > @@ -977,15 +972,12 @@ > } > } > i = start + len - loc; > - map = bbp[i]; > - bno = i * NBBY; > - for (i = 1; i< (1<< NBBY); i<<= 1, bno++) { > - if ((map& i) == 0) > - return (bno); > + map = bbp[i] ^ 0xff; > + if (map == 0) { > + printf("fs = %s\n", fs->e2fs_fsmnt); > + panic("ext2fs_mapsearch: block not in map"); > } > - printf("fs = %s\n", fs->e2fs_fsmnt); > - panic("ext2fs_mapsearch: block not in map"); > - /* NOTREACHED */ > + return (i * NBBY + ffs(map)); > } > > /* >