On Mon, Jan 23, 2017 at 9:42 AM, Ross Zwisler
<ross.zwis...@linux.intel.com> wrote:
> On Fri, Jan 20, 2017 at 12:04:46PM -0800, Dan Williams wrote:
>> [ adding Jeff ]
>>
>> Some comments on boilerplate / organization items...
>>
>>
>> On Thu, Jan 19, 2017 at 7:12 PM, Vishal Verma <vishal.l.ve...@intel.com> 
>> wrote:
>> > Add the check-namespace command to ndctl. This will check the BTT
>> > metadata layout for the given namespace, and if requested, correct any
>> > errors found. Not all metadata corruption is detectable or fixable.
>> >
>> > Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>
> <>
>> > +static int btt_read_info(struct btt_chk *bttc, struct btt_sb *btt_sb, 
>> > __u64 off)
>> > +{
>> > +       int fd, rc = 0;
>> > +       ssize_t size;
>> > +
>> > +       fd = open(bttc->path, O_RDONLY);
>>
>> Let's not open and close the btt device on each call. Open it once at
>> the beginning of time and open it O_EXCL so that we prevent the kernel
>> trying to claim the device. Let's also use O_DIRECT to bypass the
>> block_device page cache.
>
> I thought O_EXCL only mattered if it was used for creation of new files with
> O_CREAT?
>
> https://linux.die.net/man/3/open
>
> For us bttc->path is our device in /dev/, so that O_EXCL shouldn't do anything
> for us?

You overlooked this bit in man 2 open:

"In general, the behavior of  O_EXCL  is  undefined  if  it  is  used
without O_CREAT.   There is one exception: on Linux 2.6 and later,
O_EXCL can be used without O_CREAT if pathname refers to a block
device.  If the block device is in use by the system (e.g., mounted),
open() fails with the error EBUSY."
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reply via email to