lkml.org 
[lkml]   [2003]   [Aug]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] 2 of 2 - Allow O_EXCL on a block device to claim exclusive use.
On Monday August 11, hch@infradead.org wrote:
> 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/

\
 
 \ /
  Last update: 2005-03-22 13:47    [W:0.056 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site