From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Chinner Subject: Re: should bdi_init() initialize congested_fn? Date: Fri, 14 Oct 2011 10:12:46 +1100 Message-ID: <20111013231246.GQ3159@dastard> References: <4E96FFDD.5030905@itwm.fraunhofer.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "linux-fsdevel@vger.kernel.org" , Wu Fengguang To: Bernd Schubert Return-path: Received: from ipmail07.adl2.internode.on.net ([150.101.137.131]:23743 "EHLO ipmail07.adl2.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755428Ab1JMXMu (ORCPT ); Thu, 13 Oct 2011 19:12:50 -0400 Content-Disposition: inline In-Reply-To: <4E96FFDD.5030905@itwm.fraunhofer.de> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, Oct 13, 2011 at 05:12:29PM +0200, Bernd Schubert wrote: > Hello, > > while testing FhGFS I got a stack trace that seems to point out that > bdi_congested() tries to call an uninitialized bdi->congested_fn(). Right. bdi_init() assumes you've zero'd the structure before calling - it doesn't initialise any fields have a zero value. > So I checked where ->congested_fn() is initialized - with exception > of btrfs I do not find a file system that does that at all. the bdi congestion function is filled out by the underlying block device when the block device is initialised. Most filesystems get their bdi from the underlying device when they are mounted. See mount_bdev/set_bdev_super. btrfs is a special case. You'd do best to ignore the games btrfs plays while trying to understand how the generic infrastructure works. ;) > But then > bdi_init(), which is called by most file systems for initialization > also does *not* initialize it. So either I'm missing something, or > almost all bdi users have a bug? bdi_init() is only used by filesystems that done not operate directly on a block device with that a bdi can be taken from. e.g. filesystems without a backing store (ramfs, /proc, /sys, etc)Da, or have special needs (e.g. ubifs). They are all ensuring that the unused fields of the bdi are zero before calling bdi_init(). Cheers, Dave. -- Dave Chinner david@fromorbit.com