From mboxrd@z Thu Jan 1 00:00:00 1970 From: Francis Moreau Subject: Question regarding concurrent accesses through block device and fs Date: Fri, 13 Feb 2009 21:25:39 +0100 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: linux-fsdevel@vger.kernel.org Return-path: Received: from mail-fx0-f20.google.com ([209.85.220.20]:56356 "EHLO mail-fx0-f20.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752863AbZBMUZp (ORCPT ); Fri, 13 Feb 2009 15:25:45 -0500 Received: by fxm13 with SMTP id 13so3942116fxm.13 for ; Fri, 13 Feb 2009 12:25:41 -0800 (PST) Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Hello, I have a question regarding the page cache/buffer heads behaviour when some blocks are accessed through a regular file and through the block dev hosting this file. First it looks like when accessing some blocks through a block device, the same mechanisms are used as when reading a file through a file system: the page cache is used. That means that a block could be mapped by several buffers at the same time. I don't see any issues to this but looking at __block_prepare_write(), it seems that we don't want this to happen since it does: [...] if (buffer_new(bh)) { unmap_underlying_metadata(bh->b_bdev, bh->b_blocknr); [...] } where unmap_underlying_metadata() unmaps the blockdev buffer which maps b_blocknr block. Also this call seems unneeded if __block_prepare_write() is called when writing through the block dev since we already know that the buffer doesn't exist (we are here to create it). Could anybody why this is needed at all ? Also I'm wondering if the block is written first through the file system (but the data are still in the page cache, not commited to the disk) and another process try to read the same block through the block device. Does it get stale data ? thanks -- Francis