From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ingo Molnar Subject: Re: [PATCH 4/6] kill-the-BKL/reiserfs: release the write lock inside get_neighbors() Date: Fri, 1 May 2009 07:51:35 +0200 Message-ID: <20090501055135.GF5983@elte.hu> References: <1241145862-21700-1-git-send-email-fweisbec@gmail.com> <1241145862-21700-5-git-send-email-fweisbec@gmail.com> Mime-Version: 1.0 Return-path: Content-Disposition: inline In-Reply-To: <1241145862-21700-5-git-send-email-fweisbec@gmail.com> Sender: reiserfs-devel-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Frederic Weisbecker Cc: LKML , Jeff Mahoney , ReiserFS Development List , Chris Mason , Alexander Beregalov , Alessio Igor Bogani , Jonathan Corbet , Alexander Viro * Frederic Weisbecker wrote: > get_neighbors() is used to get the left and/or right blocks > against a given one in order to balance a tree. > > sb_bread() is used to read the buffer of these neighors blocks and > while it waits for this operation, it might sleep. > > The bkl was released at this point, and then we can also release > the write lock before calling sb_bread(). > > This is safe because if the filesystem is changed after this lock > release, the function returns REPEAT_SEARCH (aka SCHEDULE_OCCURRED > in the function header comments) in order to repeat the neighbhor > research. > > [ Impact: release the reiserfs write lock when it is not needed ] This should also be safe because under the BKL we _already_ dropped the lock when sb_bread() blocked (which it really would in the normal case). There's one special case to consider though: sb_read() maps to __bread() which can return without sleeping if the bh is already uptodate. So if the filesystem _knows_ that the bh is already uptodate and holds a reference to it (this is common pattern in filesystems), it can have a locking assumption on that. No such assumption seems to be present here though. Ingo