From owner-freebsd-questions@FreeBSD.ORG Sat Jul 27 15:02:14 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id D15F0EA for ; Sat, 27 Jul 2013 15:02:14 +0000 (UTC) (envelope-from frank2@fjl.co.uk) Received: from bs1.fjl.org.uk (bs1.fjl.org.uk [84.45.41.196]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 3244928F3 for ; Sat, 27 Jul 2013 15:02:13 +0000 (UTC) Received: from [192.168.1.35] (mux.fjl.org.uk [62.3.120.246]) (authenticated bits=0) by bs1.fjl.org.uk (8.14.4/8.14.4) with ESMTP id r6RF29WL033050 (version=TLSv1/SSLv3 cipher=DHE-DSS-CAMELLIA256-SHA bits=256 verify=NO) for ; Sat, 27 Jul 2013 16:02:10 +0100 (BST) (envelope-from frank2@fjl.co.uk) Message-ID: <51F3E0F1.3010401@fjl.co.uk> Date: Sat, 27 Jul 2013 16:02:09 +0100 From: Frank Leonhardt User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: freebsd-questions@freebsd.org Subject: Re: Delete a directory, crash the system References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Jul 2013 15:02:14 -0000 On 27/07/2013 13:58, David Noel wrote: >> Post the stack trace of the core and maybe someone can help you. > panic: ufs_dirrem: Bad link count 2 on parent > cpuid = 0 > KDB: stack backtrace: > #0 0xffffffff808680fe at kdb_backtrace+0x5e > #1 0xffffffff80832cb7 at panic+0x187 > #2 0xffffffff80a700e3 at ufs_rmdir+0x1c3 > #3 0xffffffff80b7d484 at VOP_RMDIR_APV+0x34 > #4 0xffffffff808ca32a at kern_rmdirat+0x21a > #5 0xffffffff80b17cf0 at amd64_syscall+0x450 > #6 0xffffffff80b03427 at Xfast_syscall+0xf7 > I'm taking a guess here - the effective link count when it came to removing the parent directory was only two and it should have been three or more. This gets sanity checked this before proceeding, and panics if it is not. Why an effective link count of three? We're talking about the parent of the directory you're trying to zap, right? There's the link to the directory from its parent, and the '.' link and the ".." link from the directory you're trying to remove. There may be more if it contains other directories, but there can't be less. Anyway - if you only had a link count of just two effective links at the start of the delete process it suggests that the link count was messed up - either a link never existed or its count was wrong. Should the kernel panic? Well it's a situation that can never happen - it could simply remove the directory and pretend everything was okay but guess it was decided it was likely to be a symptom of impending disaster. Other anomalies return an error. In over ten years with FreeBSD systems I can't say I've ever seen this "cannot happen" situation arise. I'd guess you had an interrupted (by power failure) inode operation at some time which caused the corruption. removing a directory is a PITA as it can lead to a race - a context swap could create a file it it mid-way through the process. Regards, Frank.