Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S274984AbTHLBtR (ORCPT ); Mon, 11 Aug 2003 21:49:17 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S274985AbTHLBtQ (ORCPT ); Mon, 11 Aug 2003 21:49:16 -0400 Received: from note.orchestra.cse.unsw.EDU.AU ([129.94.242.24]:12755 "HELO note.orchestra.cse.unsw.EDU.AU") by vger.kernel.org with SMTP id S274984AbTHLBtN (ORCPT ); Mon, 11 Aug 2003 21:49:13 -0400 From: Neil Brown To: Christoph Hellwig Date: Tue, 12 Aug 2003 11:48:28 +1000 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16184.18284.969212.342794@gargle.gargle.HOWL> Cc: Linus Torvalds , linux-kernel@vger.kernel.org Subject: Re: [PATCH] 2 of 2 - Allow O_EXCL on a block device to claim exclusive use. In-Reply-To: message from Christoph Hellwig on Monday August 11 References: <20030811082231.A20077@infradead.org> X-Mailer: VM 7.17 under Emacs 21.3.2 X-face: [Gw_3E*Gng}4rRrKRYotwlE?.2|**#s9D On Mon, Aug 11, 2003 at 12:35:57PM +1000, NeilBrown wrote: > > diff ./fs/block_dev.c~current~ ./fs/block_dev.c > > - return do_open(bdev, inode, filp); > > + res = do_open(bdev, inode, filp); > > + if (res) > > + return res; > > + > > + if (!(filp->f_flags & O_EXCL) ) > > + return 0; > > + > > + if (!(res = bd_claim(bdev, filp))) > > + return 0; > > + > > + blkdev_put(bdev, BDEV_FILE); > > + return res; > > Shouldn't you claim it before opening. Also what is the desired > behaviour when opening partitions vs whole device with O_EXCL? Good question. My first attempt at this did claim before openning. However that didn't work. Some aspects of the bdev that are needed for claiming are not initialised before it is first opened. In particular, bd_contains, gets set up by do_open. Also, other code uses this order. e.g. open_bdev_excl called blkdev_get (which calls do_open) before bd_claim. NeilBrown - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/